VirtualBox

Changeset 28705 in vbox


Ignore:
Timestamp:
Apr 25, 2010 12:39:42 PM (15 years ago)
Author:
vboxsync
Message:

AHCI: Fix race condition where a task could be used even if it is already active

File:
1 edited

Legend:

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

    r28620 r28705  
    292292     * and the callback copies the data to the destination. */
    293293    PFNAHCIPOSTPROCESS         pfnPostProcess;
     294#ifdef RT_STRICT
     295    /** Flag whether the task state is currently active - used for debugging */
     296    volatile bool              fActive;
     297#endif
    294298} AHCIPORTTASKSTATE;
    295299
     
    48864890        ASMAtomicOrU32(&pAhciPort->u32QueuedTasksFinished, (1 << pAhciPortTaskState->uTag));
    48874891
     4892#ifdef RT_STRICT
     4893        bool fXchg = ASMAtomicCmpXchgBool(&pAhciPortTaskState->fActive, false, true);
     4894        AssertMsg(fXchg, ("Task is not active\n"));
     4895#endif
     4896
    48884897        if (!cOutstandingTasks)
    4889             ahciSendSDBFis(pAhciPort, pAhciPort->u32QueuedTasksFinished, pAhciPortTaskState, true);
     4898            ahciSendSDBFis(pAhciPort, 0, pAhciPortTaskState, true);
    48904899    }
    48914900    else
     4901    {
     4902#ifdef RT_STRICT
     4903        bool fXchg = ASMAtomicCmpXchgBool(&pAhciPortTaskState->fActive, false, true);
     4904        AssertMsg(fXchg, ("Task is not active\n"));
     4905#endif
     4906
    48924907        ahciSendD2HFis(pAhciPort, pAhciPortTaskState, pAhciPortTaskState->cmdFis, true);
     4908    }
    48934909
    48944910    /* Add the task to the cache. */
     
    52365252        ahciLog(("%s: Processing command at slot %d\n", __FUNCTION__, pNotifierItem->iTask));
    52375253
    5238         /* Check if there is already an allocated task struct in the cache.
     5254        /*
     5255         * Check if there is already an allocated task struct in the cache.
    52395256         * Allocate a new task otherwise.
    52405257         */
     
    52485265            pAhciPortTaskState = pAhciPort->aCachedTasks[pNotifierItem->iTask];
    52495266        }
     5267
     5268#ifdef RT_STRICT
     5269        bool fXchg = ASMAtomicCmpXchgBool(&pAhciPortTaskState->fActive, true, false);
     5270        AssertMsg(fXchg, ("Task is already active\n"));
     5271#endif
    52505272
    52515273        /** Set current command slot */
     
    53385360        else
    53395361        {
     5362#ifdef RT_STRICT
     5363            bool fXchg = ASMAtomicCmpXchgBool(&pAhciPortTaskState->fActive, false, true);
     5364            AssertMsg(fXchg, ("Task is not active\n"));
     5365#endif
     5366
    53405367            /* There is nothing left to do. Notify the guest. */
    53415368            ahciSendD2HFis(pAhciPort, pAhciPortTaskState, &pAhciPortTaskState->cmdFis[0], 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