VirtualBox

Changeset 40806 in vbox


Ignore:
Timestamp:
Apr 6, 2012 9:05:19 PM (13 years ago)
Author:
vboxsync
Message:

RTSpinlock: Redid the interface, eliminating NoInts and Tmp. Whether a spinlock is interrupt safe or not is now defined at creation time, preventing stupid bugs arrising from calling the wrong acquire and/or release methods somewhere. The saved flags are stored in the spinlock strucutre, eliminating the annoying Tmp variable. Needs testing on each platform before fixing the build burn.

Location:
trunk
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r40668 r40806  
    12211221# define RTSortIsSorted                                 RT_MANGLER(RTSortIsSorted)
    12221222# define RTSpinlockAcquire                              RT_MANGLER(RTSpinlockAcquire)
    1223 # define RTSpinlockAcquireNoInts                        RT_MANGLER(RTSpinlockAcquireNoInts)
    12241223# define RTSpinlockCreate                               RT_MANGLER(RTSpinlockCreate)
    12251224# define RTSpinlockDestroy                              RT_MANGLER(RTSpinlockDestroy)
    12261225# define RTSpinlockRelease                              RT_MANGLER(RTSpinlockRelease)
    1227 # define RTSpinlockReleaseNoInts                        RT_MANGLER(RTSpinlockReleaseNoInts)
    12281226# define RTStrAAppendExNVTag                            RT_MANGLER(RTStrAAppendExNVTag)
    12291227# define RTStrAAppendNTag                               RT_MANGLER(RTStrAAppendNTag)
  • trunk/include/iprt/spinlock.h

    r28800 r40806  
    3939
    4040/**
    41  * Temporary spinlock state variable.
    42  * All members are undefined and highly platform specific.
    43  */
    44 typedef struct RTSPINLOCKTMP
    45 {
    46 #ifdef IN_RING0
    47 # ifdef RT_OS_LINUX
    48     /** The saved [R|E]FLAGS. */
    49     unsigned long   flFlags;
    50 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
    51 
    52 # elif defined(RT_OS_WINDOWS)
    53     /** The saved [R|E]FLAGS. */
    54     RTCCUINTREG     uFlags;
    55     /** The KIRQL. */
    56     unsigned char   uchIrqL;
    57 #  define RTSPINLOCKTMP_INITIALIZER { 0, 0 }
    58 
    59 # elif defined(__L4__)
    60     /** The saved [R|E]FLAGS. */
    61     unsigned long   flFlags;
    62 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
    63 
    64 # elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
    65     /** The saved [R|E]FLAGS. */
    66     RTCCUINTREG     uFlags;
    67 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
    68 
    69 # elif defined(RT_OS_OS2)
    70     /** The saved [R|E]FLAGS. (dummy) */
    71     RTCCUINTREG     uFlags;
    72 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
    73 
    74 # else
    75 #  error "PORTME\n"
    76     /** The saved [R|E]FLAGS. */
    77     RTCCUINTREG     uFlags;
    78 # endif
    79 
    80 #else /* !IN_RING0 */
    81     /** The saved [R|E]FLAGS. (dummy) */
    82     RTCCUINTREG     uFlags;
    83 # define RTSPINLOCKTMP_INITIALIZER { 0 }
    84 #endif /* !IN_RING0 */
    85 } RTSPINLOCKTMP;
    86 /** Pointer to a temporary spinlock state variable. */
    87 typedef RTSPINLOCKTMP *PRTSPINLOCKTMP;
    88 /** Pointer to a const temporary spinlock state variable. */
    89 typedef const RTSPINLOCKTMP *PCRTSPINLOCKTMP;
    90 
    91 /** @def RTSPINLOCKTMP_INITIALIZER
    92  * What to assign to a RTSPINLOCKTMP at definition.
    93  */
    94 #ifdef DOXYGEN_RUNNING
    95 # define RTSPINLOCKTMP_INITIALIZER
    96 #endif
    97 
    98 
    99 
    100 /**
    10141 * Creates a spinlock.
    10242 *
    10343 * @returns iprt status code.
    10444 * @param   pSpinlock   Where to store the spinlock handle.
     45 * @param   fFlags      Creation flags, see RTSPINLOCK_FLAGS_XXX.
     46 * @param   pszName     Spinlock name, for debugging purposes.  String lifetime
     47 *                      must be the same as the lock as it won't be copied.
    10548 */
    106 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock);
     49RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName);
     50
     51/** @name RTSPINLOCK_FLAGS_XXX
     52 * @{ */
     53/** Disable interrupts when taking the spinlock, making it interrupt safe
     54 * (sans NMI of course).
     55 *
     56 * This is generally the safest option, though it isn't really required unless
     57 * the data being protect is also accessed from interrupt handler context. */
     58#define RTSPINLOCK_FLAGS_INTERRUPT_SAFE     RT_BIT(1)
     59/** No need to disable interrupts, the protect code/data is not used by
     60 * interrupt handlers. */
     61#define RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE   RT_BIT(2)
     62/** @}  */
    10763
    10864/**
     
    11672/**
    11773 * Acquires the spinlock.
    118  * Interrupts are disabled upon return.
    11974 *
    12075 * @param   Spinlock    The spinlock to acquire.
    12176 * @param   pTmp        Where to save the state.
    12277 */
    123 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);
     78RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock);
    12479
    12580/**
     
    12984 * @param   pTmp        The state to restore. (This better be the same as for the RTSpinlockAcquire() call!)
    13085 */
    131 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);
     86RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock);
    13287
    133 /**
    134  * Acquires the spinlock.
    135  *
    136  * @param   Spinlock    The spinlock to acquire.
    137  * @param   pTmp        Where to save the state.
    138  */
    139 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);
    140 
    141 /**
    142  * Releases the spinlock.
    143  *
    144  * @param   Spinlock    The spinlock to acquire.
    145  * @param   pTmp        The state to restore. (This better be the same as for the RTSpinlockAcquire() call!)
    146  */
    147 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);
     88/* Temporarily, only for checking the spinlock creation flags. */
     89RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock);
    14890
    14991
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp

    r33540 r40806  
    164164                 * Initialize the session hash table.
    165165                 */
    166                 rc = RTSpinlockCreate(&g_Spinlock);
     166                rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestOS2");
    167167                if (RT_SUCCESS(rc))
    168168                {
     
    370370         */
    371371        unsigned iHash = SESSION_HASH(sfn);
    372         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    373         RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     372        RTSpinlockAcquire(g_Spinlock);
    374373        pSession->pNextHash = g_apSessionHashTab[iHash];
    375374        g_apSessionHashTab[iHash] = pSession;
    376         RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     375        RTSpinlockReleaseNoInts(g_Spinlock);
    377376    }
    378377
     
    392391    const RTPROCESS     Process = RTProcSelf();
    393392    const unsigned      iHash = SESSION_HASH(sfn);
    394     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    395     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     393    RTSpinlockAcquire(g_Spinlock);
    396394
    397395    pSession = g_apSessionHashTab[iHash];
     
    424422        }
    425423    }
    426     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     424    RTSpinlockReleaseNoInts(g_Spinlock);
    427425    if (!pSession)
    428426    {
     
    444442     * Find the session.
    445443     */
    446     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    447444    const RTPROCESS     Process = RTProcSelf();
    448445    const unsigned      iHash = SESSION_HASH(sfn);
    449446    PVBOXGUESTSESSION   pSession;
    450447
    451     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     448    RTSpinlockAcquire(g_Spinlock);
    452449    pSession = g_apSessionHashTab[iHash];
    453450    if (pSession && pSession->Process != Process)
     
    458455                     || pSession->Process != Process));
    459456    }
    460     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     457    RTSpinlockReleaseNoInts(g_Spinlock);
    461458    if (RT_UNLIKELY(!pSession))
    462459    {
     
    536533     * Find the session.
    537534     */
    538     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    539535    const RTPROCESS     Process = RTProcSelf();
    540536    const unsigned      iHash = SESSION_HASH(sfn);
    541537    PVBOXGUESTSESSION   pSession;
    542538
    543     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     539    RTSpinlockAcquire(g_Spinlock);
    544540    pSession = g_apSessionHashTab[iHash];
    545541    if (pSession && pSession->Process != Process)
     
    550546                     || pSession->Process != Process));
    551547    }
    552     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     548    RTSpinlockReleaseNoInts(g_Spinlock);
    553549    if (!pSession)
    554550    {
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r40483 r40806  
    747747     * Create the wait and session spinlocks as well as the ballooning mutex.
    748748     */
    749     rc = RTSpinlockCreate(&pDevExt->EventSpinlock);
     749    rc = RTSpinlockCreate(&pDevExt->EventSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestEvent");
    750750    if (RT_SUCCESS(rc))
    751         rc = RTSpinlockCreate(&pDevExt->SessionSpinlock);
     751        rc = RTSpinlockCreate(&pDevExt->SessionSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestSession");
    752752    if (RT_FAILURE(rc))
    753753    {
     
    10111011    if (pWait)
    10121012    {
    1013         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1014         RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1013        RTSpinlockAcquire(pDevExt->EventSpinlock);
    10151014
    10161015        pWait = RTListGetFirst(&pDevExt->FreeList, VBOXGUESTWAIT, ListNode);
     
    10181017            RTListNodeRemove(&pWait->ListNode);
    10191018
    1020         RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1019        RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    10211020    }
    10221021    if (!pWait)
     
    11011100static void VBoxGuestWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait)
    11021101{
    1103     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1104     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1102    RTSpinlockAcquire(pDevExt->EventSpinlock);
    11051103    VBoxGuestWaitFreeLocked(pDevExt, pWait);
    1106     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1104    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    11071105}
    11081106
     
    11211119    if (!RTListIsEmpty(&pDevExt->WakeUpList))
    11221120    {
    1123         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1124         RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1121        RTSpinlockAcquire(pDevExt->EventSpinlock);
    11251122        for (;;)
    11261123        {
     
    11301127                break;
    11311128            pWait->fPendingWakeUp = true;
    1132             RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1129            RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    11331130
    11341131            rc = RTSemEventMultiSignal(pWait->Event);
    11351132            AssertRC(rc);
    11361133
    1137             RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1134            RTSpinlockAcquire(pDevExt->EventSpinlock);
    11381135            pWait->fPendingWakeUp = false;
    11391136            if (!pWait->fFreeMe)
     
    11481145            }
    11491146        }
    1150         RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1147        RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    11511148    }
    11521149}
     
    12341231 */
    12351232DECLINLINE(int) WaitEventCheckCondition(PVBOXGUESTDEVEXT pDevExt, VBoxGuestWaitEventInfo *pInfo,
    1236                                         int iEvent, const uint32_t fReqEvents, PRTSPINLOCKTMP pTmp)
     1233                                        int iEvent, const uint32_t fReqEvents)
    12371234{
    12381235    uint32_t fMatches = pDevExt->f32PendingEvents & fReqEvents;
     
    12401237    {
    12411238        ASMAtomicAndU32(&pDevExt->f32PendingEvents, ~fMatches);
    1242         RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, pTmp);
     1239        RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    12431240
    12441241        pInfo->u32EventFlagsOut = fMatches;
     
    12501247        return VINF_SUCCESS;
    12511248    }
    1252     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, pTmp);
     1249    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    12531250    return VERR_TIMEOUT;
    12541251}
     
    12581255                                          VBoxGuestWaitEventInfo *pInfo,  size_t *pcbDataReturned, bool fInterruptible)
    12591256{
    1260     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    12611257    const uint32_t  fReqEvents = pInfo->u32EventMaskIn;
    12621258    uint32_t        fResEvents;
     
    12831279     * Check the condition up front, before doing the wait-for-event allocations.
    12841280     */
    1285     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
    1286     rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents, &Tmp);
     1281    RTSpinlockAcquire(pDevExt->EventSpinlock);
     1282    rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents);
    12871283    if (rc == VINF_SUCCESS)
    12881284        return rc;
     
    13051301     * Otherwise enter into the list and go to sleep waiting for the ISR to signal us.
    13061302     */
    1307     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1303    RTSpinlockAcquire(pDevExt->EventSpinlock);
    13081304    RTListAppend(&pDevExt->WaitList, &pWait->ListNode);
    1309     rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents, &Tmp);
     1305    rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents);
    13101306    if (rc == VINF_SUCCESS)
    13111307    {
     
    13321328     * Unlink the wait item and dispose of it.
    13331329     */
    1334     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1330    RTSpinlockAcquire(pDevExt->EventSpinlock);
    13351331    fResEvents = pWait->fResEvents;
    13361332    VBoxGuestWaitFreeLocked(pDevExt, pWait);
    1337     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1333    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    13381334
    13391335    /*
     
    13821378static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
    13831379{
    1384     RTSPINLOCKTMP           Tmp   = RTSPINLOCKTMP_INITIALIZER;
    13851380    PVBOXGUESTWAIT          pWait;
    13861381    PVBOXGUESTWAIT          pSafe;
     
    13921387     * Walk the event list and wake up anyone with a matching session.
    13931388     */
    1394     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1389    RTSpinlockAcquire(pDevExt->EventSpinlock);
    13951390    RTListForEachSafe(&pDevExt->WaitList, pWait, pSafe, VBOXGUESTWAIT, ListNode)
    13961391    {
     
    14071402        }
    14081403    }
    1409     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1404    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    14101405    Assert(rc == 0);
    14111406
     
    16921687     * us returning too early.
    16931688     */
    1694     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    16951689    PVBOXGUESTWAIT pWait;
    16961690    for (;;)
    16971691    {
    1698         RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1692        RTSpinlockAcquire(pDevExt->EventSpinlock);
    16991693        if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0)
    17001694        {
    1701             RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1695            RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    17021696            return VINF_SUCCESS;
    17031697        }
    1704         RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1698        RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    17051699
    17061700        pWait = VBoxGuestWaitAlloc(pDevExt, NULL);
     
    17191713     * Otherwise link us into the HGCM wait list and go to sleep.
    17201714     */
    1721     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     1715    RTSpinlockAcquire(pDevExt->EventSpinlock);
    17221716    RTListAppend(&pDevExt->HGCMWaitList, &pWait->ListNode);
    17231717    if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0)
    17241718    {
    17251719        VBoxGuestWaitFreeLocked(pDevExt, pWait);
    1726         RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1720        RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    17271721        return VINF_SUCCESS;
    17281722    }
    1729     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     1723    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    17301724
    17311725    if (fInterruptible)
     
    18101804             */
    18111805            unsigned i;
    1812             RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1813             RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
     1806            RTSpinlockAcquire(pDevExt->SessionSpinlock);
    18141807            for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)
    18151808                if (!pSession->aHGCMClientIds[i])
     
    18181811                    break;
    18191812                }
    1820             RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     1813            RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
    18211814            if (i >= RT_ELEMENTS(pSession->aHGCMClientIds))
    18221815            {
     
    18491842    const uint32_t  u32ClientId = pInfo->u32ClientID;
    18501843    unsigned        i;
    1851     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    1852     RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
     1844    RTSpinlockAcquire(pDevExt->SessionSpinlock);
    18531845    for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)
    18541846        if (pSession->aHGCMClientIds[i] == u32ClientId)
     
    18571849            break;
    18581850        }
    1859     RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     1851    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
    18601852    if (i >= RT_ELEMENTS(pSession->aHGCMClientIds))
    18611853    {
     
    18811873
    18821874    /* Update the client id array according to the result. */
    1883     RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
     1875    RTSpinlockAcquire(pDevExt->SessionSpinlock);
    18841876    if (pSession->aHGCMClientIds[i] == UINT32_MAX)
    18851877        pSession->aHGCMClientIds[i] = RT_SUCCESS(rc) && RT_SUCCESS(pInfo->result) ? 0 : u32ClientId;
    1886     RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     1878    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
    18871879
    18881880    return rc;
     
    18971889{
    18981890    const uint32_t  u32ClientId = pInfo->u32ClientID;
    1899     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    19001891    uint32_t        fFlags;
    19011892    size_t          cbActual;
     
    19291920     * Validate the client id.
    19301921     */
    1931     RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
     1922    RTSpinlockAcquire(pDevExt->SessionSpinlock);
    19321923    for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++)
    19331924        if (pSession->aHGCMClientIds[i] == u32ClientId)
    19341925            break;
    1935     RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     1926    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
    19361927    if (RT_UNLIKELY(i >= RT_ELEMENTS(pSession->aHGCMClientIds)))
    19371928    {
     
    22222213static int VBoxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures)
    22232214{
    2224     unsigned i;
    2225     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2226     uint32_t fNewDevExtStatus = 0;
    2227     int rc;
     2215    uint32_t    fNewDevExtStatus = 0;
     2216    unsigned    i;
     2217    int         rc;
    22282218    /* Exit early if nothing has changed - hack to work around the
    22292219     * Windows Additions not using the common code. */
    2230     bool fNoAction;
    2231 
    2232     RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp);
    2233     for (i = 0; i < sizeof(fFeatures) * 8; ++i)
     2220    bool        fNoAction;
     2221
     2222    RTSpinlockAcquire(pDevExt->SessionSpinlock);
     2223
     2224    for (i = 0; i < sizeof(fFeatures) * 8; i++)
    22342225    {
    22352226        if (RT_BIT_32(i) & VMMDEV_MOUSE_GUEST_MASK)
     
    22372228            if (   (RT_BIT_32(i) & fFeatures)
    22382229                && !(RT_BIT_32(i) & pSession->fMouseStatus))
    2239                 ++pDevExt->cMouseFeatureUsage[i];
     2230                pDevExt->cMouseFeatureUsage[i]++;
    22402231            else if (   !(RT_BIT_32(i) & fFeatures)
    22412232                     && (RT_BIT_32(i) & pSession->fMouseStatus))
    2242                 --pDevExt->cMouseFeatureUsage[i];
     2233                pDevExt->cMouseFeatureUsage[i]--;
    22432234        }
    22442235        if (pDevExt->cMouseFeatureUsage[i] > 0)
    22452236            fNewDevExtStatus |= RT_BIT_32(i);
    22462237    }
     2238
    22472239    pSession->fMouseStatus = fFeatures & VMMDEV_MOUSE_GUEST_MASK;
    22482240    fNoAction = (pDevExt->fMouseStatus == fNewDevExtStatus);
    22492241    pDevExt->fMouseStatus = fNewDevExtStatus;
    2250     RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp);
     2242
     2243    RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock);
    22512244    if (fNoAction)
    22522245        return VINF_SUCCESS;
     2246
    22532247    do
    22542248    {
    22552249        fNewDevExtStatus = pDevExt->fMouseStatus;
    22562250        rc = vboxguestcommonSetMouseStatus(fNewDevExtStatus);
    2257     } while(RT_SUCCESS(rc) && fNewDevExtStatus != pDevExt->fMouseStatus);
     2251    } while (   RT_SUCCESS(rc)
     2252             && fNewDevExtStatus != pDevExt->fMouseStatus);
     2253
    22582254    return rc;
    22592255}
     
    22712267
    22722268    g_test_fSetMouseStatus = true;
    2273     rc = RTSpinlockCreate(&Spinlock);
     2269    rc = RTSpinlockCreate(&Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestTest");
    22742270    AssertRCReturnVoid(rc);
    22752271    {
     
    25962592{
    25972593    bool                    fMousePositionChanged = false;
    2598     RTSPINLOCKTMP           Tmp                   = RTSPINLOCKTMP_INITIALIZER;
    25992594    VMMDevEvents volatile  *pReq                  = pDevExt->pIrqAckEvents;
    26002595    int                     rc                    = 0;
     
    26102605     * Enter the spinlock and check if it's our IRQ or not.
    26112606     */
    2612     RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp);
     2607    RTSpinlockAcquire(pDevExt->EventSpinlock);
    26132608    fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents;
    26142609    if (fOurIrq)
     
    26952690        LogFlow(("VBoxGuestCommonISR: not ours\n"));
    26962691
    2697     RTSpinlockReleaseNoInts(pDevExt->EventSpinlock, &Tmp);
     2692    RTSpinlockReleaseNoInts(pDevExt->EventSpinlock);
    26982693
    26992694#if defined(VBOXGUEST_USE_DEFERRED_WAKE_UP) && !defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Devices/Bus/SrvPciRawR0.cpp

    r39086 r40806  
    9595static DECLCALLBACK(bool) pcirawr0Isr(void* pContext, int32_t iHostIrq)
    9696{
    97     RTSPINLOCKTMP aTmp;
    9897    PPCIRAWDEV    pThis = (PPCIRAWDEV)pContext;
    9998
     
    114113#endif
    115114
    116     RTSpinlockAcquireNoInts(pThis->hSpinlock, &aTmp);
     115    RTSpinlockAcquire(pThis->hSpinlock);
    117116    pThis->iPendingIrq = iHostIrq;
    118     RTSpinlockReleaseNoInts(pThis->hSpinlock, &aTmp);
     117    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    119118
    120119    /**
     
    575574        if (RT_SUCCESS(rc))
    576575        {
    577             rc = RTSpinlockCreate(&pNew->hSpinlock);
     576            rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "PciRaw");
    578577            AssertRC(rc);
    579578            rc = RTSemEventCreate(&pNew->hIrqEvent);
     
    862861{
    863862    int            rc = VINF_SUCCESS;
    864     RTSPINLOCKTMP  aTmp;
    865863    bool           fTerminate = false;
    866864    int32_t        iPendingIrq = 0;
     
    870868    GET_PORT(TargetDevice);
    871869
    872     RTSpinlockAcquireNoInts(pDev->hSpinlock, &aTmp);
     870    RTSpinlockAcquire(pDev->hSpinlock);
    873871    iPendingIrq = pDev->iPendingIrq;
    874872    pDev->iPendingIrq = 0;
    875873    fTerminate = pDev->fTerminate;
    876     RTSpinlockReleaseNoInts(pDev->hSpinlock, &aTmp);
     874    RTSpinlockReleaseNoInts(pDev->hSpinlock);
    877875
    878876    /* Block until new IRQs arrives */
     
    887885                if (!ASMAtomicReadBool(&pDev->fTerminate))
    888886                {
    889                     RTSpinlockAcquireNoInts(pDev->hSpinlock, &aTmp);
     887                    RTSpinlockAcquire(pDev->hSpinlock);
    890888                    iPendingIrq = pDev->iPendingIrq;
    891889                    pDev->iPendingIrq = 0;
    892                     RTSpinlockReleaseNoInts(pDev->hSpinlock, &aTmp);
     890                    RTSpinlockReleaseNoInts(pDev->hSpinlock);
    893891                }
    894892                else
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r39091 r40806  
    11221122                                                uint8_t const cbAddr, const char *pszMsg)
    11231123{
    1124     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1125     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1124    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    11261125
    11271126    uint32_t iIf = pNetwork->MacTab.cEntries;
     
    11341133    }
    11351134
    1136     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1135    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    11371136}
    11381137
     
    11531152                                                       INTNETADDRTYPE const enmType, uint8_t const cbAddr, const char *pszMsg)
    11541153{
    1155     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1156     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1154    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    11571155
    11581156    uint32_t iIf = pNetwork->MacTab.cEntries;
     
    11681166    }
    11691167
    1170     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1168    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    11711169}
    11721170
     
    11851183DECLINLINE(PINTNETIF) intnetR0NetworkAddrCacheLookupIf(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr, INTNETADDRTYPE const enmType, uint8_t const cbAddr)
    11861184{
    1187     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1188     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1185    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    11891186
    11901187    uint32_t iIf = pNetwork->MacTab.cEntries;
     
    11961193        {
    11971194            intnetR0BusyIncIf(pIf);
    1198             RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1195            RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    11991196            return pIf;
    12001197        }
    12011198    }
    12021199
    1203     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1200    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    12041201    return NULL;
    12051202}
     
    12211218    PINTNETNETWORK  pNetwork = pIf->pNetwork;
    12221219    AssertReturnVoid(pNetwork);
    1223     RTSPINLOCKTMP   Tmp      = RTSPINLOCKTMP_INITIALIZER;
    1224     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1220    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    12251221
    12261222    if (RT_UNLIKELY(!pCache->cEntriesAlloc))
    12271223    {
    12281224        /* This shouldn't happen*/
    1229         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1225        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    12301226        return;
    12311227    }
     
    12641260    Assert(pCache->cEntries <= pCache->cEntriesAlloc);
    12651261
    1266     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1262    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    12671263}
    12681264
     
    14431439     */
    14441440    PINTNETMACTAB   pTab    = &pNetwork->MacTab;
    1445     RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
    1446     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1441    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    14471442
    14481443    pDstTab->fTrunkDst  = 0;
     
    15221517    }
    15231518
    1524     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1519    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    15251520    return pDstTab->cIfs
    15261521         ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_INTNET : INTNETSWDECISION_BROADCAST)
     
    15501545    INTNETSWDECISION    enmSwDecision   = INTNETSWDECISION_BROADCAST;
    15511546    PINTNETMACTAB       pTab            = &pNetwork->MacTab;
    1552     RTSPINLOCKTMP       Tmp             = RTSPINLOCKTMP_INITIALIZER;
    1553     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1547    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    15541548
    15551549    /* Iterate the internal network interfaces and look for matching source and
     
    15841578    }
    15851579
    1586     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1580    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    15871581    return enmSwDecision;
    15881582}
     
    16111605     */
    16121606    PINTNETMACTAB   pTab = &pNetwork->MacTab;
    1613     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    1614     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1607    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    16151608
    16161609    pDstTab->fTrunkDst  = 0;
     
    16981691    }
    16991692
    1700     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1693    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    17011694    return pDstTab->cIfs
    17021695         ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_INTNET : INTNETSWDECISION_BROADCAST)
     
    17241717     */
    17251718    PINTNETMACTAB   pTab    = &pNetwork->MacTab;
    1726     RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
    1727     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1719    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    17281720
    17291721    pDstTab->fTrunkDst  = 0;
     
    17611753    }
    17621754
    1763     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1755    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    17641756    return INTNETSWDECISION_BROADCAST;
    17651757}
     
    17861778     */
    17871779    PINTNETMACTAB   pTab    = &pNetwork->MacTab;
    1788     RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
    1789     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1780    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    17901781
    17911782    pDstTab->fTrunkDst  = 0;
     
    18231814    }
    18241815
    1825     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1816    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    18261817    return !pDstTab->cIfs
    18271818        ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_DROP   : INTNETSWDECISION_TRUNK)
     
    18461837     */
    18471838    PINTNETMACTAB   pTab= &pNetwork->MacTab;
    1848     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    1849     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1839    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    18501840
    18511841    pDstTab->fTrunkDst  = 0;
     
    18661856    }
    18671857
    1868     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1858    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    18691859    return pDstTab->fTrunkDst ? INTNETSWDECISION_TRUNK : INTNETSWDECISION_DROP;
    18701860}
     
    19121902        if (cAllocated <= INTNET_MAX_IFS)
    19131903        {
    1914             RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1915 
    19161904            /*
    19171905             * Resize the destination tables first, this can be kind of tedious.
     
    19581946                    for (;;)
    19591947                    {
    1960                         RTSpinlockAcquireNoInts(pTrunk->hDstTabSpinlock, &Tmp);
     1948                        RTSpinlockAcquire(pTrunk->hDstTabSpinlock);
    19611949                        void *pvOld = *ppDstTab;
    19621950                        if (pvOld)
    19631951                            *ppDstTab = pNew;
    1964                         RTSpinlockReleaseNoInts(pTrunk->hDstTabSpinlock, &Tmp);
     1952                        RTSpinlockReleaseNoInts(pTrunk->hDstTabSpinlock);
    19651953                        if (pvOld)
    19661954                        {
     
    19811969                if (paNew)
    19821970                {
    1983                     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1971                    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    19841972
    19851973                    PINTNETMACTABENTRY  paOld = pTab->paEntries;
     
    19961984                    pTab->cEntriesAllocated = cAllocated;
    19971985
    1998                     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     1986                    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    19991987
    20001988                    RTMemFree(paOld);
     
    20902078            {
    20912079                PINTNETIF       pMatchingIf = NULL;
    2092                 RTSPINLOCKTMP   Tmp         = RTSPINLOCKTMP_INITIALIZER;
    2093                 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     2080                RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    20942081
    20952082                uint32_t iIf = pNetwork->MacTab.cEntries;
     
    21102097                }
    21112098
    2112                 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     2099                RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    21132100
    21142101                if (pMatchingIf)
     
    21272114        case RTNET_DHCP_MT_RELEASE:
    21282115        {
    2129             RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2130             RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     2116            RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    21312117
    21322118            uint32_t iIf = pNetwork->MacTab.cEntries;
     
    21442130            }
    21452131
    2146             RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     2132            RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    21472133            break;
    21482134        }
     
    25772563     * Grab the receive/producer lock and copy over the frame.
    25782564     */
    2579     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2580     RTSpinlockAcquireNoInts(pIf->hRecvInSpinlock, &Tmp);
     2565    RTSpinlockAcquire(pIf->hRecvInSpinlock);
    25812566    int rc = intnetR0RingWriteFrame(&pIf->pIntBuf->Recv, pSG, pNewDstMac);
    2582     RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock, &Tmp);
     2567    RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock);
    25832568    if (RT_SUCCESS(rc))
    25842569    {
     
    26052590            RTThreadYield();
    26062591
    2607             RTSpinlockAcquireNoInts(pIf->hRecvInSpinlock, &Tmp);
     2592            RTSpinlockAcquire(pIf->hRecvInSpinlock);
    26082593            rc = intnetR0RingWriteFrame(&pIf->pIntBuf->Recv, pSG, pNewDstMac);
    2609             RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock, &Tmp);
     2594            RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock);
    26102595            if (RT_SUCCESS(rc))
    26112596            {
     
    30663051    /* PARANOIA: Grab the spinlock to make sure the trunk structure cannot be
    30673052                 freed while we're touching it. */
    3068     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    3069     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3053    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    30703054    PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
    30713055
     
    30753059                && (!pNetwork->MacTab.fWireActive || (pTrunk->fNoPreemptDsts & INTNETTRUNKDIR_WIRE) ) );
    30763060
    3077     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3061    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    30783062
    30793063    return fRc;
     
    33973381    {
    33983382        Log2(("IF MAC: %.6Rhxs -> %.6Rhxs\n", &pIfSender->MacAddr, &EthHdr.SrcMac));
    3399         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    3400         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3383        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    34013384
    34023385        PINTNETMACTABENTRY pIfEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIfSender);
     
    34053388        pIfSender->MacAddr    = EthHdr.SrcMac;
    34063389
    3407         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3390        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    34083391    }
    34093392
     
    37323715    if (pNetwork)
    37333716    {
    3734         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    3735         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3717        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    37363718
    37373719        if (pIf->fPromiscuousReal != fPromiscuous)
     
    37723754        }
    37733755
    3774         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3756        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    37753757    }
    37763758    else
     
    38343816    if (pNetwork)
    38353817    {
    3836         RTSPINLOCKTMP   Tmp    = RTSPINLOCKTMP_INITIALIZER;
    38373818        PINTNETTRUNKIF  pTrunk = NULL;
    38383819
    3839         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3820        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    38403821
    38413822        if (memcmp(&pIf->MacAddr, pMac, sizeof(pIf->MacAddr)))
     
    38573838        }
    38583839
    3859         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3840        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    38603841
    38613842        if (pTrunk)
     
    39173898     */
    39183899    PINTNETTRUNKIF  pTrunk  = NULL;
    3919     RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
    3920     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3900    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    39213901
    39223902    /*
     
    39573937    }
    39583938
    3959     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     3939    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    39603940
    39613941    /*
     
    43224302
    43234303        /* remove ourselves from the switch table. */
    4324         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    4325         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4304        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    43264305
    43274306        uint32_t iIf = pNetwork->MacTab.cEntries;
     
    43634342        PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk;
    43644343
    4365         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4344        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    43664345
    43674346        /* Notify the trunk about the interface being destroyed. */
     
    43734352
    43744353        /* Release our reference to the network. */
    4375         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4354        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    43764355        pIf->pNetwork = NULL;
    4377         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4356        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    43784357
    43794358        SUPR0ObjRelease(pNetwork->pvObj, pIf->pSession);
     
    45344513        rc = RTSemEventCreate((PRTSEMEVENT)&pIf->hRecvEvent);
    45354514    if (RT_SUCCESS(rc))
    4536         rc = RTSpinlockCreate(&pIf->hRecvInSpinlock);
     4515        rc = RTSpinlockCreate(&pIf->hRecvInSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hRecvInSpinlock");
    45374516    if (RT_SUCCESS(rc))
    45384517    {
     
    45674546                     * network reference of the caller.
    45684547                     */
    4569                     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    4570                     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4548                    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    45714549
    45724550                    uint32_t iIf = pNetwork->MacTab.cEntries;
     
    45904568                        intnetR0BusyIncTrunk(pTrunk);
    45914569
    4592                     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4570                    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    45934571
    45944572                    if (pTrunk)
     
    46584636    if (pNetwork)
    46594637    {
    4660         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    4661         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4638        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    46624639
    46634640        pNetwork->MacTab.HostMac = *pMacAddr;
    46644641        pThis->MacAddr           = *pMacAddr;
    46654642
    4666         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4643        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    46674644    }
    46684645    else
     
    46854662    if (pNetwork)
    46864663    {
    4687         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    4688         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4664        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    46894665
    46904666        pNetwork->MacTab.fHostPromiscuousReal = fPromiscuous
     
    46934669                                             && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST);
    46944670
    4695         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     4671        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    46964672    }
    46974673    intnetR0BusyDecTrunk(pThis);
     
    47954771        unsigned        iDstTab = 0;
    47964772        PINTNETDSTTAB   pDstTab = NULL;
    4797         RTSPINLOCKTMP   Tmp     = RTSPINLOCKTMP_INITIALIZER;
    4798         RTSpinlockAcquireNoInts(pThis->hDstTabSpinlock, &Tmp);
     4773        RTSpinlockAcquire(pThis->hDstTabSpinlock);
    47994774        if (fIntCtx)
    48004775        {
     
    48184793                }
    48194794            }
    4820             RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock, &Tmp);
     4795            RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock);
    48214796            Assert(!pDstTab || iDstTab < pThis->cIntDstTabs);
    48224797        }
     
    48314806            {
    48324807                pThis->apIntDstTabs[iDstTab] = NULL;
    4833                 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock, &Tmp);
     4808                RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock);
    48344809                Assert(iDstTab < RT_ELEMENTS(pThis->apTaskDstTabs));
    48354810            }
    48364811            else
    48374812            {
    4838                 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock, &Tmp);
     4813                RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock);
    48394814                intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, &pDstTab);
    48404815                iDstTab = 65535;
     
    48584833            else
    48594834            {
    4860                 RTSpinlockAcquireNoInts(pThis->hDstTabSpinlock, &Tmp);
     4835                RTSpinlockAcquire(pThis->hDstTabSpinlock);
    48614836                if (fIntCtx && !pThis->apIntDstTabs[iDstTab])
    48624837                    pThis->apIntDstTabs[iDstTab]  = pDstTab;
     
    48754850                        }
    48764851                }
    4877                 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock, &Tmp);
     4852                RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock);
    48784853                Assert(iDstTab < RT_MAX(RT_ELEMENTS(pThis->apTaskDstTabs), pThis->cIntDstTabs));
    48794854            }
     
    51035078         * Create the lock (we've NIL'ed the members above to simplify cleanup).
    51045079         */
    5105         rc = RTSpinlockCreate(&pTrunk->hDstTabSpinlock);
     5080        rc = RTSpinlockCreate(&pTrunk->hDstTabSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hDstTabSpinlock");
    51065081        if (RT_SUCCESS(rc))
    51075082        {
     
    52075182     *       be dereference and destroyed before the interfaces.
    52085183     */
    5209     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    5210     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5184    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    52115185
    52125186    uint32_t iIf = pNetwork->MacTab.cEntries;
     
    52205194    pNetwork->MacTab.fWireActive = false;
    52215195
    5222     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5196    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    52235197
    52245198    /* Wait for all the interfaces to quiesce.  (Interfaces cannot be
     
    52335207    /* Orphan the interfaces (not trunk).  Don't bother with calling
    52345208       pfnDisconnectInterface here since the networking is going away. */
    5235     RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5209    RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    52365210    while ((iIf = pNetwork->MacTab.cEntries) > 0)
    52375211    {
    52385212        PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf - 1].pIf;
    5239         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5213        RTSpinlockRelease(pNetwork->hAddrSpinlock);
    52405214
    52415215        intnetR0BusyWait(pNetwork, &pIf->cBusy);
    52425216
    5243         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5217        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    52445218        if (   iIf == pNetwork->MacTab.cEntries /* paranoia */
    52455219            && pIf->cBusy)
     
    52565230    pNetwork->MacTab.pTrunk = NULL;
    52575231
    5258     RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5232    RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    52595233
    52605234    if (pTrunk)
     
    54005374        LogRel(("INTNET: %s - flags changed %#x -> %#x\n", pNetwork->szName, fOldNetFlags, fNetFlags));
    54015375
    5402         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    5403         RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5376        RTSpinlockAcquire(pNetwork->hAddrSpinlock);
    54045377
    54055378        pNetwork->fFlags = fNetFlags;
     
    54495422        }
    54505423
    5451         RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock, &Tmp);
     5424        RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock);
    54525425    }
    54535426
     
    56575630    int rc = RTSemEventCreate(&pNetwork->hEvtBusyIf);
    56585631    if (RT_SUCCESS(rc))
    5659         rc = RTSpinlockCreate(&pNetwork->hAddrSpinlock);
     5632        rc = RTSpinlockCreate(&pNetwork->hAddrSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hAddrSpinlock");
    56605633    if (RT_SUCCESS(rc))
    56615634    {
  • trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp

    r39091 r40806  
    178178
    179179/* No CLI/POPF, please. */
    180 #define RTSpinlockAcquireNoInts             RTSpinlockAcquire
    181 #define RTSpinlockReleaseNoInts             RTSpinlockRelease
     180#include <iprt/spinlock.h>
     181#undef  RTSPINLOCK_FLAGS_INTERRUPT_SAFE
     182#define RTSPINLOCK_FLAGS_INTERRUPT_SAFE     RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE
    182183
    183184
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r40804 r40806  
    342342    { "RTSemMutexRequestNoResumeDebug",         (void *)RTSemMutexRequestNoResumeDebug },
    343343    { "RTSpinlockAcquire",                      (void *)RTSpinlockAcquire },
    344     { "RTSpinlockAcquireNoInts",                (void *)RTSpinlockAcquireNoInts },
    345344    { "RTSpinlockCreate",                       (void *)RTSpinlockCreate },
    346345    { "RTSpinlockDestroy",                      (void *)RTSpinlockDestroy },
     
    452451     */
    453452    memset(pDevExt, 0, sizeof(*pDevExt));
    454     rc = RTSpinlockCreate(&pDevExt->Spinlock);
     453    rc = RTSpinlockCreate(&pDevExt->Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "SUPDrvDevExt");
    455454    if (RT_SUCCESS(rc))
    456455    {
    457         rc = RTSpinlockCreate(&pDevExt->spinGip);
     456        rc = RTSpinlockCreate(&pDevExt->hGipSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "SUPDrvGip");
    458457        if (RT_SUCCESS(rc))
    459458        {
     
    563562#endif
    564563            }
    565             RTSpinlockDestroy(pDevExt->spinGip);
    566             pDevExt->spinGip = NIL_RTSPINLOCK;
     564            RTSpinlockDestroy(pDevExt->hGipSpinlock);
     565            pDevExt->hGipSpinlock = NIL_RTSPINLOCK;
    567566        }
    568567        RTSpinlockDestroy(pDevExt->Spinlock);
     
    636635    /* kill the GIP. */
    637636    supdrvGipDestroy(pDevExt);
    638     RTSpinlockDestroy(pDevExt->spinGip);
    639     pDevExt->spinGip = NIL_RTSPINLOCK;
     637    RTSpinlockDestroy(pDevExt->hGipSpinlock);
     638    pDevExt->hGipSpinlock = NIL_RTSPINLOCK;
    640639
    641640    supdrvTracerTerm(pDevExt);
     
    667666    {
    668667        /* Initialize session data. */
    669         rc = RTSpinlockCreate(&pSession->Spinlock);
     668        rc = RTSpinlockCreate(&pSession->Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "SUPDrvSession");
    670669        if (!rc)
    671670        {
     
    777776    if (pSession->pUsage)
    778777    {
    779         RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    780778        PSUPDRVUSAGE    pUsage;
    781         RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     779        RTSpinlockAcquire(pDevExt->Spinlock);
    782780
    783781        while ((pUsage = pSession->pUsage) != NULL)
     
    790788            {
    791789                pObj->cUsage -= pUsage->cUsage;
    792                 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     790                RTSpinlockRelease(pDevExt->Spinlock);
    793791            }
    794792            else
     
    808806                    Assert(pObjPrev);
    809807                }
    810                 RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     808                RTSpinlockRelease(pDevExt->Spinlock);
    811809
    812810                Log(("supdrvCleanupSession: destroying %p/%d (%p/%p) cpid=%RTproc pid=%RTproc dtor=%p\n",
     
    820818            RTMemFree(pUsage);
    821819
    822             RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
    823         }
    824 
    825         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     820            RTSpinlockAcquire(pDevExt->Spinlock);
     821        }
     822
     823        RTSpinlockRelease(pDevExt->Spinlock);
    826824        AssertMsg(!pSession->pUsage, ("Some buster reregistered an object during desturction!\n"));
    827825    }
     
    20022000SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2)
    20032001{
    2004     RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    20052002    PSUPDRVDEVEXT   pDevExt     = pSession->pDevExt;
    20062003    PSUPDRVOBJ      pObj;
     
    20362033     * (We keep freed usage records around to simplify SUPR0ObjAddRefEx().)
    20372034     */
    2038     RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     2035    RTSpinlockAcquire(pDevExt->Spinlock);
    20392036
    20402037    pUsage = pDevExt->pUsageFree;
     
    20432040    else
    20442041    {
    2045         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2042        RTSpinlockRelease(pDevExt->Spinlock);
    20462043        pUsage = (PSUPDRVUSAGE)RTMemAlloc(sizeof(*pUsage));
    20472044        if (!pUsage)
     
    20502047            return NULL;
    20512048        }
    2052         RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     2049        RTSpinlockAcquire(pDevExt->Spinlock);
    20532050    }
    20542051
     
    20672064    pSession->pUsage    = pUsage;
    20682065
    2069     RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2066    RTSpinlockRelease(pDevExt->Spinlock);
    20702067
    20712068    Log(("SUPR0ObjRegister: returns %p (pvUser1=%p, pvUser=%p)\n", pObj, pvUser1, pvUser2));
     
    21132110SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking)
    21142111{
    2115     RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    21162112    PSUPDRVDEVEXT   pDevExt     = pSession->pDevExt;
    21172113    PSUPDRVOBJ      pObj        = (PSUPDRVOBJ)pvObj;
     
    21312127                    VERR_INVALID_PARAMETER);
    21322128
    2133     RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     2129    RTSpinlockAcquire(pDevExt->Spinlock);
    21342130
    21352131    if (RT_UNLIKELY(pObj->u32Magic != SUPDRVOBJ_MAGIC))
    21362132    {
    2137         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2133        RTSpinlockRelease(pDevExt->Spinlock);
    21382134
    21392135        AssertMsgFailed(("pvObj=%p magic=%#x\n", pvObj, pObj->u32Magic));
     
    21492145    else if (!fNoBlocking)
    21502146    {
    2151         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2147        RTSpinlockRelease(pDevExt->Spinlock);
    21522148        pUsagePre = (PSUPDRVUSAGE)RTMemAlloc(sizeof(*pUsagePre));
    21532149        if (!pUsagePre)
    21542150            return VERR_NO_MEMORY;
    21552151
    2156         RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     2152        RTSpinlockAcquire(pDevExt->Spinlock);
    21572153        if (RT_UNLIKELY(pObj->u32Magic != SUPDRVOBJ_MAGIC))
    21582154        {
    2159             RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2155            RTSpinlockRelease(pDevExt->Spinlock);
    21602156
    21612157            AssertMsgFailed(("pvObj=%p magic=%#x\n", pvObj, pObj->u32Magic));
     
    22062202    }
    22072203
    2208     RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2204    RTSpinlockRelease(pDevExt->Spinlock);
    22092205
    22102206    return rc;
     
    22282224SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession)
    22292225{
    2230     RTSPINLOCKTMP       SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    22312226    PSUPDRVDEVEXT       pDevExt     = pSession->pDevExt;
    22322227    PSUPDRVOBJ          pObj        = (PSUPDRVOBJ)pvObj;
     
    22462241     * Acquire the spinlock and look for the usage record.
    22472242     */
    2248     RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     2243    RTSpinlockAcquire(pDevExt->Spinlock);
    22492244
    22502245    for (pUsagePrev = NULL, pUsage = pSession->pUsage;
     
    23032298    }
    23042299
    2305     RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     2300    RTSpinlockRelease(pDevExt->Spinlock);
    23062301
    23072302    /*
     
    26862681{
    26872682    PSUPDRVBUNDLE pBundle;
    2688     RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    26892683    LogFlow(("SUPR0MemGetPhys: pSession=%p uPtr=%p paPages=%p\n", pSession, (void *)uPtr, paPages));
    26902684
     
    26992693     * Search for the address.
    27002694     */
    2701     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     2695    RTSpinlockAcquire(pSession->Spinlock);
    27022696    for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
    27032697    {
     
    27222716                        paPages[iPage].uReserved = 0;
    27232717                    }
    2724                     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     2718                    RTSpinlockRelease(pSession->Spinlock);
    27252719                    return VINF_SUCCESS;
    27262720                }
     
    27282722        }
    27292723    }
    2730     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     2724    RTSpinlockRelease(pSession->Spinlock);
    27312725    Log(("Failed to find %p!!!\n", (void *)uPtr));
    27322726    return VERR_INVALID_PARAMETER;
     
    28512845    int             rc;
    28522846    PSUPDRVBUNDLE   pBundle;
    2853     RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    28542847    RTR0MEMOBJ      hMemObj = NIL_RTR0MEMOBJ;
    28552848    LogFlow(("SUPR0PageMapKernel: pSession=%p pvR3=%p offSub=%#x cbSub=%#x\n", pSession, pvR3, offSub, cbSub));
     
    28682861     * Find the memory object.
    28692862     */
    2870     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     2863    RTSpinlockAcquire(pSession->Spinlock);
    28712864    for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
    28722865    {
     
    28912884        }
    28922885    }
    2893     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     2886    RTSpinlockRelease(pSession->Spinlock);
    28942887
    28952888    rc = VERR_INVALID_PARAMETER;
     
    29372930    int             rc;
    29382931    PSUPDRVBUNDLE   pBundle;
    2939     RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    29402932    RTR0MEMOBJ      hMemObjR0 = NIL_RTR0MEMOBJ;
    29412933    RTR0MEMOBJ      hMemObjR3 = NIL_RTR0MEMOBJ;
     
    29542946     * Find the memory object.
    29552947     */
    2956     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     2948    RTSpinlockAcquire(pSession->Spinlock);
    29572949    for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
    29582950    {
     
    29802972        }
    29812973    }
    2982     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     2974    RTSpinlockRelease(pSession->Spinlock);
    29832975
    29842976    rc = VERR_INVALID_PARAMETER;
     
    36963688{
    36973689    PSUPDRVBUNDLE pBundle;
    3698     RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    36993690
    37003691    /*
    37013692     * Find free entry and record the allocation.
    37023693     */
    3703     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     3694    RTSpinlockAcquire(pSession->Spinlock);
    37043695    for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
    37053696    {
     
    37133704                    pBundle->cUsed++;
    37143705                    pBundle->aMem[i] = *pMem;
    3715                     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     3706                    RTSpinlockRelease(pSession->Spinlock);
    37163707                    return VINF_SUCCESS;
    37173708                }
     
    37203711        }
    37213712    }
    3722     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     3713    RTSpinlockRelease(pSession->Spinlock);
    37233714
    37243715    /*
     
    37353726
    37363727    /* insert into list. */
    3737     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     3728    RTSpinlockAcquire(pSession->Spinlock);
    37383729    pBundle->pNext = pSession->Bundle.pNext;
    37393730    pSession->Bundle.pNext = pBundle;
    3740     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     3731    RTSpinlockRelease(pSession->Spinlock);
    37413732
    37423733    return VINF_SUCCESS;
     
    37553746{
    37563747    PSUPDRVBUNDLE pBundle;
    3757     RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    37583748
    37593749    /*
     
    37693759     * Search for the address.
    37703760     */
    3771     RTSpinlockAcquire(pSession->Spinlock, &SpinlockTmp);
     3761    RTSpinlockAcquire(pSession->Spinlock);
    37723762    for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext)
    37733763    {
     
    37893779                    pBundle->aMem[i].MemObj = NIL_RTR0MEMOBJ;
    37903780                    pBundle->aMem[i].MapObjR3 = NIL_RTR0MEMOBJ;
    3791                     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     3781                    RTSpinlockRelease(pSession->Spinlock);
    37923782
    37933783                    if (Mem.MapObjR3 != NIL_RTR0MEMOBJ)
     
    38063796        }
    38073797    }
    3808     RTSpinlockRelease(pSession->Spinlock, &SpinlockTmp);
     3798    RTSpinlockRelease(pSession->Spinlock);
    38093799    Log(("Failed to find %p!!! (eType=%d)\n", (void *)uPtr, eType));
    38103800    return VERR_INVALID_PARAMETER;
     
    42124202         * clean things up in the right order and not leave them all dangling.
    42134203         */
    4214         RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    4215         RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     4204        RTSpinlockAcquire(pDevExt->Spinlock);
    42164205        if (pImage->cUsage <= 1)
    42174206        {
     
    42344223                }
    42354224        }
    4236         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     4225        RTSpinlockRelease(pDevExt->Spinlock);
    42374226        if (rc == VINF_SUCCESS)
    42384227        {
     
    45724561        unsigned        cObjs = 0;
    45734562        PSUPDRVOBJ      pObj;
    4574         RTSPINLOCKTMP   SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    4575         RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp);
     4563        RTSpinlockAcquire(pDevExt->Spinlock);
    45764564        for (pObj = pDevExt->pObjs; pObj; pObj = pObj->pNext)
    45774565            if (RT_UNLIKELY((uintptr_t)pObj->pfnDestructor - (uintptr_t)pImage->pvImage < pImage->cbImageBits))
     
    45804568                cObjs++;
    45814569            }
    4582         RTSpinlockRelease(pDevExt->Spinlock, &SpinlockTmp);
     4570        RTSpinlockRelease(pDevExt->Spinlock);
    45834571        if (cObjs)
    45844572            OSDBGPRINT(("supdrvLdrFree: Image '%s' has %d dangling objects!\n", pImage->szName, cObjs));
     
    50875075    uint32_t    i = 0;
    50885076    uint64_t    u64NanoTS = 0;
    5089     RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    50905077    PSUPGLOBALINFOPAGE pGip = pDevExt->pGip;
    50915078
     
    50985085     * on all CPUs simultaneously, see #6110.
    50995086     */
    5100     RTSpinlockAcquireNoInts(pDevExt->spinGip, &SpinlockTmp);
     5087    RTSpinlockAcquire(pDevExt->hGipSpinlock);
    51015088
    51025089    /*
     
    51335120    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_ONLINE);
    51345121
    5135     RTSpinlockReleaseNoInts(pDevExt->spinGip, &SpinlockTmp);
     5122    RTSpinlockReleaseNoInts(pDevExt->hGipSpinlock);
    51365123}
    51375124
     
    51515138
    51525139    PSUPGLOBALINFOPAGE pGip   = pDevExt->pGip;
    5153     RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    51545140
    51555141    AssertPtrReturnVoid(pGip);
    5156     RTSpinlockAcquireNoInts(pDevExt->spinGip, &SpinlockTmp);
     5142    RTSpinlockAcquire(pDevExt->hGipSpinlock);
    51575143
    51585144    iCpuSet = RTMpCpuIdToSetIndex(idCpu);
     
    51695155    ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_OFFLINE);
    51705156
    5171     RTSpinlockReleaseNoInts(pDevExt->spinGip, &SpinlockTmp);
     5157    RTSpinlockReleaseNoInts(pDevExt->hGipSpinlock);
    51725158}
    51735159
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r40763 r40806  
    191191 *
    192192 * @todo Pending work on next major version change:
    193  *          - None.
    194  */
    195 #define SUPDRV_IOC_VERSION                              0x00190002
     193 *          - Remove RTSpinlockReleaseNoInts.
     194 */
     195#define SUPDRV_IOC_VERSION                              0x001a0000
    196196
    197197/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r40777 r40806  
    517517#endif
    518518    /** GIP spinlock protecting GIP members during Mp events. */
    519     RTSPINLOCK                      spinGip;
     519    RTSPINLOCK                      hGipSpinlock;
    520520    /** Pointer to the Global Info Page (GIP). */
    521521    PSUPGLOBALINFOPAGE              pGip;
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r37970 r40806  
    239239             */
    240240            memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab)); /* paranoia */
    241             rc = RTSpinlockCreate(&g_Spinlock);
     241            rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvDarwin");
    242242            if (RT_SUCCESS(rc))
    243243            {
     
    370370        RTPROCESS       Process = RTProcSelf();
    371371        unsigned        iHash = SESSION_HASH(Process);
    372         RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    373         RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     372        RTSpinlockAcquire(g_Spinlock);
    374373
    375374        pSession = g_apSessionHashTab[iHash];
     
    393392            rc = VERR_GENERAL_FAILURE;
    394393
    395         RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     394        RTSpinlockReleaseNoInts(g_Spinlock);
    396395#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
    397396        kauth_cred_unref(&pCred);
     
    442441static int VBoxDrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)
    443442{
    444     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    445443    const RTPROCESS     Process = proc_pid(pProcess);
    446444    const unsigned      iHash = SESSION_HASH(Process);
     
    450448     * Find the session.
    451449     */
    452     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     450    RTSpinlockAcquire(g_Spinlock);
    453451    pSession = g_apSessionHashTab[iHash];
    454452    if (pSession && pSession->Process != Process)
     
    457455        while (pSession && pSession->Process != Process);
    458456    }
    459     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     457    RTSpinlockReleaseNoInts(g_Spinlock);
    460458    if (!pSession)
    461459    {
     
    982980                 */
    983981                unsigned iHash = SESSION_HASH(m_pSession->Process);
    984                 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    985                 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     982                RTSpinlockAcquire(g_Spinlock);
    986983
    987984                PSUPDRVSESSION pCur = g_apSessionHashTab[iHash];
     
    1002999                    rc = VERR_ALREADY_LOADED;
    10031000
    1004                 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     1001                RTSpinlockReleaseNoInts(g_Spinlock);
    10051002                if (RT_SUCCESS(rc))
    10061003                {
     
    10341031     */
    10351032    const unsigned  iHash = SESSION_HASH(Process);
    1036     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    1037     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     1033    RTSpinlockAcquire(g_Spinlock);
    10381034    PSUPDRVSESSION  pSession = g_apSessionHashTab[iHash];
    10391035    if (pSession)
     
    10651061        }
    10661062    }
    1067     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     1063    RTSpinlockReleaseNoInts(g_Spinlock);
    10681064    if (!pSession)
    10691065    {
  • trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp

    r37249 r40806  
    108108             * Initialize the session hash table.
    109109             */
    110             rc = RTSpinlockCreate(&g_Spinlock);
     110            rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvOS2");
    111111            if (RT_SUCCESS(rc))
    112112            {
     
    160160         */
    161161        unsigned iHash = SESSION_HASH(sfn);
    162         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    163         RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     162        RTSpinlockAcquire(g_Spinlock);
    164163        pSession->pNextHash = g_apSessionHashTab[iHash];
    165164        g_apSessionHashTab[iHash] = pSession;
    166         RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     165        RTSpinlockReleaseNoInts(g_Spinlock);
    167166    }
    168167
     
    182181    const RTPROCESS Process = RTProcSelf();
    183182    const unsigned  iHash = SESSION_HASH(sfn);
    184     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    185     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     183    RTSpinlockAcquire(g_Spinlock);
    186184
    187185    pSession = g_apSessionHashTab[iHash];
     
    214212        }
    215213    }
    216     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     214    RTSpinlockReleaseNoInts(g_Spinlock);
    217215    if (!pSession)
    218216    {
     
    234232     * Find the session.
    235233     */
    236     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    237234    const RTPROCESS     Process = RTProcSelf();
    238235    const unsigned      iHash = SESSION_HASH(sfn);
    239236    PSUPDRVSESSION      pSession;
    240237
    241     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     238    RTSpinlockAcquire(g_Spinlock);
    242239    pSession = g_apSessionHashTab[iHash];
    243240    if (pSession && pSession->Process != Process)
     
    248245                     || pSession->Process != Process));
    249246    }
    250     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     247    RTSpinlockReleaseNoInts(g_Spinlock);
    251248    if (RT_UNLIKELY(!pSession))
    252249    {
     
    268265     * Find the session.
    269266     */
    270     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    271267    const RTPROCESS     Process = RTProcSelf();
    272268    const unsigned      iHash = SESSION_HASH(sfn);
    273269    PSUPDRVSESSION      pSession;
    274270
    275     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     271    RTSpinlockAcquire(g_Spinlock);
    276272    pSession = g_apSessionHashTab[iHash];
    277273    if (pSession && pSession->Process != Process)
     
    282278                     || pSession->Process != Process));
    283279    }
    284     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     280    RTSpinlockReleaseNoInts(g_Spinlock);
    285281    if (!pSession)
    286282    {
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c

    r40616 r40806  
    224224             */
    225225            memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab));
    226             rc = RTSpinlockCreate(&g_Spinlock);
     226            rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvSol");
    227227            if (RT_SUCCESS(rc))
    228228            {
     
    494494    if (RT_SUCCESS(rc))
    495495    {
    496         RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    497496        unsigned        iHash;
    498497
     
    504503         */
    505504        iHash = SESSION_HASH(pSession->Process);
    506         RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     505        RTSpinlockAcquire(g_Spinlock);
    507506        pSession->pNextHash = g_apSessionHashTab[iHash];
    508507        g_apSessionHashTab[iHash] = pSession;
    509         RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     508        RTSpinlockReleaseNoInts(g_Spinlock);
    510509        LogFlow((DEVICE_NAME ":VBoxDrvSolarisOpen success\n"));
    511510    }
     
    560559
    561560#else
    562     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    563561    const RTPROCESS Process = RTProcSelf();
    564562    const unsigned  iHash = SESSION_HASH(Process);
     
    568566     * Remove from the hash table.
    569567     */
    570     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     568    RTSpinlockAcquire(g_Spinlock);
    571569    pSession = g_apSessionHashTab[iHash];
    572570    if (pSession)
     
    596594        }
    597595    }
    598     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     596    RTSpinlockReleaseNoInts(g_Spinlock);
    599597    if (!pSession)
    600598    {
     
    659657    }
    660658#else
    661     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    662659    const RTPROCESS     Process = RTProcSelf();
    663660    const unsigned      iHash = SESSION_HASH(Process);
     
    667664     * Find the session.
    668665     */
    669     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     666    RTSpinlockAcquire(g_Spinlock);
    670667    pSession = g_apSessionHashTab[iHash];
    671668    if (pSession && pSession->Process != Process)
     
    674671        while (pSession && pSession->Process != Process);
    675672    }
    676     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     673    RTSpinlockReleaseNoInts(g_Spinlock);
    677674    if (!pSession)
    678675    {
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c

    r38408 r40806  
    106106DECLINLINE(void) vboxNetAdpSetStateWithLock(PVBOXNETADP pThis, VBOXNETADPSTATE enmNewState)
    107107{
    108     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    109108    Log(("vboxNetAdpSetStateWithLock: pThis=%p, state=%d.\n", pThis, enmNewState));
    110     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     109    RTSpinlockAcquire(pThis->hSpinlock);
    111110    vboxNetAdpSetState(pThis, enmNewState);
    112     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     111    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    113112}
    114113
     
    125124{
    126125    VBOXNETADPSTATE enmState;
    127     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    128     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     126    RTSpinlockAcquire(pThis->hSpinlock);
    129127    enmState = vboxNetAdpGetState(pThis);
    130     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     128    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    131129    Log(("vboxNetAdpGetStateWithLock: pThis=%p, state=%d.\n", pThis, enmState));
    132130    return enmState;
     
    147145    VBOXNETADPSTATE enmActualState;
    148146    bool fRc = true; /* be optimistic */
    149     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    150 
    151     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     147
     148    RTSpinlockAcquire(pThis->hSpinlock);
    152149    enmActualState = vboxNetAdpGetState(pThis); /** @todo r=bird: ASMAtomicCmpXchgU32()*/
    153150    if (enmActualState == enmOldState)
     
    155152    else
    156153        fRc = false;
    157     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     154    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    158155
    159156    if (fRc)
     
    178175    for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++)
    179176    {
    180         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    181177        PVBOXNETADP pThis = &pGlobals->aAdapters[i];
    182         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     178        RTSpinlockAcquire(pThis->hSpinlock);
    183179        if (    vboxNetAdpGetState(pThis)
    184180            &&  !strcmp(pThis->szName, pszName))
    185181        {
    186             RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     182            RTSpinlockReleaseNoInts(pThis->hSpinlock);
    187183            return pThis;
    188184        }
    189         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     185        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    190186    }
    191187    return NULL;
     
    340336DECLHIDDEN(bool) vboxNetAdpPrepareToReceive(PVBOXNETADP pThis)
    341337{
    342     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    343338    bool fCanReceive  = false;
    344339    /*
     
    347342    AssertPtr(pThis);
    348343    Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION);
    349     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     344    RTSpinlockAcquire(pThis->hSpinlock);
    350345    if (vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active)
    351346    {
     
    354349        vboxNetAdpBusy(pThis);
    355350    }
    356     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     351    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    357352    Log(("vboxNetAdpPrepareToReceive: fCanReceive=%d.\n", fCanReceive));
    358353
     
    368363DECLHIDDEN(void) vboxNetAdpReceive(PVBOXNETADP pThis, PINTNETSG pSG)
    369364{
    370     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    371365    /*
    372366     * Input validation.
     
    401395static DECLCALLBACK(int) vboxNetAdpPortXmit(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG, uint32_t fDst)
    402396{
    403     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    404397    PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort);
    405398    int rc = VINF_SUCCESS;
     
    417410     * Do a retain/busy, invoke the OS specific code.
    418411     */
    419     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     412    RTSpinlockAcquire(pThis->hSpinlock);
    420413    if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Active)
    421414    {
    422         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     415        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    423416        Log(("vboxNetAdpReceive: Dropping incoming packet for inactive interface %s.\n",
    424417             pThis->szName));
     
    427420    vboxNetAdpRetain(pThis);
    428421    vboxNetAdpBusy(pThis);
    429     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     422    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    430423
    431424    rc = vboxNetAdpPortOsXmit(pThis, pSG, fDst);
     
    494487{
    495488    bool fPreviouslyActive;
    496     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    497489    PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort);
    498490
     
    505497
    506498    Log(("vboxNetAdpPortSetActive: pThis=%p, fActive=%d, state before: %d.\n", pThis, fActive, vboxNetAdpGetState(pThis)));
    507     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     499    RTSpinlockAcquire(pThis->hSpinlock);
    508500
    509501    fPreviouslyActive = vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active;
     
    523515    }
    524516
    525     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     517    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    526518    Log(("vboxNetAdpPortSetActive: state after: %RTbool.\n", vboxNetAdpGetState(pThis)));
    527519    return fPreviouslyActive;
     
    535527{
    536528    PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort);
    537     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    538529
    539530    /*
     
    551542     * Disconnect and release it.
    552543     */
    553     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     544    RTSpinlockAcquire(pThis->hSpinlock);
    554545    //Assert(vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Connected);
    555546    Assert(!pThis->cBusy);
    556547    vboxNetAdpSetState(pThis, kVBoxNetAdpState_Transitional);
    557     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     548    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    558549
    559550    vboxNetAdpOsDisconnectIt(pThis);
    560551    pThis->pSwitchPort = NULL;
    561552
    562     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     553    RTSpinlockAcquire(pThis->hSpinlock);
    563554    vboxNetAdpSetState(pThis, kVBoxNetAdpState_Available);
    564     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     555    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    565556
    566557    vboxNetAdpRelease(pThis);
     
    590581int vboxNetAdpCreate(PINTNETTRUNKFACTORY pIfFactory, PVBOXNETADP *ppNew)
    591582{
     583    PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
     584    unsigned i;
    592585    int rc;
    593     unsigned i;
    594     PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));
    595586
    596587    for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++)
    597588    {
    598         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    599589        PVBOXNETADP pThis = &pGlobals->aAdapters[i];
    600590
     
    608598            rc = vboxNetAdpOsCreate(pThis, &Mac);
    609599            *ppNew = pThis;
    610             RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     600
     601            RTSpinlockAcquire(pThis->hSpinlock);
    611602            vboxNetAdpSetState(pThis, kVBoxNetAdpState_Available);
    612             RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     603            RTSpinlockReleaseNoInts(pThis->hSpinlock);
    613604            return rc;
    614605        }
     
    622613{
    623614    int rc = VINF_SUCCESS;
    624     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    625 
    626     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     615
     616    RTSpinlockAcquire(pThis->hSpinlock);
    627617    if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Available || pThis->cBusy)
    628618    {
    629         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     619        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    630620        return VERR_INTNET_FLT_IF_BUSY;
    631621    }
    632622    vboxNetAdpSetState(pThis, kVBoxNetAdpState_Transitional);
    633     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     623    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    634624    vboxNetAdpRelease(pThis);
    635625
    636626    vboxNetAdpOsDestroy(pThis);
    637627
    638     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     628    RTSpinlockAcquire(pThis->hSpinlock);
    639629    vboxNetAdpSetState(pThis, kVBoxNetAdpState_Invalid);
    640     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     630    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    641631
    642632    return rc;
     
    856846    pNew->hEventIdle                    = NIL_RTSEMEVENT;
    857847
    858     rc = RTSpinlockCreate(&pNew->hSpinlock);
     848    rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxNetAdptSlotCreate");
    859849    if (RT_SUCCESS(rc))
    860850    {
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r33540 r40806  
    375375static bool vboxNetFltMaybeRediscovered(PVBOXNETFLTINS pThis)
    376376{
    377     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    378377    uint64_t        Now;
    379378    bool            fRediscovered;
     
    396395     */
    397396    Now = RTTimeNanoTS();
    398     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     397    RTSpinlockAcquire(pThis->hSpinlock);
    399398
    400399    fRediscovered = !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost);
     
    405404        ASMAtomicWriteBool(&pThis->fRediscoveryPending, true);
    406405
    407     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     406    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    408407
    409408    /*
     
    499498{
    500499    PVBOXNETFLTINS      pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
    501     RTSPINLOCKTMP       Tmp   = RTSPINLOCKTMP_INITIALIZER;
    502500    INTNETTRUNKIFSTATE  enmOldTrunkState;
    503501
     
    515513     * Take the lock and change the state.
    516514     */
    517     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     515    RTSpinlockAcquire(pThis->hSpinlock);
    518516    enmOldTrunkState = pThis->enmTrunkState;
    519517    if (enmOldTrunkState != enmState)
    520518        ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmTrunkState, enmState);
    521     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     519    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    522520
    523521    /*
     
    602600{
    603601    PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort);
    604     RTSPINLOCKTMP  Tmp   = RTSPINLOCKTMP_INITIALIZER;
    605602
    606603    /*
     
    623620     * Disconnect and release it.
    624621     */
    625     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     622    RTSpinlockAcquire(pThis->hSpinlock);
    626623    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Disconnecting);
    627     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     624    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    628625
    629626    vboxNetFltOsDisconnectIt(pThis);
     
    631628
    632629#ifdef VBOXNETFLT_STATIC_CONFIG
    633     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     630    RTSpinlockAcquire(pThis->hSpinlock);
    634631    vboxNetFltSetState(pThis, kVBoxNetFltInsState_Unconnected);
    635     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     632    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    636633#endif
    637634
     
    814811DECLHIDDEN(bool) vboxNetFltTryRetainBusyActive(PVBOXNETFLTINS pThis)
    815812{
    816     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    817813    uint32_t        cRefs;
    818814    bool            fRc;
     
    834830     * Do the retaining and checking behind the spinlock.
    835831     */
    836     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     832    RTSpinlockAcquire(pThis->hSpinlock);
    837833    fRc = pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE;
    838834    if (fRc)
     
    844840        AssertMsg(cRefs >= 1 && cRefs < UINT32_MAX / 2, ("%d\n", cRefs)); NOREF(cRefs);
    845841    }
    846     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     842    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    847843
    848844    return fRc;
     
    861857DECLHIDDEN(bool) vboxNetFltTryRetainBusyNotDisconnected(PVBOXNETFLTINS pThis)
    862858{
    863     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    864859    uint32_t        cRefs;
    865860    bool            fRc;
     
    881876     * Do the retaining and checking behind the spinlock.
    882877     */
    883     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     878    RTSpinlockAcquire(pThis->hSpinlock);
    884879    fRc =  pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE
    885880        || pThis->enmTrunkState == INTNETTRUNKIFSTATE_INACTIVE;
     
    892887        AssertMsg(cRefs >= 1 && cRefs < UINT32_MAX / 2, ("%d\n", cRefs)); NOREF(cRefs);
    893888    }
    894     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     889    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    895890
    896891    return fRc;
     
    10171012    memcpy(pNew->szName, pszName, cchName + 1);
    10181013
    1019     rc = RTSpinlockCreate(&pNew->hSpinlock);
     1014    rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxNetFltNewInstance");
    10201015    if (RT_SUCCESS(rc))
    10211016    {
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r38485 r40806  
    227227DECLINLINE(ifnet_t) vboxNetFltDarwinRetainIfNet(PVBOXNETFLTINS pThis)
    228228{
    229     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    230229    ifnet_t pIfNet = NULL;
    231230
     
    233232     * Be careful here to avoid problems racing the detached callback.
    234233     */
    235     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     234    RTSpinlockAcquire(pThis->hSpinlock);
    236235    if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
    237236    {
     
    240239            ifnet_reference(pIfNet);
    241240    }
    242     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     241    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    243242
    244243    return pIfNet;
     
    639638{
    640639    PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis;
    641     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    642640    uint64_t NanoTS = RTTimeSystemNanoTS();
    643641    LogFlow(("vboxNetFltDarwinIffDetached: pThis=%p NanoTS=%RU64 (%d)\n",
     
    658656     * behind it in order to avoid problematic races with the detached callback.
    659657     */
    660     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     658    RTSpinlockAcquire(pThis->hSpinlock);
    661659
    662660    pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
     
    671669    ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
    672670
    673     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     671    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    674672
    675673    if (pIfNet)
     
    916914    }
    917915
    918     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    919     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     916    RTSpinlockAcquire(pThis->hSpinlock);
    920917    ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, pIfNet);
    921     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     918    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    922919
    923920    /*
     
    943940        Assert(err || pIfFilter);
    944941
    945         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     942        RTSpinlockAcquire(pThis->hSpinlock);
    946943        pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
    947944        if (pIfNet && !err)
     
    951948            pIfNet = NULL; /* don't dereference it */
    952949        }
    953         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     950        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    954951
    955952        /* Report capabilities. */
     
    11631160void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
    11641161{
    1165     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    11661162    interface_filter_t pIfFilter;
    11671163
     
    11691165     * Carefully obtain the interface filter reference and detach it.
    11701166     */
    1171     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1167    RTSpinlockAcquire(pThis->hSpinlock);
    11721168    pIfFilter = ASMAtomicUoReadPtrT(&pThis->u.s.pIfFilter, interface_filter_t);
    11731169    if (pIfFilter)
    11741170        ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfFilter);
    1175     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1171    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    11761172
    11771173    if (pIfFilter)
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c

    r37423 r40806  
    581581    struct ifnet *ifp;
    582582    node_p node;
    583     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    584583
    585584    VBOXCURVNET_SET_FROM_UCRED();
     
    593592        return VERR_INTERNAL_ERROR;
    594593
    595     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     594    RTSpinlockAcquire(pThis->hSpinlock);
    596595
    597596    ASMAtomicUoWritePtr(&pThis->u.s.ifp, ifp);
     
    610609    TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis);
    611610
    612     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     611    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    613612
    614613    NG_NODE_SET_PRIVATE(node, pThis);
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r40733 r40806  
    382382{
    383383    PVBOXNETDEVICEOPSOVERRIDE   pOverride;
    384     RTSPINLOCKTMP               Tmp = RTSPINLOCKTMP_INITIALIZER;
    385384
    386385    /* Cancel override if ethtool_ops is missing (host-only case, #5712) */
     
    402401    pOverride->pVBoxNetFlt          = pThis;
    403402
    404     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); /* (this isn't necessary, but so what) */
     403    RTSpinlockAcquire(pThis->hSpinlock); /* (this isn't necessary, but so what) */
    405404    ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride);
    406405# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
    407406    ASMAtomicXchgPtr((void * volatile *)&pDev->hard_start_xmit, vboxNetFltLinuxStartXmitFilter);
    408407# endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
    409     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     408    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    410409}
    411410
     
    420419{
    421420    PVBOXNETDEVICEOPSOVERRIDE   pOverride;
    422     RTSPINLOCKTMP               Tmp = RTSPINLOCKTMP_INITIALIZER;
    423 
    424     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     421
     422    RTSpinlockAcquire(pThis->hSpinlock);
    425423    if (!pDev)
    426424        pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *);
     
    444442    else
    445443        pOverride = NULL;
    446     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     444    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    447445
    448446    if (pOverride)
     
    465463{
    466464#if 0
    467     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    468465    struct net_device *pDev = NULL;
    469466
     
    472469     * Be careful here to avoid problems racing the detached callback.
    473470     */
    474     RTSpinlockAcquire(pThis->hSpinlock, &Tmp);
     471    RTSpinlockAcquire(pThis->hSpinlock);
    475472    if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
    476473    {
     
    489486        }
    490487    }
    491     RTSpinlockRelease(pThis->hSpinlock, &Tmp);
     488    RTSpinlockRelease(pThis->hSpinlock);
    492489
    493490    Log(("vboxNetFltLinuxRetainNetDev - done\n"));
     
    13821379        PINTNETTRUNKSWPORT  pSwitchPort;
    13831380        unsigned int        fFeatures;
    1384         RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    1385 
    1386         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1381
     1382        RTSpinlockAcquire(pThis->hSpinlock);
    13871383
    13881384        pSwitchPort = pThis->pSwitchPort; /* this doesn't need to be here, but it doesn't harm. */
     
    13931389            fFeatures = 0;
    13941390
    1395         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1391        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    13961392
    13971393        if (pThis->pSwitchPort)
     
    14981494static int vboxNetFltLinuxAttachToInterface(PVBOXNETFLTINS pThis, struct net_device *pDev)
    14991495{
    1500     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    15011496    LogFlow(("vboxNetFltLinuxAttachToInterface: pThis=%p (%s)\n", pThis, pThis->szName));
    15021497
     
    15061501    dev_hold(pDev);
    15071502
    1508     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1503    RTSpinlockAcquire(pThis->hSpinlock);
    15091504    ASMAtomicUoWritePtr(&pThis->u.s.pDev, pDev);
    1510     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1505    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    15111506
    15121507    Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n",
     
    15461541     * the device notification handle.
    15471542     */
    1548     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1543    RTSpinlockAcquire(pThis->hSpinlock);
    15491544    pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *);
    15501545    if (pDev)
     
    15541549        pDev = NULL; /* don't dereference it */
    15551550    }
    1556     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1551    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    15571552    Log(("vboxNetFltLinuxAttachToInterface: this=%p: Packet handler installed.\n", pThis));
    15581553
     
    15781573        vboxNetFltLinuxUnhookDev(pThis, pDev);
    15791574#endif
    1580         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1575        RTSpinlockAcquire(pThis->hSpinlock);
    15811576        ASMAtomicUoWriteNullPtr(&pThis->u.s.pDev);
    1582         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1577        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    15831578        dev_put(pDev);
    15841579        Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) released. ref=%d\n",
     
    15991594static int vboxNetFltLinuxUnregisterDevice(PVBOXNETFLTINS pThis, struct net_device *pDev)
    16001595{
    1601     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1602 
    16031596    Assert(!pThis->fDisconnectedFromHost);
    16041597
     
    16071600#endif
    16081601
    1609     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1602    RTSpinlockAcquire(pThis->hSpinlock);
    16101603    ASMAtomicWriteBool(&pThis->u.s.fRegistered, false);
    16111604    ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
    16121605    ASMAtomicUoWriteNullPtr(&pThis->u.s.pDev);
    1613     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1606    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    16141607
    16151608    dev_remove_pack(&pThis->u.s.PacketType);
     
    19021895    struct net_device  *pDev;
    19031896    bool                fRegistered;
    1904     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    19051897
    19061898#ifdef VBOXNETFLT_WITH_HOST2WIRE_FILTER
     
    19131905     *        ways. */
    19141906
    1915     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1907    RTSpinlockAcquire(pThis->hSpinlock);
    19161908    pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *);
    19171909    fRegistered = ASMAtomicUoReadBool(&pThis->u.s.fRegistered);
    1918     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1910    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    19191911
    19201912    if (fRegistered)
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r40231 r40806  
    10811081             * the promiscuous OFF acknowledgement case).
    10821082             */
    1083             RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1084             RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1083            RTSpinlockAcquire(pThis->hSpinlock);
    10851084            const bool fActive = pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE;
    10861085            vboxNetFltRetain(pThis, true /* fBusy */);
    1087             RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1086            RTSpinlockReleaseNoInts(pThis->hSpinlock);
    10881087
    10891088            vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pStream;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltM-win.cpp

    r36184 r40806  
    132132DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoDeinitialization(PVBOXNETFLTINS pNetFlt)
    133133{
    134     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    135134    uint64_t NanoTS = RTTimeSystemNanoTS();
    136135
    137136    Assert(vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.MpState) == kVBoxNetDevOpState_Initialized);
    138137
    139     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     138    RTSpinlockAcquire(pNetFlt->hSpinlock);
    140139    ASMAtomicUoWriteBool(&pNetFlt->fDisconnectedFromHost, true);
    141140    ASMAtomicUoWriteBool(&pNetFlt->fRediscoveryPending, false);
     
    144143    vboxNetFltWinSetOpState(&pNetFlt->u.s.WinIf.MpState, kVBoxNetDevOpState_Deinitializing);
    145144
    146     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     145    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    147146
    148147    vboxNetFltWinWaitDereference(&pNetFlt->u.s.WinIf.MpState);
     
    505504static UINT vboxNetFltWinMpRequestStatePrep(PVBOXNETFLTINS pNetFlt, NDIS_STATUS *pStatus)
    506505{
    507     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    508 
    509506    Assert(!pNetFlt->u.s.WinIf.StateFlags.fRequestInfo);
    510507
     
    516513    }
    517514
    518     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     515    RTSpinlockAcquire(pNetFlt->hSpinlock);
    519516    Assert(!pNetFlt->u.s.WinIf.StateFlags.fRequestInfo);
    520517    if (vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.PtState) > kVBoxNetDevOpState_Initialized /* protocol unbind in progress */
    521518            || vboxNetFltWinGetPowerState(&pNetFlt->u.s.WinIf.MpState) > NdisDeviceStateD0)
    522519    {
    523         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     520        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    524521        *pStatus = NDIS_STATUS_FAILURE;
    525522        return 0;
     
    530527    {
    531528        pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS | VBOXNDISREQUEST_QUEUED;
    532         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     529        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    533530        *pStatus = NDIS_STATUS_PENDING;
    534531        return VBOXNDISREQUEST_INPROGRESS | VBOXNDISREQUEST_QUEUED;
     
    537534    if (pNetFlt->u.s.WinIf.StateFlags.fStandBy)
    538535    {
    539         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     536        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    540537        *pStatus = NDIS_STATUS_FAILURE;
    541538        return 0;
     
    544541    pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS;
    545542
    546     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     543    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    547544
    548545    *pStatus = NDIS_STATUS_SUCCESS;
     
    776773{
    777774    PVBOXNETFLTINS pNetFlt = (PVBOXNETFLTINS)MiniportAdapterContext;
    778     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    779775    NDIS_STATUS Status = NDIS_STATUS_FAILURE;
    780776
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltM-win.h

    r36207 r40806  
    2626DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoInitialization(PVBOXNETFLTINS pThis, NDIS_HANDLE hMiniportAdapter, NDIS_HANDLE hWrapperConfigurationContext);
    2727DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoDeinitialization(PVBOXNETFLTINS pThis);
     28
    2829#else
     30
    2931DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpInitializeDevideInstance(PVBOXNETFLTINS pThis);
    3032DECLHIDDEN(bool) vboxNetFltWinMpDeInitializeDeviceInstance(PVBOXNETFLTINS pThis, PNDIS_STATUS pStatus);
     33
    3134DECLINLINE(VOID) vboxNetFltWinMpRequestStateComplete(PVBOXNETFLTINS pNetFlt)
    3235{
    33     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    34     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     36    RTSpinlockAcquire(pNetFlt->hSpinlock);
    3537    pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = 0;
    36     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     38    RTSpinlockRelease(pNetFlt->hSpinlock);
    3739}
     40
    3841DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpRequestPost(PVBOXNETFLTINS pNetFlt);
    3942#endif
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltP-win.cpp

    r36184 r40806  
    162162static void vboxNetFltWinPtRequestsWaitComplete(PVBOXNETFLTINS pNetFlt)
    163163{
    164     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    165 
    166164    /* wait for request to complete */
    167165    while (vboxNetFltWinAtomicUoReadWinState(pNetFlt->u.s.WinIf.StateFlags).fRequestInfo == VBOXNDISREQUEST_INPROGRESS)
     
    173171     * If the below miniport is going to low power state, complete the queued request
    174172     */
    175     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     173    RTSpinlockAcquire(pNetFlt->hSpinlock);
    176174    if (pNetFlt->u.s.WinIf.StateFlags.fRequestInfo & VBOXNDISREQUEST_QUEUED)
    177175    {
    178176        /* mark the request as InProgress before posting it to RequestComplete */
    179177        pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS;
    180         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     178        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    181179        vboxNetFltWinPtRequestComplete(pNetFlt, &pNetFlt->u.s.WinIf.PassDownRequest, NDIS_STATUS_FAILURE);
    182180    }
    183181    else
    184182    {
    185         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     183        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    186184    }
    187185}
     
    190188{
    191189    NDIS_STATUS Status;
    192     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    193190    uint64_t NanoTS = RTTimeSystemNanoTS();
    194191    int cPPUsage;
     
    200197    Assert(vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.PtState) == kVBoxNetDevOpState_Initialized);
    201198
    202     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     199    RTSpinlockAcquire(pNetFlt->hSpinlock);
    203200
    204201    ASMAtomicUoWriteBool(&pNetFlt->fDisconnectedFromHost, true);
     
    212209    }
    213210
    214     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     211    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    215212
    216213    vboxNetFltWinPtRequestsWaitComplete(pNetFlt);
     
    14001397DECLHIDDEN(bool) vboxNetFltWinPtCloseInterface(PVBOXNETFLTINS pNetFlt, PNDIS_STATUS pStatus)
    14011398{
    1402     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1403 
    1404     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     1399    RTSpinlockAcquire(pNetFlt->hSpinlock);
    14051400
    14061401    if (pNetFlt->u.s.WinIf.StateFlags.fInterfaceClosing)
    14071402    {
    1408         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1403        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14091404        Assert(0);
    14101405        return false;
     
    14121407    if (pNetFlt->u.s.WinIf.hBinding == NULL)
    14131408    {
    1414         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1409        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14151410        Assert(0);
    14161411        return false;
     
    14181413
    14191414    pNetFlt->u.s.WinIf.StateFlags.fInterfaceClosing = TRUE;
    1420     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1415    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14211416
    14221417    NdisResetEvent(&pNetFlt->u.s.WinIf.OpenCloseEvent);
     
    14381433{
    14391434    NDIS_DEVICE_POWER_STATE enmPrevPowerState = vboxNetFltWinGetPowerState(&pNetFlt->u.s.WinIf.PtState);
    1440     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1441 
    1442     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     1435
     1436    RTSpinlockAcquire(pNetFlt->hSpinlock);
    14431437
    14441438    vboxNetFltWinSetPowerState(&pNetFlt->u.s.WinIf.PtState, enmPowerState);
     
    14501444            pNetFlt->u.s.WinIf.StateFlags.fStandBy = TRUE;
    14511445        }
    1452         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1446        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14531447        vboxNetFltWinPtRequestsWaitComplete(pNetFlt);
    14541448        vboxNetFltWinWaitDereference(&pNetFlt->u.s.WinIf.MpState);
     
    14751469        {
    14761470            pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS;
    1477             RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1471            RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14781472
    14791473            vboxNetFltWinMpRequestPost(pNetFlt);
     
    14811475        else
    14821476        {
    1483             RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     1477            RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    14841478        }
    14851479    }
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltRt-win.cpp

    r37161 r40806  
    10591059DECLHIDDEN(void) vboxNetFltWinQuFiniPacketQueue(PVBOXNETFLTINS pInstance)
    10601060{
    1061     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    10621061    PINTNETSG pSG;
    10631062    PPACKET_QUEUE_WORKER pWorker = &pInstance->u.s.PacketQueueWorker;
     
    10651064
    10661065    /* using the pPacketQueueSG as an indicator that the packet queue is initialized */
    1067     RTSpinlockAcquireNoInts((pInstance)->hSpinlock, &Tmp);
     1066    RTSpinlockAcquire((pInstance)->hSpinlock);
    10681067    if (pWorker->pSG)
    10691068    {
    10701069        pSG = pWorker->pSG;
    10711070        pWorker->pSG = NULL;
    1072         RTSpinlockReleaseNoInts((pInstance)->hSpinlock, &Tmp);
     1071        RTSpinlockReleaseNoInts((pInstance)->hSpinlock);
    10731072        KeSetEvent(&pWorker->KillEvent, 0, FALSE);
    10741073
     
    10841083    else
    10851084    {
    1086         RTSpinlockReleaseNoInts((pInstance)->hSpinlock, &Tmp);
     1085        RTSpinlockReleaseNoInts((pInstance)->hSpinlock);
    10871086    }
    10881087}
     
    18451844        USHORT cbAnsiName = pBindToMiniportName->Length;/* the length is is bytes ; *2 ;RtlUnicodeStringToAnsiSize(pBindToMiniportName)*/
    18461845        CREATE_INSTANCE_CONTEXT Context;
    1847         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    18481846
    18491847# ifndef VBOXNETADP
     
    26112609static int vboxNetFltWinDeleteInstance(PVBOXNETFLTINS pThis)
    26122610{
    2613     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    26142611    LogFlow(("vboxNetFltWinDeleteInstance: pThis=0x%p \n", pThis));
    26152612
     
    26462643DECLHIDDEN(NDIS_STATUS) vboxNetFltWinDetachFromInterface(PVBOXNETFLTINS pNetFlt, bool bOnUnbind)
    26472644{
    2648     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    26492645    NDIS_STATUS Status;
    26502646    int rc;
     
    27872783    if (RT_SUCCESS(rc))
    27882784    {
    2789         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    27902785        Assert(vboxNetFltWinGetWinIfState(pThis) == kVBoxWinIfState_Disconnected);
    27912786        Assert(vboxNetFltWinGetOpState(&pThis->u.s.WinIf.MpState) == kVBoxNetDevOpState_Deinitialized);
     
    28302825#endif
    28312826                        /* 4. mark as connected */
    2832                         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     2827                        RTSpinlockAcquire(pThis->hSpinlock);
    28332828                        ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false);
    2834                         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     2829                        RTSpinlockRelease(pThis->hSpinlock);
    28352830
    28362831                        pAttachInfo->Status = VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltRt-win.h

    r36184 r40806  
    587587DECLINLINE(bool) vboxNetFltWinReferenceWinIfNetFlt(PVBOXNETFLTINS pNetFlt, bool * pbNetFltActive)
    588588{
    589     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    590 
    591     RTSpinlockAcquireNoInts((pNetFlt)->hSpinlock, &Tmp);
     589    RTSpinlockAcquire((pNetFlt)->hSpinlock);
    592590#ifndef VBOXNETADP
    593591    if(!vboxNetFltWinDoReferenceDevices(&pNetFlt->u.s.WinIf.MpState, &pNetFlt->u.s.WinIf.PtState))
     
    596594#endif
    597595    {
    598         RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock, &Tmp);
     596        RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock);
    599597        *pbNetFltActive = false;
    600598        return false;
     
    604602    {
    605603        vboxNetFltWinReferenceModePassThru(pNetFlt);
    606         RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock, &Tmp);
     604        RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock);
    607605        *pbNetFltActive = false;
    608606        return true;
     
    611609    vboxNetFltRetain((pNetFlt), true /* fBusy */);
    612610    vboxNetFltWinReferenceModeNetFlt(pNetFlt);
    613     RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock, &Tmp);
     611    RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock);
    614612
    615613    *pbNetFltActive = true;
     
    619617DECLINLINE(bool) vboxNetFltWinIncReferenceWinIfNetFlt(PVBOXNETFLTINS pNetFlt, uint32_t v, bool *pbNetFltActive)
    620618{
    621     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    622619    uint32_t i;
    623620
     
    629626    }
    630627
    631     RTSpinlockAcquireNoInts((pNetFlt)->hSpinlock, &Tmp);
     628    RTSpinlockAcquire((pNetFlt)->hSpinlock);
    632629#ifndef VBOXNETADP
    633630    if(!vboxNetFltWinDoIncReferenceDevices(&pNetFlt->u.s.WinIf.MpState, &pNetFlt->u.s.WinIf.PtState, v))
     
    636633#endif
    637634    {
    638         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     635        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    639636        *pbNetFltActive = false;
    640637        return false;
     
    645642        vboxNetFltWinIncReferenceModePassThru(pNetFlt, v);
    646643
    647         RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock, &Tmp);
     644        RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock);
    648645        *pbNetFltActive = false;
    649646        return true;
     
    654651    vboxNetFltWinIncReferenceModeNetFlt(pNetFlt, v);
    655652
    656     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     653    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    657654
    658655    /* we have marked it as busy, so can do the res references outside the lock */
     
    705702DECLINLINE(bool) vboxNetFltWinIncReferenceWinIf(PVBOXNETFLTINS pNetFlt, uint32_t v)
    706703{
    707     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    708 
    709704    Assert(v);
    710705    if(!v)
     
    713708    }
    714709
    715     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     710    RTSpinlockAcquire(pNetFlt->hSpinlock);
    716711#ifdef VBOXNETADP
    717712    if(vboxNetFltWinDoIncReferenceDevice(&pNetFlt->u.s.WinIf.MpState, v))
     
    720715#endif
    721716    {
    722         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     717        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    723718        return true;
    724719    }
    725720
    726     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     721    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    727722    return false;
    728723}
     
    730725DECLINLINE(bool) vboxNetFltWinReferenceWinIf(PVBOXNETFLTINS pNetFlt)
    731726{
    732     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    733     RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     727    RTSpinlockAcquire(pNetFlt->hSpinlock);
    734728#ifdef VBOXNETADP
    735729    if(vboxNetFltWinDoReferenceDevice(&pNetFlt->u.s.WinIf.MpState))
     
    738732#endif
    739733    {
    740         RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     734        RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    741735        return true;
    742736    }
    743737
    744     RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
     738    RTSpinlockReleaseNoInts(pNetFlt->hSpinlock);
    745739    return false;
    746740}
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c

    r37423 r40806  
    7474    return NULL;
    7575}
    76 DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis,
    77                                PRTSPINLOCKTMP pTmp)
     76DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis)
    7877{
    7978#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    80     RTSpinlockAcquireNoInts(pThis->hSpinlock, pTmp);
     79    RTSpinlockAcquire(pThis->hSpinlock);
    8180    return VINF_SUCCESS;
    8281#else
     
    8988}
    9089
    91 DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis,
    92                                   PRTSPINLOCKTMP pTmp)
     90DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis)
    9391{
    9492#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    95     RTSpinlockReleaseNoInts(pThis->hSpinlock, pTmp);
     93    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    9694#else
    9795    NOREF(pTmp);
     
    184182    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    185183    int rc;
    186     RTSPINLOCKTMP aTmp;
    187 
    188     vboxPciDevLock(pThis, &aTmp);
     184
     185    vboxPciDevLock(pThis);
    189186
    190187    rc = vboxPciOsDevInit(pThis, fFlags);
    191188
    192     vboxPciDevUnlock(pThis, &aTmp);
     189    vboxPciDevUnlock(pThis);
    193190
    194191    return rc;
     
    202199    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    203200    int            rc;
    204     RTSPINLOCKTMP  aTmp;
    205 
    206     vboxPciDevLock(pThis, &aTmp);
     201
     202    vboxPciDevLock(pThis);
    207203
    208204    if (pThis->IrqHandler.pfnIrqHandler)
     
    215211    rc = vboxPciOsDevDeinit(pThis, fFlags);
    216212
    217     vboxPciDevUnlock(pThis, &aTmp);
     213    vboxPciDevUnlock(pThis);
    218214
    219215    return rc;
     
    265261    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    266262    int            rc;
    267     RTSPINLOCKTMP  aTmp;
    268 
    269     vboxPciDevLock(pThis, &aTmp);
     263
     264    vboxPciDevLock(pThis);
    270265
    271266    rc = vboxPciOsDevGetRegionInfo(pThis, iRegion,
    272267                                   pRegionStart, pu64RegionSize,
    273268                                   pfPresent, pfFlags);
    274     vboxPciDevUnlock(pThis, &aTmp);
     269    vboxPciDevUnlock(pThis);
    275270
    276271    return rc;
     
    289284    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    290285    int            rc;
    291     RTSPINLOCKTMP  aTmp;
    292 
    293     vboxPciDevLock(pThis, &aTmp);
     286
     287    vboxPciDevLock(pThis);
    294288
    295289    rc = vboxPciOsDevMapRegion(pThis, iRegion, RegionStart, u64RegionSize, fFlags, pRegionBase);
    296290
    297     vboxPciDevUnlock(pThis, &aTmp);
     291    vboxPciDevUnlock(pThis);
    298292
    299293    return rc;
     
    311305    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    312306    int            rc;
    313     RTSPINLOCKTMP  aTmp;
    314 
    315     vboxPciDevLock(pThis, &aTmp);
     307
     308    vboxPciDevLock(pThis);
    316309
    317310    rc = vboxPciOsDevUnmapRegion(pThis, iRegion, RegionStart, u64RegionSize, RegionBase);
    318311
    319     vboxPciDevUnlock(pThis, &aTmp);
     312    vboxPciDevUnlock(pThis);
    320313
    321314    return rc;
     
    330323{
    331324    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    332     RTSPINLOCKTMP  aTmp;
    333     int            rc;
    334 
    335     vboxPciDevLock(pThis, &aTmp);
     325    int            rc;
     326
     327    vboxPciDevLock(pThis);
    336328
    337329    rc = vboxPciOsDevPciCfgRead(pThis, Register, pValue);
    338330
    339     vboxPciDevUnlock(pThis, &aTmp);
     331    vboxPciDevUnlock(pThis);
    340332
    341333    return rc;
     
    351343    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    352344    int            rc;
    353     RTSPINLOCKTMP  aTmp;
    354 
    355     vboxPciDevLock(pThis, &aTmp);
     345
     346    vboxPciDevLock(pThis);
    356347
    357348    rc = vboxPciOsDevPciCfgWrite(pThis, Register, pValue);
    358349
    359     vboxPciDevUnlock(pThis, &aTmp);
     350    vboxPciDevUnlock(pThis);
    360351
    361352    return rc;
     
    370361    int            rc;
    371362    int32_t        iHostIrq = 0;
    372     RTSPINLOCKTMP  aTmp;
    373363
    374364    if (pfnHandler == NULL)
    375365        return VERR_INVALID_PARAMETER;
    376366
    377     vboxPciDevLock(pThis, &aTmp);
     367    vboxPciDevLock(pThis);
    378368
    379369    if (pThis->IrqHandler.pfnIrqHandler)
     
    393383    }
    394384
    395     vboxPciDevUnlock(pThis, &aTmp);
     385    vboxPciDevUnlock(pThis);
    396386
    397387    return rc;
     
    403393    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    404394    int            rc;
    405     RTSPINLOCKTMP  aTmp;
    406395
    407396    if (hIsr != 0xcafe0000)
    408397        return VERR_INVALID_PARAMETER;
    409398
    410     vboxPciDevLock(pThis, &aTmp);
     399    vboxPciDevLock(pThis);
    411400
    412401    rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq);
     
    417406        pThis->IrqHandler.iHostIrq = 0;
    418407    }
    419     vboxPciDevUnlock(pThis, &aTmp);
     408    vboxPciDevUnlock(pThis);
    420409
    421410    return rc;
     
    428417    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    429418    int            rc;
    430     RTSPINLOCKTMP  aTmp;
    431 
    432     vboxPciDevLock(pThis, &aTmp);
     419
     420    vboxPciDevLock(pThis);
    433421
    434422    rc = vboxPciOsDevPowerStateChange(pThis, aState);
     
    448436
    449437
    450     vboxPciDevUnlock(pThis, &aTmp);
     438    vboxPciDevUnlock(pThis);
    451439
    452440    return rc;
  • trunk/src/VBox/HostDrivers/VBoxUSB/VBoxUSBFilterMgr.cpp

    r36941 r40806  
    4646
    4747# define VBOXUSBFILTERMGR_LOCK() \
    48     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; \
    49     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp)
     48    RTSpinlockAcquire(g_Spinlock)
    5049
    5150# define VBOXUSBFILTERMGR_UNLOCK() \
    52     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp)
     51    RTSpinlockRelease(g_Spinlock)
    5352
    5453#else
     
    124123{
    125124#ifdef VBOXUSBFILTERMGR_USB_SPINLOCK
    126     int rc = RTSpinlockCreate(&g_Spinlock);
     125    int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxUSBFilter");
    127126#else
    128127    int rc = RTSemFastMutexCreate(&g_Mtx);
  • trunk/src/VBox/Runtime/VBox/VBoxRTImp.def

    r39851 r40806  
    10361036    RTSocketWriteNB
    10371037    RTSpinlockAcquire
    1038     RTSpinlockAcquireNoInts
    10391038    RTSpinlockCreate
    10401039    RTSpinlockDestroy
    10411040    RTSpinlockRelease
    1042     RTSpinlockReleaseNoInts
    10431041    RTStrAAppendExNVTag
    10441042    RTStrAAppendNTag
  • trunk/src/VBox/Runtime/common/misc/handletable.cpp

    r33540 r40806  
    103103    if (fFlags & RTHANDLETABLE_FLAGS_LOCKED)
    104104    {
    105         int rc = RTSpinlockCreate(&pThis->hSpinlock);
     105        int rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTHandleTableCreateEx");
    106106        if (RT_FAILURE(rc))
    107107        {
     
    127127{
    128128    PRTHANDLETABLEINT   pThis;
    129     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    130129    uint32_t            i1;
    131130    uint32_t            i;
     
    145144     * Then kill the lock.
    146145     */
    147     rtHandleTableLock(pThis, &Tmp);
     146    rtHandleTableLock(pThis);
    148147    ASMAtomicWriteU32(&pThis->u32Magic, ~RTHANDLETABLE_MAGIC);
    149     rtHandleTableUnlock(pThis, &Tmp);
     148    rtHandleTableUnlock(pThis);
    150149
    151150    if (pThis->hSpinlock != NIL_RTSPINLOCK)
    152151    {
    153         rtHandleTableLock(pThis, &Tmp);
    154         rtHandleTableUnlock(pThis, &Tmp);
     152        rtHandleTableLock(pThis);
     153        rtHandleTableUnlock(pThis);
    155154
    156155        RTSpinlockDestroy(pThis->hSpinlock);
  • trunk/src/VBox/Runtime/common/misc/handletable.h

    r28800 r40806  
    219219 *
    220220 * @param   pThis           The handle table structure.
    221  * @param   pTmp            The spinlock temp variable.
    222  */
    223 DECLINLINE(void) rtHandleTableLock(PRTHANDLETABLEINT pThis, PRTSPINLOCKTMP pTmp)
     221 */
     222DECLINLINE(void) rtHandleTableLock(PRTHANDLETABLEINT pThis)
    224223{
    225224    if (pThis->hSpinlock != NIL_RTSPINLOCK)
    226225    {
    227         RTSPINLOCKTMP const Tmp = RTSPINLOCKTMP_INITIALIZER;
    228         *pTmp = Tmp;
    229         RTSpinlockAcquire(pThis->hSpinlock, pTmp);
     226        RTSpinlockAcquire(pThis->hSpinlock);
    230227    }
    231228}
     
    236233 *
    237234 * @param   pThis           The handle table structure.
    238  * @param   pTmp            The spinlock temp variable.
    239  */
    240 DECLINLINE(void) rtHandleTableUnlock(PRTHANDLETABLEINT pThis, PRTSPINLOCKTMP pTmp)
     235 */
     236DECLINLINE(void) rtHandleTableUnlock(PRTHANDLETABLEINT pThis)
    241237{
    242238    if (pThis->hSpinlock != NIL_RTSPINLOCK)
    243         RTSpinlockRelease(pThis->hSpinlock, pTmp);
    244 }
    245 
     239        RTSpinlockRelease(pThis->hSpinlock);
     240}
     241
  • trunk/src/VBox/Runtime/common/misc/handletablectx.cpp

    r28800 r40806  
    4646{
    4747    PRTHANDLETABLEINT   pThis;
    48     RTSPINLOCKTMP       Tmp /*= no init */;
    4948    int                 rc;
    5049
     
    6160     * Allocation loop.
    6261     */
    63     rtHandleTableLock(pThis, &Tmp);
     62    rtHandleTableLock(pThis);
    6463
    6564    do
     
    116115
    117116            /* leave the lock (never do fancy stuff from behind a spinlock). */
    118             rtHandleTableUnlock(pThis, &Tmp);
     117            rtHandleTableUnlock(pThis);
    119118
    120119            /*
     
    138137
    139138            /* re-enter the lock. */
    140             rtHandleTableLock(pThis, &Tmp);
     139            rtHandleTableLock(pThis);
    141140
    142141            /*
     
    162161
    163162                /* free the obsolete one (outside the lock of course) */
    164                 rtHandleTableUnlock(pThis, &Tmp);
     163                rtHandleTableUnlock(pThis);
    165164                RTMemFree(papvLevel1);
    166                 rtHandleTableLock(pThis, &Tmp);
     165                rtHandleTableLock(pThis);
    167166            }
    168167
     
    200199            {
    201200                /* free the table (raced someone, and we lost). */
    202                 rtHandleTableUnlock(pThis, &Tmp);
     201                rtHandleTableUnlock(pThis);
    203202                RTMemFree(paTable);
    204                 rtHandleTableLock(pThis, &Tmp);
     203                rtHandleTableLock(pThis);
    205204            }
    206205
     
    209208    } while (rc == VERR_TRY_AGAIN);
    210209
    211     rtHandleTableUnlock(pThis, &Tmp);
     210    rtHandleTableUnlock(pThis);
    212211
    213212    return rc;
     
    221220    PRTHTENTRYCTX       pEntry;
    222221    PRTHANDLETABLEINT   pThis;
    223     RTSPINLOCKTMP       Tmp /*= no init */;
    224222
    225223    /* validate the input */
     
    231229
    232230    /* acquire the lock */
    233     rtHandleTableLock(pThis, &Tmp);
     231    rtHandleTableLock(pThis);
    234232
    235233    /*
     
    254252
    255253    /* release the lock */
    256     rtHandleTableUnlock(pThis, &Tmp);
     254    rtHandleTableUnlock(pThis);
    257255    return pvObj;
    258256}
     
    265263    PRTHTENTRYCTX       pEntry;
    266264    PRTHANDLETABLEINT   pThis;
    267     RTSPINLOCKTMP       Tmp /*= no init */;
    268265
    269266    /* validate the input */
     
    275272
    276273    /* acquire the lock */
    277     rtHandleTableLock(pThis, &Tmp);
     274    rtHandleTableLock(pThis);
    278275
    279276    /*
     
    326323
    327324    /* release the lock */
    328     rtHandleTableUnlock(pThis, &Tmp);
     325    rtHandleTableUnlock(pThis);
    329326    return pvObj;
    330327}
  • trunk/src/VBox/Runtime/common/misc/handletablesimple.cpp

    r28800 r40806  
    5757     * Allocation loop.
    5858     */
    59     RTSPINLOCKTMP Tmp /*= no init */;
    60     rtHandleTableLock(pThis, &Tmp);
     59    rtHandleTableLock(pThis);
    6160
    6261    int rc;
     
    108107
    109108            /* leave the lock (never do fancy stuff from behind a spinlock). */
    110             rtHandleTableUnlock(pThis, &Tmp);
     109            rtHandleTableUnlock(pThis);
    111110
    112111            /*
     
    130129
    131130            /* re-enter the lock. */
    132             rtHandleTableLock(pThis, &Tmp);
     131            rtHandleTableLock(pThis);
    133132
    134133            /*
     
    152151
    153152                /* free the obsolete one (outside the lock of course) */
    154                 rtHandleTableUnlock(pThis, &Tmp);
     153                rtHandleTableUnlock(pThis);
    155154                RTMemFree(papvLevel1);
    156                 rtHandleTableLock(pThis, &Tmp);
     155                rtHandleTableLock(pThis);
    157156            }
    158157
     
    186185            {
    187186                /* free the table (raced someone, and we lost). */
    188                 rtHandleTableUnlock(pThis, &Tmp);
     187                rtHandleTableUnlock(pThis);
    189188                RTMemFree(paTable);
    190                 rtHandleTableLock(pThis, &Tmp);
     189                rtHandleTableLock(pThis);
    191190            }
    192191
     
    195194    } while (rc == VERR_TRY_AGAIN);
    196195
    197     rtHandleTableUnlock(pThis, &Tmp);
     196    rtHandleTableUnlock(pThis);
    198197
    199198    return rc;
     
    213212
    214213    /* acquire the lock */
    215     RTSPINLOCKTMP Tmp /*= no init */;
    216     rtHandleTableLock(pThis, &Tmp);
     214    rtHandleTableLock(pThis);
    217215
    218216    /*
     
    237235
    238236    /* release the lock */
    239     rtHandleTableUnlock(pThis, &Tmp);
     237    rtHandleTableUnlock(pThis);
    240238    return pvObj;
    241239}
     
    254252
    255253    /* acquire the lock */
    256     RTSPINLOCKTMP Tmp /*= no init */;
    257     rtHandleTableLock(pThis, &Tmp);
     254    rtHandleTableLock(pThis);
    258255
    259256    /*
     
    301298
    302299    /* release the lock */
    303     rtHandleTableUnlock(pThis, &Tmp);
     300    rtHandleTableUnlock(pThis);
    304301    return pvObj;
    305302}
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r39456 r40806  
    5858*******************************************************************************/
    5959#ifdef IN_RING0
    60 # define RT_THREAD_LOCK_TMP(Tmp)    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER
    61 # define RT_THREAD_LOCK_RW(Tmp)     RTSpinlockAcquireNoInts(g_ThreadSpinlock, &(Tmp))
    62 # define RT_THREAD_UNLOCK_RW(Tmp)   RTSpinlockReleaseNoInts(g_ThreadSpinlock, &(Tmp))
    63 # define RT_THREAD_LOCK_RD(Tmp)     RTSpinlockAcquireNoInts(g_ThreadSpinlock, &(Tmp))
    64 # define RT_THREAD_UNLOCK_RD(Tmp)   RTSpinlockReleaseNoInts(g_ThreadSpinlock, &(Tmp))
     60# define RT_THREAD_LOCK_RW()        RTSpinlockAcquire(g_ThreadSpinlock)
     61# define RT_THREAD_UNLOCK_RW()      RTSpinlockRelease(g_ThreadSpinlock)
     62# define RT_THREAD_LOCK_RD()        RTSpinlockAcquire(g_ThreadSpinlock)
     63# define RT_THREAD_UNLOCK_RD()      RTSpinlockRelease(g_ThreadSpinlock)
    6564#else
    66 # define RT_THREAD_LOCK_TMP(Tmp)
    67 # define RT_THREAD_LOCK_RW(Tmp)     rtThreadLockRW()
    68 # define RT_THREAD_UNLOCK_RW(Tmp)   rtThreadUnLockRW()
    69 # define RT_THREAD_LOCK_RD(Tmp)     rtThreadLockRD()
    70 # define RT_THREAD_UNLOCK_RD(Tmp)   rtThreadUnLockRD()
     65# define RT_THREAD_LOCK_RW()        rtThreadLockRW()
     66# define RT_THREAD_UNLOCK_RW()      rtThreadUnLockRW()
     67# define RT_THREAD_LOCK_RD()        rtThreadLockRD()
     68# define RT_THREAD_UNLOCK_RD()      rtThreadUnLockRD()
    7169#endif
    7270
     
    167165     */
    168166    Assert(g_ThreadSpinlock == NIL_RTSPINLOCK);
    169     rc = RTSpinlockCreate(&g_ThreadSpinlock);
     167    rc = RTSpinlockCreate(&g_ThreadSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTThread");
    170168    if (RT_SUCCESS(rc))
    171169    {
     
    406404
    407405    {
    408         RT_THREAD_LOCK_TMP(Tmp);
    409         RT_THREAD_LOCK_RW(Tmp);
     406        RT_THREAD_LOCK_RW();
    410407
    411408        /*
     
    450447        }
    451448
    452         RT_THREAD_UNLOCK_RW(Tmp);
     449        RT_THREAD_UNLOCK_RW();
    453450    }
    454451}
     
    479476static void rtThreadRemove(PRTTHREADINT pThread)
    480477{
    481     RT_THREAD_LOCK_TMP(Tmp);
    482     RT_THREAD_LOCK_RW(Tmp);
     478    RT_THREAD_LOCK_RW();
    483479    if (ASMAtomicBitTestAndClear(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE_BIT))
    484480        rtThreadRemoveLocked(pThread);
    485     RT_THREAD_UNLOCK_RW(Tmp);
     481    RT_THREAD_UNLOCK_RW();
    486482}
    487483
     
    512508     * Simple tree lookup.
    513509     */
    514     RT_THREAD_LOCK_TMP(Tmp);
    515     RT_THREAD_LOCK_RD(Tmp);
     510    RT_THREAD_LOCK_RD();
    516511    pThread = (PRTTHREADINT)RTAvlPVGet(&g_ThreadTree, (void *)NativeThread);
    517     RT_THREAD_UNLOCK_RD(Tmp);
     512    RT_THREAD_UNLOCK_RD();
    518513    return pThread;
    519514}
     
    12411236                 * Do the job.
    12421237                 */
    1243                 RT_THREAD_LOCK_TMP(Tmp);
    1244                 RT_THREAD_LOCK_RW(Tmp);
     1238                RT_THREAD_LOCK_RW();
    12451239                rc = rtThreadNativeSetPriority(pThread, enmType);
    12461240                if (RT_SUCCESS(rc))
    12471241                    ASMAtomicXchgSize(&pThread->enmType, enmType);
    1248                 RT_THREAD_UNLOCK_RW(Tmp);
     1242                RT_THREAD_UNLOCK_RW();
    12491243                if (RT_FAILURE(rc))
    12501244                    Log(("RTThreadSetType: failed on thread %p (%s), rc=%Rrc!!!\n", Thread, pThread->szName, rc));
     
    13021296int rtThreadDoCalcDefaultPriority(RTTHREADTYPE enmType)
    13031297{
    1304     RT_THREAD_LOCK_TMP(Tmp);
    1305     RT_THREAD_LOCK_RW(Tmp);
     1298    RT_THREAD_LOCK_RW();
    13061299    int rc = rtSchedNativeCalcDefaultPriority(enmType);
    1307     RT_THREAD_UNLOCK_RW(Tmp);
     1300    RT_THREAD_UNLOCK_RW();
    13081301    return rc;
    13091302}
     
    13501343     * scheduling attributes defined by the specified process priority.
    13511344     */
    1352     RT_THREAD_LOCK_TMP(Tmp);
    1353     RT_THREAD_LOCK_RW(Tmp);
     1345    RT_THREAD_LOCK_RW();
    13541346    int rc = rtProcNativeSetPriority(enmPriority);
    13551347    if (RT_SUCCESS(rc))
     
    13701362        }
    13711363    }
    1372     RT_THREAD_UNLOCK_RW(Tmp);
     1364    RT_THREAD_UNLOCK_RW();
    13731365    LogFlow(("rtThreadDoSetProcPriority: returns %Rrc\n", rc));
    13741366    return rc;
     
    15261518DECLHIDDEN(void) rtThreadClearTlsEntry(RTTLS iTls)
    15271519{
    1528     RT_THREAD_LOCK_TMP(Tmp);
    1529     RT_THREAD_LOCK_RD(Tmp);
     1520    RT_THREAD_LOCK_RD();
    15301521    RTAvlPVDoWithAll(&g_ThreadTree, true /* fFromLeft*/, rtThreadClearTlsEntryCallback, (void *)(uintptr_t)iTls);
    1531     RT_THREAD_UNLOCK_RD(Tmp);
     1522    RT_THREAD_UNLOCK_RD();
    15321523}
    15331524
  • trunk/src/VBox/Runtime/generic/mempool-generic.cpp

    r33540 r40806  
    138138    if (!pMemPool)
    139139        return VERR_NO_MEMORY;
    140     int rc = RTSpinlockCreate(&pMemPool->hSpinLock);
     140    int rc = RTSpinlockCreate(&pMemPool->hSpinLock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTMemPoolCreate");
    141141    if (RT_SUCCESS(rc))
    142142    {
     
    203203    if (pMemPool->hSpinLock != NIL_RTSPINLOCK)
    204204    {
    205         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    206         RTSpinlockAcquire(pMemPool->hSpinLock, &Tmp);
     205        RTSpinlockAcquire(pMemPool->hSpinLock);
    207206
    208207        PRTMEMPOOLENTRY pHead = pMemPool->pHead;
     
    212211        pMemPool->pHead = pEntry;
    213212
    214         RTSpinlockRelease(pMemPool->hSpinLock, &Tmp);
     213        RTSpinlockRelease(pMemPool->hSpinLock);
    215214    }
    216215
     
    224223    if (pMemPool->hSpinLock != NIL_RTSPINLOCK)
    225224    {
    226         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    227         RTSpinlockAcquire(pMemPool->hSpinLock, &Tmp);
     225        RTSpinlockAcquire(pMemPool->hSpinLock);
    228226
    229227        PRTMEMPOOLENTRY pNext = pEntry->pNext;
     
    237235        pEntry->pMemPool = NULL;
    238236
    239         RTSpinlockRelease(pMemPool->hSpinLock, &Tmp);
     237        RTSpinlockRelease(pMemPool->hSpinLock);
    240238    }
    241239    else
  • trunk/src/VBox/Runtime/generic/spinlock-generic.cpp

    r34239 r40806  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6565    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    6666    uint32_t            u32Magic;
     67    /** The spinlock creation flags. */
     68    uint32_t            fFlags;
    6769    /** The spinlock. */
    6870    uint32_t volatile   fLocked;
     71    /** The saved CPU interrupt. */
     72    uint32_t volatile   fIntSaved;
    6973} RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL;
    7074
    7175
    72 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
    73 {
     76RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
     77{
     78    PRTSPINLOCKINTERNAL pThis;
     79    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     80
    7481    /*
    7582     * Allocate.
    7683     */
    77     PRTSPINLOCKINTERNAL pSpinlockInt;
    78     pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));
    79     if (!pSpinlockInt)
     84    pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     85    if (!pThis)
    8086        return VERR_NO_MEMORY;
    8187
     
    8389     * Initialize and return.
    8490     */
    85     pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
    86     ASMAtomicXchgU32(&pSpinlockInt->fLocked, 0);
    87 
    88     *pSpinlock = pSpinlockInt;
     91    pThis->u32Magic  = RTSPINLOCK_MAGIC;
     92    pThis->fFlags    = fFlags;
     93    pThis->fIntSaved = 0;
     94    ASMAtomicWriteU32(&pThis->fLocked, 0);
     95
     96    *pSpinlock = pThis;
    8997    return VINF_SUCCESS;
    9098}
     
    97105     * Validate input.
    98106     */
    99     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    100     if (!pSpinlockInt)
     107    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     108    if (!pThis)
    101109        return VERR_INVALID_PARAMETER;
    102     if (pSpinlockInt->u32Magic != RTSPINLOCK_MAGIC)
    103     {
    104         AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pSpinlockInt, pSpinlockInt->u32Magic));
     110    if (pThis->u32Magic != RTSPINLOCK_MAGIC)
     111    {
     112        AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic));
    105113        return VERR_INVALID_PARAMETER;
    106114    }
    107115
    108     ASMAtomicIncU32(&pSpinlockInt->u32Magic);
    109     RTMemFree(pSpinlockInt);
     116    ASMAtomicIncU32(&pThis->u32Magic);
     117    RTMemFree(pThis);
    110118    return VINF_SUCCESS;
    111119}
     
    113121
    114122
    115 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    116 {
    117     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    118     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    119               ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
    120 
    121 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    122     pTmp->uFlags = ASMGetFlags();
     123RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
     124{
     125    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     126    AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
     127              ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
     128
     129    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     130    {
     131#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     132        uint32_t fIntSaved = ASMGetFlags();
     133#endif
     134
     135#if RT_CFG_SPINLOCK_GENERIC_DO_SLEEP
     136        for (;;)
     137        {
     138            ASMIntDisable();
     139            for (int c = RT_CFG_SPINLOCK_GENERIC_DO_SLEEP; c > 0; c--)
     140            {
     141                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     142                {
     143# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     144                    pThis->fIntSaved = fIntSaved;
     145# endif
     146                    return;
     147                }
     148                ASMNopPause();
     149            }
     150            ASMSetFlags(fIntSaved);
     151            RTThreadYield();
     152        }
    123153#else
    124     pTmp->uFlags = 0;
    125 #endif
     154        for (;;)
     155        {
     156            ASMIntDisable();
     157            if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     158            {
     159# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     160                pThis->fIntSaved = fIntSaved;
     161# endif
     162                return;
     163            }
     164            ASMSetFlags(fIntSaved);
     165            ASMNopPause();
     166        }
     167#endif
     168    }
     169    else
     170    {
    126171#if RT_CFG_SPINLOCK_GENERIC_DO_SLEEP
    127     for (;;)
    128     {
    129 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    130         ASMIntDisable();
    131 # endif
    132         for (int c = RT_CFG_SPINLOCK_GENERIC_DO_SLEEP; c > 0; c--)
    133             if (ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 1, 0))
    134                 return;
    135         RTThreadYield();
    136     }
     172        for (;;)
     173        {
     174            for (int c = RT_CFG_SPINLOCK_GENERIC_DO_SLEEP; c > 0; c--)
     175            {
     176                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     177                    return;
     178                ASMNopPause();
     179            }
     180            RTThreadYield();
     181        }
    137182#else
    138 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    139     ASMIntDisable();
    140 # endif
    141     while (!ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 1, 0))
    142         /*nothing */;
    143 #endif
    144 }
    145 RT_EXPORT_SYMBOL(RTSpinlockAcquireNoInts);
    146 
    147 
    148 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    149 {
    150     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    151     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    152               ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
    153     NOREF(pSpinlockInt);
    154 
    155     if (!ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 0, 1))
    156         AssertMsgFailed(("Spinlock %p was not locked!\n", pSpinlockInt));
    157 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    158     ASMSetFlags(pTmp->uFlags);
    159 #endif
     183        while (!ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     184            ASMNopPause();
     185#endif
     186    }
     187}
     188RT_EXPORT_SYMBOL(RTSpinlockAcquire);
     189
     190
     191RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
     192{
     193    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     194    AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
     195              ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
     196
     197    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     198    {
     199#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     200        uint32_t fIntSaved = pThis->fIntSaved;
     201        pThis->fIntSaved   = 0;
     202#endif
     203
     204        if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
     205            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
     206
     207#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     208        ASMSetFlags(fIntSaved);
     209#endif
     210    }
     211    else
     212    {
     213        if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
     214            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
     215    }
     216}
     217RT_EXPORT_SYMBOL(RTSpinlockRelease);
     218
     219
     220RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
     221{
     222#if 1
     223    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     224        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
     225#else
     226    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     227#endif
     228    RTSpinlockRelease(Spinlock);
    160229}
    161230RT_EXPORT_SYMBOL(RTSpinlockReleaseNoInts);
    162231
    163 
    164 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    165 {
    166     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    167     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    168               ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
    169     NOREF(pTmp);
    170 
    171 #if RT_CFG_SPINLOCK_GENERIC_DO_SLEEP
    172     for (;;)
    173     {
    174         for (int c = RT_CFG_SPINLOCK_GENERIC_DO_SLEEP; c > 0; c--)
    175             if (ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 1, 0))
    176                 return;
    177         RTThreadYield();
    178     }
    179 #else
    180     while (!ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 1, 0))
    181         /*nothing */;
    182 #endif
    183 }
    184 RT_EXPORT_SYMBOL(RTSpinlockAcquire);
    185 
    186 
    187 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    188 {
    189     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    190     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    191               ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
    192     NOREF(pTmp);
    193 
    194     if (!ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 0, 1))
    195         AssertMsgFailed(("Spinlock %p was not locked!\n", pSpinlockInt));
    196 }
    197 RT_EXPORT_SYMBOL(RTSpinlockRelease);
    198 
  • trunk/src/VBox/Runtime/r0drv/darwin/spinlock-r0drv-darwin.cpp

    r29255 r40806  
    5555    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    5656    uint32_t volatile   u32Magic;
     57    /** Saved interrupt flag. */
     58    uint32_t volatile   fIntSaved;
     59    /** Creation flags. */
     60    uint32_t            fFlags;
    5761    /** The Darwin spinlock structure. */
    5862    lck_spin_t         *pSpinLock;
     63    /** The spinlock name. */
     64    const char         *pszName;
    5965} RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL;
    6066
    6167
    6268
    63 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
     69RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
    6470{
    6571    RT_ASSERT_PREEMPTIBLE();
     72    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
    6673
    6774    /*
     
    6976     */
    7077    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    71     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));
    72     if (!pSpinlockInt)
     78    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     79    if (!pThis)
    7380        return VERR_NO_MEMORY;
    7481
     
    7683     * Initialize & return.
    7784     */
    78     pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
     85    pThis->u32Magic  = RTSPINLOCK_MAGIC;
     86    pThis->fIntSaved = 0;
     87    pThis->fFlags    = fFlags;
     88    pThis->pszName   = pszName;
    7989    Assert(g_pDarwinLockGroup);
    80     pSpinlockInt->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL);
    81     if (!pSpinlockInt->pSpinLock)
     90    pThis->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL);
     91    if (!pThis->pSpinLock)
    8292    {
    83         RTMemFree(pSpinlockInt);
     93        RTMemFree(pThis);
    8494        return VERR_NO_MEMORY;
    8595    }
    8696
    87     *pSpinlock = pSpinlockInt;
     97    *pSpinlock = pThis;
    8898    return VINF_SUCCESS;
    8999}
     
    95105     * Validate input.
    96106     */
    97     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    98     if (!pSpinlockInt)
     107    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     108    if (!pThis)
    99109        return VERR_INVALID_PARAMETER;
    100     AssertMsgReturn(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    101                     ("Invalid spinlock %p magic=%#x\n", pSpinlockInt, pSpinlockInt->u32Magic),
     110    AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC,
     111                    ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic),
    102112                    VERR_INVALID_PARAMETER);
    103113
     
    105115     * Make the lock invalid and release the memory.
    106116     */
    107     ASMAtomicIncU32(&pSpinlockInt->u32Magic);
     117    ASMAtomicIncU32(&pThis->u32Magic);
    108118
    109119    Assert(g_pDarwinLockGroup);
    110     lck_spin_destroy(pSpinlockInt->pSpinLock, g_pDarwinLockGroup);
    111     pSpinlockInt->pSpinLock = NULL;
     120    lck_spin_destroy(pThis->pSpinLock, g_pDarwinLockGroup);
     121    pThis->pSpinLock = NULL;
    112122
    113     RTMemFree(pSpinlockInt);
     123    RTMemFree(pThis);
    114124    return VINF_SUCCESS;
    115125}
    116126
    117127
    118 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     128RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
    119129{
    120     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    121     AssertPtr(pSpinlockInt);
    122     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
     130    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     131    AssertPtr(pThis);
     132    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    123133
    124     lck_spin_lock(pSpinlockInt->pSpinLock);
    125 
    126     pTmp->uFlags = ASMGetFlags();
    127     ASMIntDisable();
     134    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     135    {
     136        uint32_t fIntSaved = ASMGetFlags();
     137        ASMIntDisable();
     138        lck_spin_lock(pThis->pSpinLock);
     139        pThis->fIntSaved = fIntSaved;
     140    }
     141    else
     142        lck_spin_lock(pThis->pSpinLock);
    128143}
    129144
    130145
    131 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     146RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
    132147{
    133     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    134     AssertPtr(pSpinlockInt);
    135     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
     148    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     149    AssertPtr(pThis);
     150    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    136151
    137     ASMSetFlags(pTmp->uFlags);
    138     lck_spin_unlock(pSpinlockInt->pSpinLock);
     152    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     153    {
     154        uint32_t fIntSaved = pThis->fIntSaved;
     155        pThis->fIntSaved = 0;
     156        lck_spin_unlock(pThis->pSpinLock);
     157        ASMSetFlags(fIntSaved);
     158    }
     159    else
     160        lck_spin_unlock(pThis->pSpinLock);
    139161}
    140162
    141163
    142 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     164RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
    143165{
    144     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    145     AssertPtr(pSpinlockInt);
    146     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
    147 
    148     lck_spin_lock(pSpinlockInt->pSpinLock);
     166#if 1
     167    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     168        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (%s)\n", Spinlock, Spinlock->pszName);
     169#else
     170    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     171#endif
     172    RTSpinlockRelease(Spinlock);
    149173}
    150174
    151 
    152 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    153 {
    154     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    155     AssertPtr(pSpinlockInt);
    156     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
    157 
    158     lck_spin_unlock(pSpinlockInt->pSpinLock);
    159 }
    160 
  • trunk/src/VBox/Runtime/r0drv/freebsd/spinlock-r0drv-freebsd.c

    r29500 r40806  
    5959    /** The spinlock. */
    6060    uint32_t volatile   fLocked;
    61     /** Reserved to satisfy compile assertion below. */
    62     uint32_t            uReserved;
     61    /** Saved interrupt flag. */
     62    uint32_t volatile   fIntSaved;
     63    /** The spinlock creation flags. */
     64    uint32_t            fFlags;
    6365#ifdef RT_MORE_STRICT
    6466    /** The idAssertCpu variable before acquring the lock for asserting after
     
    7173
    7274
    73 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
    74 {
     75RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
     76{
     77    RT_ASSERT_PREEMPTIBLE();
     78    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     79
    7580    /*
    7681     * Allocate.
    7782     */
    78     RT_ASSERT_PREEMPTIBLE();
    7983    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    8084    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pThis));
     
    8589     * Initialize & return.
    8690     */
    87     pThis->u32Magic = RTSPINLOCK_MAGIC;
    88     pThis->fLocked  = 0;
     91    pThis->u32Magic  = RTSPINLOCK_MAGIC;
     92    pThis->fLocked   = 0;
     93    pThis->fFlags    = fFlags;
     94    pThis->fIntSaved = 0;
     95
    8996    *pSpinlock = pThis;
    9097    return VINF_SUCCESS;
     
    114121
    115122
    116 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    117 {
    118     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    119     AssertPtr(pThis);
    120     Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    121     RT_ASSERT_PREEMPT_CPUID_VAR();
    122     Assert(pTmp->uFlags == 0);
    123 
    124     for (;;)
    125     {
    126         pTmp->uFlags = ASMIntDisableFlags();
    127         critical_enter();
    128 
    129         int c = 50;
    130         for (;;)
    131         {
    132             if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
    133             {
    134                 RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
    135                 return;
    136             }
    137             if (--c <= 0)
    138                 break;
    139             cpu_spinwait();
    140         }
    141 
    142         /* Enable interrupts while we sleep. */
    143         ASMSetFlags(pTmp->uFlags);
    144         critical_exit();
    145         DELAY(1);
    146     }
    147 }
    148 
    149 
    150 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    151 {
    152     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    153     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS();
    154 
    155     AssertPtr(pThis);
    156     Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    157     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    158 
    159     if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
    160         AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
    161 
    162     ASMSetFlags(pTmp->uFlags);
    163     critical_exit();
    164     pTmp->uFlags = 0;
    165 }
    166 
    167 
    168 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     123RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
    169124{
    170125    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    172127    AssertPtr(pThis);
    173128    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    174 #ifdef RT_STRICT
    175     Assert(pTmp->uFlags == 0);
    176     pTmp->uFlags = 42;
    177 #endif
    178 
    179     NOREF(pTmp);
    180 
    181     for (;;)
    182     {
    183         critical_enter();
    184 
    185         int c = 50;
     129
     130    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     131    {
    186132        for (;;)
    187133        {
    188             if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     134            uint32_t fIntSaved = ASMIntDisableFlags();
     135            critical_enter();
     136
     137            int c = 50;
     138            for (;;)
    189139            {
    190                 RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
    191                 return;
     140                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     141                {
     142                    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
     143                    pThis->fIntSaved = fIntSaved;
     144                    return;
     145                }
     146                if (--c <= 0)
     147                    break;
     148                cpu_spinwait();
    192149            }
    193             if (--c <= 0)
    194                 break;
    195             cpu_spinwait();
     150
     151            /* Enable interrupts while we sleep. */
     152            critical_exit();
     153            ASMSetFlags(fIntSaved);
     154            DELAY(1);
    196155        }
    197 
    198         critical_exit();
    199         DELAY(1);
    200     }
    201 }
    202 
    203 
    204 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     156    }
     157    else
     158    {
     159        for (;;)
     160        {
     161            critical_enter();
     162
     163            int c = 50;
     164            for (;;)
     165            {
     166                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
     167                {
     168                    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
     169                    return;
     170                }
     171                if (--c <= 0)
     172                    break;
     173                cpu_spinwait();
     174            }
     175
     176            critical_exit();
     177            DELAY(1);
     178        }
     179    }
     180}
     181
     182
     183RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
    205184{
    206185    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    210189    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    211190    RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    212 #ifdef RT_STRICT
    213     Assert(pTmp->uFlags == 42);
    214     pTmp->uFlags = 0;
     191
     192    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     193    {
     194        uint32_t fIntSaved = pThis->fIntSaved;
     195        pThis->fIntSaved = 0;
     196        if (ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
     197            ASMSetFlags(pThis->fIntSaved);
     198        else
     199            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
     200    }
     201    else
     202    {
     203        if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
     204            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
     205    }
     206
     207    critical_exit();
     208}
     209
     210
     211RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
     212{
     213#if 1
     214    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     215        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
     216#else
     217    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
    215218#endif
    216     NOREF(pTmp);
    217 
    218     if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
    219         AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
    220 
    221     critical_exit();
    222 }
    223 
     219    RTSpinlockRelease(Spinlock);
     220}
     221
  • trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c

    r36962 r40806  
    117117    AssertReturn(g_HeapExec == NIL_RTHEAPSIMPLE, VERR_WRONG_ORDER);
    118118
    119     rc = RTSpinlockCreate(&g_HeapExecSpinlock);
     119    rc = RTSpinlockCreate(&g_HeapExecSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0MemExecDonate");
    120120    if (RT_SUCCESS(rc))
    121121    {
     
    147147    AssertReturn(g_HeapExec == NIL_RTHEAPSIMPLE, VERR_WRONG_ORDER);
    148148
    149     rc = RTSpinlockCreate(&g_HeapExecSpinlock);
     149    rc = RTSpinlockCreate(&g_HeapExecSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0MemExecInit");
    150150    if (RT_SUCCESS(rc))
    151151    {
     
    220220        if (g_HeapExec != NIL_RTHEAPSIMPLE)
    221221        {
    222             RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    223             RTSpinlockAcquireNoInts(g_HeapExecSpinlock, &SpinlockTmp);
     222            RTSpinlockAcquire(g_HeapExecSpinlock);
    224223            pHdr = (PRTMEMHDR)RTHeapSimpleAlloc(g_HeapExec, cb + sizeof(*pHdr), 0);
    225             RTSpinlockReleaseNoInts(g_HeapExecSpinlock, &SpinlockTmp);
     224            RTSpinlockRelease(g_HeapExecSpinlock);
    226225            fFlags |= RTMEMHDR_FLAG_EXEC_HEAP;
    227226        }
     
    290289    else if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC_HEAP)
    291290    {
    292         RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;
    293         RTSpinlockAcquireNoInts(g_HeapExecSpinlock, &SpinlockTmp);
     291        RTSpinlockAcquire(g_HeapExecSpinlock);
    294292        RTHeapSimpleFree(g_HeapExec, pHdr);
    295         RTSpinlockReleaseNoInts(g_HeapExecSpinlock, &SpinlockTmp);
     293        RTSpinlockRelease(g_HeapExecSpinlock);
    296294    }
    297295#endif
  • trunk/src/VBox/Runtime/r0drv/linux/spinlock-r0drv-linux.c

    r29250 r40806  
    5454{
    5555    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    56     uint32_t volatile   u32Magic;
     56    uint32_t volatile       u32Magic;
     57    /** The spinlock creation flags.  */
     58    uint32_t                fFlags;
     59    /** The saved interrupt flag. */
     60    unsigned long volatile  fIntSaved;
    5761    /** The linux spinlock structure. */
    58     spinlock_t          Spinlock;
     62    spinlock_t              Spinlock;
    5963#ifdef RT_MORE_STRICT
    6064    /** The idAssertCpu variable before acquring the lock for asserting after
    6165     *  releasing the spinlock. */
    62     RTCPUID volatile    idAssertCpu;
     66    RTCPUID volatile        idAssertCpu;
    6367    /** The CPU that owns the lock. */
    64     RTCPUID volatile    idCpuOwner;
    65 #elif !defined(CONFIG_SMP) || defined(RT_ARCH_AMD64)
    66     /** A placeholder on Uni systems so we won't piss off RTMemAlloc(). */
    67     void                *pvUniDummy;
    68 #endif
    69 #ifdef RT_STRICT
    70     /** Set if we've seen any fNoIrqs usage.
    71      * This must be consistent or it won't work you know. */
    72     bool                fNoIrqs;
     68    RTCPUID volatile        idCpuOwner;
    7369#endif
    7470} RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL;
    7571
    7672
     73This code has changed and need testing!;
    7774
    78 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
     75
     76RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
    7977{
     78    PRTSPINLOCKINTERNAL pThis;
     79    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     80
    8081    /*
    8182     * Allocate.
    8283     */
    83     PRTSPINLOCKINTERNAL pThis;
    8484    Assert(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    8585    pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     
    8989     * Initialize and return.
    9090     */
    91     pThis->u32Magic    = RTSPINLOCK_MAGIC;
     91    pThis->u32Magic     = RTSPINLOCK_MAGIC;
     92    pThis->fFlags       = fFlags;
     93    pThis->fIntSaved    = 0;
    9294#ifdef RT_MORE_STRICT
    93     pThis->idCpuOwner  = NIL_RTCPUID;
    94     pThis->idAssertCpu = NIL_RTCPUID;
    95 #endif
    96 #ifdef RT_STRICT
    97     pThis->fNoIrqs     = false;
     95    pThis->idCpuOwner   = NIL_RTCPUID;
     96    pThis->idAssertCpu  = NIL_RTCPUID;
    9897#endif
    9998    spin_lock_init(&pThis->Spinlock);
     
    126125
    127126
    128 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     127RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
    129128{
    130129    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    133132              ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
    134133
    135     spin_lock_irqsave(&pThis->Spinlock, pTmp->flFlags);
    136 
    137     RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
    138 #ifdef RT_STRICT
    139     pThis->fNoIrqs = true;
    140 #endif
    141 }
    142 RT_EXPORT_SYMBOL(RTSpinlockAcquireNoInts);
    143 
    144 
    145 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    146 {
    147     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    148     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS();
    149 
    150     AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
    151               ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
    152     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    153     Assert(pThis->fNoIrqs);
    154 
    155     spin_unlock_irqrestore(&pThis->Spinlock, pTmp->flFlags);
    156 
    157     RT_ASSERT_PREEMPT_CPUID();
    158 }
    159 RT_EXPORT_SYMBOL(RTSpinlockReleaseNoInts);
    160 
    161 
    162 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    163 {
    164     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    165     RT_ASSERT_PREEMPT_CPUID_VAR();
    166     AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
    167               ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
    168     NOREF(pTmp);
    169     Assert(!pThis->fNoIrqs || !ASMIntAreEnabled());
    170 
    171     spin_lock(&pThis->Spinlock);
     134    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     135    {
     136        unsigned long fIntSaved;
     137        spin_lock_irqsave(&pThis->Spinlock, fIntSaved);
     138        pThis->fIntSaved = fIntSaved;
     139    }
     140    else
     141        spin_lock(&pThis->Spinlock);
    172142
    173143    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
     
    176146
    177147
    178 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     148RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
    179149{
    180150    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    182152    AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC,
    183153              ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0));
    184     NOREF(pTmp);
    185154    RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    186     Assert(!pThis->fNoIrqs || !ASMIntAreEnabled());
    187155
    188     spin_unlock(&pThis->Spinlock);
     156    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     157    {
     158        unsigned long fIntSaved = pThis->fIntSaved;
     159        pThis->fIntSaved = 0;
     160        spin_unlock_irqrestore(&pThis->Spinlock, fIntSaved);
     161    }
     162    else
     163        spin_unlock(&pThis->Spinlock);
    189164
    190165    RT_ASSERT_PREEMPT_CPUID();
     
    192167RT_EXPORT_SYMBOL(RTSpinlockRelease);
    193168
     169
     170RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
     171{
     172#if 1
     173    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     174        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
     175#else
     176    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     177#endif
     178    RTSpinlockRelease(Spinlock);
     179}
     180RT_EXPORT_SYMBOL(RTSpinlockReleaseNoInts);
     181
  • trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c

    r39008 r40806  
    490490    {
    491491        uint32_t        iCpu        = pTimer->cCpus;
    492         RTSPINLOCKTMP   Tmp         = RTSPINLOCKTMP_INITIALIZER;
    493         RTSpinlockAcquire(pTimer->hSpinlock, &Tmp);
     492        RTSpinlockAcquire(pTimer->hSpinlock);
    494493
    495494        Assert(pSubTimer->enmState == RTTIMERLNXSTATE_CB_DESTROYING);
     
    499498            if (rtTimerLnxGetState(&pTimer->aSubTimers[iCpu].enmState) != RTTIMERLNXSTATE_STOPPED)
    500499            {
    501                 RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     500                RTSpinlockRelease(pTimer->hSpinlock);
    502501                return;
    503502            }
    504503
    505         RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     504        RTSpinlockRelease(pTimer->hSpinlock);
    506505    }
    507506
     
    525524{
    526525    RTTIMERLNXSTATE enmState;
    527     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    528526    if (pTimer->cCpus > 1)
    529         RTSpinlockAcquire(pTimer->hSpinlock, &Tmp);
     527        RTSpinlockAcquire(pTimer->hSpinlock);
    530528
    531529    do
     
    555553            {
    556554                if (pTimer->cCpus > 1)
    557                     RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     555                    RTSpinlockRelease(pTimer->hSpinlock);
    558556
    559557                rtTimerLnxCallbackDestroy(pTimer, pSubTimer);
     
    564562
    565563    if (pTimer->cCpus > 1)
    566         RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     564        RTSpinlockRelease(pTimer->hSpinlock);
    567565}
    568566#endif /* CONFIG_SMP */
     
    900898static int rtTimerLnxOmniStart(PRTTIMER pTimer, PRTTIMERLINUXSTARTONCPUARGS pArgs)
    901899{
    902     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    903900    RTCPUID         iCpu;
    904901    RTCPUSET        OnlineSet;
     
    912909     * should something happen while we're looping.
    913910     */
    914     RTSpinlockAcquire(pTimer->hSpinlock, &Tmp);
     911    RTSpinlockAcquire(pTimer->hSpinlock);
    915912
    916913    /* Just make it a omni timer restriction that no stop/start races are allowed. */
     
    918915        if (rtTimerLnxGetState(&pTimer->aSubTimers[iCpu].enmState) != RTTIMERLNXSTATE_STOPPED)
    919916        {
    920             RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     917            RTSpinlockRelease(pTimer->hSpinlock);
    921918            return VERR_TIMER_BUSY;
    922919        }
     
    937934    ASMAtomicWriteBool(&pTimer->fSuspended, false);
    938935
    939     RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     936    RTSpinlockRelease(pTimer->hSpinlock);
    940937
    941938    /*
     
    950947     * Reset the sub-timers who didn't start up (ALL CPUs case).
    951948     */
    952     RTSpinlockAcquire(pTimer->hSpinlock, &Tmp);
     949    RTSpinlockAcquire(pTimer->hSpinlock);
    953950
    954951    for (iCpu = 0; iCpu < pTimer->cCpus; iCpu++)
     
    962959        }
    963960
    964     RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     961    RTSpinlockRelease(pTimer->hSpinlock);
    965962
    966963    return VINF_SUCCESS;
     
    978975{
    979976    bool            fActiveCallbacks = false;
    980     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    981977    RTCPUID         iCpu;
    982978    RTTIMERLNXSTATE enmState;
     
    987983     * for those being stopped by an MP event.
    988984     */
    989     RTSpinlockAcquire(pTimer->hSpinlock, &Tmp);
     985    RTSpinlockAcquire(pTimer->hSpinlock);
    990986
    991987    ASMAtomicWriteBool(&pTimer->fSuspended, true);
     
    10211017    }
    10221018
    1023     RTSpinlockRelease(pTimer->hSpinlock, &Tmp);
     1019    RTSpinlockRelease(pTimer->hSpinlock);
    10241020
    10251021    /*
     
    10581054        &&  pTimer->u32Magic == RTTIMER_MAGIC)
    10591055    {
    1060         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    1061         RTSpinlockAcquire(hSpinlock, &Tmp);
     1056        RTSpinlockAcquire(hSpinlock);
    10621057
    10631058        if (    !ASMAtomicUoReadBool(&pTimer->fSuspended)
     
    10701065        }
    10711066
    1072         RTSpinlockRelease(hSpinlock, &Tmp);
     1067        RTSpinlockRelease(hSpinlock);
    10731068    }
    10741069}
     
    10861081    PRTTIMER            pTimer    = (PRTTIMER)pvUser;
    10871082    PRTTIMERLNXSUBTIMER pSubTimer = &pTimer->aSubTimers[idCpu];
    1088     RTSPINLOCKTMP       Tmp       = RTSPINLOCKTMP_INITIALIZER;
    10891083    RTSPINLOCK          hSpinlock;
    10901084
     
    11001094        return;
    11011095
    1102     RTSpinlockAcquire(hSpinlock, &Tmp);
     1096    RTSpinlockAcquire(hSpinlock);
    11031097
    11041098    /* Is it active? */
     
    11241118                    {
    11251119                        rtTimerLnxSetState(&pSubTimer->enmState, RTTIMERLNXSTATE_STOPPED); /* we'll recheck it. */
    1126                         RTSpinlockRelease(hSpinlock, &Tmp);
     1120                        RTSpinlockRelease(hSpinlock);
    11271121
    11281122                        RTMpOnSpecific(idCpu, rtTimerLinuxMpStartOnCpu, pTimer, &Args);
     
    11491143                        if (rtTimerLnxCmpXchgState(&pSubTimer->enmState, RTTIMERLNXSTATE_MP_STOPPING, RTTIMERLNXSTATE_ACTIVE))
    11501144                        {
    1151                             RTSpinlockRelease(hSpinlock, &Tmp);
     1145                            RTSpinlockRelease(hSpinlock);
    11521146
    11531147                            rtTimerLnxStopSubTimer(pSubTimer, pTimer->fHighRes);
     
    11661160    }
    11671161
    1168     RTSpinlockRelease(hSpinlock, &Tmp);
     1162    RTSpinlockRelease(hSpinlock);
    11691163}
    11701164
     
    14161410    {
    14171411        uint32_t        iCpu = pTimer->cCpus;
    1418         RTSPINLOCKTMP   Tmp  = RTSPINLOCKTMP_INITIALIZER;
    14191412        if (pTimer->cCpus > 1)
    1420             RTSpinlockAcquireNoInts(pTimer->hSpinlock, &Tmp);
     1413            RTSpinlockAcquire(pTimer->hSpinlock);
    14211414
    14221415        fCanDestroy = true;
     
    14481441
    14491442        if (pTimer->cCpus > 1)
    1450             RTSpinlockReleaseNoInts(pTimer->hSpinlock, &Tmp);
     1443            RTSpinlockReleaseNoInts(pTimer->hSpinlock);
    14511444    }
    14521445
     
    15651558    if (cCpus > 1)
    15661559    {
    1567         int rc = RTSpinlockCreate(&pTimer->hSpinlock);
     1560        int rc = RTSpinlockCreate(&pTimer->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTTimerLnx");
    15681561        if (RT_SUCCESS(rc))
    15691562            rc = RTMpNotificationRegister(rtTimerLinuxMpEvent, pTimer);
  • trunk/src/VBox/Runtime/r0drv/mpnotification-r0drv.c

    r37211 r40806  
    9494    PRTMPNOTIFYREG  pCur;
    9595    RTSPINLOCK      hSpinlock;
    96     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    9796
    9897    /*
     
    119118    if (hSpinlock == NIL_RTSPINLOCK)
    120119        return;
    121     RTSpinlockAcquire(hSpinlock, &Tmp);
     120    RTSpinlockAcquire(hSpinlock);
    122121
    123122    /* Clear the bit. */
     
    138137                void *pvUser = pCur->pvUser;
    139138                pCur = pCur->pNext;
    140                 RTSpinlockRelease(g_hRTMpNotifySpinLock, &Tmp);
     139                RTSpinlockRelease(g_hRTMpNotifySpinLock);
    141140
    142141                pfnCallback(enmEvent, idCpu, pvUser);
     
    146145                if (hSpinlock == NIL_RTSPINLOCK)
    147146                    return;
    148                 RTSpinlockAcquire(hSpinlock, &Tmp);
     147                RTSpinlockAcquire(hSpinlock);
    149148                if (ASMAtomicUoReadU32(&g_iRTMpGeneration) != iGeneration)
    150149                    break;
     
    155154    } while (pCur);
    156155
    157     RTSpinlockRelease(hSpinlock, &Tmp);
     156    RTSpinlockRelease(hSpinlock);
    158157}
    159158
     
    164163    PRTMPNOTIFYREG  pCur;
    165164    PRTMPNOTIFYREG  pNew;
    166     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    167165
    168166    /*
     
    173171    RT_ASSERT_PREEMPTIBLE();
    174172
    175     RTSpinlockAcquire(g_hRTMpNotifySpinLock, &Tmp);
     173    RTSpinlockAcquire(g_hRTMpNotifySpinLock);
    176174    for (pCur = g_pRTMpCallbackHead; pCur; pCur = pCur->pNext)
    177175        if (    pCur->pvUser == pvUser
    178176            &&  pCur->pfnCallback == pfnCallback)
    179177            break;
    180     RTSpinlockRelease(g_hRTMpNotifySpinLock, &Tmp);
     178    RTSpinlockRelease(g_hRTMpNotifySpinLock);
    181179    AssertMsgReturn(!pCur, ("pCur=%p pfnCallback=%p pvUser=%p\n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS);
    182180
     
    193191    memset(&pNew->bmDone[0], 0xff, sizeof(pNew->bmDone));
    194192
    195     RTSpinlockAcquire(g_hRTMpNotifySpinLock, &Tmp);
     193    RTSpinlockAcquire(g_hRTMpNotifySpinLock);
    196194
    197195    pCur = g_pRTMpCallbackHead;
     
    214212    ASMAtomicIncU32(&g_iRTMpGeneration);
    215213
    216     RTSpinlockRelease(g_hRTMpNotifySpinLock, &Tmp);
     214    RTSpinlockRelease(g_hRTMpNotifySpinLock);
    217215
    218216    /* duplicate? */
     
    232230    PRTMPNOTIFYREG  pPrev;
    233231    PRTMPNOTIFYREG  pCur;
    234     RTSPINLOCKTMP   Tmp = RTSPINLOCKTMP_INITIALIZER;
    235232
    236233    /*
     
    244241     * Find and unlink the record from the list.
    245242     */
    246     RTSpinlockAcquire(g_hRTMpNotifySpinLock, &Tmp);
     243    RTSpinlockAcquire(g_hRTMpNotifySpinLock);
    247244    pPrev = NULL;
    248245    for (pCur = g_pRTMpCallbackHead; pCur; pCur = pCur->pNext)
     
    261258        ASMAtomicIncU32(&g_iRTMpGeneration);
    262259    }
    263     RTSpinlockRelease(g_hRTMpNotifySpinLock, &Tmp);
     260    RTSpinlockRelease(g_hRTMpNotifySpinLock);
    264261
    265262    if (!pCur)
     
    280277DECLHIDDEN(int) rtR0MpNotificationInit(void)
    281278{
    282     int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTMpNotifySpinLock);
     279    int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTMpNotifySpinLock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTR0Mp");
    283280    if (RT_SUCCESS(rc))
    284281    {
     
    297294{
    298295    PRTMPNOTIFYREG  pHead;
    299     RTSPINLOCKTMP   Tmp       = RTSPINLOCKTMP_INITIALIZER;
    300296    RTSPINLOCK      hSpinlock = g_hRTMpNotifySpinLock;
    301297    AssertReturnVoid(hSpinlock != NIL_RTSPINLOCK);
     
    304300
    305301    /* pick up the list and the spinlock. */
    306     RTSpinlockAcquire(hSpinlock, &Tmp);
     302    RTSpinlockAcquire(hSpinlock);
    307303    ASMAtomicWriteHandle(&g_hRTMpNotifySpinLock, NIL_RTSPINLOCK);
    308304    pHead = g_pRTMpCallbackHead;
    309305    g_pRTMpCallbackHead = NULL;
    310306    ASMAtomicIncU32(&g_iRTMpGeneration);
    311     RTSpinlockRelease(hSpinlock, &Tmp);
     307    RTSpinlockRelease(hSpinlock);
    312308
    313309    /* free the list. */
  • trunk/src/VBox/Runtime/r0drv/nt/spinlock-r0drv-nt.cpp

    r32463 r40806  
    7272    uint32_t volatile   u32Hack;
    7373#endif
     74    /** The saved IRQL. */
     75    KIRQL volatile      SavedIrql;
     76    /** The saved interrupt flag. */
     77    uint32_t volatile   fIntSaved;
     78    /** The spinlock creation flags. */
     79    uint32_t            fFlags;
    7480    /** The NT spinlock structure. */
    7581    KSPIN_LOCK          Spinlock;
     
    7783
    7884
    79 
    80 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
    81 {
     85This code has changed and need testing!;
     86
     87
     88RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
     89{
     90    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     91
    8292    /*
    8393     * Allocate.
    8494     */
    8595    Assert(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    86     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));
    87     if (!pSpinlockInt)
     96    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     97    if (!pThis)
    8898        return VERR_NO_MEMORY;
    8999
     
    91101     * Initialize & return.
    92102     */
    93     pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
     103    pThis->u32Magic    = RTSPINLOCK_MAGIC;
    94104#ifdef RTSPINLOCK_NT_HACK_NOIRQ
    95     pSpinlockInt->u32Hack  = RTSPINLOCK_NT_HACK_NOIRQ_FREE;
    96 #endif
    97     KeInitializeSpinLock(&pSpinlockInt->Spinlock);
    98     Assert(sizeof(KIRQL) == sizeof(unsigned char));
    99     AssertCompile(sizeof(KIRQL) == sizeof(unsigned char));
    100 
    101     *pSpinlock = pSpinlockInt;
     105    pThis->u32Hack      = RTSPINLOCK_NT_HACK_NOIRQ_FREE;
     106#endif
     107    pThis->SavedIrql    = 0;
     108    pThis->fIntSaved    = 0;
     109    pThis->fFlags       = fFlags;
     110    KeInitializeSpinLock(&pThis->Spinlock);
     111
     112    *pSpinlock = pThis;
    102113    return VINF_SUCCESS;
    103114}
     
    109120     * Validate input.
    110121     */
    111     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    112     if (!pSpinlockInt)
     122    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     123    if (!pThis)
    113124        return VERR_INVALID_PARAMETER;
    114     if (pSpinlockInt->u32Magic != RTSPINLOCK_MAGIC)
     125    if (pThis->u32Magic != RTSPINLOCK_MAGIC)
    115126    {
    116         AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pSpinlockInt, pSpinlockInt->u32Magic));
     127        AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic));
    117128        return VERR_INVALID_PARAMETER;
    118129    }
    119130
    120     ASMAtomicIncU32(&pSpinlockInt->u32Magic);
    121     RTMemFree(pSpinlockInt);
     131    ASMAtomicIncU32(&pThis->u32Magic);
     132    RTMemFree(pThis);
    122133    return VINF_SUCCESS;
    123134}
    124135
    125136
    126 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    127 {
    128     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    129     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    130 
     137RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
     138{
     139    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     140    AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pThis->u32Magic));
     141
     142    KIRQL SavedIrql;
     143    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     144    {
    131145#ifndef RTSPINLOCK_NT_HACK_NOIRQ
    132     KeAcquireSpinLock(&pSpinlockInt->Spinlock, &pTmp->uchIrqL);
    133     pTmp->uFlags = ASMGetFlags();
    134     ASMIntDisable();
     146        uint32_t fIntSaved = ASMGetFlags();
     147        ASMIntDisable();
     148        KeAcquireSpinLock(&pThis->Spinlock, &SavedIrql);
    135149#else
    136     pTmp->uchIrqL = KeGetCurrentIrql();
    137     if (pTmp->uchIrqL < DISPATCH_LEVEL)
     150        SavedIrql = KeGetCurrentIrql();
     151        if (SavedIrql < DISPATCH_LEVEL)
     152        {
     153            KeRaiseIrql(DISPATCH_LEVEL, &SavedIrql);
     154            Assert(SavedIrql < DISPATCH_LEVEL);
     155        }
     156        uint32_t fIntSaved = ASMGetFlags();
     157        ASMIntDisable();
     158
     159        if (!ASMAtomicCmpXchgU32(&pThis->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE))
     160        {
     161            while (!ASMAtomicCmpXchgU32(&pThis->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE))
     162                ASMNopPause();
     163        }
     164
     165        pThis->fIntSaved = fIntSaved;
     166#endif
     167    }
     168    else
     169        KeAcquireSpinLock(&pThis->Spinlock, &SavedIrql);
     170    pThis->SavedIrql = SavedIrql;
     171}
     172
     173
     174RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
     175{
     176    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     177    AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pThis->u32Magic));
     178
     179    KIRQL SavedIrql = pThis->SavedIrql;
     180    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
    138181    {
    139         KeRaiseIrql(DISPATCH_LEVEL, &pTmp->uchIrqL);
    140         Assert(pTmp->uchIrqL < DISPATCH_LEVEL);
     182        uint32_t fIntSaved = pThis->fIntSaved;
     183        pThis->fIntSaved = 0;
     184
     185#ifndef RTSPINLOCK_NT_HACK_NOIRQ
     186        KeReleaseSpinLock(&pThis->Spinlock, SavedIrql);
     187        ASMSetFlags(fIntSaved);
     188#else
     189        Assert(pThis->u32Hack == RTSPINLOCK_NT_HACK_NOIRQ_TAKEN);
     190
     191        ASMAtomicWriteU32(&pThis->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_FREE);
     192        ASMSetFlags(fIntSaved);
     193        if (SavedIrql < DISPATCH_LEVEL)
     194            KeLowerIrql(SavedIrql);
     195#endif
    141196    }
    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
    150 }
    151 
    152 
    153 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    154 {
    155     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    156     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    157 
    158 #ifndef RTSPINLOCK_NT_HACK_NOIRQ
    159     ASMSetFlags(pTmp->uFlags);
    160     KeReleaseSpinLock(&pSpinlockInt->Spinlock, pTmp->uchIrqL);
     197    else
     198        KeReleaseSpinLock(&pThis->Spinlock, SavedIrql);
     199}
     200
     201
     202RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
     203{
     204#if 1
     205    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     206        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
    161207#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
    168 }
    169 
    170 
    171 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    172 {
    173     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    174     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    175 
    176     KeAcquireSpinLock(&pSpinlockInt->Spinlock, &pTmp->uchIrqL);
    177 }
    178 
    179 
    180 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    181 {
    182     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    183     AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic));
    184 
    185     KeReleaseSpinLock(&pSpinlockInt->Spinlock, pTmp->uchIrqL);
    186 }
     208    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     209#endif
     210    RTSpinlockRelease(Spinlock);
     211}
     212
  • trunk/src/VBox/Runtime/r0drv/os2/spinlock-r0drv-os2.cpp

    r8245 r40806  
    5353    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    5454    uint32_t volatile   u32Magic;
     55    /** Spinlock creation flags.  */
     56    uint32_t            fFlags;
    5557    /** The OS/2 spinlock structure. */
    5658    SpinLock_t          Spinlock;
     
    5860
    5961
    60 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
     62RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
    6163{
     64    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     65
    6266    /*
    6367     * Allocate.
    6468     */
    6569    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    66     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));
    67     if (!pSpinlockInt)
     70    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     71    if (!pThis)
    6872        return VERR_NO_MEMORY;
    6973
     
    7175     * Initialize & return.
    7276     */
    73     pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC;
    74     KernAllocSpinLock(&pSpinlockInt->Spinlock);
    75     *pSpinlock = pSpinlockInt;
     77    pThis->u32Magic     = RTSPINLOCK_MAGIC;
     78    pThis->fFlags       = fFlags;
     79    pThis->fIntSaved    = 0;
     80    KernAllocSpinLock(&pThis->Spinlock);
     81    *pSpinlock = pThis;
    7682    return VINF_SUCCESS;
    7783}
     
    8389     * Validate input.
    8490     */
    85     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    86     if (!pSpinlockInt)
     91    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     92    if (!pThis)
    8793        return VERR_INVALID_PARAMETER;
    88     AssertMsgReturn(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    89                     ("Invalid spinlock %p magic=%#x\n", pSpinlockInt, pSpinlockInt->u32Magic),
     94    AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC,
     95                    ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic),
    9096                    VERR_INVALID_PARAMETER);
    9197
     
    9399     * Make the lock invalid and release the memory.
    94100     */
    95     ASMAtomicIncU32(&pSpinlockInt->u32Magic);
    96     KernFreeSpinLock(&pSpinlockInt->Spinlock);
    97     RTMemFree(pSpinlockInt);
     101    ASMAtomicIncU32(&pThis->u32Magic);
     102    KernFreeSpinLock(&pThis->Spinlock);
     103    RTMemFree(pThis);
    98104    return VINF_SUCCESS;
    99105}
    100106
    101107
    102 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     108RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
    103109{
    104     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    105     AssertPtr(pSpinlockInt);
    106     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
     110    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     111    AssertPtr(pThis);
     112    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    107113
    108     KernAcquireSpinLock(&pSpinlockInt->Spinlock);
    109     NOREF(pTmp);
     114    KernAcquireSpinLock(&pThis->Spinlock);
     115    Assert(!ASMIntAreEnabled()); /** @todo verify that interrupts are disabled. */
    110116}
    111117
    112118
    113 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     119RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
    114120{
    115     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    116     AssertPtr(pSpinlockInt);
    117     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
     121    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     122    AssertPtr(pThis);
     123    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    118124
    119     KernReleaseSpinLock(&pSpinlockInt->Spinlock);
    120     NOREF(pTmp);
     125    KernReleaseSpinLock(&pThis->Spinlock);
    121126}
    122127
    123128
    124 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     129RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
    125130{
    126     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    127     AssertPtr(pSpinlockInt);
    128     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
    129 
    130     KernAcquireSpinLock(&pSpinlockInt->Spinlock);
    131     NOREF(pTmp);
     131#if 1
     132    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     133        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
     134#else
     135    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     136#endif
     137    RTSpinlockRelease(Spinlock);
    132138}
    133139
    134 
    135 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    136 {
    137     PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
    138     AssertPtr(pSpinlockInt);
    139     Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
    140 
    141     KernReleaseSpinLock(&pSpinlockInt->Spinlock);
    142     NOREF(pTmp);
    143 }
    144 
  • trunk/src/VBox/Runtime/r0drv/os2/timer-r0drv-os2.cpp

    r33540 r40806  
    125125    {
    126126        RTSPINLOCK Spinlock;
    127         int rc = RTSpinlockCreate(&Spinlock);
     127        int rc = RTSpinlockCreate(&Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTTimerOS2");
    128128        AssertRCReturn(rc, rc);
    129129        //bool fRc;
     
    152152     * Insert the timer into the list (LIFO atm).
    153153     */
    154     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    155     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     154    RTSpinlockAcquire(g_Spinlock);
    156155    g_u32ChangeNo++;
    157156    pTimer->pNext = g_pTimerHead;
    158157    g_pTimerHead = pTimer;
    159158    g_cTimers++;
    160     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     159    RTSpinlockReleaseNoInts(g_Spinlock);
    161160
    162161    *ppTimer = pTimer;
     
    190189     * Remove it from the list.
    191190     */
    192     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    193     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     191    RTSpinlockAcquire(g_Spinlock);
    194192    g_u32ChangeNo++;
    195193    if (g_pTimerHead == pTimer)
     
    203201            if (RT_UNLIKELY(!pPrev))
    204202            {
    205                 RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     203                RTSpinlockReleaseNoInts(g_Spinlock);
    206204                return VERR_INVALID_HANDLE;
    207205            }
     
    218216            rtTimerOs2Dearm();
    219217    }
    220     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     218    RTSpinlockReleaseNoInts(g_Spinlock);
    221219
    222220    /*
     
    241239    u64First += RTTimeNanoTS();
    242240
    243     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    244     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     241    RTSpinlockAcquire(g_Spinlock);
    245242    g_u32ChangeNo++;
    246243    if (!g_cActiveTimers)
     
    249246        if (RT_FAILURE(rc))
    250247        {
    251             RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     248            RTSpinlockReleaseNoInts(g_Spinlock);
    252249            return rc;
    253250        }
     
    259256    pTimer->u64StartTS = u64First;
    260257    pTimer->u64NextTS = u64First;
    261     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     258    RTSpinlockReleaseNoInts(g_Spinlock);
    262259
    263260    return VINF_SUCCESS;
     
    275272     * Suspend the timer.
    276273     */
    277     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    278     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     274    RTSpinlockAcquire(g_Spinlock);
    279275    g_u32ChangeNo++;
    280276    pTimer->fSuspended = true;
     
    283279    if (!g_cActiveTimers)
    284280        rtTimerOs2Dearm();
    285     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     281    RTSpinlockReleaseNoInts(g_Spinlock);
    286282
    287283    return VINF_SUCCESS;
     
    305301    const uint64_t u64NanoTS = RTTimeNanoTS();
    306302
    307     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    308     RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     303    RTSpinlockAcquire(g_Spinlock);
    309304
    310305    /*
     
    343338            PFNRTTIMER  pfnTimer = pTimer->pfnTimer;
    344339            void       *pvUser   = pTimer->pvUser;
    345             RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     340            RTSpinlockReleaseNoInts(g_Spinlock);
    346341            pfnTimer(pTimer, pvUser, pTimer->iTick);
    347342
    348             RTSpinlockAcquireNoInts(g_Spinlock, &Tmp);
     343            RTSpinlockAcquire(g_Spinlock);
    349344
    350345            /* check if anything changed. */
     
    360355    }
    361356
    362     RTSpinlockReleaseNoInts(g_Spinlock, &Tmp);
     357    RTSpinlockReleaseNoInts(g_Spinlock);
    363358}
    364359
  • trunk/src/VBox/Runtime/r0drv/powernotification-r0drv.c

    r37211 r40806  
    8989    PRTPOWERNOTIFYREG pCur;
    9090    RTSPINLOCK        hSpinlock;
    91     RTSPINLOCKTMP     Tmp = RTSPINLOCKTMP_INITIALIZER;
    9291
    9392    /*
     
    114113    if (hSpinlock == NIL_RTSPINLOCK)
    115114        return VERR_ACCESS_DENIED;
    116     RTSpinlockAcquire(hSpinlock, &Tmp);
     115    RTSpinlockAcquire(hSpinlock);
    117116
    118117    /* Clear the bit. */
     
    133132                void *pvUser = pCur->pvUser;
    134133                pCur = pCur->pNext;
    135                 RTSpinlockRelease(g_hRTPowerNotifySpinLock, &Tmp);
     134                RTSpinlockRelease(g_hRTPowerNotifySpinLock);
    136135
    137136                pfnCallback(enmEvent, pvUser);
     
    141140                if (hSpinlock == NIL_RTSPINLOCK)
    142141                    return VERR_ACCESS_DENIED;
    143                 RTSpinlockAcquire(hSpinlock, &Tmp);
     142                RTSpinlockAcquire(hSpinlock);
    144143                if (ASMAtomicUoReadU32(&g_iRTPowerGeneration) != iGeneration)
    145144                    break;
     
    150149    } while (pCur);
    151150
    152     RTSpinlockRelease(hSpinlock, &Tmp);
     151    RTSpinlockRelease(hSpinlock);
    153152    return VINF_SUCCESS;
    154153}
     
    160159    PRTPOWERNOTIFYREG   pCur;
    161160    PRTPOWERNOTIFYREG   pNew;
    162     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    163161
    164162    /*
     
    169167    RT_ASSERT_PREEMPTIBLE();
    170168
    171     RTSpinlockAcquire(g_hRTPowerNotifySpinLock, &Tmp);
     169    RTSpinlockAcquire(g_hRTPowerNotifySpinLock);
    172170    for (pCur = g_pRTPowerCallbackHead; pCur; pCur = pCur->pNext)
    173171        if (    pCur->pvUser == pvUser
    174172            &&  pCur->pfnCallback == pfnCallback)
    175173            break;
    176     RTSpinlockRelease(g_hRTPowerNotifySpinLock, &Tmp);
     174    RTSpinlockRelease(g_hRTPowerNotifySpinLock);
    177175    AssertMsgReturn(!pCur, ("pCur=%p pfnCallback=%p pvUser=%p\n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS);
    178176
     
    189187    memset(&pNew->bmDone[0], 0xff, sizeof(pNew->bmDone));
    190188
    191     RTSpinlockAcquire(g_hRTPowerNotifySpinLock, &Tmp);
     189    RTSpinlockAcquire(g_hRTPowerNotifySpinLock);
    192190
    193191    pCur = g_pRTPowerCallbackHead;
     
    210208    ASMAtomicIncU32(&g_iRTPowerGeneration);
    211209
    212     RTSpinlockRelease(g_hRTPowerNotifySpinLock, &Tmp);
     210    RTSpinlockRelease(g_hRTPowerNotifySpinLock);
    213211
    214212    /* duplicate? */
     
    228226    PRTPOWERNOTIFYREG   pPrev;
    229227    PRTPOWERNOTIFYREG   pCur;
    230     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
    231228
    232229    /*
     
    240237     * Find and unlink the record from the list.
    241238     */
    242     RTSpinlockAcquire(g_hRTPowerNotifySpinLock, &Tmp);
     239    RTSpinlockAcquire(g_hRTPowerNotifySpinLock);
    243240    pPrev = NULL;
    244241    for (pCur = g_pRTPowerCallbackHead; pCur; pCur = pCur->pNext)
     
    257254        ASMAtomicIncU32(&g_iRTPowerGeneration);
    258255    }
    259     RTSpinlockRelease(g_hRTPowerNotifySpinLock, &Tmp);
     256    RTSpinlockRelease(g_hRTPowerNotifySpinLock);
    260257
    261258    if (!pCur)
     
    276273DECLHIDDEN(int) rtR0PowerNotificationInit(void)
    277274{
    278     int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTPowerNotifySpinLock);
     275    int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTPowerNotifySpinLock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0Power");
    279276    if (RT_SUCCESS(rc))
    280277    {
     
    293290{
    294291    PRTPOWERNOTIFYREG   pHead;
    295     RTSPINLOCKTMP       Tmp       = RTSPINLOCKTMP_INITIALIZER;
    296292    RTSPINLOCK          hSpinlock = g_hRTPowerNotifySpinLock;
    297293    AssertReturnVoid(hSpinlock != NIL_RTSPINLOCK);
     
    300296
    301297    /* pick up the list and the spinlock. */
    302     RTSpinlockAcquire(hSpinlock, &Tmp);
     298    RTSpinlockAcquire(hSpinlock);
    303299    ASMAtomicWriteHandle(&g_hRTPowerNotifySpinLock, NIL_RTSPINLOCK);
    304300    pHead = g_pRTPowerCallbackHead;
    305301    g_pRTPowerCallbackHead = NULL;
    306302    ASMAtomicIncU32(&g_iRTPowerGeneration);
    307     RTSpinlockRelease(hSpinlock, &Tmp);
     303    RTSpinlockRelease(hSpinlock);
    308304
    309305    /* free the list. */
  • trunk/src/VBox/Runtime/r0drv/solaris/spinlock-r0drv-solaris.c

    r40149 r40806  
    5555    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
    5656    uint32_t volatile   u32Magic;
     57    /** Spinlock creation flags.  */
     58    uint32_t            fFlags;
     59    /** Saved interrupt flag. */
     60    uint32_t volatile   fIntSaved;
    5761    /** A Solaris spinlock. */
    5862    kmutex_t            Mtx;
     
    6771
    6872
    69 
    70 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock)
    71 {
     73This code has changed and need testing!;
     74
     75
     76RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
     77{
     78    RT_ASSERT_PREEMPTIBLE();
     79    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
     80
    7281    /*
    7382     * Allocate.
    7483     */
    75     RT_ASSERT_PREEMPTIBLE();
    7684    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
    7785    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
     
    8290     * Initialize & return.
    8391     */
    84     pThis->u32Magic = RTSPINLOCK_MAGIC;
     92    pThis->u32Magic  = RTSPINLOCK_MAGIC;
     93    pThis->fFlags    = fFlags;
     94    pThis->fIntSaved = 0;
     95    /** @todo Consider different PIL when not interrupt safe requirement. */
    8596    mutex_init(&pThis->Mtx, "IPRT Spinlock", MUTEX_SPIN, (void *)ipltospl(PIL_MAX));
    8697    *pSpinlock = pThis;
     
    112123
    113124
    114 RTDECL(void) RTSpinlockAcquireNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    115 {
    116     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    117     RT_ASSERT_PREEMPT_CPUID_VAR();
    118 
    119     AssertPtr(pThis);
    120     Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    121 
    122 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    123     pTmp->uFlags = ASMIntDisableFlags();
    124 #else
    125     pTmp->uFlags = 0;
    126 #endif
    127     mutex_enter(&pThis->Mtx);
    128 
    129     /*
    130      * Solaris 10 doesn't preserve the interrupt flag, but since we're at PIL_MAX we should be
    131      * fine and not get interrupts while lock is held. Re-disable interrupts to not upset
    132      * assertions & assumptions callers might have.
    133      */
    134 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    135     ASMIntDisable();
    136 #endif
    137 
    138 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    139     Assert(!ASMIntAreEnabled());
    140 #endif
    141     RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
    142 }
    143 
    144 
    145 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
    146 {
    147     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
    148     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS();
    149 
    150     AssertPtr(pThis);
    151     Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    152     RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    153     NOREF(pTmp);
    154 
    155     mutex_exit(&pThis->Mtx);
    156 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    157     ASMSetFlags(pTmp->uFlags);
    158 #endif
    159 
    160     RT_ASSERT_PREEMPT_CPUID();
    161 }
    162 
    163 
    164 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     125RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
    165126{
    166127    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    168129    AssertPtr(pThis);
    169130    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    170     NOREF(pTmp);
     131
     132    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     133    {
     134#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     135        uint32_t fIntSaved = ASMIntDisableFlags();
     136#endif
     137        mutex_enter(&pThis->Mtx);
     138
     139        /*
     140         * Solaris 10 doesn't preserve the interrupt flag, but since we're at PIL_MAX we should be
     141         * fine and not get interrupts while lock is held. Re-disable interrupts to not upset
     142         * assertions & assumptions callers might have.
     143         */
     144#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     145        ASMIntDisable();
     146#endif
     147
     148#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     149        Assert(!ASMIntAreEnabled());
     150#endif
     151        pThis->fIntSaved = fIntSaved;
     152    }
     153    else
     154    {
    171155#if defined(RT_STRICT) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
    172     bool fIntsOn = ASMIntAreEnabled();
    173 #endif
    174 
    175     mutex_enter(&pThis->Mtx);
    176 
    177 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    178     AssertMsg(fIntsOn == ASMIntAreEnabled(), ("fIntsOn=%RTbool\n", fIntsOn));
    179 #endif
     156        bool fIntsOn = ASMIntAreEnabled();
     157#endif
     158
     159        mutex_enter(&pThis->Mtx);
     160
     161#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     162        AssertMsg(fIntsOn == ASMIntAreEnabled(), ("fIntsOn=%RTbool\n", fIntsOn));
     163#endif
     164    }
    180165
    181166    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
     
    183168
    184169
    185 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)
     170RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
    186171{
    187172    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
     
    191176    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
    192177    RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
    193     NOREF(pTmp);
     178
     179    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
     180    {
     181#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     182        uint32_t fIntSaved = pThis->fIntSaved;
     183        pThis->fIntSaved = 0;
     184#endif
     185        mutex_exit(&pThis->Mtx);
     186
     187#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     188        ASMSetFlags(fIntSaved);
     189#endif
     190    }
     191    else
     192    {
    194193#if defined(RT_STRICT) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
    195     bool fIntsOn = ASMIntAreEnabled();
    196 #endif
    197 
    198     mutex_exit(&pThis->Mtx);
    199 
    200 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    201     AssertMsg(fIntsOn == ASMIntAreEnabled(), ("fIntsOn=%RTbool\n", fIntsOn));
    202 #endif
     194        bool fIntsOn = ASMIntAreEnabled();
     195#endif
     196
     197        mutex_exit(&pThis->Mtx);
     198
     199#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     200        AssertMsg(fIntsOn == ASMIntAreEnabled(), ("fIntsOn=%RTbool\n", fIntsOn));
     201#endif
     202    }
     203
    203204    RT_ASSERT_PREEMPT_CPUID();
    204205}
    205206
     207
     208RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock)
     209{
     210#if 1
     211    if (RT_UNLIKELY(!(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)))
     212        RTAssertMsg2("RTSpinlockReleaseNoInts: %p (magic=%#x)\n", Spinlock, Spinlock->u32Magic);
     213#else
     214    AssertRelease(Spinlock->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE);
     215#endif
     216    RTSpinlockRelease(Spinlock);
     217}
     218
  • trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp

    r40595 r40806  
    416416                                         &pGVMM->aHostCpus[iCpu]);
    417417                    if (RT_SUCCESS(rc))
    418                         rc = RTSpinlockCreate(&pGVMM->aHostCpus[iCpu].Ppt.hSpinlock);
     418                        rc = RTSpinlockCreate(&pGVMM->aHostCpus[iCpu].Ppt.hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "GVMM/CPU");
    419419                    if (RT_FAILURE(rc))
    420420                    {
     
    21762176     * Do the house keeping.
    21772177     */
    2178     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2179     RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2178    RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    21802179
    21812180    if (++pCpu->Ppt.iTickHistorization >= pCpu->Ppt.cTicksHistoriziationInterval)
     
    21972196                uHistMaxHz = pCpu->Ppt.aHzHistory[i];
    21982197        if (uHistMaxHz == pCpu->Ppt.uTimerHz)
    2199             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2198            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22002199        else if (uHistMaxHz)
    22012200        {
     
    22142213            else
    22152214                pCpu->Ppt.cTicksHistoriziationInterval = 1;
    2216             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2215            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22172216
    22182217            /*SUPR0Printf("Cpu%u: change to %u Hz / %u ns\n", pCpu->idxCpuSet, uHistMaxHz, cNsInterval);*/
     
    22272226            pCpu->Ppt.uTimerHz    = 0;
    22282227            pCpu->Ppt.cNsInterval = 0;
    2229             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2228            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22302229
    22312230            /*SUPR0Printf("Cpu%u: stopping (%u Hz)\n", pCpu->idxCpuSet, uHistMaxHz);*/
     
    22342233    }
    22352234    else
    2236         RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2235        RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    22372236}
    22382237#endif /* GVMM_SCHED_WITH_PPT */
     
    22812280                    && !pCpu->Ppt.fStarting /* solaris paranoia */))
    22822281    {
    2283         RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    2284         RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2282        RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    22852283
    22862284        pCpu->Ppt.uDesiredHz = uHz;
     
    23022300        }
    23032301
    2304         RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2302        RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    23052303
    23062304        if (cNsInterval)
     
    23102308            AssertRC(rc);
    23112309
    2312             RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2310            RTSpinlockAcquire(pCpu->Ppt.hSpinlock);
    23132311            if (RT_FAILURE(rc))
    23142312                pCpu->Ppt.fStarted = false;
    23152313            pCpu->Ppt.fStarting = false;
    2316             RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock, &Tmp);
     2314            RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock);
    23172315        }
    23182316    }
  • trunk/src/VBox/VMM/VMMR3/PDMBlkCache.cpp

    r39515 r40806  
    657657    /* The list is moved to a new header to reduce locking overhead. */
    658658    RTLISTANCHOR ListDirtyNotCommitted;
    659     RTSPINLOCKTMP Tmp;
    660659
    661660    RTListInit(&ListDirtyNotCommitted);
    662     RTSpinlockAcquire(pBlkCache->LockList, &Tmp);
     661    RTSpinlockAcquire(pBlkCache->LockList);
    663662    RTListMove(&ListDirtyNotCommitted, &pBlkCache->ListDirtyNotCommitted);
    664     RTSpinlockRelease(pBlkCache->LockList, &Tmp);
     663    RTSpinlockRelease(pBlkCache->LockList);
    665664
    666665    if (!RTListIsEmpty(&ListDirtyNotCommitted))
     
    755754        pEntry->fFlags |= PDMBLKCACHE_ENTRY_IS_DIRTY;
    756755
    757         RTSPINLOCKTMP Tmp;
    758         RTSpinlockAcquire(pBlkCache->LockList, &Tmp);
     756        RTSpinlockAcquire(pBlkCache->LockList);
    759757        RTListAppend(&pBlkCache->ListDirtyNotCommitted, &pEntry->NodeNotCommitted);
    760         RTSpinlockRelease(pBlkCache->LockList, &Tmp);
     758        RTSpinlockRelease(pBlkCache->LockList);
    761759
    762760        uint32_t cbDirty = ASMAtomicAddU32(&pCache->cbDirty, pEntry->cbData);
     
    12201218            RTListInit(&pBlkCache->ListDirtyNotCommitted);
    12211219
    1222             rc = RTSpinlockCreate(&pBlkCache->LockList);
     1220            rc = RTSpinlockCreate(&pBlkCache->LockList, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "pdmR3BlkCacheRetain");
    12231221            if (RT_SUCCESS(rc))
    12241222            {
  • trunk/src/VBox/VMM/VMMRZ/PGMRZDynMap.cpp

    r39745 r40806  
    8888 */
    8989# define PGMRZDYNMAP_SPINLOCK_ACQUIRE(pThis) \
    90     RTSPINLOCKTMP   MySpinlockTmp = RTSPINLOCKTMP_INITIALIZER; \
    91     RTSpinlockAcquire((pThis)->hSpinlock, &MySpinlockTmp)
     90    RTSpinlockAcquire((pThis)->hSpinlock)
     91
    9292/**
    9393 * Releases the spinlock.
    9494 */
    9595# define PGMRZDYNMAP_SPINLOCK_RELEASE(pThis) \
    96     RTSpinlockRelease((pThis)->hSpinlock, &MySpinlockTmp)
     96    RTSpinlockRelease((pThis)->hSpinlock)
    9797
    9898/**
     
    100100 */
    101101# define PGMRZDYNMAP_SPINLOCK_REACQUIRE(pThis) \
    102     RTSpinlockAcquire((pThis)->hSpinlock, &MySpinlockTmp)
     102    RTSpinlockAcquire((pThis)->hSpinlock)
    103103#else
    104104# define PGMRZDYNMAP_SPINLOCK_ACQUIRE(pThis)   do { } while (0)
     
    408408        if (RT_SUCCESS(rc))
    409409        {
    410             rc = RTSpinlockCreate(&pThis->hSpinlock);
     410            rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "PGMR0DynMap");
    411411            if (RT_SUCCESS(rc))
    412412            {
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