VirtualBox

Changeset 32453 in vbox


Ignore:
Timestamp:
Sep 13, 2010 2:46:00 PM (14 years ago)
Author:
vboxsync
Message:

spinlock-r0drv-nt.cpp: Hack to try to resolve the ISR issue in VBoxGuest (disabled).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/spinlock-r0drv-nt.cpp

    r29254 r32453  
    4545
    4646/*******************************************************************************
     47*   Defined Constants And Macros                                               *
     48*******************************************************************************/
     49/** Apply the NoIrq hack if defined. */
     50//#define RTSPINLOCK_NT_HACK_NOIRQ
     51
     52#ifdef RTSPINLOCK_NT_HACK_NOIRQ
     53/** Indicates that the spinlock is taken. */
     54# define RTSPINLOCK_NT_HACK_NOIRQ_TAKEN  UINT32(0x00c0ffee)
     55/** Indicates that the spinlock is taken. */
     56# define RTSPINLOCK_NT_HACK_NOIRQ_FREE   UINT32(0xfe0000fe)
     57#endif
     58
     59
     60/*******************************************************************************
    4761*   Structures and Typedefs                                                    *
    4862*******************************************************************************/
     
    5468    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    5569    uint32_t volatile   u32Magic;
     70#ifdef RTSPINLOCK_NT_HACK_NOIRQ
     71    /** Spinlock hack. */
     72    uint32_t volatile   u32Hack;
     73#endif
    5674    /** The NT spinlock structure. */
    5775    KSPIN_LOCK          Spinlock;
     
    7492     */
    7593    pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
     94#ifdef RTSPINLOCK_NT_HACK_NOIRQ
     95    pSpinlockInt->u32Hack  = RTSPINLOCK_NT_HACK_NOIRQ;
     96#endif
    7697    KeInitializeSpinLock(&pSpinlockInt->Spinlock);
    7798    Assert(sizeof(KIRQL) == sizeof(unsigned char));
     99    AssertCompile(sizeof(KIRQL) == sizeof(unsigned char));
    78100
    79101    *pSpinlock = pSpinlockInt;
     
    107129    AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    108130
     131#ifndef RTSPINLOCK_NT_HACK_NOIRQ
    109132    KeAcquireSpinLock(&pSpinlockInt->Spinlock, &pTmp->uchIrqL);
    110133    pTmp->uFlags = ASMGetFlags();
    111134    ASMIntDisable();
     135#else
     136    pTmp->uchIrqL = KeGetCurrentIrql();
     137    if (pTmp->uchIrqL < DISPATCH_LEVEL)
     138    {
     139        KeRaiseIrql(DISPATCH_LEVEL, &pTmp->uchIrqL);
     140        Assert(pTmp->uchIrqL < DISPATCH_LEVEL);
     141    }
     142    pTmp->uFlags = ASMGetFlags();
     143    ASMIntDisable();
     144    if (!ASMAtomicCmpXchgU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE))
     145    {
     146        while (!ASMAtomicCmpXchgU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE))
     147            ASMNopPause();
     148    }
     149#endif
    112150}
    113151
     
    118156    AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    119157
     158#ifndef RTSPINLOCK_NT_HACK_NOIRQ
    120159    ASMSetFlags(pTmp->uFlags);
    121160    KeReleaseSpinLock(&pSpinlockInt->Spinlock, pTmp->uchIrqL);
     161#else
     162    Assert(pSpinlockInt->u32Hack == RTSPINLOCK_NT_HACK_NOIRQ_TAKEN);
     163    ASMAtomicWriteU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_FREE);
     164    ASMSetFlags(pTmp->uFlags);
     165    if (pTmp->uchIrqL < DISPATCH_LEVEL)
     166        KeLowerIrql(pTmp->uchIrqL);
     167#endif
    122168}
    123169
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