VirtualBox

Changeset 40740 in vbox


Ignore:
Timestamp:
Apr 2, 2012 11:54:41 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77217
Message:

SUPDrv: Update GIP data behind a spinlock for online/offline race conditions.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r40667 r40740  
    208208    /** The max CPU ID (RTMpGetMaxCpuId). */
    209209    RTCPUID             idCpuMax;
     210    /** Padding to 8 byte alignment. */
     211    uint16_t            au16Padding1[2];
     212    /** Spinlock protecting the GIP array members. */
     213    RTSPINLOCK          Spinlock;                       /* 144 */
    210214
    211215    /** Padding / reserved space for future data. */
    212     uint32_t            au32Padding1[29];
     216    uint32_t            au32Padding1[26];
    213217
    214218    /** Table indexed by the CPU APIC ID to get the CPU table index. */
  • trunk/include/VBox/sup.mac

    r36262 r40740  
    6363    .u16Padding0                resw 1
    6464    .idCpuMax                   resd 1
    65     .au32Padding1               resd 29
     65    .au16Padding1               resw 2
     66    .Spinlock                   RTR0PTR_RES 1
     67    .au32Padding1               resd 26
    6668    .aiCpuFromApicId            resw 256
    6769    .aiCpuFromCpuSetIdx         resw 256
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r40649 r40740  
    49084908    supdrvGipInit(pDevExt, pGip, HCPhysGip, RTTimeSystemNanoTS(), 1000000000 / u32Interval /*=Hz*/, cCpus);
    49094909
     4910    rc = RTSpinlockCreate(&pGip->Spinlock);
     4911    if (RT_FAILURE(rc))
     4912    {
     4913        supdrvGipDestroy(pDevExt);
     4914        return rc;
     4915    }
     4916
    49104917    /*
    49114918     * Create the timer.
     
    49764983    {
    49774984        supdrvGipTerm(pDevExt->pGip);
     4985        if (pDevExt->pGip->Spinlock)
     4986        {
     4987            RTSpinlockDestroy(pDevExt->pGip->Spinlock);
     4988            pDevExt->pGip->Spinlock = NIL_RTSPINLOCK;
     4989        }
     4990
    49784991        pDevExt->pGip = NULL;
    49794992    }
     
    50965109    uint32_t    i = 0;
    50975110    uint64_t    u64NanoTS = 0;
     5111    RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    50985112
    50995113    AssertRelease(idCpu == RTMpCpuId());
    51005114    Assert(pGip->cPossibleCpus == RTMpGetCount());
     5115
     5116    /*
     5117     * Do this behind a spinlock with interrupts disabled as this can fire
     5118     * on all CPUs simultaneously, see #6110.
     5119     */
     5120    RTSpinlockAcquireNoInts(pGip->Spinlock, &SpinlockTmp);
    51015121
    51025122    /*
     
    51325152    /* commit it */
    51335153    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_ONLINE);
     5154
     5155    RTSpinlockReleaseNoInts(pGip->Spinlock, &SpinlockTmp);
    51345156}
    51355157
     
    51475169    int         iCpuSet;
    51485170    unsigned    i;
     5171
     5172    RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
     5173    RTSpinlockAcquireNoInts(pGip->Spinlock, &SpinlockTmp);
    51495174
    51505175    iCpuSet = RTMpCpuIdToSetIndex(idCpu);
     
    51605185    /* commit it */
    51615186    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_OFFLINE);
     5187
     5188    RTSpinlockReleaseNoInts(pGip->Spinlock, &SpinlockTmp);
    51625189}
    51635190
     
    54695496    pGip->cPossibleCpus         = RTMpGetCount();
    54705497    pGip->idCpuMax              = RTMpGetMaxCpuId();
     5498    pGip->Spinlock              = NULL;
    54715499    for (i = 0; i < RT_ELEMENTS(pGip->aiCpuFromApicId); i++)
    54725500        pGip->aiCpuFromApicId[i]    = 0;
Note: See TracChangeset for help on using the changeset viewer.

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