VirtualBox

Changeset 42324 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Jul 23, 2012 1:42:08 PM (12 years ago)
Author:
vboxsync
Message:

ATA: Handle some off-size port accesses.

File:
1 edited

Legend:

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

    r41825 r42324  
    59555955    if (rc != VINF_SUCCESS)
    59565956        return rc;
    5957     if (cb == 1)
    5958         rc = ataIOPortWriteU8(pCtl, Port, u32);
    5959     else if (Port == pCtl->IOPortBase1)
    5960     {
     5957    if (Port == pCtl->IOPortBase1)
     5958    {
     5959        /* Writes to the data port may be 16-bit or 32-bit. */
    59615960        Assert(cb == 2 || cb == 4);
    59625961        rc = ataDataWrite(pCtl, Port, cb, (const uint8_t *)&u32);
    59635962    }
    59645963    else
    5965         AssertMsgFailed(("ataIOPortWrite1: unsupported write to port %x val=%x size=%d\n", Port, u32, cb));
     5964    {
     5965        /* Writes to the other command block ports should be 8-bit only. If they
     5966         * are not, the high bits are simply discarded. Undocumented, but observed
     5967         * on a real PIIX4 system.
     5968         */
     5969        if (cb > 1)
     5970            Log(("ataIOPortWrite1: suspect write to port %x val=%x size=%d\n", Port, u32, cb));
     5971
     5972        rc = ataIOPortWriteU8(pCtl, Port, u32);
     5973    }
    59665974    PDMCritSectLeave(&pCtl->lock);
    59675975    return rc;
     
    59855993    if (rc != VINF_SUCCESS)
    59865994        return rc;
    5987     if (cb == 1)
    5988     {
    5989         rc = ataIOPortReadU8(pCtl, Port, pu32);
    5990     }
    5991     else if (Port == pCtl->IOPortBase1)
    5992     {
     5995    if (Port == pCtl->IOPortBase1)
     5996    {
     5997        /* Reads from the data register may be 16-bit or 32-bit. */
    59935998        Assert(cb == 2 || cb == 4);
    59945999        rc = ataDataRead(pCtl, Port, cb, (uint8_t *)pu32);
     
    59986003    else
    59996004    {
    6000         AssertMsgFailed(("ataIOPortRead1: unsupported read from port %x size=%d\n", Port, cb));
    6001         rc = VERR_IOM_IOPORT_UNUSED;
     6005        /* Reads from the other command block registers should be 8-bit only.
     6006         * If they are not, the low byte is propagated to the high bits.
     6007         * Undocumented, but observed on a real PIIX4 system.
     6008         */
     6009        rc = ataIOPortReadU8(pCtl, Port, pu32);
     6010        if (cb > 1)
     6011        {
     6012            uint32_t    pad;
     6013
     6014            /* Replicate the 8-bit result into the upper three bytes. */
     6015            pad = *pu32 & 0xff;
     6016            pad = pad | (pad << 8);
     6017            pad = pad | (pad << 16);
     6018            *pu32 = pad;
     6019            Log(("ataIOPortRead1: suspect read from port %x size=%d\n", Port, cb));
     6020        }
    60026021    }
    60036022    PDMCritSectLeave(&pCtl->lock);
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