Menu

#75 improper operation on 'fwdownload-modee-max' option

v1.0 (example)
open
nobody
None
5
2017-12-06
2017-11-02
Jihoon Lee
No

- Summary

It is not correctly working when the user uses 'fwdownload-modee-max' parameter which is supported on hdparm for deferred firmware download. (Tested on v9.52)

- Causes

When the user performs deferred firmware download via hdparm, there is two options;
'fwdownload-modee' for download microcode operation with minimum transfer data blocks size and 'fwdownload-modee-max' for the same with maximum.
If the user selects the 'fwdownload-modee-max' option, then hdparm sets a global variable named 'xfer_mode' to 0xE0.
This value will be passed to feature field in taskfile struct and transferred to ATA device.
According to ATA Command Set specification, only 0x3, 0x7, 0xE, 0xF values are allowed to perform 'download microcode' command,
and for this reason the 'xfer_mode' value should be modified 0xE0 to 0xE again after that it is transferred to fwdownload module in hdparm.
However, current version of hdparm transfers it without proper modification, so the device goes an unexpected state or deals it with 'command abort'.

- To Fix

I'll suggest a code block to fix this issue as below.
if (xfer_mode == 0x30) { // mode-3, using xfer_max xfer_mode = 3; xfer_size = xfer_max; } else if (xfer_mode == 3) { xfer_size = xfer_min; } else if (xfer_mode == 0x0e) { xfer_mode = 0x0e; // to be added(++) // xfer_size = xfer_max; // to be modified as below xfer_size = xfer_min; } else if (xfer_mode == 0xe0) { // xfer_size = xfer_min; // to be modified as below xfer_size = xfer_max; } else { xfer_size = st.st_size / 512; if (xfer_size > 0xffff) { fprintf(stderr, "Error: file size (%llu) too large for mode7 transfers\n", (__u64)st.st_size); err = EINVAL; goto done; } }

Discussion

  • Mark Lord

    Mark Lord - 2017-12-05

    Could you possibly fix that "code block" above to be more readable, and convert it into a patch so that I know where in the code it ought to be placed?

    Thanks.

     
  • Jihoon Lee

    Jihoon Lee - 2017-12-06

    I'm sorry for the poor readability. I was gladly willing to make a patch file for fix this issue, but I can't upload it due to the security policy of the company. I paste the patch file's contents to replace the file upload. I'm sorry to bother you. Thanks.

    --- fwdownload.c 2017-12-06 10:39:37.323178683 +0900
    +++ fwdownload-modified.c 2017-12-06 10:40:46.885942683 +0900
    @@ -160,9 +160,10 @@
    } else if (xfer_mode == 3) {
    xfer_size = xfer_min;
    } else if (xfer_mode == 0x0e) {

    • xfer_size = xfer_max;
    • } else if (xfer_mode == 0xe0) {
      xfer_size = xfer_min;
    • } else if (xfer_mode == 0xe0) {
    • xfer_mode = 0x0e;
    • xfer_size = xfer_max;
      } else {
      xfer_size = st.st_size / 512;
      if (xfer_size > 0xffff) {
     

Log in to post a comment.

MongoDB Logo MongoDB