Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
Fix 12 byte input data size on Windows SCM passthrough
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha Venkatachari Sundarajan <[email protected]>
  • Loading branch information
swetha-intel authored and Juston Li committed Mar 5, 2018
1 parent ec8b64b commit 756d222
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/lib/win_scm2_ioctl_passthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ int win_scm2_ioctl_passthrough_cmd(unsigned short nfit_handle,
// already, we need to subtract those bytes from the total buffer size
ioctl_data.InputDataSize = sizeof (NVDIMM_PASSTHROUGH_IN) +
input_payload_size - 1; // minus 1 byte no padding cause the struct is packed
if(input_payload_size == 0)
ioctl_data.InputDataSize += 4; // Microsoft driver expects 12 bytes
ioctl_data.OutputDataSize = sizeof (NVDIMM_PASSTHROUGH_OUT) +
if (ioctl_data.InputDataSize < 12)
ioctl_data.InputDataSize = 12; // Microsoft driver expects 12 bytes

ioctl_data.OutputDataSize = sizeof (NVDIMM_PASSTHROUGH_OUT) +
output_payload_size - 1; // minus 1 byte no padding cause the struct is packed
if(output_payload_size == 0)
ioctl_data.OutputDataSize += 4; // Microsoft driver expects 12 bytes
if(ioctl_data.OutputDataSize < 12)
ioctl_data.OutputDataSize = 12; // Microsoft driver expects 12 bytes

SCM_LOG_INFO_F("buf_size (%xh, %xh): in %d, out %d", op_code, sub_op_code,
(int)ioctl_data.InputDataSize, (int)ioctl_data.OutputDataSize);

Expand All @@ -81,18 +82,16 @@ int win_scm2_ioctl_passthrough_cmd(unsigned short nfit_handle,
// minus 1 byte no padding cause the struct is packed
p_input_data->DataSize = sizeof (DSM_VENDOR_SPECIFIC_COMMAND_INPUT_PAYLOAD)
+ input_payload_size - 1;

if (p_input_data->DataSize < 12)
p_input_data->DataSize = 12; // Microsoft driver expects 12 byte

// prepare the input data buffer
if (input_payload_size > 0)
{
memmove(p_input_data->Data.Arg3OpCodeParameterDataBuffer,
input_payload,
input_payload_size);
}
else
{
p_input_data->DataSize += 4; // Microsoft driver expects 12 bytes
}

enum WIN_SCM2_IOCTL_RETURN_CODES ioctl_rc = win_scm2_ioctl_execute(nfit_handle,
&ioctl_data, IOCTL_CR_PASS_THROUGH);
Expand Down

0 comments on commit 756d222

Please sign in to comment.