VirtualBox

Changeset 52434 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 20, 2014 8:09:10 PM (10 years ago)
Author:
vboxsync
Message:

Storage/AHCI: Fix tight race when the guest resets a port leading to an inconsistent active request counter and a release assertion later on. The release assertion must be removed though because it might trigger by mistake now if the request counter is 0 due to thread preemption

File:
1 edited

Legend:

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

    r52412 r52434  
    57185718    }
    57195719
    5720     AssertRelease(   !ASMAtomicReadU32(&pAhciPort->cTasksActive)
    5721                   || (pAhciReqExcept && ASMAtomicReadU32(&pAhciPort->cTasksActive) == 1));
    57225720    return true; /* always true for now because tasks don't use guest memory as the buffer which makes canceling a task impossible. */
    57235721}
     
    59795977    }
    59805978
     5979    bool fPortReset = ASMAtomicReadBool(&pAhciPort->fPortReset);
    59815980    fXchg = ASMAtomicCmpXchgU32((volatile uint32_t *)&pAhciReq->enmTxState, AHCITXSTATE_FREE, AHCITXSTATE_ACTIVE);
    59825981
    5983     if (   fXchg
    5984         && !ASMAtomicReadBool(&pAhciPort->fPortReset))
     5982    if (fXchg && !fPortReset)
    59855983    {
    59865984        if (pAhciReq->enmTxDir == AHCITXDIR_READ)
     
    60976095         * The guest might use it for other things now because it doesn't know about that task anymore.
    60986096         */
    6099         AssertMsg(   pAhciReq->enmTxState == AHCITXSTATE_CANCELED
    6100                   || pAhciPort->fPortReset,
    6101                   ("Task is not active but wasn't canceled!\n"));
     6097        AssertMsg(pAhciReq->enmTxState == AHCITXSTATE_CANCELED || fPortReset,
     6098                  ("Task is not active but wasn't canceled and no port reset is active!\n"));
     6099
     6100        /*
     6101         * If this handler switched the request state from active to free the request counter
     6102         * must be decremented.
     6103         */
     6104        if (fXchg)
     6105        {
     6106            Assert(fPortReset);
     6107            AssertReleaseMsg(ASMAtomicReadU32(&pAhciPort->cTasksActive) > 0 ,
     6108                             ("Inconsistent request counter\n"));
     6109            ASMAtomicDecU32(&pAhciPort->cTasksActive);
     6110        }
    61026111
    61036112        fCanceled = true;
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