VirtualBox

Changeset 64413 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 25, 2016 1:07:55 PM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/HostDVD: Fix sense reporting, don't call drvHostDvdCmdError() after the command was passed through because the sense buffer is already valid and would be zeroed out, fixes at least a Windows hang when trying to access an audio CD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp

    r64407 r64413  
    116116}
    117117
    118 static void drvHostDvdCmdOK(PDRVHOSTDVD pThis)
     118static uint8_t drvHostDvdCmdOK(PDRVHOSTDVD pThis)
    119119{
    120120    memset(pThis->abATAPISense, '\0', sizeof(pThis->abATAPISense));
    121121    pThis->abATAPISense[0] = 0x70;
    122122    pThis->abATAPISense[7] = 10;
    123 }
    124 
    125 static void drvHostDvdCmdError(PDRVHOSTDVD pThis, const uint8_t *pabATAPISense, size_t cbATAPISense)
     123    return SCSI_STATUS_OK;
     124}
     125
     126static uint8_t drvHostDvdCmdError(PDRVHOSTDVD pThis, const uint8_t *pabATAPISense, size_t cbATAPISense)
    126127{
    127128    Log(("%s: sense=%#x (%s) asc=%#x ascq=%#x (%s)\n", __FUNCTION__, pabATAPISense[2] & 0x0f, SCSISenseText(pabATAPISense[2] & 0x0f),
     
    129130    memset(pThis->abATAPISense, '\0', sizeof(pThis->abATAPISense));
    130131    memcpy(pThis->abATAPISense, pabATAPISense, RT_MIN(cbATAPISense, sizeof(pThis->abATAPISense)));
     132    return SCSI_STATUS_CHECK_CONDITION;
    131133}
    132134
    133135/** @todo deprecated function - doesn't provide enough info. Replace by direct
    134136 * calls to drvHostDvdCmdError()  with full data. */
    135 static void drvHostDvdCmdErrorSimple(PDRVHOSTDVD pThis, uint8_t uATAPISenseKey, uint8_t uATAPIASC)
     137static uint8_t drvHostDvdCmdErrorSimple(PDRVHOSTDVD pThis, uint8_t uATAPISenseKey, uint8_t uATAPIASC)
    136138{
    137139    uint8_t abATAPISense[ATAPI_SENSE_SIZE];
     
    141143    abATAPISense[7] = 10;
    142144    abATAPISense[12] = uATAPIASC;
    143     drvHostDvdCmdError(pThis, abATAPISense, sizeof(abATAPISense));
     145    return drvHostDvdCmdError(pThis, abATAPISense, sizeof(abATAPISense));
    144146}
    145147
     
    443445                case 0x0f: /* activate deferred microcode */
    444446                    LogRel(("HostDVD#%u: CD-ROM passthrough command attempted to update firmware, blocked\n", pThis->Core.pDrvIns->iInstance));
    445                     drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
    446                     *pu8ScsiSts = SCSI_STATUS_CHECK_CONDITION;
     447                    *pu8ScsiSts = drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_INV_FIELD_IN_CMD_PACKET);
    447448                    break;
    448449                default:
     
    464465             * opcode 0x01" in syslog) and replies with a sense code of 0,
    465466             * which sends cdrecord to an endless loop. */
    466             drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    467             *pu8ScsiSts = SCSI_STATUS_CHECK_CONDITION;
     467            *pu8ScsiSts = drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    468468            break;
    469469        default:
    470470            LogRel(("HostDVD#%u: Passthrough unimplemented for command %#x\n", pThis->Core.pDrvIns->iInstance, pbCdb[0]));
    471             drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    472             *pu8ScsiSts = SCSI_STATUS_CHECK_CONDITION;
     471            *pu8ScsiSts = drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    473472            break;
    474473    }
     
    605604                    AssertMsgFailed(("Don't know how to split command %#04x\n", pbCdb[0]));
    606605                    LogRelMax(10, ("HostDVD#%u: CD-ROM passthrough split error\n", pThis->Core.pDrvIns->iInstance));
    607                     drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    608                     *pu8ScsiSts = SCSI_STATUS_CHECK_CONDITION;
     606                    *pu8ScsiSts = drvHostDvdCmdErrorSimple(pThis, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_ILLEGAL_OPCODE);
    609607                    rc = drvHostBaseBufferRelease(&pThis->Core, pReq, cbBuf, enmXferDir == PDMMEDIATXDIR_TO_DEVICE, pvBuf);
    610608                    RTCritSectLeave(&pThis->Core.CritSect);
     
    712710            }
    713711
    714             drvHostDvdCmdOK(pThis);
    715             *pu8ScsiSts = SCSI_STATUS_OK;
     712            *pu8ScsiSts = drvHostDvdCmdOK(pThis);
    716713        }
    717714        else
     
    730727                          pThis->abATAPISense[12], pThis->abATAPISense[13], rc));
    731728            } while (0);
    732             drvHostDvdCmdError(pThis, &pThis->abATAPISense[0], sizeof(pThis->abATAPISense));
    733729            *pu8ScsiSts = SCSI_STATUS_CHECK_CONDITION;
    734730            rc = VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette