Changeset 40806 in vbox
- Timestamp:
- Apr 6, 2012 9:05:19 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r40668 r40806 1221 1221 # define RTSortIsSorted RT_MANGLER(RTSortIsSorted) 1222 1222 # define RTSpinlockAcquire RT_MANGLER(RTSpinlockAcquire) 1223 # define RTSpinlockAcquireNoInts RT_MANGLER(RTSpinlockAcquireNoInts)1224 1223 # define RTSpinlockCreate RT_MANGLER(RTSpinlockCreate) 1225 1224 # define RTSpinlockDestroy RT_MANGLER(RTSpinlockDestroy) 1226 1225 # define RTSpinlockRelease RT_MANGLER(RTSpinlockRelease) 1227 # define RTSpinlockReleaseNoInts RT_MANGLER(RTSpinlockReleaseNoInts)1228 1226 # define RTStrAAppendExNVTag RT_MANGLER(RTStrAAppendExNVTag) 1229 1227 # define RTStrAAppendNTag RT_MANGLER(RTStrAAppendNTag) -
trunk/include/iprt/spinlock.h
r28800 r40806 39 39 40 40 /** 41 * Temporary spinlock state variable.42 * All members are undefined and highly platform specific.43 */44 typedef struct RTSPINLOCKTMP45 {46 #ifdef IN_RING047 # ifdef RT_OS_LINUX48 /** 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 # else75 # error "PORTME\n"76 /** The saved [R|E]FLAGS. */77 RTCCUINTREG uFlags;78 # endif79 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_INITIALIZER92 * What to assign to a RTSPINLOCKTMP at definition.93 */94 #ifdef DOXYGEN_RUNNING95 # define RTSPINLOCKTMP_INITIALIZER96 #endif97 98 99 100 /**101 41 * Creates a spinlock. 102 42 * 103 43 * @returns iprt status code. 104 44 * @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. 105 48 */ 106 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock); 49 RTDECL(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 /** @} */ 107 63 108 64 /** … … 116 72 /** 117 73 * Acquires the spinlock. 118 * Interrupts are disabled upon return.119 74 * 120 75 * @param Spinlock The spinlock to acquire. 121 76 * @param pTmp Where to save the state. 122 77 */ 123 RTDECL(void) RTSpinlockAcquire NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);78 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock); 124 79 125 80 /** … … 129 84 * @param pTmp The state to restore. (This better be the same as for the RTSpinlockAcquire() call!) 130 85 */ 131 RTDECL(void) RTSpinlockRelease NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp);86 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock); 132 87 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. */ 89 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock); 148 90 149 91 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp
r33540 r40806 164 164 * Initialize the session hash table. 165 165 */ 166 rc = RTSpinlockCreate(&g_Spinlock );166 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestOS2"); 167 167 if (RT_SUCCESS(rc)) 168 168 { … … 370 370 */ 371 371 unsigned iHash = SESSION_HASH(sfn); 372 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 373 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 372 RTSpinlockAcquire(g_Spinlock); 374 373 pSession->pNextHash = g_apSessionHashTab[iHash]; 375 374 g_apSessionHashTab[iHash] = pSession; 376 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);375 RTSpinlockReleaseNoInts(g_Spinlock); 377 376 } 378 377 … … 392 391 const RTPROCESS Process = RTProcSelf(); 393 392 const unsigned iHash = SESSION_HASH(sfn); 394 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 395 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 393 RTSpinlockAcquire(g_Spinlock); 396 394 397 395 pSession = g_apSessionHashTab[iHash]; … … 424 422 } 425 423 } 426 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);424 RTSpinlockReleaseNoInts(g_Spinlock); 427 425 if (!pSession) 428 426 { … … 444 442 * Find the session. 445 443 */ 446 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;447 444 const RTPROCESS Process = RTProcSelf(); 448 445 const unsigned iHash = SESSION_HASH(sfn); 449 446 PVBOXGUESTSESSION pSession; 450 447 451 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);448 RTSpinlockAcquire(g_Spinlock); 452 449 pSession = g_apSessionHashTab[iHash]; 453 450 if (pSession && pSession->Process != Process) … … 458 455 || pSession->Process != Process)); 459 456 } 460 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);457 RTSpinlockReleaseNoInts(g_Spinlock); 461 458 if (RT_UNLIKELY(!pSession)) 462 459 { … … 536 533 * Find the session. 537 534 */ 538 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;539 535 const RTPROCESS Process = RTProcSelf(); 540 536 const unsigned iHash = SESSION_HASH(sfn); 541 537 PVBOXGUESTSESSION pSession; 542 538 543 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);539 RTSpinlockAcquire(g_Spinlock); 544 540 pSession = g_apSessionHashTab[iHash]; 545 541 if (pSession && pSession->Process != Process) … … 550 546 || pSession->Process != Process)); 551 547 } 552 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);548 RTSpinlockReleaseNoInts(g_Spinlock); 553 549 if (!pSession) 554 550 { -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r40483 r40806 747 747 * Create the wait and session spinlocks as well as the ballooning mutex. 748 748 */ 749 rc = RTSpinlockCreate(&pDevExt->EventSpinlock );749 rc = RTSpinlockCreate(&pDevExt->EventSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestEvent"); 750 750 if (RT_SUCCESS(rc)) 751 rc = RTSpinlockCreate(&pDevExt->SessionSpinlock );751 rc = RTSpinlockCreate(&pDevExt->SessionSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestSession"); 752 752 if (RT_FAILURE(rc)) 753 753 { … … 1011 1011 if (pWait) 1012 1012 { 1013 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1014 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1013 RTSpinlockAcquire(pDevExt->EventSpinlock); 1015 1014 1016 1015 pWait = RTListGetFirst(&pDevExt->FreeList, VBOXGUESTWAIT, ListNode); … … 1018 1017 RTListNodeRemove(&pWait->ListNode); 1019 1018 1020 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1019 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1021 1020 } 1022 1021 if (!pWait) … … 1101 1100 static void VBoxGuestWaitFreeUnlocked(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTWAIT pWait) 1102 1101 { 1103 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1104 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1102 RTSpinlockAcquire(pDevExt->EventSpinlock); 1105 1103 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1106 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1104 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1107 1105 } 1108 1106 … … 1121 1119 if (!RTListIsEmpty(&pDevExt->WakeUpList)) 1122 1120 { 1123 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1124 RTSpinlockAcquireNoInts(pDevExt->EventSpinlock, &Tmp); 1121 RTSpinlockAcquire(pDevExt->EventSpinlock); 1125 1122 for (;;) 1126 1123 { … … 1130 1127 break; 1131 1128 pWait->fPendingWakeUp = true; 1132 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1129 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1133 1130 1134 1131 rc = RTSemEventMultiSignal(pWait->Event); 1135 1132 AssertRC(rc); 1136 1133 1137 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1134 RTSpinlockAcquire(pDevExt->EventSpinlock); 1138 1135 pWait->fPendingWakeUp = false; 1139 1136 if (!pWait->fFreeMe) … … 1148 1145 } 1149 1146 } 1150 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1147 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1151 1148 } 1152 1149 } … … 1234 1231 */ 1235 1232 DECLINLINE(int) WaitEventCheckCondition(PVBOXGUESTDEVEXT pDevExt, VBoxGuestWaitEventInfo *pInfo, 1236 int iEvent, const uint32_t fReqEvents , PRTSPINLOCKTMP pTmp)1233 int iEvent, const uint32_t fReqEvents) 1237 1234 { 1238 1235 uint32_t fMatches = pDevExt->f32PendingEvents & fReqEvents; … … 1240 1237 { 1241 1238 ASMAtomicAndU32(&pDevExt->f32PendingEvents, ~fMatches); 1242 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , pTmp);1239 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1243 1240 1244 1241 pInfo->u32EventFlagsOut = fMatches; … … 1250 1247 return VINF_SUCCESS; 1251 1248 } 1252 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , pTmp);1249 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1253 1250 return VERR_TIMEOUT; 1254 1251 } … … 1258 1255 VBoxGuestWaitEventInfo *pInfo, size_t *pcbDataReturned, bool fInterruptible) 1259 1256 { 1260 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1261 1257 const uint32_t fReqEvents = pInfo->u32EventMaskIn; 1262 1258 uint32_t fResEvents; … … 1283 1279 * Check the condition up front, before doing the wait-for-event allocations. 1284 1280 */ 1285 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1286 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents , &Tmp);1281 RTSpinlockAcquire(pDevExt->EventSpinlock); 1282 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents); 1287 1283 if (rc == VINF_SUCCESS) 1288 1284 return rc; … … 1305 1301 * Otherwise enter into the list and go to sleep waiting for the ISR to signal us. 1306 1302 */ 1307 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1303 RTSpinlockAcquire(pDevExt->EventSpinlock); 1308 1304 RTListAppend(&pDevExt->WaitList, &pWait->ListNode); 1309 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents , &Tmp);1305 rc = WaitEventCheckCondition(pDevExt, pInfo, iEvent, fReqEvents); 1310 1306 if (rc == VINF_SUCCESS) 1311 1307 { … … 1332 1328 * Unlink the wait item and dispose of it. 1333 1329 */ 1334 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1330 RTSpinlockAcquire(pDevExt->EventSpinlock); 1335 1331 fResEvents = pWait->fResEvents; 1336 1332 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1337 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1333 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1338 1334 1339 1335 /* … … 1382 1378 static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession) 1383 1379 { 1384 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1385 1380 PVBOXGUESTWAIT pWait; 1386 1381 PVBOXGUESTWAIT pSafe; … … 1392 1387 * Walk the event list and wake up anyone with a matching session. 1393 1388 */ 1394 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1389 RTSpinlockAcquire(pDevExt->EventSpinlock); 1395 1390 RTListForEachSafe(&pDevExt->WaitList, pWait, pSafe, VBOXGUESTWAIT, ListNode) 1396 1391 { … … 1407 1402 } 1408 1403 } 1409 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1404 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1410 1405 Assert(rc == 0); 1411 1406 … … 1692 1687 * us returning too early. 1693 1688 */ 1694 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1695 1689 PVBOXGUESTWAIT pWait; 1696 1690 for (;;) 1697 1691 { 1698 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1692 RTSpinlockAcquire(pDevExt->EventSpinlock); 1699 1693 if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0) 1700 1694 { 1701 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1695 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1702 1696 return VINF_SUCCESS; 1703 1697 } 1704 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1698 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1705 1699 1706 1700 pWait = VBoxGuestWaitAlloc(pDevExt, NULL); … … 1719 1713 * Otherwise link us into the HGCM wait list and go to sleep. 1720 1714 */ 1721 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);1715 RTSpinlockAcquire(pDevExt->EventSpinlock); 1722 1716 RTListAppend(&pDevExt->HGCMWaitList, &pWait->ListNode); 1723 1717 if ((pHdr->fu32Flags & VBOX_HGCM_REQ_DONE) != 0) 1724 1718 { 1725 1719 VBoxGuestWaitFreeLocked(pDevExt, pWait); 1726 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1720 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1727 1721 return VINF_SUCCESS; 1728 1722 } 1729 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);1723 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 1730 1724 1731 1725 if (fInterruptible) … … 1810 1804 */ 1811 1805 unsigned i; 1812 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1813 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp); 1806 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1814 1807 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1815 1808 if (!pSession->aHGCMClientIds[i]) … … 1818 1811 break; 1819 1812 } 1820 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1813 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1821 1814 if (i >= RT_ELEMENTS(pSession->aHGCMClientIds)) 1822 1815 { … … 1849 1842 const uint32_t u32ClientId = pInfo->u32ClientID; 1850 1843 unsigned i; 1851 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1852 RTSpinlockAcquireNoInts(pDevExt->SessionSpinlock, &Tmp); 1844 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1853 1845 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1854 1846 if (pSession->aHGCMClientIds[i] == u32ClientId) … … 1857 1849 break; 1858 1850 } 1859 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1851 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1860 1852 if (i >= RT_ELEMENTS(pSession->aHGCMClientIds)) 1861 1853 { … … 1881 1873 1882 1874 /* Update the client id array according to the result. */ 1883 RTSpinlockAcquire NoInts(pDevExt->SessionSpinlock, &Tmp);1875 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1884 1876 if (pSession->aHGCMClientIds[i] == UINT32_MAX) 1885 1877 pSession->aHGCMClientIds[i] = RT_SUCCESS(rc) && RT_SUCCESS(pInfo->result) ? 0 : u32ClientId; 1886 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1878 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1887 1879 1888 1880 return rc; … … 1897 1889 { 1898 1890 const uint32_t u32ClientId = pInfo->u32ClientID; 1899 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1900 1891 uint32_t fFlags; 1901 1892 size_t cbActual; … … 1929 1920 * Validate the client id. 1930 1921 */ 1931 RTSpinlockAcquire NoInts(pDevExt->SessionSpinlock, &Tmp);1922 RTSpinlockAcquire(pDevExt->SessionSpinlock); 1932 1923 for (i = 0; i < RT_ELEMENTS(pSession->aHGCMClientIds); i++) 1933 1924 if (pSession->aHGCMClientIds[i] == u32ClientId) 1934 1925 break; 1935 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock , &Tmp);1926 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 1936 1927 if (RT_UNLIKELY(i >= RT_ELEMENTS(pSession->aHGCMClientIds))) 1937 1928 { … … 2222 2213 static int VBoxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures) 2223 2214 { 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; 2228 2218 /* Exit early if nothing has changed - hack to work around the 2229 2219 * 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++) 2234 2225 { 2235 2226 if (RT_BIT_32(i) & VMMDEV_MOUSE_GUEST_MASK) … … 2237 2228 if ( (RT_BIT_32(i) & fFeatures) 2238 2229 && !(RT_BIT_32(i) & pSession->fMouseStatus)) 2239 ++pDevExt->cMouseFeatureUsage[i];2230 pDevExt->cMouseFeatureUsage[i]++; 2240 2231 else if ( !(RT_BIT_32(i) & fFeatures) 2241 2232 && (RT_BIT_32(i) & pSession->fMouseStatus)) 2242 --pDevExt->cMouseFeatureUsage[i];2233 pDevExt->cMouseFeatureUsage[i]--; 2243 2234 } 2244 2235 if (pDevExt->cMouseFeatureUsage[i] > 0) 2245 2236 fNewDevExtStatus |= RT_BIT_32(i); 2246 2237 } 2238 2247 2239 pSession->fMouseStatus = fFeatures & VMMDEV_MOUSE_GUEST_MASK; 2248 2240 fNoAction = (pDevExt->fMouseStatus == fNewDevExtStatus); 2249 2241 pDevExt->fMouseStatus = fNewDevExtStatus; 2250 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock, &Tmp); 2242 2243 RTSpinlockReleaseNoInts(pDevExt->SessionSpinlock); 2251 2244 if (fNoAction) 2252 2245 return VINF_SUCCESS; 2246 2253 2247 do 2254 2248 { 2255 2249 fNewDevExtStatus = pDevExt->fMouseStatus; 2256 2250 rc = vboxguestcommonSetMouseStatus(fNewDevExtStatus); 2257 } while(RT_SUCCESS(rc) && fNewDevExtStatus != pDevExt->fMouseStatus); 2251 } while ( RT_SUCCESS(rc) 2252 && fNewDevExtStatus != pDevExt->fMouseStatus); 2253 2258 2254 return rc; 2259 2255 } … … 2271 2267 2272 2268 g_test_fSetMouseStatus = true; 2273 rc = RTSpinlockCreate(&Spinlock );2269 rc = RTSpinlockCreate(&Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestTest"); 2274 2270 AssertRCReturnVoid(rc); 2275 2271 { … … 2596 2592 { 2597 2593 bool fMousePositionChanged = false; 2598 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;2599 2594 VMMDevEvents volatile *pReq = pDevExt->pIrqAckEvents; 2600 2595 int rc = 0; … … 2610 2605 * Enter the spinlock and check if it's our IRQ or not. 2611 2606 */ 2612 RTSpinlockAcquire NoInts(pDevExt->EventSpinlock, &Tmp);2607 RTSpinlockAcquire(pDevExt->EventSpinlock); 2613 2608 fOurIrq = pDevExt->pVMMDevMemory->V.V1_04.fHaveEvents; 2614 2609 if (fOurIrq) … … 2695 2690 LogFlow(("VBoxGuestCommonISR: not ours\n")); 2696 2691 2697 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock , &Tmp);2692 RTSpinlockReleaseNoInts(pDevExt->EventSpinlock); 2698 2693 2699 2694 #if defined(VBOXGUEST_USE_DEFERRED_WAKE_UP) && !defined(RT_OS_WINDOWS) -
trunk/src/VBox/Devices/Bus/SrvPciRawR0.cpp
r39086 r40806 95 95 static DECLCALLBACK(bool) pcirawr0Isr(void* pContext, int32_t iHostIrq) 96 96 { 97 RTSPINLOCKTMP aTmp;98 97 PPCIRAWDEV pThis = (PPCIRAWDEV)pContext; 99 98 … … 114 113 #endif 115 114 116 RTSpinlockAcquire NoInts(pThis->hSpinlock, &aTmp);115 RTSpinlockAcquire(pThis->hSpinlock); 117 116 pThis->iPendingIrq = iHostIrq; 118 RTSpinlockReleaseNoInts(pThis->hSpinlock , &aTmp);117 RTSpinlockReleaseNoInts(pThis->hSpinlock); 119 118 120 119 /** … … 575 574 if (RT_SUCCESS(rc)) 576 575 { 577 rc = RTSpinlockCreate(&pNew->hSpinlock );576 rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "PciRaw"); 578 577 AssertRC(rc); 579 578 rc = RTSemEventCreate(&pNew->hIrqEvent); … … 862 861 { 863 862 int rc = VINF_SUCCESS; 864 RTSPINLOCKTMP aTmp;865 863 bool fTerminate = false; 866 864 int32_t iPendingIrq = 0; … … 870 868 GET_PORT(TargetDevice); 871 869 872 RTSpinlockAcquire NoInts(pDev->hSpinlock, &aTmp);870 RTSpinlockAcquire(pDev->hSpinlock); 873 871 iPendingIrq = pDev->iPendingIrq; 874 872 pDev->iPendingIrq = 0; 875 873 fTerminate = pDev->fTerminate; 876 RTSpinlockReleaseNoInts(pDev->hSpinlock , &aTmp);874 RTSpinlockReleaseNoInts(pDev->hSpinlock); 877 875 878 876 /* Block until new IRQs arrives */ … … 887 885 if (!ASMAtomicReadBool(&pDev->fTerminate)) 888 886 { 889 RTSpinlockAcquire NoInts(pDev->hSpinlock, &aTmp);887 RTSpinlockAcquire(pDev->hSpinlock); 890 888 iPendingIrq = pDev->iPendingIrq; 891 889 pDev->iPendingIrq = 0; 892 RTSpinlockReleaseNoInts(pDev->hSpinlock , &aTmp);890 RTSpinlockReleaseNoInts(pDev->hSpinlock); 893 891 } 894 892 else -
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r39091 r40806 1122 1122 uint8_t const cbAddr, const char *pszMsg) 1123 1123 { 1124 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1125 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1124 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1126 1125 1127 1126 uint32_t iIf = pNetwork->MacTab.cEntries; … … 1134 1133 } 1135 1134 1136 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1135 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1137 1136 } 1138 1137 … … 1153 1152 INTNETADDRTYPE const enmType, uint8_t const cbAddr, const char *pszMsg) 1154 1153 { 1155 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1156 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1154 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1157 1155 1158 1156 uint32_t iIf = pNetwork->MacTab.cEntries; … … 1168 1166 } 1169 1167 1170 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1168 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1171 1169 } 1172 1170 … … 1185 1183 DECLINLINE(PINTNETIF) intnetR0NetworkAddrCacheLookupIf(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr, INTNETADDRTYPE const enmType, uint8_t const cbAddr) 1186 1184 { 1187 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1188 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1185 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1189 1186 1190 1187 uint32_t iIf = pNetwork->MacTab.cEntries; … … 1196 1193 { 1197 1194 intnetR0BusyIncIf(pIf); 1198 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1195 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1199 1196 return pIf; 1200 1197 } 1201 1198 } 1202 1199 1203 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1200 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1204 1201 return NULL; 1205 1202 } … … 1221 1218 PINTNETNETWORK pNetwork = pIf->pNetwork; 1222 1219 AssertReturnVoid(pNetwork); 1223 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1224 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1220 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1225 1221 1226 1222 if (RT_UNLIKELY(!pCache->cEntriesAlloc)) 1227 1223 { 1228 1224 /* This shouldn't happen*/ 1229 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1225 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1230 1226 return; 1231 1227 } … … 1264 1260 Assert(pCache->cEntries <= pCache->cEntriesAlloc); 1265 1261 1266 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1262 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1267 1263 } 1268 1264 … … 1443 1439 */ 1444 1440 PINTNETMACTAB pTab = &pNetwork->MacTab; 1445 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1446 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1441 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1447 1442 1448 1443 pDstTab->fTrunkDst = 0; … … 1522 1517 } 1523 1518 1524 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1519 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1525 1520 return pDstTab->cIfs 1526 1521 ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_INTNET : INTNETSWDECISION_BROADCAST) … … 1550 1545 INTNETSWDECISION enmSwDecision = INTNETSWDECISION_BROADCAST; 1551 1546 PINTNETMACTAB pTab = &pNetwork->MacTab; 1552 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1553 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1547 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1554 1548 1555 1549 /* Iterate the internal network interfaces and look for matching source and … … 1584 1578 } 1585 1579 1586 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1580 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1587 1581 return enmSwDecision; 1588 1582 } … … 1611 1605 */ 1612 1606 PINTNETMACTAB pTab = &pNetwork->MacTab; 1613 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1614 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1607 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1615 1608 1616 1609 pDstTab->fTrunkDst = 0; … … 1698 1691 } 1699 1692 1700 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1693 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1701 1694 return pDstTab->cIfs 1702 1695 ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_INTNET : INTNETSWDECISION_BROADCAST) … … 1724 1717 */ 1725 1718 PINTNETMACTAB pTab = &pNetwork->MacTab; 1726 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1727 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1719 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1728 1720 1729 1721 pDstTab->fTrunkDst = 0; … … 1761 1753 } 1762 1754 1763 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1755 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1764 1756 return INTNETSWDECISION_BROADCAST; 1765 1757 } … … 1786 1778 */ 1787 1779 PINTNETMACTAB pTab = &pNetwork->MacTab; 1788 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1789 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1780 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1790 1781 1791 1782 pDstTab->fTrunkDst = 0; … … 1823 1814 } 1824 1815 1825 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1816 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1826 1817 return !pDstTab->cIfs 1827 1818 ? (!pDstTab->fTrunkDst ? INTNETSWDECISION_DROP : INTNETSWDECISION_TRUNK) … … 1846 1837 */ 1847 1838 PINTNETMACTAB pTab= &pNetwork->MacTab; 1848 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1849 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 1839 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1850 1840 1851 1841 pDstTab->fTrunkDst = 0; … … 1866 1856 } 1867 1857 1868 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1858 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1869 1859 return pDstTab->fTrunkDst ? INTNETSWDECISION_TRUNK : INTNETSWDECISION_DROP; 1870 1860 } … … 1912 1902 if (cAllocated <= INTNET_MAX_IFS) 1913 1903 { 1914 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1915 1916 1904 /* 1917 1905 * Resize the destination tables first, this can be kind of tedious. … … 1958 1946 for (;;) 1959 1947 { 1960 RTSpinlockAcquire NoInts(pTrunk->hDstTabSpinlock, &Tmp);1948 RTSpinlockAcquire(pTrunk->hDstTabSpinlock); 1961 1949 void *pvOld = *ppDstTab; 1962 1950 if (pvOld) 1963 1951 *ppDstTab = pNew; 1964 RTSpinlockReleaseNoInts(pTrunk->hDstTabSpinlock , &Tmp);1952 RTSpinlockReleaseNoInts(pTrunk->hDstTabSpinlock); 1965 1953 if (pvOld) 1966 1954 { … … 1981 1969 if (paNew) 1982 1970 { 1983 RTSpinlockAcquire NoInts(pNetwork->hAddrSpinlock, &Tmp);1971 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 1984 1972 1985 1973 PINTNETMACTABENTRY paOld = pTab->paEntries; … … 1996 1984 pTab->cEntriesAllocated = cAllocated; 1997 1985 1998 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);1986 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 1999 1987 2000 1988 RTMemFree(paOld); … … 2090 2078 { 2091 2079 PINTNETIF pMatchingIf = NULL; 2092 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2093 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 2080 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 2094 2081 2095 2082 uint32_t iIf = pNetwork->MacTab.cEntries; … … 2110 2097 } 2111 2098 2112 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);2099 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 2113 2100 2114 2101 if (pMatchingIf) … … 2127 2114 case RTNET_DHCP_MT_RELEASE: 2128 2115 { 2129 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2130 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 2116 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 2131 2117 2132 2118 uint32_t iIf = pNetwork->MacTab.cEntries; … … 2144 2130 } 2145 2131 2146 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);2132 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 2147 2133 break; 2148 2134 } … … 2577 2563 * Grab the receive/producer lock and copy over the frame. 2578 2564 */ 2579 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2580 RTSpinlockAcquireNoInts(pIf->hRecvInSpinlock, &Tmp); 2565 RTSpinlockAcquire(pIf->hRecvInSpinlock); 2581 2566 int rc = intnetR0RingWriteFrame(&pIf->pIntBuf->Recv, pSG, pNewDstMac); 2582 RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock , &Tmp);2567 RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock); 2583 2568 if (RT_SUCCESS(rc)) 2584 2569 { … … 2605 2590 RTThreadYield(); 2606 2591 2607 RTSpinlockAcquire NoInts(pIf->hRecvInSpinlock, &Tmp);2592 RTSpinlockAcquire(pIf->hRecvInSpinlock); 2608 2593 rc = intnetR0RingWriteFrame(&pIf->pIntBuf->Recv, pSG, pNewDstMac); 2609 RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock , &Tmp);2594 RTSpinlockReleaseNoInts(pIf->hRecvInSpinlock); 2610 2595 if (RT_SUCCESS(rc)) 2611 2596 { … … 3066 3051 /* PARANOIA: Grab the spinlock to make sure the trunk structure cannot be 3067 3052 freed while we're touching it. */ 3068 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3069 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 3053 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 3070 3054 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk; 3071 3055 … … 3075 3059 && (!pNetwork->MacTab.fWireActive || (pTrunk->fNoPreemptDsts & INTNETTRUNKDIR_WIRE) ) ); 3076 3060 3077 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);3061 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 3078 3062 3079 3063 return fRc; … … 3397 3381 { 3398 3382 Log2(("IF MAC: %.6Rhxs -> %.6Rhxs\n", &pIfSender->MacAddr, &EthHdr.SrcMac)); 3399 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3400 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 3383 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 3401 3384 3402 3385 PINTNETMACTABENTRY pIfEntry = intnetR0NetworkFindMacAddrEntry(pNetwork, pIfSender); … … 3405 3388 pIfSender->MacAddr = EthHdr.SrcMac; 3406 3389 3407 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);3390 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 3408 3391 } 3409 3392 … … 3732 3715 if (pNetwork) 3733 3716 { 3734 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3735 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 3717 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 3736 3718 3737 3719 if (pIf->fPromiscuousReal != fPromiscuous) … … 3772 3754 } 3773 3755 3774 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);3756 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 3775 3757 } 3776 3758 else … … 3834 3816 if (pNetwork) 3835 3817 { 3836 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;3837 3818 PINTNETTRUNKIF pTrunk = NULL; 3838 3819 3839 RTSpinlockAcquire NoInts(pNetwork->hAddrSpinlock, &Tmp);3820 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 3840 3821 3841 3822 if (memcmp(&pIf->MacAddr, pMac, sizeof(pIf->MacAddr))) … … 3857 3838 } 3858 3839 3859 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);3840 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 3860 3841 3861 3842 if (pTrunk) … … 3917 3898 */ 3918 3899 PINTNETTRUNKIF pTrunk = NULL; 3919 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 3920 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 3900 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 3921 3901 3922 3902 /* … … 3957 3937 } 3958 3938 3959 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);3939 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 3960 3940 3961 3941 /* … … 4322 4302 4323 4303 /* remove ourselves from the switch table. */ 4324 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 4325 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 4304 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 4326 4305 4327 4306 uint32_t iIf = pNetwork->MacTab.cEntries; … … 4363 4342 PINTNETTRUNKIF pTrunk = pNetwork->MacTab.pTrunk; 4364 4343 4365 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);4344 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 4366 4345 4367 4346 /* Notify the trunk about the interface being destroyed. */ … … 4373 4352 4374 4353 /* Release our reference to the network. */ 4375 RTSpinlockAcquire NoInts(pNetwork->hAddrSpinlock, &Tmp);4354 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 4376 4355 pIf->pNetwork = NULL; 4377 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);4356 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 4378 4357 4379 4358 SUPR0ObjRelease(pNetwork->pvObj, pIf->pSession); … … 4534 4513 rc = RTSemEventCreate((PRTSEMEVENT)&pIf->hRecvEvent); 4535 4514 if (RT_SUCCESS(rc)) 4536 rc = RTSpinlockCreate(&pIf->hRecvInSpinlock );4515 rc = RTSpinlockCreate(&pIf->hRecvInSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hRecvInSpinlock"); 4537 4516 if (RT_SUCCESS(rc)) 4538 4517 { … … 4567 4546 * network reference of the caller. 4568 4547 */ 4569 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 4570 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 4548 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 4571 4549 4572 4550 uint32_t iIf = pNetwork->MacTab.cEntries; … … 4590 4568 intnetR0BusyIncTrunk(pTrunk); 4591 4569 4592 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);4570 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 4593 4571 4594 4572 if (pTrunk) … … 4658 4636 if (pNetwork) 4659 4637 { 4660 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 4661 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 4638 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 4662 4639 4663 4640 pNetwork->MacTab.HostMac = *pMacAddr; 4664 4641 pThis->MacAddr = *pMacAddr; 4665 4642 4666 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);4643 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 4667 4644 } 4668 4645 else … … 4685 4662 if (pNetwork) 4686 4663 { 4687 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 4688 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 4664 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 4689 4665 4690 4666 pNetwork->MacTab.fHostPromiscuousReal = fPromiscuous … … 4693 4669 && (pNetwork->fFlags & INTNET_OPEN_FLAGS_PROMISC_ALLOW_TRUNK_HOST); 4694 4670 4695 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);4671 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 4696 4672 } 4697 4673 intnetR0BusyDecTrunk(pThis); … … 4795 4771 unsigned iDstTab = 0; 4796 4772 PINTNETDSTTAB pDstTab = NULL; 4797 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 4798 RTSpinlockAcquireNoInts(pThis->hDstTabSpinlock, &Tmp); 4773 RTSpinlockAcquire(pThis->hDstTabSpinlock); 4799 4774 if (fIntCtx) 4800 4775 { … … 4818 4793 } 4819 4794 } 4820 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock , &Tmp);4795 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock); 4821 4796 Assert(!pDstTab || iDstTab < pThis->cIntDstTabs); 4822 4797 } … … 4831 4806 { 4832 4807 pThis->apIntDstTabs[iDstTab] = NULL; 4833 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock , &Tmp);4808 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock); 4834 4809 Assert(iDstTab < RT_ELEMENTS(pThis->apTaskDstTabs)); 4835 4810 } 4836 4811 else 4837 4812 { 4838 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock , &Tmp);4813 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock); 4839 4814 intnetR0AllocDstTab(pNetwork->MacTab.cEntriesAllocated, &pDstTab); 4840 4815 iDstTab = 65535; … … 4858 4833 else 4859 4834 { 4860 RTSpinlockAcquire NoInts(pThis->hDstTabSpinlock, &Tmp);4835 RTSpinlockAcquire(pThis->hDstTabSpinlock); 4861 4836 if (fIntCtx && !pThis->apIntDstTabs[iDstTab]) 4862 4837 pThis->apIntDstTabs[iDstTab] = pDstTab; … … 4875 4850 } 4876 4851 } 4877 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock , &Tmp);4852 RTSpinlockReleaseNoInts(pThis->hDstTabSpinlock); 4878 4853 Assert(iDstTab < RT_MAX(RT_ELEMENTS(pThis->apTaskDstTabs), pThis->cIntDstTabs)); 4879 4854 } … … 5103 5078 * Create the lock (we've NIL'ed the members above to simplify cleanup). 5104 5079 */ 5105 rc = RTSpinlockCreate(&pTrunk->hDstTabSpinlock );5080 rc = RTSpinlockCreate(&pTrunk->hDstTabSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hDstTabSpinlock"); 5106 5081 if (RT_SUCCESS(rc)) 5107 5082 { … … 5207 5182 * be dereference and destroyed before the interfaces. 5208 5183 */ 5209 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 5210 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 5184 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 5211 5185 5212 5186 uint32_t iIf = pNetwork->MacTab.cEntries; … … 5220 5194 pNetwork->MacTab.fWireActive = false; 5221 5195 5222 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);5196 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 5223 5197 5224 5198 /* Wait for all the interfaces to quiesce. (Interfaces cannot be … … 5233 5207 /* Orphan the interfaces (not trunk). Don't bother with calling 5234 5208 pfnDisconnectInterface here since the networking is going away. */ 5235 RTSpinlockAcquire NoInts(pNetwork->hAddrSpinlock, &Tmp);5209 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 5236 5210 while ((iIf = pNetwork->MacTab.cEntries) > 0) 5237 5211 { 5238 5212 PINTNETIF pIf = pNetwork->MacTab.paEntries[iIf - 1].pIf; 5239 RTSpinlockRelease NoInts(pNetwork->hAddrSpinlock, &Tmp);5213 RTSpinlockRelease(pNetwork->hAddrSpinlock); 5240 5214 5241 5215 intnetR0BusyWait(pNetwork, &pIf->cBusy); 5242 5216 5243 RTSpinlockAcquire NoInts(pNetwork->hAddrSpinlock, &Tmp);5217 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 5244 5218 if ( iIf == pNetwork->MacTab.cEntries /* paranoia */ 5245 5219 && pIf->cBusy) … … 5256 5230 pNetwork->MacTab.pTrunk = NULL; 5257 5231 5258 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);5232 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 5259 5233 5260 5234 if (pTrunk) … … 5400 5374 LogRel(("INTNET: %s - flags changed %#x -> %#x\n", pNetwork->szName, fOldNetFlags, fNetFlags)); 5401 5375 5402 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 5403 RTSpinlockAcquireNoInts(pNetwork->hAddrSpinlock, &Tmp); 5376 RTSpinlockAcquire(pNetwork->hAddrSpinlock); 5404 5377 5405 5378 pNetwork->fFlags = fNetFlags; … … 5449 5422 } 5450 5423 5451 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock , &Tmp);5424 RTSpinlockReleaseNoInts(pNetwork->hAddrSpinlock); 5452 5425 } 5453 5426 … … 5657 5630 int rc = RTSemEventCreate(&pNetwork->hEvtBusyIf); 5658 5631 if (RT_SUCCESS(rc)) 5659 rc = RTSpinlockCreate(&pNetwork->hAddrSpinlock );5632 rc = RTSpinlockCreate(&pNetwork->hAddrSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "hAddrSpinlock"); 5660 5633 if (RT_SUCCESS(rc)) 5661 5634 { -
trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp
r39091 r40806 178 178 179 179 /* 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 182 183 183 184 -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r40804 r40806 342 342 { "RTSemMutexRequestNoResumeDebug", (void *)RTSemMutexRequestNoResumeDebug }, 343 343 { "RTSpinlockAcquire", (void *)RTSpinlockAcquire }, 344 { "RTSpinlockAcquireNoInts", (void *)RTSpinlockAcquireNoInts },345 344 { "RTSpinlockCreate", (void *)RTSpinlockCreate }, 346 345 { "RTSpinlockDestroy", (void *)RTSpinlockDestroy }, … … 452 451 */ 453 452 memset(pDevExt, 0, sizeof(*pDevExt)); 454 rc = RTSpinlockCreate(&pDevExt->Spinlock );453 rc = RTSpinlockCreate(&pDevExt->Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "SUPDrvDevExt"); 455 454 if (RT_SUCCESS(rc)) 456 455 { 457 rc = RTSpinlockCreate(&pDevExt-> spinGip);456 rc = RTSpinlockCreate(&pDevExt->hGipSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "SUPDrvGip"); 458 457 if (RT_SUCCESS(rc)) 459 458 { … … 563 562 #endif 564 563 } 565 RTSpinlockDestroy(pDevExt-> spinGip);566 pDevExt-> spinGip= NIL_RTSPINLOCK;564 RTSpinlockDestroy(pDevExt->hGipSpinlock); 565 pDevExt->hGipSpinlock = NIL_RTSPINLOCK; 567 566 } 568 567 RTSpinlockDestroy(pDevExt->Spinlock); … … 636 635 /* kill the GIP. */ 637 636 supdrvGipDestroy(pDevExt); 638 RTSpinlockDestroy(pDevExt-> spinGip);639 pDevExt-> spinGip= NIL_RTSPINLOCK;637 RTSpinlockDestroy(pDevExt->hGipSpinlock); 638 pDevExt->hGipSpinlock = NIL_RTSPINLOCK; 640 639 641 640 supdrvTracerTerm(pDevExt); … … 667 666 { 668 667 /* Initialize session data. */ 669 rc = RTSpinlockCreate(&pSession->Spinlock );668 rc = RTSpinlockCreate(&pSession->Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "SUPDrvSession"); 670 669 if (!rc) 671 670 { … … 777 776 if (pSession->pUsage) 778 777 { 779 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;780 778 PSUPDRVUSAGE pUsage; 781 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);779 RTSpinlockAcquire(pDevExt->Spinlock); 782 780 783 781 while ((pUsage = pSession->pUsage) != NULL) … … 790 788 { 791 789 pObj->cUsage -= pUsage->cUsage; 792 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);790 RTSpinlockRelease(pDevExt->Spinlock); 793 791 } 794 792 else … … 808 806 Assert(pObjPrev); 809 807 } 810 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);808 RTSpinlockRelease(pDevExt->Spinlock); 811 809 812 810 Log(("supdrvCleanupSession: destroying %p/%d (%p/%p) cpid=%RTproc pid=%RTproc dtor=%p\n", … … 820 818 RTMemFree(pUsage); 821 819 822 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);823 } 824 825 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);820 RTSpinlockAcquire(pDevExt->Spinlock); 821 } 822 823 RTSpinlockRelease(pDevExt->Spinlock); 826 824 AssertMsg(!pSession->pUsage, ("Some buster reregistered an object during desturction!\n")); 827 825 } … … 2002 2000 SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2) 2003 2001 { 2004 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2005 2002 PSUPDRVDEVEXT pDevExt = pSession->pDevExt; 2006 2003 PSUPDRVOBJ pObj; … … 2036 2033 * (We keep freed usage records around to simplify SUPR0ObjAddRefEx().) 2037 2034 */ 2038 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);2035 RTSpinlockAcquire(pDevExt->Spinlock); 2039 2036 2040 2037 pUsage = pDevExt->pUsageFree; … … 2043 2040 else 2044 2041 { 2045 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2042 RTSpinlockRelease(pDevExt->Spinlock); 2046 2043 pUsage = (PSUPDRVUSAGE)RTMemAlloc(sizeof(*pUsage)); 2047 2044 if (!pUsage) … … 2050 2047 return NULL; 2051 2048 } 2052 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);2049 RTSpinlockAcquire(pDevExt->Spinlock); 2053 2050 } 2054 2051 … … 2067 2064 pSession->pUsage = pUsage; 2068 2065 2069 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2066 RTSpinlockRelease(pDevExt->Spinlock); 2070 2067 2071 2068 Log(("SUPR0ObjRegister: returns %p (pvUser1=%p, pvUser=%p)\n", pObj, pvUser1, pvUser2)); … … 2113 2110 SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking) 2114 2111 { 2115 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2116 2112 PSUPDRVDEVEXT pDevExt = pSession->pDevExt; 2117 2113 PSUPDRVOBJ pObj = (PSUPDRVOBJ)pvObj; … … 2131 2127 VERR_INVALID_PARAMETER); 2132 2128 2133 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);2129 RTSpinlockAcquire(pDevExt->Spinlock); 2134 2130 2135 2131 if (RT_UNLIKELY(pObj->u32Magic != SUPDRVOBJ_MAGIC)) 2136 2132 { 2137 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2133 RTSpinlockRelease(pDevExt->Spinlock); 2138 2134 2139 2135 AssertMsgFailed(("pvObj=%p magic=%#x\n", pvObj, pObj->u32Magic)); … … 2149 2145 else if (!fNoBlocking) 2150 2146 { 2151 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2147 RTSpinlockRelease(pDevExt->Spinlock); 2152 2148 pUsagePre = (PSUPDRVUSAGE)RTMemAlloc(sizeof(*pUsagePre)); 2153 2149 if (!pUsagePre) 2154 2150 return VERR_NO_MEMORY; 2155 2151 2156 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);2152 RTSpinlockAcquire(pDevExt->Spinlock); 2157 2153 if (RT_UNLIKELY(pObj->u32Magic != SUPDRVOBJ_MAGIC)) 2158 2154 { 2159 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2155 RTSpinlockRelease(pDevExt->Spinlock); 2160 2156 2161 2157 AssertMsgFailed(("pvObj=%p magic=%#x\n", pvObj, pObj->u32Magic)); … … 2206 2202 } 2207 2203 2208 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2204 RTSpinlockRelease(pDevExt->Spinlock); 2209 2205 2210 2206 return rc; … … 2228 2224 SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession) 2229 2225 { 2230 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2231 2226 PSUPDRVDEVEXT pDevExt = pSession->pDevExt; 2232 2227 PSUPDRVOBJ pObj = (PSUPDRVOBJ)pvObj; … … 2246 2241 * Acquire the spinlock and look for the usage record. 2247 2242 */ 2248 RTSpinlockAcquire(pDevExt->Spinlock , &SpinlockTmp);2243 RTSpinlockAcquire(pDevExt->Spinlock); 2249 2244 2250 2245 for (pUsagePrev = NULL, pUsage = pSession->pUsage; … … 2303 2298 } 2304 2299 2305 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);2300 RTSpinlockRelease(pDevExt->Spinlock); 2306 2301 2307 2302 /* … … 2686 2681 { 2687 2682 PSUPDRVBUNDLE pBundle; 2688 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2689 2683 LogFlow(("SUPR0MemGetPhys: pSession=%p uPtr=%p paPages=%p\n", pSession, (void *)uPtr, paPages)); 2690 2684 … … 2699 2693 * Search for the address. 2700 2694 */ 2701 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);2695 RTSpinlockAcquire(pSession->Spinlock); 2702 2696 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext) 2703 2697 { … … 2722 2716 paPages[iPage].uReserved = 0; 2723 2717 } 2724 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);2718 RTSpinlockRelease(pSession->Spinlock); 2725 2719 return VINF_SUCCESS; 2726 2720 } … … 2728 2722 } 2729 2723 } 2730 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);2724 RTSpinlockRelease(pSession->Spinlock); 2731 2725 Log(("Failed to find %p!!!\n", (void *)uPtr)); 2732 2726 return VERR_INVALID_PARAMETER; … … 2851 2845 int rc; 2852 2846 PSUPDRVBUNDLE pBundle; 2853 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2854 2847 RTR0MEMOBJ hMemObj = NIL_RTR0MEMOBJ; 2855 2848 LogFlow(("SUPR0PageMapKernel: pSession=%p pvR3=%p offSub=%#x cbSub=%#x\n", pSession, pvR3, offSub, cbSub)); … … 2868 2861 * Find the memory object. 2869 2862 */ 2870 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);2863 RTSpinlockAcquire(pSession->Spinlock); 2871 2864 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext) 2872 2865 { … … 2891 2884 } 2892 2885 } 2893 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);2886 RTSpinlockRelease(pSession->Spinlock); 2894 2887 2895 2888 rc = VERR_INVALID_PARAMETER; … … 2937 2930 int rc; 2938 2931 PSUPDRVBUNDLE pBundle; 2939 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;2940 2932 RTR0MEMOBJ hMemObjR0 = NIL_RTR0MEMOBJ; 2941 2933 RTR0MEMOBJ hMemObjR3 = NIL_RTR0MEMOBJ; … … 2954 2946 * Find the memory object. 2955 2947 */ 2956 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);2948 RTSpinlockAcquire(pSession->Spinlock); 2957 2949 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext) 2958 2950 { … … 2980 2972 } 2981 2973 } 2982 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);2974 RTSpinlockRelease(pSession->Spinlock); 2983 2975 2984 2976 rc = VERR_INVALID_PARAMETER; … … 3696 3688 { 3697 3689 PSUPDRVBUNDLE pBundle; 3698 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;3699 3690 3700 3691 /* 3701 3692 * Find free entry and record the allocation. 3702 3693 */ 3703 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);3694 RTSpinlockAcquire(pSession->Spinlock); 3704 3695 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext) 3705 3696 { … … 3713 3704 pBundle->cUsed++; 3714 3705 pBundle->aMem[i] = *pMem; 3715 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);3706 RTSpinlockRelease(pSession->Spinlock); 3716 3707 return VINF_SUCCESS; 3717 3708 } … … 3720 3711 } 3721 3712 } 3722 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);3713 RTSpinlockRelease(pSession->Spinlock); 3723 3714 3724 3715 /* … … 3735 3726 3736 3727 /* insert into list. */ 3737 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);3728 RTSpinlockAcquire(pSession->Spinlock); 3738 3729 pBundle->pNext = pSession->Bundle.pNext; 3739 3730 pSession->Bundle.pNext = pBundle; 3740 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);3731 RTSpinlockRelease(pSession->Spinlock); 3741 3732 3742 3733 return VINF_SUCCESS; … … 3755 3746 { 3756 3747 PSUPDRVBUNDLE pBundle; 3757 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;3758 3748 3759 3749 /* … … 3769 3759 * Search for the address. 3770 3760 */ 3771 RTSpinlockAcquire(pSession->Spinlock , &SpinlockTmp);3761 RTSpinlockAcquire(pSession->Spinlock); 3772 3762 for (pBundle = &pSession->Bundle; pBundle; pBundle = pBundle->pNext) 3773 3763 { … … 3789 3779 pBundle->aMem[i].MemObj = NIL_RTR0MEMOBJ; 3790 3780 pBundle->aMem[i].MapObjR3 = NIL_RTR0MEMOBJ; 3791 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);3781 RTSpinlockRelease(pSession->Spinlock); 3792 3782 3793 3783 if (Mem.MapObjR3 != NIL_RTR0MEMOBJ) … … 3806 3796 } 3807 3797 } 3808 RTSpinlockRelease(pSession->Spinlock , &SpinlockTmp);3798 RTSpinlockRelease(pSession->Spinlock); 3809 3799 Log(("Failed to find %p!!! (eType=%d)\n", (void *)uPtr, eType)); 3810 3800 return VERR_INVALID_PARAMETER; … … 4212 4202 * clean things up in the right order and not leave them all dangling. 4213 4203 */ 4214 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 4215 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); 4204 RTSpinlockAcquire(pDevExt->Spinlock); 4216 4205 if (pImage->cUsage <= 1) 4217 4206 { … … 4234 4223 } 4235 4224 } 4236 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);4225 RTSpinlockRelease(pDevExt->Spinlock); 4237 4226 if (rc == VINF_SUCCESS) 4238 4227 { … … 4572 4561 unsigned cObjs = 0; 4573 4562 PSUPDRVOBJ pObj; 4574 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 4575 RTSpinlockAcquire(pDevExt->Spinlock, &SpinlockTmp); 4563 RTSpinlockAcquire(pDevExt->Spinlock); 4576 4564 for (pObj = pDevExt->pObjs; pObj; pObj = pObj->pNext) 4577 4565 if (RT_UNLIKELY((uintptr_t)pObj->pfnDestructor - (uintptr_t)pImage->pvImage < pImage->cbImageBits)) … … 4580 4568 cObjs++; 4581 4569 } 4582 RTSpinlockRelease(pDevExt->Spinlock , &SpinlockTmp);4570 RTSpinlockRelease(pDevExt->Spinlock); 4583 4571 if (cObjs) 4584 4572 OSDBGPRINT(("supdrvLdrFree: Image '%s' has %d dangling objects!\n", pImage->szName, cObjs)); … … 5087 5075 uint32_t i = 0; 5088 5076 uint64_t u64NanoTS = 0; 5089 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;5090 5077 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 5091 5078 … … 5098 5085 * on all CPUs simultaneously, see #6110. 5099 5086 */ 5100 RTSpinlockAcquire NoInts(pDevExt->spinGip, &SpinlockTmp);5087 RTSpinlockAcquire(pDevExt->hGipSpinlock); 5101 5088 5102 5089 /* … … 5133 5120 ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_ONLINE); 5134 5121 5135 RTSpinlockReleaseNoInts(pDevExt-> spinGip, &SpinlockTmp);5122 RTSpinlockReleaseNoInts(pDevExt->hGipSpinlock); 5136 5123 } 5137 5124 … … 5151 5138 5152 5139 PSUPGLOBALINFOPAGE pGip = pDevExt->pGip; 5153 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER;5154 5140 5155 5141 AssertPtrReturnVoid(pGip); 5156 RTSpinlockAcquire NoInts(pDevExt->spinGip, &SpinlockTmp);5142 RTSpinlockAcquire(pDevExt->hGipSpinlock); 5157 5143 5158 5144 iCpuSet = RTMpCpuIdToSetIndex(idCpu); … … 5169 5155 ASMAtomicWriteSize(&pGip->aCPUs[i].enmState, SUPGIPCPUSTATE_OFFLINE); 5170 5156 5171 RTSpinlockReleaseNoInts(pDevExt-> spinGip, &SpinlockTmp);5157 RTSpinlockReleaseNoInts(pDevExt->hGipSpinlock); 5172 5158 } 5173 5159 -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r40763 r40806 191 191 * 192 192 * @todo Pending work on next major version change: 193 * - None.194 */ 195 #define SUPDRV_IOC_VERSION 0x001 90002193 * - Remove RTSpinlockReleaseNoInts. 194 */ 195 #define SUPDRV_IOC_VERSION 0x001a0000 196 196 197 197 /** SUP_IOCTL_COOKIE. */ -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r40777 r40806 517 517 #endif 518 518 /** GIP spinlock protecting GIP members during Mp events. */ 519 RTSPINLOCK spinGip;519 RTSPINLOCK hGipSpinlock; 520 520 /** Pointer to the Global Info Page (GIP). */ 521 521 PSUPGLOBALINFOPAGE pGip; -
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r37970 r40806 239 239 */ 240 240 memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab)); /* paranoia */ 241 rc = RTSpinlockCreate(&g_Spinlock );241 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvDarwin"); 242 242 if (RT_SUCCESS(rc)) 243 243 { … … 370 370 RTPROCESS Process = RTProcSelf(); 371 371 unsigned iHash = SESSION_HASH(Process); 372 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 373 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 372 RTSpinlockAcquire(g_Spinlock); 374 373 375 374 pSession = g_apSessionHashTab[iHash]; … … 393 392 rc = VERR_GENERAL_FAILURE; 394 393 395 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);394 RTSpinlockReleaseNoInts(g_Spinlock); 396 395 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 397 396 kauth_cred_unref(&pCred); … … 442 441 static int VBoxDrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess) 443 442 { 444 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;445 443 const RTPROCESS Process = proc_pid(pProcess); 446 444 const unsigned iHash = SESSION_HASH(Process); … … 450 448 * Find the session. 451 449 */ 452 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);450 RTSpinlockAcquire(g_Spinlock); 453 451 pSession = g_apSessionHashTab[iHash]; 454 452 if (pSession && pSession->Process != Process) … … 457 455 while (pSession && pSession->Process != Process); 458 456 } 459 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);457 RTSpinlockReleaseNoInts(g_Spinlock); 460 458 if (!pSession) 461 459 { … … 982 980 */ 983 981 unsigned iHash = SESSION_HASH(m_pSession->Process); 984 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 985 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 982 RTSpinlockAcquire(g_Spinlock); 986 983 987 984 PSUPDRVSESSION pCur = g_apSessionHashTab[iHash]; … … 1002 999 rc = VERR_ALREADY_LOADED; 1003 1000 1004 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);1001 RTSpinlockReleaseNoInts(g_Spinlock); 1005 1002 if (RT_SUCCESS(rc)) 1006 1003 { … … 1034 1031 */ 1035 1032 const unsigned iHash = SESSION_HASH(Process); 1036 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1037 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 1033 RTSpinlockAcquire(g_Spinlock); 1038 1034 PSUPDRVSESSION pSession = g_apSessionHashTab[iHash]; 1039 1035 if (pSession) … … 1065 1061 } 1066 1062 } 1067 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);1063 RTSpinlockReleaseNoInts(g_Spinlock); 1068 1064 if (!pSession) 1069 1065 { -
trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
r37249 r40806 108 108 * Initialize the session hash table. 109 109 */ 110 rc = RTSpinlockCreate(&g_Spinlock );110 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvOS2"); 111 111 if (RT_SUCCESS(rc)) 112 112 { … … 160 160 */ 161 161 unsigned iHash = SESSION_HASH(sfn); 162 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 163 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 162 RTSpinlockAcquire(g_Spinlock); 164 163 pSession->pNextHash = g_apSessionHashTab[iHash]; 165 164 g_apSessionHashTab[iHash] = pSession; 166 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);165 RTSpinlockReleaseNoInts(g_Spinlock); 167 166 } 168 167 … … 182 181 const RTPROCESS Process = RTProcSelf(); 183 182 const unsigned iHash = SESSION_HASH(sfn); 184 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 185 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 183 RTSpinlockAcquire(g_Spinlock); 186 184 187 185 pSession = g_apSessionHashTab[iHash]; … … 214 212 } 215 213 } 216 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);214 RTSpinlockReleaseNoInts(g_Spinlock); 217 215 if (!pSession) 218 216 { … … 234 232 * Find the session. 235 233 */ 236 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;237 234 const RTPROCESS Process = RTProcSelf(); 238 235 const unsigned iHash = SESSION_HASH(sfn); 239 236 PSUPDRVSESSION pSession; 240 237 241 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);238 RTSpinlockAcquire(g_Spinlock); 242 239 pSession = g_apSessionHashTab[iHash]; 243 240 if (pSession && pSession->Process != Process) … … 248 245 || pSession->Process != Process)); 249 246 } 250 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);247 RTSpinlockReleaseNoInts(g_Spinlock); 251 248 if (RT_UNLIKELY(!pSession)) 252 249 { … … 268 265 * Find the session. 269 266 */ 270 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;271 267 const RTPROCESS Process = RTProcSelf(); 272 268 const unsigned iHash = SESSION_HASH(sfn); 273 269 PSUPDRVSESSION pSession; 274 270 275 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);271 RTSpinlockAcquire(g_Spinlock); 276 272 pSession = g_apSessionHashTab[iHash]; 277 273 if (pSession && pSession->Process != Process) … … 282 278 || pSession->Process != Process)); 283 279 } 284 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);280 RTSpinlockReleaseNoInts(g_Spinlock); 285 281 if (!pSession) 286 282 { -
trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
r40616 r40806 224 224 */ 225 225 memset(g_apSessionHashTab, 0, sizeof(g_apSessionHashTab)); 226 rc = RTSpinlockCreate(&g_Spinlock );226 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxDrvSol"); 227 227 if (RT_SUCCESS(rc)) 228 228 { … … 494 494 if (RT_SUCCESS(rc)) 495 495 { 496 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;497 496 unsigned iHash; 498 497 … … 504 503 */ 505 504 iHash = SESSION_HASH(pSession->Process); 506 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);505 RTSpinlockAcquire(g_Spinlock); 507 506 pSession->pNextHash = g_apSessionHashTab[iHash]; 508 507 g_apSessionHashTab[iHash] = pSession; 509 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);508 RTSpinlockReleaseNoInts(g_Spinlock); 510 509 LogFlow((DEVICE_NAME ":VBoxDrvSolarisOpen success\n")); 511 510 } … … 560 559 561 560 #else 562 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;563 561 const RTPROCESS Process = RTProcSelf(); 564 562 const unsigned iHash = SESSION_HASH(Process); … … 568 566 * Remove from the hash table. 569 567 */ 570 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);568 RTSpinlockAcquire(g_Spinlock); 571 569 pSession = g_apSessionHashTab[iHash]; 572 570 if (pSession) … … 596 594 } 597 595 } 598 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);596 RTSpinlockReleaseNoInts(g_Spinlock); 599 597 if (!pSession) 600 598 { … … 659 657 } 660 658 #else 661 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;662 659 const RTPROCESS Process = RTProcSelf(); 663 660 const unsigned iHash = SESSION_HASH(Process); … … 667 664 * Find the session. 668 665 */ 669 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);666 RTSpinlockAcquire(g_Spinlock); 670 667 pSession = g_apSessionHashTab[iHash]; 671 668 if (pSession && pSession->Process != Process) … … 674 671 while (pSession && pSession->Process != Process); 675 672 } 676 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);673 RTSpinlockReleaseNoInts(g_Spinlock); 677 674 if (!pSession) 678 675 { -
trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c
r38408 r40806 106 106 DECLINLINE(void) vboxNetAdpSetStateWithLock(PVBOXNETADP pThis, VBOXNETADPSTATE enmNewState) 107 107 { 108 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;109 108 Log(("vboxNetAdpSetStateWithLock: pThis=%p, state=%d.\n", pThis, enmNewState)); 110 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);109 RTSpinlockAcquire(pThis->hSpinlock); 111 110 vboxNetAdpSetState(pThis, enmNewState); 112 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);111 RTSpinlockReleaseNoInts(pThis->hSpinlock); 113 112 } 114 113 … … 125 124 { 126 125 VBOXNETADPSTATE enmState; 127 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 128 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 126 RTSpinlockAcquire(pThis->hSpinlock); 129 127 enmState = vboxNetAdpGetState(pThis); 130 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);128 RTSpinlockReleaseNoInts(pThis->hSpinlock); 131 129 Log(("vboxNetAdpGetStateWithLock: pThis=%p, state=%d.\n", pThis, enmState)); 132 130 return enmState; … … 147 145 VBOXNETADPSTATE enmActualState; 148 146 bool fRc = true; /* be optimistic */ 149 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 150 151 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 147 148 RTSpinlockAcquire(pThis->hSpinlock); 152 149 enmActualState = vboxNetAdpGetState(pThis); /** @todo r=bird: ASMAtomicCmpXchgU32()*/ 153 150 if (enmActualState == enmOldState) … … 155 152 else 156 153 fRc = false; 157 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);154 RTSpinlockReleaseNoInts(pThis->hSpinlock); 158 155 159 156 if (fRc) … … 178 175 for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++) 179 176 { 180 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;181 177 PVBOXNETADP pThis = &pGlobals->aAdapters[i]; 182 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);178 RTSpinlockAcquire(pThis->hSpinlock); 183 179 if ( vboxNetAdpGetState(pThis) 184 180 && !strcmp(pThis->szName, pszName)) 185 181 { 186 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);182 RTSpinlockReleaseNoInts(pThis->hSpinlock); 187 183 return pThis; 188 184 } 189 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);185 RTSpinlockReleaseNoInts(pThis->hSpinlock); 190 186 } 191 187 return NULL; … … 340 336 DECLHIDDEN(bool) vboxNetAdpPrepareToReceive(PVBOXNETADP pThis) 341 337 { 342 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;343 338 bool fCanReceive = false; 344 339 /* … … 347 342 AssertPtr(pThis); 348 343 Assert(pThis->MyPort.u32Version == INTNETTRUNKIFPORT_VERSION); 349 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);344 RTSpinlockAcquire(pThis->hSpinlock); 350 345 if (vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active) 351 346 { … … 354 349 vboxNetAdpBusy(pThis); 355 350 } 356 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);351 RTSpinlockReleaseNoInts(pThis->hSpinlock); 357 352 Log(("vboxNetAdpPrepareToReceive: fCanReceive=%d.\n", fCanReceive)); 358 353 … … 368 363 DECLHIDDEN(void) vboxNetAdpReceive(PVBOXNETADP pThis, PINTNETSG pSG) 369 364 { 370 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;371 365 /* 372 366 * Input validation. … … 401 395 static DECLCALLBACK(int) vboxNetAdpPortXmit(PINTNETTRUNKIFPORT pIfPort, PINTNETSG pSG, uint32_t fDst) 402 396 { 403 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;404 397 PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort); 405 398 int rc = VINF_SUCCESS; … … 417 410 * Do a retain/busy, invoke the OS specific code. 418 411 */ 419 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);412 RTSpinlockAcquire(pThis->hSpinlock); 420 413 if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Active) 421 414 { 422 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);415 RTSpinlockReleaseNoInts(pThis->hSpinlock); 423 416 Log(("vboxNetAdpReceive: Dropping incoming packet for inactive interface %s.\n", 424 417 pThis->szName)); … … 427 420 vboxNetAdpRetain(pThis); 428 421 vboxNetAdpBusy(pThis); 429 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);422 RTSpinlockReleaseNoInts(pThis->hSpinlock); 430 423 431 424 rc = vboxNetAdpPortOsXmit(pThis, pSG, fDst); … … 494 487 { 495 488 bool fPreviouslyActive; 496 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;497 489 PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort); 498 490 … … 505 497 506 498 Log(("vboxNetAdpPortSetActive: pThis=%p, fActive=%d, state before: %d.\n", pThis, fActive, vboxNetAdpGetState(pThis))); 507 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);499 RTSpinlockAcquire(pThis->hSpinlock); 508 500 509 501 fPreviouslyActive = vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Active; … … 523 515 } 524 516 525 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);517 RTSpinlockReleaseNoInts(pThis->hSpinlock); 526 518 Log(("vboxNetAdpPortSetActive: state after: %RTbool.\n", vboxNetAdpGetState(pThis))); 527 519 return fPreviouslyActive; … … 535 527 { 536 528 PVBOXNETADP pThis = IFPORT_2_VBOXNETADP(pIfPort); 537 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;538 529 539 530 /* … … 551 542 * Disconnect and release it. 552 543 */ 553 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);544 RTSpinlockAcquire(pThis->hSpinlock); 554 545 //Assert(vboxNetAdpGetState(pThis) == kVBoxNetAdpState_Connected); 555 546 Assert(!pThis->cBusy); 556 547 vboxNetAdpSetState(pThis, kVBoxNetAdpState_Transitional); 557 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);548 RTSpinlockReleaseNoInts(pThis->hSpinlock); 558 549 559 550 vboxNetAdpOsDisconnectIt(pThis); 560 551 pThis->pSwitchPort = NULL; 561 552 562 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);553 RTSpinlockAcquire(pThis->hSpinlock); 563 554 vboxNetAdpSetState(pThis, kVBoxNetAdpState_Available); 564 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);555 RTSpinlockReleaseNoInts(pThis->hSpinlock); 565 556 566 557 vboxNetAdpRelease(pThis); … … 590 581 int vboxNetAdpCreate(PINTNETTRUNKFACTORY pIfFactory, PVBOXNETADP *ppNew) 591 582 { 583 PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory)); 584 unsigned i; 592 585 int rc; 593 unsigned i;594 PVBOXNETADPGLOBALS pGlobals = (PVBOXNETADPGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETADPGLOBALS, TrunkFactory));595 586 596 587 for (i = 0; i < RT_ELEMENTS(pGlobals->aAdapters); i++) 597 588 { 598 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;599 589 PVBOXNETADP pThis = &pGlobals->aAdapters[i]; 600 590 … … 608 598 rc = vboxNetAdpOsCreate(pThis, &Mac); 609 599 *ppNew = pThis; 610 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 600 601 RTSpinlockAcquire(pThis->hSpinlock); 611 602 vboxNetAdpSetState(pThis, kVBoxNetAdpState_Available); 612 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);603 RTSpinlockReleaseNoInts(pThis->hSpinlock); 613 604 return rc; 614 605 } … … 622 613 { 623 614 int rc = VINF_SUCCESS; 624 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 625 626 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 615 616 RTSpinlockAcquire(pThis->hSpinlock); 627 617 if (vboxNetAdpGetState(pThis) != kVBoxNetAdpState_Available || pThis->cBusy) 628 618 { 629 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);619 RTSpinlockReleaseNoInts(pThis->hSpinlock); 630 620 return VERR_INTNET_FLT_IF_BUSY; 631 621 } 632 622 vboxNetAdpSetState(pThis, kVBoxNetAdpState_Transitional); 633 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);623 RTSpinlockReleaseNoInts(pThis->hSpinlock); 634 624 vboxNetAdpRelease(pThis); 635 625 636 626 vboxNetAdpOsDestroy(pThis); 637 627 638 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);628 RTSpinlockAcquire(pThis->hSpinlock); 639 629 vboxNetAdpSetState(pThis, kVBoxNetAdpState_Invalid); 640 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);630 RTSpinlockReleaseNoInts(pThis->hSpinlock); 641 631 642 632 return rc; … … 856 846 pNew->hEventIdle = NIL_RTSEMEVENT; 857 847 858 rc = RTSpinlockCreate(&pNew->hSpinlock );848 rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxNetAdptSlotCreate"); 859 849 if (RT_SUCCESS(rc)) 860 850 { -
trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c
r33540 r40806 375 375 static bool vboxNetFltMaybeRediscovered(PVBOXNETFLTINS pThis) 376 376 { 377 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;378 377 uint64_t Now; 379 378 bool fRediscovered; … … 396 395 */ 397 396 Now = RTTimeNanoTS(); 398 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);397 RTSpinlockAcquire(pThis->hSpinlock); 399 398 400 399 fRediscovered = !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); … … 405 404 ASMAtomicWriteBool(&pThis->fRediscoveryPending, true); 406 405 407 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);406 RTSpinlockReleaseNoInts(pThis->hSpinlock); 408 407 409 408 /* … … 499 498 { 500 499 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort); 501 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;502 500 INTNETTRUNKIFSTATE enmOldTrunkState; 503 501 … … 515 513 * Take the lock and change the state. 516 514 */ 517 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);515 RTSpinlockAcquire(pThis->hSpinlock); 518 516 enmOldTrunkState = pThis->enmTrunkState; 519 517 if (enmOldTrunkState != enmState) 520 518 ASMAtomicWriteU32((uint32_t volatile *)&pThis->enmTrunkState, enmState); 521 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);519 RTSpinlockReleaseNoInts(pThis->hSpinlock); 522 520 523 521 /* … … 602 600 { 603 601 PVBOXNETFLTINS pThis = IFPORT_2_VBOXNETFLTINS(pIfPort); 604 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;605 602 606 603 /* … … 623 620 * Disconnect and release it. 624 621 */ 625 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);622 RTSpinlockAcquire(pThis->hSpinlock); 626 623 vboxNetFltSetState(pThis, kVBoxNetFltInsState_Disconnecting); 627 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);624 RTSpinlockReleaseNoInts(pThis->hSpinlock); 628 625 629 626 vboxNetFltOsDisconnectIt(pThis); … … 631 628 632 629 #ifdef VBOXNETFLT_STATIC_CONFIG 633 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);630 RTSpinlockAcquire(pThis->hSpinlock); 634 631 vboxNetFltSetState(pThis, kVBoxNetFltInsState_Unconnected); 635 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);632 RTSpinlockReleaseNoInts(pThis->hSpinlock); 636 633 #endif 637 634 … … 814 811 DECLHIDDEN(bool) vboxNetFltTryRetainBusyActive(PVBOXNETFLTINS pThis) 815 812 { 816 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;817 813 uint32_t cRefs; 818 814 bool fRc; … … 834 830 * Do the retaining and checking behind the spinlock. 835 831 */ 836 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);832 RTSpinlockAcquire(pThis->hSpinlock); 837 833 fRc = pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE; 838 834 if (fRc) … … 844 840 AssertMsg(cRefs >= 1 && cRefs < UINT32_MAX / 2, ("%d\n", cRefs)); NOREF(cRefs); 845 841 } 846 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);842 RTSpinlockReleaseNoInts(pThis->hSpinlock); 847 843 848 844 return fRc; … … 861 857 DECLHIDDEN(bool) vboxNetFltTryRetainBusyNotDisconnected(PVBOXNETFLTINS pThis) 862 858 { 863 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;864 859 uint32_t cRefs; 865 860 bool fRc; … … 881 876 * Do the retaining and checking behind the spinlock. 882 877 */ 883 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);878 RTSpinlockAcquire(pThis->hSpinlock); 884 879 fRc = pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE 885 880 || pThis->enmTrunkState == INTNETTRUNKIFSTATE_INACTIVE; … … 892 887 AssertMsg(cRefs >= 1 && cRefs < UINT32_MAX / 2, ("%d\n", cRefs)); NOREF(cRefs); 893 888 } 894 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);889 RTSpinlockReleaseNoInts(pThis->hSpinlock); 895 890 896 891 return fRc; … … 1017 1012 memcpy(pNew->szName, pszName, cchName + 1); 1018 1013 1019 rc = RTSpinlockCreate(&pNew->hSpinlock );1014 rc = RTSpinlockCreate(&pNew->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxNetFltNewInstance"); 1020 1015 if (RT_SUCCESS(rc)) 1021 1016 { -
trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp
r38485 r40806 227 227 DECLINLINE(ifnet_t) vboxNetFltDarwinRetainIfNet(PVBOXNETFLTINS pThis) 228 228 { 229 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;230 229 ifnet_t pIfNet = NULL; 231 230 … … 233 232 * Be careful here to avoid problems racing the detached callback. 234 233 */ 235 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);234 RTSpinlockAcquire(pThis->hSpinlock); 236 235 if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost)) 237 236 { … … 240 239 ifnet_reference(pIfNet); 241 240 } 242 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);241 RTSpinlockReleaseNoInts(pThis->hSpinlock); 243 242 244 243 return pIfNet; … … 639 638 { 640 639 PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis; 641 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;642 640 uint64_t NanoTS = RTTimeSystemNanoTS(); 643 641 LogFlow(("vboxNetFltDarwinIffDetached: pThis=%p NanoTS=%RU64 (%d)\n", … … 658 656 * behind it in order to avoid problematic races with the detached callback. 659 657 */ 660 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);658 RTSpinlockAcquire(pThis->hSpinlock); 661 659 662 660 pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t); … … 671 669 ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true); 672 670 673 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);671 RTSpinlockReleaseNoInts(pThis->hSpinlock); 674 672 675 673 if (pIfNet) … … 916 914 } 917 915 918 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 919 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 916 RTSpinlockAcquire(pThis->hSpinlock); 920 917 ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, pIfNet); 921 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);918 RTSpinlockReleaseNoInts(pThis->hSpinlock); 922 919 923 920 /* … … 943 940 Assert(err || pIfFilter); 944 941 945 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);942 RTSpinlockAcquire(pThis->hSpinlock); 946 943 pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t); 947 944 if (pIfNet && !err) … … 951 948 pIfNet = NULL; /* don't dereference it */ 952 949 } 953 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);950 RTSpinlockReleaseNoInts(pThis->hSpinlock); 954 951 955 952 /* Report capabilities. */ … … 1163 1160 void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) 1164 1161 { 1165 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1166 1162 interface_filter_t pIfFilter; 1167 1163 … … 1169 1165 * Carefully obtain the interface filter reference and detach it. 1170 1166 */ 1171 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1167 RTSpinlockAcquire(pThis->hSpinlock); 1172 1168 pIfFilter = ASMAtomicUoReadPtrT(&pThis->u.s.pIfFilter, interface_filter_t); 1173 1169 if (pIfFilter) 1174 1170 ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfFilter); 1175 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1171 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1176 1172 1177 1173 if (pIfFilter) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c
r37423 r40806 581 581 struct ifnet *ifp; 582 582 node_p node; 583 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;584 583 585 584 VBOXCURVNET_SET_FROM_UCRED(); … … 593 592 return VERR_INTERNAL_ERROR; 594 593 595 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);594 RTSpinlockAcquire(pThis->hSpinlock); 596 595 597 596 ASMAtomicUoWritePtr(&pThis->u.s.ifp, ifp); … … 610 609 TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); 611 610 612 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);611 RTSpinlockReleaseNoInts(pThis->hSpinlock); 613 612 614 613 NG_NODE_SET_PRIVATE(node, pThis); -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r40733 r40806 382 382 { 383 383 PVBOXNETDEVICEOPSOVERRIDE pOverride; 384 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;385 384 386 385 /* Cancel override if ethtool_ops is missing (host-only case, #5712) */ … … 402 401 pOverride->pVBoxNetFlt = pThis; 403 402 404 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp); /* (this isn't necessary, but so what) */403 RTSpinlockAcquire(pThis->hSpinlock); /* (this isn't necessary, but so what) */ 405 404 ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride); 406 405 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) 407 406 ASMAtomicXchgPtr((void * volatile *)&pDev->hard_start_xmit, vboxNetFltLinuxStartXmitFilter); 408 407 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */ 409 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);408 RTSpinlockReleaseNoInts(pThis->hSpinlock); 410 409 } 411 410 … … 420 419 { 421 420 PVBOXNETDEVICEOPSOVERRIDE pOverride; 422 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 423 424 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 421 422 RTSpinlockAcquire(pThis->hSpinlock); 425 423 if (!pDev) 426 424 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); … … 444 442 else 445 443 pOverride = NULL; 446 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);444 RTSpinlockReleaseNoInts(pThis->hSpinlock); 447 445 448 446 if (pOverride) … … 465 463 { 466 464 #if 0 467 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;468 465 struct net_device *pDev = NULL; 469 466 … … 472 469 * Be careful here to avoid problems racing the detached callback. 473 470 */ 474 RTSpinlockAcquire(pThis->hSpinlock , &Tmp);471 RTSpinlockAcquire(pThis->hSpinlock); 475 472 if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost)) 476 473 { … … 489 486 } 490 487 } 491 RTSpinlockRelease(pThis->hSpinlock , &Tmp);488 RTSpinlockRelease(pThis->hSpinlock); 492 489 493 490 Log(("vboxNetFltLinuxRetainNetDev - done\n")); … … 1382 1379 PINTNETTRUNKSWPORT pSwitchPort; 1383 1380 unsigned int fFeatures; 1384 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1385 1386 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 1381 1382 RTSpinlockAcquire(pThis->hSpinlock); 1387 1383 1388 1384 pSwitchPort = pThis->pSwitchPort; /* this doesn't need to be here, but it doesn't harm. */ … … 1393 1389 fFeatures = 0; 1394 1390 1395 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1391 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1396 1392 1397 1393 if (pThis->pSwitchPort) … … 1498 1494 static int vboxNetFltLinuxAttachToInterface(PVBOXNETFLTINS pThis, struct net_device *pDev) 1499 1495 { 1500 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1501 1496 LogFlow(("vboxNetFltLinuxAttachToInterface: pThis=%p (%s)\n", pThis, pThis->szName)); 1502 1497 … … 1506 1501 dev_hold(pDev); 1507 1502 1508 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1503 RTSpinlockAcquire(pThis->hSpinlock); 1509 1504 ASMAtomicUoWritePtr(&pThis->u.s.pDev, pDev); 1510 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1505 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1511 1506 1512 1507 Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n", … … 1546 1541 * the device notification handle. 1547 1542 */ 1548 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1543 RTSpinlockAcquire(pThis->hSpinlock); 1549 1544 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1550 1545 if (pDev) … … 1554 1549 pDev = NULL; /* don't dereference it */ 1555 1550 } 1556 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1551 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1557 1552 Log(("vboxNetFltLinuxAttachToInterface: this=%p: Packet handler installed.\n", pThis)); 1558 1553 … … 1578 1573 vboxNetFltLinuxUnhookDev(pThis, pDev); 1579 1574 #endif 1580 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1575 RTSpinlockAcquire(pThis->hSpinlock); 1581 1576 ASMAtomicUoWriteNullPtr(&pThis->u.s.pDev); 1582 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1577 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1583 1578 dev_put(pDev); 1584 1579 Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) released. ref=%d\n", … … 1599 1594 static int vboxNetFltLinuxUnregisterDevice(PVBOXNETFLTINS pThis, struct net_device *pDev) 1600 1595 { 1601 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1602 1603 1596 Assert(!pThis->fDisconnectedFromHost); 1604 1597 … … 1607 1600 #endif 1608 1601 1609 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1602 RTSpinlockAcquire(pThis->hSpinlock); 1610 1603 ASMAtomicWriteBool(&pThis->u.s.fRegistered, false); 1611 1604 ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true); 1612 1605 ASMAtomicUoWriteNullPtr(&pThis->u.s.pDev); 1613 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1606 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1614 1607 1615 1608 dev_remove_pack(&pThis->u.s.PacketType); … … 1902 1895 struct net_device *pDev; 1903 1896 bool fRegistered; 1904 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1905 1897 1906 1898 #ifdef VBOXNETFLT_WITH_HOST2WIRE_FILTER … … 1913 1905 * ways. */ 1914 1906 1915 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);1907 RTSpinlockAcquire(pThis->hSpinlock); 1916 1908 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1917 1909 fRegistered = ASMAtomicUoReadBool(&pThis->u.s.fRegistered); 1918 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1910 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1919 1911 1920 1912 if (fRegistered) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r40231 r40806 1081 1081 * the promiscuous OFF acknowledgement case). 1082 1082 */ 1083 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1084 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 1083 RTSpinlockAcquire(pThis->hSpinlock); 1085 1084 const bool fActive = pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE; 1086 1085 vboxNetFltRetain(pThis, true /* fBusy */); 1087 RTSpinlockReleaseNoInts(pThis->hSpinlock , &Tmp);1086 RTSpinlockReleaseNoInts(pThis->hSpinlock); 1088 1087 1089 1088 vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pStream; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltM-win.cpp
r36184 r40806 132 132 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoDeinitialization(PVBOXNETFLTINS pNetFlt) 133 133 { 134 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;135 134 uint64_t NanoTS = RTTimeSystemNanoTS(); 136 135 137 136 Assert(vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.MpState) == kVBoxNetDevOpState_Initialized); 138 137 139 RTSpinlockAcquire NoInts(pNetFlt->hSpinlock, &Tmp);138 RTSpinlockAcquire(pNetFlt->hSpinlock); 140 139 ASMAtomicUoWriteBool(&pNetFlt->fDisconnectedFromHost, true); 141 140 ASMAtomicUoWriteBool(&pNetFlt->fRediscoveryPending, false); … … 144 143 vboxNetFltWinSetOpState(&pNetFlt->u.s.WinIf.MpState, kVBoxNetDevOpState_Deinitializing); 145 144 146 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);145 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 147 146 148 147 vboxNetFltWinWaitDereference(&pNetFlt->u.s.WinIf.MpState); … … 505 504 static UINT vboxNetFltWinMpRequestStatePrep(PVBOXNETFLTINS pNetFlt, NDIS_STATUS *pStatus) 506 505 { 507 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;508 509 506 Assert(!pNetFlt->u.s.WinIf.StateFlags.fRequestInfo); 510 507 … … 516 513 } 517 514 518 RTSpinlockAcquire NoInts(pNetFlt->hSpinlock, &Tmp);515 RTSpinlockAcquire(pNetFlt->hSpinlock); 519 516 Assert(!pNetFlt->u.s.WinIf.StateFlags.fRequestInfo); 520 517 if (vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.PtState) > kVBoxNetDevOpState_Initialized /* protocol unbind in progress */ 521 518 || vboxNetFltWinGetPowerState(&pNetFlt->u.s.WinIf.MpState) > NdisDeviceStateD0) 522 519 { 523 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);520 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 524 521 *pStatus = NDIS_STATUS_FAILURE; 525 522 return 0; … … 530 527 { 531 528 pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS | VBOXNDISREQUEST_QUEUED; 532 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);529 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 533 530 *pStatus = NDIS_STATUS_PENDING; 534 531 return VBOXNDISREQUEST_INPROGRESS | VBOXNDISREQUEST_QUEUED; … … 537 534 if (pNetFlt->u.s.WinIf.StateFlags.fStandBy) 538 535 { 539 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);536 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 540 537 *pStatus = NDIS_STATUS_FAILURE; 541 538 return 0; … … 544 541 pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS; 545 542 546 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);543 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 547 544 548 545 *pStatus = NDIS_STATUS_SUCCESS; … … 776 773 { 777 774 PVBOXNETFLTINS pNetFlt = (PVBOXNETFLTINS)MiniportAdapterContext; 778 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;779 775 NDIS_STATUS Status = NDIS_STATUS_FAILURE; 780 776 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltM-win.h
r36207 r40806 26 26 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoInitialization(PVBOXNETFLTINS pThis, NDIS_HANDLE hMiniportAdapter, NDIS_HANDLE hWrapperConfigurationContext); 27 27 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpDoDeinitialization(PVBOXNETFLTINS pThis); 28 28 29 #else 30 29 31 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpInitializeDevideInstance(PVBOXNETFLTINS pThis); 30 32 DECLHIDDEN(bool) vboxNetFltWinMpDeInitializeDeviceInstance(PVBOXNETFLTINS pThis, PNDIS_STATUS pStatus); 33 31 34 DECLINLINE(VOID) vboxNetFltWinMpRequestStateComplete(PVBOXNETFLTINS pNetFlt) 32 35 { 33 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 34 RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp); 36 RTSpinlockAcquire(pNetFlt->hSpinlock); 35 37 pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = 0; 36 RTSpinlockRelease NoInts(pNetFlt->hSpinlock, &Tmp);38 RTSpinlockRelease(pNetFlt->hSpinlock); 37 39 } 40 38 41 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinMpRequestPost(PVBOXNETFLTINS pNetFlt); 39 42 #endif -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltP-win.cpp
r36184 r40806 162 162 static void vboxNetFltWinPtRequestsWaitComplete(PVBOXNETFLTINS pNetFlt) 163 163 { 164 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;165 166 164 /* wait for request to complete */ 167 165 while (vboxNetFltWinAtomicUoReadWinState(pNetFlt->u.s.WinIf.StateFlags).fRequestInfo == VBOXNDISREQUEST_INPROGRESS) … … 173 171 * If the below miniport is going to low power state, complete the queued request 174 172 */ 175 RTSpinlockAcquire NoInts(pNetFlt->hSpinlock, &Tmp);173 RTSpinlockAcquire(pNetFlt->hSpinlock); 176 174 if (pNetFlt->u.s.WinIf.StateFlags.fRequestInfo & VBOXNDISREQUEST_QUEUED) 177 175 { 178 176 /* mark the request as InProgress before posting it to RequestComplete */ 179 177 pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS; 180 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);178 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 181 179 vboxNetFltWinPtRequestComplete(pNetFlt, &pNetFlt->u.s.WinIf.PassDownRequest, NDIS_STATUS_FAILURE); 182 180 } 183 181 else 184 182 { 185 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);183 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 186 184 } 187 185 } … … 190 188 { 191 189 NDIS_STATUS Status; 192 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;193 190 uint64_t NanoTS = RTTimeSystemNanoTS(); 194 191 int cPPUsage; … … 200 197 Assert(vboxNetFltWinGetOpState(&pNetFlt->u.s.WinIf.PtState) == kVBoxNetDevOpState_Initialized); 201 198 202 RTSpinlockAcquire NoInts(pNetFlt->hSpinlock, &Tmp);199 RTSpinlockAcquire(pNetFlt->hSpinlock); 203 200 204 201 ASMAtomicUoWriteBool(&pNetFlt->fDisconnectedFromHost, true); … … 212 209 } 213 210 214 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);211 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 215 212 216 213 vboxNetFltWinPtRequestsWaitComplete(pNetFlt); … … 1400 1397 DECLHIDDEN(bool) vboxNetFltWinPtCloseInterface(PVBOXNETFLTINS pNetFlt, PNDIS_STATUS pStatus) 1401 1398 { 1402 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1403 1404 RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp); 1399 RTSpinlockAcquire(pNetFlt->hSpinlock); 1405 1400 1406 1401 if (pNetFlt->u.s.WinIf.StateFlags.fInterfaceClosing) 1407 1402 { 1408 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1403 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1409 1404 Assert(0); 1410 1405 return false; … … 1412 1407 if (pNetFlt->u.s.WinIf.hBinding == NULL) 1413 1408 { 1414 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1409 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1415 1410 Assert(0); 1416 1411 return false; … … 1418 1413 1419 1414 pNetFlt->u.s.WinIf.StateFlags.fInterfaceClosing = TRUE; 1420 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1415 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1421 1416 1422 1417 NdisResetEvent(&pNetFlt->u.s.WinIf.OpenCloseEvent); … … 1438 1433 { 1439 1434 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); 1443 1437 1444 1438 vboxNetFltWinSetPowerState(&pNetFlt->u.s.WinIf.PtState, enmPowerState); … … 1450 1444 pNetFlt->u.s.WinIf.StateFlags.fStandBy = TRUE; 1451 1445 } 1452 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1446 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1453 1447 vboxNetFltWinPtRequestsWaitComplete(pNetFlt); 1454 1448 vboxNetFltWinWaitDereference(&pNetFlt->u.s.WinIf.MpState); … … 1475 1469 { 1476 1470 pNetFlt->u.s.WinIf.StateFlags.fRequestInfo = VBOXNDISREQUEST_INPROGRESS; 1477 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1471 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1478 1472 1479 1473 vboxNetFltWinMpRequestPost(pNetFlt); … … 1481 1475 else 1482 1476 { 1483 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);1477 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 1484 1478 } 1485 1479 } -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltRt-win.cpp
r37161 r40806 1059 1059 DECLHIDDEN(void) vboxNetFltWinQuFiniPacketQueue(PVBOXNETFLTINS pInstance) 1060 1060 { 1061 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1062 1061 PINTNETSG pSG; 1063 1062 PPACKET_QUEUE_WORKER pWorker = &pInstance->u.s.PacketQueueWorker; … … 1065 1064 1066 1065 /* using the pPacketQueueSG as an indicator that the packet queue is initialized */ 1067 RTSpinlockAcquire NoInts((pInstance)->hSpinlock, &Tmp);1066 RTSpinlockAcquire((pInstance)->hSpinlock); 1068 1067 if (pWorker->pSG) 1069 1068 { 1070 1069 pSG = pWorker->pSG; 1071 1070 pWorker->pSG = NULL; 1072 RTSpinlockReleaseNoInts((pInstance)->hSpinlock , &Tmp);1071 RTSpinlockReleaseNoInts((pInstance)->hSpinlock); 1073 1072 KeSetEvent(&pWorker->KillEvent, 0, FALSE); 1074 1073 … … 1084 1083 else 1085 1084 { 1086 RTSpinlockReleaseNoInts((pInstance)->hSpinlock , &Tmp);1085 RTSpinlockReleaseNoInts((pInstance)->hSpinlock); 1087 1086 } 1088 1087 } … … 1845 1844 USHORT cbAnsiName = pBindToMiniportName->Length;/* the length is is bytes ; *2 ;RtlUnicodeStringToAnsiSize(pBindToMiniportName)*/ 1846 1845 CREATE_INSTANCE_CONTEXT Context; 1847 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1848 1846 1849 1847 # ifndef VBOXNETADP … … 2611 2609 static int vboxNetFltWinDeleteInstance(PVBOXNETFLTINS pThis) 2612 2610 { 2613 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;2614 2611 LogFlow(("vboxNetFltWinDeleteInstance: pThis=0x%p \n", pThis)); 2615 2612 … … 2646 2643 DECLHIDDEN(NDIS_STATUS) vboxNetFltWinDetachFromInterface(PVBOXNETFLTINS pNetFlt, bool bOnUnbind) 2647 2644 { 2648 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;2649 2645 NDIS_STATUS Status; 2650 2646 int rc; … … 2787 2783 if (RT_SUCCESS(rc)) 2788 2784 { 2789 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;2790 2785 Assert(vboxNetFltWinGetWinIfState(pThis) == kVBoxWinIfState_Disconnected); 2791 2786 Assert(vboxNetFltWinGetOpState(&pThis->u.s.WinIf.MpState) == kVBoxNetDevOpState_Deinitialized); … … 2830 2825 #endif 2831 2826 /* 4. mark as connected */ 2832 RTSpinlockAcquire NoInts(pThis->hSpinlock, &Tmp);2827 RTSpinlockAcquire(pThis->hSpinlock); 2833 2828 ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); 2834 RTSpinlockRelease NoInts(pThis->hSpinlock, &Tmp);2829 RTSpinlockRelease(pThis->hSpinlock); 2835 2830 2836 2831 pAttachInfo->Status = VINF_SUCCESS; -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltRt-win.h
r36184 r40806 587 587 DECLINLINE(bool) vboxNetFltWinReferenceWinIfNetFlt(PVBOXNETFLTINS pNetFlt, bool * pbNetFltActive) 588 588 { 589 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 590 591 RTSpinlockAcquireNoInts((pNetFlt)->hSpinlock, &Tmp); 589 RTSpinlockAcquire((pNetFlt)->hSpinlock); 592 590 #ifndef VBOXNETADP 593 591 if(!vboxNetFltWinDoReferenceDevices(&pNetFlt->u.s.WinIf.MpState, &pNetFlt->u.s.WinIf.PtState)) … … 596 594 #endif 597 595 { 598 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock , &Tmp);596 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock); 599 597 *pbNetFltActive = false; 600 598 return false; … … 604 602 { 605 603 vboxNetFltWinReferenceModePassThru(pNetFlt); 606 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock , &Tmp);604 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock); 607 605 *pbNetFltActive = false; 608 606 return true; … … 611 609 vboxNetFltRetain((pNetFlt), true /* fBusy */); 612 610 vboxNetFltWinReferenceModeNetFlt(pNetFlt); 613 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock , &Tmp);611 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock); 614 612 615 613 *pbNetFltActive = true; … … 619 617 DECLINLINE(bool) vboxNetFltWinIncReferenceWinIfNetFlt(PVBOXNETFLTINS pNetFlt, uint32_t v, bool *pbNetFltActive) 620 618 { 621 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;622 619 uint32_t i; 623 620 … … 629 626 } 630 627 631 RTSpinlockAcquire NoInts((pNetFlt)->hSpinlock, &Tmp);628 RTSpinlockAcquire((pNetFlt)->hSpinlock); 632 629 #ifndef VBOXNETADP 633 630 if(!vboxNetFltWinDoIncReferenceDevices(&pNetFlt->u.s.WinIf.MpState, &pNetFlt->u.s.WinIf.PtState, v)) … … 636 633 #endif 637 634 { 638 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);635 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 639 636 *pbNetFltActive = false; 640 637 return false; … … 645 642 vboxNetFltWinIncReferenceModePassThru(pNetFlt, v); 646 643 647 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock , &Tmp);644 RTSpinlockReleaseNoInts((pNetFlt)->hSpinlock); 648 645 *pbNetFltActive = false; 649 646 return true; … … 654 651 vboxNetFltWinIncReferenceModeNetFlt(pNetFlt, v); 655 652 656 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);653 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 657 654 658 655 /* we have marked it as busy, so can do the res references outside the lock */ … … 705 702 DECLINLINE(bool) vboxNetFltWinIncReferenceWinIf(PVBOXNETFLTINS pNetFlt, uint32_t v) 706 703 { 707 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;708 709 704 Assert(v); 710 705 if(!v) … … 713 708 } 714 709 715 RTSpinlockAcquire NoInts(pNetFlt->hSpinlock, &Tmp);710 RTSpinlockAcquire(pNetFlt->hSpinlock); 716 711 #ifdef VBOXNETADP 717 712 if(vboxNetFltWinDoIncReferenceDevice(&pNetFlt->u.s.WinIf.MpState, v)) … … 720 715 #endif 721 716 { 722 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);717 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 723 718 return true; 724 719 } 725 720 726 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);721 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 727 722 return false; 728 723 } … … 730 725 DECLINLINE(bool) vboxNetFltWinReferenceWinIf(PVBOXNETFLTINS pNetFlt) 731 726 { 732 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 733 RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp); 727 RTSpinlockAcquire(pNetFlt->hSpinlock); 734 728 #ifdef VBOXNETADP 735 729 if(vboxNetFltWinDoReferenceDevice(&pNetFlt->u.s.WinIf.MpState)) … … 738 732 #endif 739 733 { 740 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);734 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 741 735 return true; 742 736 } 743 737 744 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock , &Tmp);738 RTSpinlockReleaseNoInts(pNetFlt->hSpinlock); 745 739 return false; 746 740 } -
trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c
r37423 r40806 74 74 return NULL; 75 75 } 76 DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis, 77 PRTSPINLOCKTMP pTmp) 76 DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis) 78 77 { 79 78 #ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS 80 RTSpinlockAcquire NoInts(pThis->hSpinlock, pTmp);79 RTSpinlockAcquire(pThis->hSpinlock); 81 80 return VINF_SUCCESS; 82 81 #else … … 89 88 } 90 89 91 DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis, 92 PRTSPINLOCKTMP pTmp) 90 DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis) 93 91 { 94 92 #ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS 95 RTSpinlockReleaseNoInts(pThis->hSpinlock , pTmp);93 RTSpinlockReleaseNoInts(pThis->hSpinlock); 96 94 #else 97 95 NOREF(pTmp); … … 184 182 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 185 183 int rc; 186 RTSPINLOCKTMP aTmp; 187 188 vboxPciDevLock(pThis, &aTmp); 184 185 vboxPciDevLock(pThis); 189 186 190 187 rc = vboxPciOsDevInit(pThis, fFlags); 191 188 192 vboxPciDevUnlock(pThis , &aTmp);189 vboxPciDevUnlock(pThis); 193 190 194 191 return rc; … … 202 199 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 203 200 int rc; 204 RTSPINLOCKTMP aTmp; 205 206 vboxPciDevLock(pThis, &aTmp); 201 202 vboxPciDevLock(pThis); 207 203 208 204 if (pThis->IrqHandler.pfnIrqHandler) … … 215 211 rc = vboxPciOsDevDeinit(pThis, fFlags); 216 212 217 vboxPciDevUnlock(pThis , &aTmp);213 vboxPciDevUnlock(pThis); 218 214 219 215 return rc; … … 265 261 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 266 262 int rc; 267 RTSPINLOCKTMP aTmp; 268 269 vboxPciDevLock(pThis, &aTmp); 263 264 vboxPciDevLock(pThis); 270 265 271 266 rc = vboxPciOsDevGetRegionInfo(pThis, iRegion, 272 267 pRegionStart, pu64RegionSize, 273 268 pfPresent, pfFlags); 274 vboxPciDevUnlock(pThis , &aTmp);269 vboxPciDevUnlock(pThis); 275 270 276 271 return rc; … … 289 284 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 290 285 int rc; 291 RTSPINLOCKTMP aTmp; 292 293 vboxPciDevLock(pThis, &aTmp); 286 287 vboxPciDevLock(pThis); 294 288 295 289 rc = vboxPciOsDevMapRegion(pThis, iRegion, RegionStart, u64RegionSize, fFlags, pRegionBase); 296 290 297 vboxPciDevUnlock(pThis , &aTmp);291 vboxPciDevUnlock(pThis); 298 292 299 293 return rc; … … 311 305 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 312 306 int rc; 313 RTSPINLOCKTMP aTmp; 314 315 vboxPciDevLock(pThis, &aTmp); 307 308 vboxPciDevLock(pThis); 316 309 317 310 rc = vboxPciOsDevUnmapRegion(pThis, iRegion, RegionStart, u64RegionSize, RegionBase); 318 311 319 vboxPciDevUnlock(pThis , &aTmp);312 vboxPciDevUnlock(pThis); 320 313 321 314 return rc; … … 330 323 { 331 324 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 332 RTSPINLOCKTMP aTmp; 333 int rc; 334 335 vboxPciDevLock(pThis, &aTmp); 325 int rc; 326 327 vboxPciDevLock(pThis); 336 328 337 329 rc = vboxPciOsDevPciCfgRead(pThis, Register, pValue); 338 330 339 vboxPciDevUnlock(pThis , &aTmp);331 vboxPciDevUnlock(pThis); 340 332 341 333 return rc; … … 351 343 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 352 344 int rc; 353 RTSPINLOCKTMP aTmp; 354 355 vboxPciDevLock(pThis, &aTmp); 345 346 vboxPciDevLock(pThis); 356 347 357 348 rc = vboxPciOsDevPciCfgWrite(pThis, Register, pValue); 358 349 359 vboxPciDevUnlock(pThis , &aTmp);350 vboxPciDevUnlock(pThis); 360 351 361 352 return rc; … … 370 361 int rc; 371 362 int32_t iHostIrq = 0; 372 RTSPINLOCKTMP aTmp;373 363 374 364 if (pfnHandler == NULL) 375 365 return VERR_INVALID_PARAMETER; 376 366 377 vboxPciDevLock(pThis , &aTmp);367 vboxPciDevLock(pThis); 378 368 379 369 if (pThis->IrqHandler.pfnIrqHandler) … … 393 383 } 394 384 395 vboxPciDevUnlock(pThis , &aTmp);385 vboxPciDevUnlock(pThis); 396 386 397 387 return rc; … … 403 393 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 404 394 int rc; 405 RTSPINLOCKTMP aTmp;406 395 407 396 if (hIsr != 0xcafe0000) 408 397 return VERR_INVALID_PARAMETER; 409 398 410 vboxPciDevLock(pThis , &aTmp);399 vboxPciDevLock(pThis); 411 400 412 401 rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq); … … 417 406 pThis->IrqHandler.iHostIrq = 0; 418 407 } 419 vboxPciDevUnlock(pThis , &aTmp);408 vboxPciDevUnlock(pThis); 420 409 421 410 return rc; … … 428 417 PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); 429 418 int rc; 430 RTSPINLOCKTMP aTmp; 431 432 vboxPciDevLock(pThis, &aTmp); 419 420 vboxPciDevLock(pThis); 433 421 434 422 rc = vboxPciOsDevPowerStateChange(pThis, aState); … … 448 436 449 437 450 vboxPciDevUnlock(pThis , &aTmp);438 vboxPciDevUnlock(pThis); 451 439 452 440 return rc; -
trunk/src/VBox/HostDrivers/VBoxUSB/VBoxUSBFilterMgr.cpp
r36941 r40806 46 46 47 47 # define VBOXUSBFILTERMGR_LOCK() \ 48 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; \ 49 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp) 48 RTSpinlockAcquire(g_Spinlock) 50 49 51 50 # define VBOXUSBFILTERMGR_UNLOCK() \ 52 RTSpinlockRelease NoInts(g_Spinlock, &Tmp)51 RTSpinlockRelease(g_Spinlock) 53 52 54 53 #else … … 124 123 { 125 124 #ifdef VBOXUSBFILTERMGR_USB_SPINLOCK 126 int rc = RTSpinlockCreate(&g_Spinlock );125 int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxUSBFilter"); 127 126 #else 128 127 int rc = RTSemFastMutexCreate(&g_Mtx); -
trunk/src/VBox/Runtime/VBox/VBoxRTImp.def
r39851 r40806 1036 1036 RTSocketWriteNB 1037 1037 RTSpinlockAcquire 1038 RTSpinlockAcquireNoInts1039 1038 RTSpinlockCreate 1040 1039 RTSpinlockDestroy 1041 1040 RTSpinlockRelease 1042 RTSpinlockReleaseNoInts1043 1041 RTStrAAppendExNVTag 1044 1042 RTStrAAppendNTag -
trunk/src/VBox/Runtime/common/misc/handletable.cpp
r33540 r40806 103 103 if (fFlags & RTHANDLETABLE_FLAGS_LOCKED) 104 104 { 105 int rc = RTSpinlockCreate(&pThis->hSpinlock );105 int rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTHandleTableCreateEx"); 106 106 if (RT_FAILURE(rc)) 107 107 { … … 127 127 { 128 128 PRTHANDLETABLEINT pThis; 129 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;130 129 uint32_t i1; 131 130 uint32_t i; … … 145 144 * Then kill the lock. 146 145 */ 147 rtHandleTableLock(pThis , &Tmp);146 rtHandleTableLock(pThis); 148 147 ASMAtomicWriteU32(&pThis->u32Magic, ~RTHANDLETABLE_MAGIC); 149 rtHandleTableUnlock(pThis , &Tmp);148 rtHandleTableUnlock(pThis); 150 149 151 150 if (pThis->hSpinlock != NIL_RTSPINLOCK) 152 151 { 153 rtHandleTableLock(pThis , &Tmp);154 rtHandleTableUnlock(pThis , &Tmp);152 rtHandleTableLock(pThis); 153 rtHandleTableUnlock(pThis); 155 154 156 155 RTSpinlockDestroy(pThis->hSpinlock); -
trunk/src/VBox/Runtime/common/misc/handletable.h
r28800 r40806 219 219 * 220 220 * @param pThis The handle table structure. 221 * @param pTmp The spinlock temp variable. 222 */ 223 DECLINLINE(void) rtHandleTableLock(PRTHANDLETABLEINT pThis, PRTSPINLOCKTMP pTmp) 221 */ 222 DECLINLINE(void) rtHandleTableLock(PRTHANDLETABLEINT pThis) 224 223 { 225 224 if (pThis->hSpinlock != NIL_RTSPINLOCK) 226 225 { 227 RTSPINLOCKTMP const Tmp = RTSPINLOCKTMP_INITIALIZER; 228 *pTmp = Tmp; 229 RTSpinlockAcquire(pThis->hSpinlock, pTmp); 226 RTSpinlockAcquire(pThis->hSpinlock); 230 227 } 231 228 } … … 236 233 * 237 234 * @param pThis The handle table structure. 238 * @param pTmp The spinlock temp variable. 239 */ 240 DECLINLINE(void) rtHandleTableUnlock(PRTHANDLETABLEINT pThis, PRTSPINLOCKTMP pTmp) 235 */ 236 DECLINLINE(void) rtHandleTableUnlock(PRTHANDLETABLEINT pThis) 241 237 { 242 238 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 46 46 { 47 47 PRTHANDLETABLEINT pThis; 48 RTSPINLOCKTMP Tmp /*= no init */;49 48 int rc; 50 49 … … 61 60 * Allocation loop. 62 61 */ 63 rtHandleTableLock(pThis , &Tmp);62 rtHandleTableLock(pThis); 64 63 65 64 do … … 116 115 117 116 /* leave the lock (never do fancy stuff from behind a spinlock). */ 118 rtHandleTableUnlock(pThis , &Tmp);117 rtHandleTableUnlock(pThis); 119 118 120 119 /* … … 138 137 139 138 /* re-enter the lock. */ 140 rtHandleTableLock(pThis , &Tmp);139 rtHandleTableLock(pThis); 141 140 142 141 /* … … 162 161 163 162 /* free the obsolete one (outside the lock of course) */ 164 rtHandleTableUnlock(pThis , &Tmp);163 rtHandleTableUnlock(pThis); 165 164 RTMemFree(papvLevel1); 166 rtHandleTableLock(pThis , &Tmp);165 rtHandleTableLock(pThis); 167 166 } 168 167 … … 200 199 { 201 200 /* free the table (raced someone, and we lost). */ 202 rtHandleTableUnlock(pThis , &Tmp);201 rtHandleTableUnlock(pThis); 203 202 RTMemFree(paTable); 204 rtHandleTableLock(pThis , &Tmp);203 rtHandleTableLock(pThis); 205 204 } 206 205 … … 209 208 } while (rc == VERR_TRY_AGAIN); 210 209 211 rtHandleTableUnlock(pThis , &Tmp);210 rtHandleTableUnlock(pThis); 212 211 213 212 return rc; … … 221 220 PRTHTENTRYCTX pEntry; 222 221 PRTHANDLETABLEINT pThis; 223 RTSPINLOCKTMP Tmp /*= no init */;224 222 225 223 /* validate the input */ … … 231 229 232 230 /* acquire the lock */ 233 rtHandleTableLock(pThis , &Tmp);231 rtHandleTableLock(pThis); 234 232 235 233 /* … … 254 252 255 253 /* release the lock */ 256 rtHandleTableUnlock(pThis , &Tmp);254 rtHandleTableUnlock(pThis); 257 255 return pvObj; 258 256 } … … 265 263 PRTHTENTRYCTX pEntry; 266 264 PRTHANDLETABLEINT pThis; 267 RTSPINLOCKTMP Tmp /*= no init */;268 265 269 266 /* validate the input */ … … 275 272 276 273 /* acquire the lock */ 277 rtHandleTableLock(pThis , &Tmp);274 rtHandleTableLock(pThis); 278 275 279 276 /* … … 326 323 327 324 /* release the lock */ 328 rtHandleTableUnlock(pThis , &Tmp);325 rtHandleTableUnlock(pThis); 329 326 return pvObj; 330 327 } -
trunk/src/VBox/Runtime/common/misc/handletablesimple.cpp
r28800 r40806 57 57 * Allocation loop. 58 58 */ 59 RTSPINLOCKTMP Tmp /*= no init */; 60 rtHandleTableLock(pThis, &Tmp); 59 rtHandleTableLock(pThis); 61 60 62 61 int rc; … … 108 107 109 108 /* leave the lock (never do fancy stuff from behind a spinlock). */ 110 rtHandleTableUnlock(pThis , &Tmp);109 rtHandleTableUnlock(pThis); 111 110 112 111 /* … … 130 129 131 130 /* re-enter the lock. */ 132 rtHandleTableLock(pThis , &Tmp);131 rtHandleTableLock(pThis); 133 132 134 133 /* … … 152 151 153 152 /* free the obsolete one (outside the lock of course) */ 154 rtHandleTableUnlock(pThis , &Tmp);153 rtHandleTableUnlock(pThis); 155 154 RTMemFree(papvLevel1); 156 rtHandleTableLock(pThis , &Tmp);155 rtHandleTableLock(pThis); 157 156 } 158 157 … … 186 185 { 187 186 /* free the table (raced someone, and we lost). */ 188 rtHandleTableUnlock(pThis , &Tmp);187 rtHandleTableUnlock(pThis); 189 188 RTMemFree(paTable); 190 rtHandleTableLock(pThis , &Tmp);189 rtHandleTableLock(pThis); 191 190 } 192 191 … … 195 194 } while (rc == VERR_TRY_AGAIN); 196 195 197 rtHandleTableUnlock(pThis , &Tmp);196 rtHandleTableUnlock(pThis); 198 197 199 198 return rc; … … 213 212 214 213 /* acquire the lock */ 215 RTSPINLOCKTMP Tmp /*= no init */; 216 rtHandleTableLock(pThis, &Tmp); 214 rtHandleTableLock(pThis); 217 215 218 216 /* … … 237 235 238 236 /* release the lock */ 239 rtHandleTableUnlock(pThis , &Tmp);237 rtHandleTableUnlock(pThis); 240 238 return pvObj; 241 239 } … … 254 252 255 253 /* acquire the lock */ 256 RTSPINLOCKTMP Tmp /*= no init */; 257 rtHandleTableLock(pThis, &Tmp); 254 rtHandleTableLock(pThis); 258 255 259 256 /* … … 301 298 302 299 /* release the lock */ 303 rtHandleTableUnlock(pThis , &Tmp);300 rtHandleTableUnlock(pThis); 304 301 return pvObj; 305 302 } -
trunk/src/VBox/Runtime/common/misc/thread.cpp
r39456 r40806 58 58 *******************************************************************************/ 59 59 #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) 65 64 #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() 71 69 #endif 72 70 … … 167 165 */ 168 166 Assert(g_ThreadSpinlock == NIL_RTSPINLOCK); 169 rc = RTSpinlockCreate(&g_ThreadSpinlock );167 rc = RTSpinlockCreate(&g_ThreadSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTThread"); 170 168 if (RT_SUCCESS(rc)) 171 169 { … … 406 404 407 405 { 408 RT_THREAD_LOCK_TMP(Tmp); 409 RT_THREAD_LOCK_RW(Tmp); 406 RT_THREAD_LOCK_RW(); 410 407 411 408 /* … … 450 447 } 451 448 452 RT_THREAD_UNLOCK_RW( Tmp);449 RT_THREAD_UNLOCK_RW(); 453 450 } 454 451 } … … 479 476 static void rtThreadRemove(PRTTHREADINT pThread) 480 477 { 481 RT_THREAD_LOCK_TMP(Tmp); 482 RT_THREAD_LOCK_RW(Tmp); 478 RT_THREAD_LOCK_RW(); 483 479 if (ASMAtomicBitTestAndClear(&pThread->fIntFlags, RTTHREADINT_FLAG_IN_TREE_BIT)) 484 480 rtThreadRemoveLocked(pThread); 485 RT_THREAD_UNLOCK_RW( Tmp);481 RT_THREAD_UNLOCK_RW(); 486 482 } 487 483 … … 512 508 * Simple tree lookup. 513 509 */ 514 RT_THREAD_LOCK_TMP(Tmp); 515 RT_THREAD_LOCK_RD(Tmp); 510 RT_THREAD_LOCK_RD(); 516 511 pThread = (PRTTHREADINT)RTAvlPVGet(&g_ThreadTree, (void *)NativeThread); 517 RT_THREAD_UNLOCK_RD( Tmp);512 RT_THREAD_UNLOCK_RD(); 518 513 return pThread; 519 514 } … … 1241 1236 * Do the job. 1242 1237 */ 1243 RT_THREAD_LOCK_TMP(Tmp); 1244 RT_THREAD_LOCK_RW(Tmp); 1238 RT_THREAD_LOCK_RW(); 1245 1239 rc = rtThreadNativeSetPriority(pThread, enmType); 1246 1240 if (RT_SUCCESS(rc)) 1247 1241 ASMAtomicXchgSize(&pThread->enmType, enmType); 1248 RT_THREAD_UNLOCK_RW( Tmp);1242 RT_THREAD_UNLOCK_RW(); 1249 1243 if (RT_FAILURE(rc)) 1250 1244 Log(("RTThreadSetType: failed on thread %p (%s), rc=%Rrc!!!\n", Thread, pThread->szName, rc)); … … 1302 1296 int rtThreadDoCalcDefaultPriority(RTTHREADTYPE enmType) 1303 1297 { 1304 RT_THREAD_LOCK_TMP(Tmp); 1305 RT_THREAD_LOCK_RW(Tmp); 1298 RT_THREAD_LOCK_RW(); 1306 1299 int rc = rtSchedNativeCalcDefaultPriority(enmType); 1307 RT_THREAD_UNLOCK_RW( Tmp);1300 RT_THREAD_UNLOCK_RW(); 1308 1301 return rc; 1309 1302 } … … 1350 1343 * scheduling attributes defined by the specified process priority. 1351 1344 */ 1352 RT_THREAD_LOCK_TMP(Tmp); 1353 RT_THREAD_LOCK_RW(Tmp); 1345 RT_THREAD_LOCK_RW(); 1354 1346 int rc = rtProcNativeSetPriority(enmPriority); 1355 1347 if (RT_SUCCESS(rc)) … … 1370 1362 } 1371 1363 } 1372 RT_THREAD_UNLOCK_RW( Tmp);1364 RT_THREAD_UNLOCK_RW(); 1373 1365 LogFlow(("rtThreadDoSetProcPriority: returns %Rrc\n", rc)); 1374 1366 return rc; … … 1526 1518 DECLHIDDEN(void) rtThreadClearTlsEntry(RTTLS iTls) 1527 1519 { 1528 RT_THREAD_LOCK_TMP(Tmp); 1529 RT_THREAD_LOCK_RD(Tmp); 1520 RT_THREAD_LOCK_RD(); 1530 1521 RTAvlPVDoWithAll(&g_ThreadTree, true /* fFromLeft*/, rtThreadClearTlsEntryCallback, (void *)(uintptr_t)iTls); 1531 RT_THREAD_UNLOCK_RD( Tmp);1522 RT_THREAD_UNLOCK_RD(); 1532 1523 } 1533 1524 -
trunk/src/VBox/Runtime/generic/mempool-generic.cpp
r33540 r40806 138 138 if (!pMemPool) 139 139 return VERR_NO_MEMORY; 140 int rc = RTSpinlockCreate(&pMemPool->hSpinLock );140 int rc = RTSpinlockCreate(&pMemPool->hSpinLock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTMemPoolCreate"); 141 141 if (RT_SUCCESS(rc)) 142 142 { … … 203 203 if (pMemPool->hSpinLock != NIL_RTSPINLOCK) 204 204 { 205 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 206 RTSpinlockAcquire(pMemPool->hSpinLock, &Tmp); 205 RTSpinlockAcquire(pMemPool->hSpinLock); 207 206 208 207 PRTMEMPOOLENTRY pHead = pMemPool->pHead; … … 212 211 pMemPool->pHead = pEntry; 213 212 214 RTSpinlockRelease(pMemPool->hSpinLock , &Tmp);213 RTSpinlockRelease(pMemPool->hSpinLock); 215 214 } 216 215 … … 224 223 if (pMemPool->hSpinLock != NIL_RTSPINLOCK) 225 224 { 226 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 227 RTSpinlockAcquire(pMemPool->hSpinLock, &Tmp); 225 RTSpinlockAcquire(pMemPool->hSpinLock); 228 226 229 227 PRTMEMPOOLENTRY pNext = pEntry->pNext; … … 237 235 pEntry->pMemPool = NULL; 238 236 239 RTSpinlockRelease(pMemPool->hSpinLock , &Tmp);237 RTSpinlockRelease(pMemPool->hSpinLock); 240 238 } 241 239 else -
trunk/src/VBox/Runtime/generic/spinlock-generic.cpp
r34239 r40806 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 65 65 /** Spinlock magic value (RTSPINLOCK_MAGIC). */ 66 66 uint32_t u32Magic; 67 /** The spinlock creation flags. */ 68 uint32_t fFlags; 67 69 /** The spinlock. */ 68 70 uint32_t volatile fLocked; 71 /** The saved CPU interrupt. */ 72 uint32_t volatile fIntSaved; 69 73 } RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL; 70 74 71 75 72 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock) 73 { 76 RTDECL(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 74 81 /* 75 82 * Allocate. 76 83 */ 77 PRTSPINLOCKINTERNAL pSpinlockInt; 78 pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt)); 79 if (!pSpinlockInt) 84 pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); 85 if (!pThis) 80 86 return VERR_NO_MEMORY; 81 87 … … 83 89 * Initialize and return. 84 90 */ 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; 89 97 return VINF_SUCCESS; 90 98 } … … 97 105 * Validate input. 98 106 */ 99 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;100 if (!p SpinlockInt)107 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 108 if (!pThis) 101 109 return VERR_INVALID_PARAMETER; 102 if (p SpinlockInt->u32Magic != RTSPINLOCK_MAGIC)103 { 104 AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", p SpinlockInt, pSpinlockInt->u32Magic));110 if (pThis->u32Magic != RTSPINLOCK_MAGIC) 111 { 112 AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic)); 105 113 return VERR_INVALID_PARAMETER; 106 114 } 107 115 108 ASMAtomicIncU32(&p SpinlockInt->u32Magic);109 RTMemFree(p SpinlockInt);116 ASMAtomicIncU32(&pThis->u32Magic); 117 RTMemFree(pThis); 110 118 return VINF_SUCCESS; 111 119 } … … 113 121 114 122 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(); 123 RTDECL(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 } 123 153 #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 { 126 171 #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 } 137 182 #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 } 188 RT_EXPORT_SYMBOL(RTSpinlockAcquire); 189 190 191 RTDECL(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 } 217 RT_EXPORT_SYMBOL(RTSpinlockRelease); 218 219 220 RTDECL(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); 160 229 } 161 230 RT_EXPORT_SYMBOL(RTSpinlockReleaseNoInts); 162 231 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_SLEEP172 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 #else180 while (!ASMAtomicCmpXchgU32(&pSpinlockInt->fLocked, 1, 0))181 /*nothing */;182 #endif183 }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 55 55 /** Spinlock magic value (RTSPINLOCK_MAGIC). */ 56 56 uint32_t volatile u32Magic; 57 /** Saved interrupt flag. */ 58 uint32_t volatile fIntSaved; 59 /** Creation flags. */ 60 uint32_t fFlags; 57 61 /** The Darwin spinlock structure. */ 58 62 lck_spin_t *pSpinLock; 63 /** The spinlock name. */ 64 const char *pszName; 59 65 } RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL; 60 66 61 67 62 68 63 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock )69 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName) 64 70 { 65 71 RT_ASSERT_PREEMPTIBLE(); 72 AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER); 66 73 67 74 /* … … 69 76 */ 70 77 AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 71 PRTSPINLOCKINTERNAL p SpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));72 if (!p SpinlockInt)78 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); 79 if (!pThis) 73 80 return VERR_NO_MEMORY; 74 81 … … 76 83 * Initialize & return. 77 84 */ 78 pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC; 85 pThis->u32Magic = RTSPINLOCK_MAGIC; 86 pThis->fIntSaved = 0; 87 pThis->fFlags = fFlags; 88 pThis->pszName = pszName; 79 89 Assert(g_pDarwinLockGroup); 80 p SpinlockInt->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL);81 if (!p SpinlockInt->pSpinLock)90 pThis->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL); 91 if (!pThis->pSpinLock) 82 92 { 83 RTMemFree(p SpinlockInt);93 RTMemFree(pThis); 84 94 return VERR_NO_MEMORY; 85 95 } 86 96 87 *pSpinlock = p SpinlockInt;97 *pSpinlock = pThis; 88 98 return VINF_SUCCESS; 89 99 } … … 95 105 * Validate input. 96 106 */ 97 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;98 if (!p SpinlockInt)107 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 108 if (!pThis) 99 109 return VERR_INVALID_PARAMETER; 100 AssertMsgReturn(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC,101 ("Invalid spinlock %p magic=%#x\n", p SpinlockInt, pSpinlockInt->u32Magic),110 AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC, 111 ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic), 102 112 VERR_INVALID_PARAMETER); 103 113 … … 105 115 * Make the lock invalid and release the memory. 106 116 */ 107 ASMAtomicIncU32(&p SpinlockInt->u32Magic);117 ASMAtomicIncU32(&pThis->u32Magic); 108 118 109 119 Assert(g_pDarwinLockGroup); 110 lck_spin_destroy(p SpinlockInt->pSpinLock, g_pDarwinLockGroup);111 p SpinlockInt->pSpinLock = NULL;120 lck_spin_destroy(pThis->pSpinLock, g_pDarwinLockGroup); 121 pThis->pSpinLock = NULL; 112 122 113 RTMemFree(p SpinlockInt);123 RTMemFree(pThis); 114 124 return VINF_SUCCESS; 115 125 } 116 126 117 127 118 RTDECL(void) RTSpinlockAcquire NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)128 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock) 119 129 { 120 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;121 AssertPtr(p SpinlockInt);122 Assert(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC);130 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 131 AssertPtr(pThis); 132 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 123 133 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); 128 143 } 129 144 130 145 131 RTDECL(void) RTSpinlockRelease NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)146 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock) 132 147 { 133 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;134 AssertPtr(p SpinlockInt);135 Assert(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC);148 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 149 AssertPtr(pThis); 150 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 136 151 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); 139 161 } 140 162 141 163 142 RTDECL(void) RTSpinlock Acquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)164 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock) 143 165 { 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); 149 173 } 150 174 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 59 59 /** The spinlock. */ 60 60 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; 63 65 #ifdef RT_MORE_STRICT 64 66 /** The idAssertCpu variable before acquring the lock for asserting after … … 71 73 72 74 73 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock) 74 { 75 RTDECL(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 75 80 /* 76 81 * Allocate. 77 82 */ 78 RT_ASSERT_PREEMPTIBLE();79 83 AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 80 84 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pThis)); … … 85 89 * Initialize & return. 86 90 */ 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 89 96 *pSpinlock = pThis; 90 97 return VINF_SUCCESS; … … 114 121 115 122 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) 123 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock) 169 124 { 170 125 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 172 127 AssertPtr(pThis); 173 128 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 { 186 132 for (;;) 187 133 { 188 if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0)) 134 uint32_t fIntSaved = ASMIntDisableFlags(); 135 critical_enter(); 136 137 int c = 50; 138 for (;;) 189 139 { 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(); 192 149 } 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); 196 155 } 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 183 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock) 205 184 { 206 185 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 210 189 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 211 190 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 211 RTDECL(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); 215 218 #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 117 117 AssertReturn(g_HeapExec == NIL_RTHEAPSIMPLE, VERR_WRONG_ORDER); 118 118 119 rc = RTSpinlockCreate(&g_HeapExecSpinlock );119 rc = RTSpinlockCreate(&g_HeapExecSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0MemExecDonate"); 120 120 if (RT_SUCCESS(rc)) 121 121 { … … 147 147 AssertReturn(g_HeapExec == NIL_RTHEAPSIMPLE, VERR_WRONG_ORDER); 148 148 149 rc = RTSpinlockCreate(&g_HeapExecSpinlock );149 rc = RTSpinlockCreate(&g_HeapExecSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0MemExecInit"); 150 150 if (RT_SUCCESS(rc)) 151 151 { … … 220 220 if (g_HeapExec != NIL_RTHEAPSIMPLE) 221 221 { 222 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 223 RTSpinlockAcquireNoInts(g_HeapExecSpinlock, &SpinlockTmp); 222 RTSpinlockAcquire(g_HeapExecSpinlock); 224 223 pHdr = (PRTMEMHDR)RTHeapSimpleAlloc(g_HeapExec, cb + sizeof(*pHdr), 0); 225 RTSpinlockRelease NoInts(g_HeapExecSpinlock, &SpinlockTmp);224 RTSpinlockRelease(g_HeapExecSpinlock); 226 225 fFlags |= RTMEMHDR_FLAG_EXEC_HEAP; 227 226 } … … 290 289 else if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC_HEAP) 291 290 { 292 RTSPINLOCKTMP SpinlockTmp = RTSPINLOCKTMP_INITIALIZER; 293 RTSpinlockAcquireNoInts(g_HeapExecSpinlock, &SpinlockTmp); 291 RTSpinlockAcquire(g_HeapExecSpinlock); 294 292 RTHeapSimpleFree(g_HeapExec, pHdr); 295 RTSpinlockRelease NoInts(g_HeapExecSpinlock, &SpinlockTmp);293 RTSpinlockRelease(g_HeapExecSpinlock); 296 294 } 297 295 #endif -
trunk/src/VBox/Runtime/r0drv/linux/spinlock-r0drv-linux.c
r29250 r40806 54 54 { 55 55 /** 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; 57 61 /** The linux spinlock structure. */ 58 spinlock_t Spinlock;62 spinlock_t Spinlock; 59 63 #ifdef RT_MORE_STRICT 60 64 /** The idAssertCpu variable before acquring the lock for asserting after 61 65 * releasing the spinlock. */ 62 RTCPUID volatile idAssertCpu;66 RTCPUID volatile idAssertCpu; 63 67 /** 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; 73 69 #endif 74 70 } RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL; 75 71 76 72 73 This code has changed and need testing!; 77 74 78 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock) 75 76 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName) 79 77 { 78 PRTSPINLOCKINTERNAL pThis; 79 AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER); 80 80 81 /* 81 82 * Allocate. 82 83 */ 83 PRTSPINLOCKINTERNAL pThis;84 84 Assert(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 85 85 pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); … … 89 89 * Initialize and return. 90 90 */ 91 pThis->u32Magic = RTSPINLOCK_MAGIC; 91 pThis->u32Magic = RTSPINLOCK_MAGIC; 92 pThis->fFlags = fFlags; 93 pThis->fIntSaved = 0; 92 94 #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; 98 97 #endif 99 98 spin_lock_init(&pThis->Spinlock); … … 126 125 127 126 128 RTDECL(void) RTSpinlockAcquire NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)127 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock) 129 128 { 130 129 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 133 132 ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0)); 134 133 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); 172 142 173 143 RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis); … … 176 146 177 147 178 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock , PRTSPINLOCKTMP pTmp)148 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock) 179 149 { 180 150 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 182 152 AssertMsg(pThis && pThis->u32Magic == RTSPINLOCK_MAGIC, 183 153 ("pThis=%p u32Magic=%08x\n", pThis, pThis ? (int)pThis->u32Magic : 0)); 184 NOREF(pTmp);185 154 RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis); 186 Assert(!pThis->fNoIrqs || !ASMIntAreEnabled());187 155 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); 189 164 190 165 RT_ASSERT_PREEMPT_CPUID(); … … 192 167 RT_EXPORT_SYMBOL(RTSpinlockRelease); 193 168 169 170 RTDECL(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 } 180 RT_EXPORT_SYMBOL(RTSpinlockReleaseNoInts); 181 -
trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c
r39008 r40806 490 490 { 491 491 uint32_t iCpu = pTimer->cCpus; 492 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 493 RTSpinlockAcquire(pTimer->hSpinlock, &Tmp); 492 RTSpinlockAcquire(pTimer->hSpinlock); 494 493 495 494 Assert(pSubTimer->enmState == RTTIMERLNXSTATE_CB_DESTROYING); … … 499 498 if (rtTimerLnxGetState(&pTimer->aSubTimers[iCpu].enmState) != RTTIMERLNXSTATE_STOPPED) 500 499 { 501 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);500 RTSpinlockRelease(pTimer->hSpinlock); 502 501 return; 503 502 } 504 503 505 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);504 RTSpinlockRelease(pTimer->hSpinlock); 506 505 } 507 506 … … 525 524 { 526 525 RTTIMERLNXSTATE enmState; 527 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;528 526 if (pTimer->cCpus > 1) 529 RTSpinlockAcquire(pTimer->hSpinlock , &Tmp);527 RTSpinlockAcquire(pTimer->hSpinlock); 530 528 531 529 do … … 555 553 { 556 554 if (pTimer->cCpus > 1) 557 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);555 RTSpinlockRelease(pTimer->hSpinlock); 558 556 559 557 rtTimerLnxCallbackDestroy(pTimer, pSubTimer); … … 564 562 565 563 if (pTimer->cCpus > 1) 566 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);564 RTSpinlockRelease(pTimer->hSpinlock); 567 565 } 568 566 #endif /* CONFIG_SMP */ … … 900 898 static int rtTimerLnxOmniStart(PRTTIMER pTimer, PRTTIMERLINUXSTARTONCPUARGS pArgs) 901 899 { 902 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;903 900 RTCPUID iCpu; 904 901 RTCPUSET OnlineSet; … … 912 909 * should something happen while we're looping. 913 910 */ 914 RTSpinlockAcquire(pTimer->hSpinlock , &Tmp);911 RTSpinlockAcquire(pTimer->hSpinlock); 915 912 916 913 /* Just make it a omni timer restriction that no stop/start races are allowed. */ … … 918 915 if (rtTimerLnxGetState(&pTimer->aSubTimers[iCpu].enmState) != RTTIMERLNXSTATE_STOPPED) 919 916 { 920 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);917 RTSpinlockRelease(pTimer->hSpinlock); 921 918 return VERR_TIMER_BUSY; 922 919 } … … 937 934 ASMAtomicWriteBool(&pTimer->fSuspended, false); 938 935 939 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);936 RTSpinlockRelease(pTimer->hSpinlock); 940 937 941 938 /* … … 950 947 * Reset the sub-timers who didn't start up (ALL CPUs case). 951 948 */ 952 RTSpinlockAcquire(pTimer->hSpinlock , &Tmp);949 RTSpinlockAcquire(pTimer->hSpinlock); 953 950 954 951 for (iCpu = 0; iCpu < pTimer->cCpus; iCpu++) … … 962 959 } 963 960 964 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);961 RTSpinlockRelease(pTimer->hSpinlock); 965 962 966 963 return VINF_SUCCESS; … … 978 975 { 979 976 bool fActiveCallbacks = false; 980 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;981 977 RTCPUID iCpu; 982 978 RTTIMERLNXSTATE enmState; … … 987 983 * for those being stopped by an MP event. 988 984 */ 989 RTSpinlockAcquire(pTimer->hSpinlock , &Tmp);985 RTSpinlockAcquire(pTimer->hSpinlock); 990 986 991 987 ASMAtomicWriteBool(&pTimer->fSuspended, true); … … 1021 1017 } 1022 1018 1023 RTSpinlockRelease(pTimer->hSpinlock , &Tmp);1019 RTSpinlockRelease(pTimer->hSpinlock); 1024 1020 1025 1021 /* … … 1058 1054 && pTimer->u32Magic == RTTIMER_MAGIC) 1059 1055 { 1060 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1061 RTSpinlockAcquire(hSpinlock, &Tmp); 1056 RTSpinlockAcquire(hSpinlock); 1062 1057 1063 1058 if ( !ASMAtomicUoReadBool(&pTimer->fSuspended) … … 1070 1065 } 1071 1066 1072 RTSpinlockRelease(hSpinlock , &Tmp);1067 RTSpinlockRelease(hSpinlock); 1073 1068 } 1074 1069 } … … 1086 1081 PRTTIMER pTimer = (PRTTIMER)pvUser; 1087 1082 PRTTIMERLNXSUBTIMER pSubTimer = &pTimer->aSubTimers[idCpu]; 1088 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1089 1083 RTSPINLOCK hSpinlock; 1090 1084 … … 1100 1094 return; 1101 1095 1102 RTSpinlockAcquire(hSpinlock , &Tmp);1096 RTSpinlockAcquire(hSpinlock); 1103 1097 1104 1098 /* Is it active? */ … … 1124 1118 { 1125 1119 rtTimerLnxSetState(&pSubTimer->enmState, RTTIMERLNXSTATE_STOPPED); /* we'll recheck it. */ 1126 RTSpinlockRelease(hSpinlock , &Tmp);1120 RTSpinlockRelease(hSpinlock); 1127 1121 1128 1122 RTMpOnSpecific(idCpu, rtTimerLinuxMpStartOnCpu, pTimer, &Args); … … 1149 1143 if (rtTimerLnxCmpXchgState(&pSubTimer->enmState, RTTIMERLNXSTATE_MP_STOPPING, RTTIMERLNXSTATE_ACTIVE)) 1150 1144 { 1151 RTSpinlockRelease(hSpinlock , &Tmp);1145 RTSpinlockRelease(hSpinlock); 1152 1146 1153 1147 rtTimerLnxStopSubTimer(pSubTimer, pTimer->fHighRes); … … 1166 1160 } 1167 1161 1168 RTSpinlockRelease(hSpinlock , &Tmp);1162 RTSpinlockRelease(hSpinlock); 1169 1163 } 1170 1164 … … 1416 1410 { 1417 1411 uint32_t iCpu = pTimer->cCpus; 1418 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;1419 1412 if (pTimer->cCpus > 1) 1420 RTSpinlockAcquire NoInts(pTimer->hSpinlock, &Tmp);1413 RTSpinlockAcquire(pTimer->hSpinlock); 1421 1414 1422 1415 fCanDestroy = true; … … 1448 1441 1449 1442 if (pTimer->cCpus > 1) 1450 RTSpinlockReleaseNoInts(pTimer->hSpinlock , &Tmp);1443 RTSpinlockReleaseNoInts(pTimer->hSpinlock); 1451 1444 } 1452 1445 … … 1565 1558 if (cCpus > 1) 1566 1559 { 1567 int rc = RTSpinlockCreate(&pTimer->hSpinlock );1560 int rc = RTSpinlockCreate(&pTimer->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTTimerLnx"); 1568 1561 if (RT_SUCCESS(rc)) 1569 1562 rc = RTMpNotificationRegister(rtTimerLinuxMpEvent, pTimer); -
trunk/src/VBox/Runtime/r0drv/mpnotification-r0drv.c
r37211 r40806 94 94 PRTMPNOTIFYREG pCur; 95 95 RTSPINLOCK hSpinlock; 96 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;97 96 98 97 /* … … 119 118 if (hSpinlock == NIL_RTSPINLOCK) 120 119 return; 121 RTSpinlockAcquire(hSpinlock , &Tmp);120 RTSpinlockAcquire(hSpinlock); 122 121 123 122 /* Clear the bit. */ … … 138 137 void *pvUser = pCur->pvUser; 139 138 pCur = pCur->pNext; 140 RTSpinlockRelease(g_hRTMpNotifySpinLock , &Tmp);139 RTSpinlockRelease(g_hRTMpNotifySpinLock); 141 140 142 141 pfnCallback(enmEvent, idCpu, pvUser); … … 146 145 if (hSpinlock == NIL_RTSPINLOCK) 147 146 return; 148 RTSpinlockAcquire(hSpinlock , &Tmp);147 RTSpinlockAcquire(hSpinlock); 149 148 if (ASMAtomicUoReadU32(&g_iRTMpGeneration) != iGeneration) 150 149 break; … … 155 154 } while (pCur); 156 155 157 RTSpinlockRelease(hSpinlock , &Tmp);156 RTSpinlockRelease(hSpinlock); 158 157 } 159 158 … … 164 163 PRTMPNOTIFYREG pCur; 165 164 PRTMPNOTIFYREG pNew; 166 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;167 165 168 166 /* … … 173 171 RT_ASSERT_PREEMPTIBLE(); 174 172 175 RTSpinlockAcquire(g_hRTMpNotifySpinLock , &Tmp);173 RTSpinlockAcquire(g_hRTMpNotifySpinLock); 176 174 for (pCur = g_pRTMpCallbackHead; pCur; pCur = pCur->pNext) 177 175 if ( pCur->pvUser == pvUser 178 176 && pCur->pfnCallback == pfnCallback) 179 177 break; 180 RTSpinlockRelease(g_hRTMpNotifySpinLock , &Tmp);178 RTSpinlockRelease(g_hRTMpNotifySpinLock); 181 179 AssertMsgReturn(!pCur, ("pCur=%p pfnCallback=%p pvUser=%p\n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS); 182 180 … … 193 191 memset(&pNew->bmDone[0], 0xff, sizeof(pNew->bmDone)); 194 192 195 RTSpinlockAcquire(g_hRTMpNotifySpinLock , &Tmp);193 RTSpinlockAcquire(g_hRTMpNotifySpinLock); 196 194 197 195 pCur = g_pRTMpCallbackHead; … … 214 212 ASMAtomicIncU32(&g_iRTMpGeneration); 215 213 216 RTSpinlockRelease(g_hRTMpNotifySpinLock , &Tmp);214 RTSpinlockRelease(g_hRTMpNotifySpinLock); 217 215 218 216 /* duplicate? */ … … 232 230 PRTMPNOTIFYREG pPrev; 233 231 PRTMPNOTIFYREG pCur; 234 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;235 232 236 233 /* … … 244 241 * Find and unlink the record from the list. 245 242 */ 246 RTSpinlockAcquire(g_hRTMpNotifySpinLock , &Tmp);243 RTSpinlockAcquire(g_hRTMpNotifySpinLock); 247 244 pPrev = NULL; 248 245 for (pCur = g_pRTMpCallbackHead; pCur; pCur = pCur->pNext) … … 261 258 ASMAtomicIncU32(&g_iRTMpGeneration); 262 259 } 263 RTSpinlockRelease(g_hRTMpNotifySpinLock , &Tmp);260 RTSpinlockRelease(g_hRTMpNotifySpinLock); 264 261 265 262 if (!pCur) … … 280 277 DECLHIDDEN(int) rtR0MpNotificationInit(void) 281 278 { 282 int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTMpNotifySpinLock );279 int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTMpNotifySpinLock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "RTR0Mp"); 283 280 if (RT_SUCCESS(rc)) 284 281 { … … 297 294 { 298 295 PRTMPNOTIFYREG pHead; 299 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;300 296 RTSPINLOCK hSpinlock = g_hRTMpNotifySpinLock; 301 297 AssertReturnVoid(hSpinlock != NIL_RTSPINLOCK); … … 304 300 305 301 /* pick up the list and the spinlock. */ 306 RTSpinlockAcquire(hSpinlock , &Tmp);302 RTSpinlockAcquire(hSpinlock); 307 303 ASMAtomicWriteHandle(&g_hRTMpNotifySpinLock, NIL_RTSPINLOCK); 308 304 pHead = g_pRTMpCallbackHead; 309 305 g_pRTMpCallbackHead = NULL; 310 306 ASMAtomicIncU32(&g_iRTMpGeneration); 311 RTSpinlockRelease(hSpinlock , &Tmp);307 RTSpinlockRelease(hSpinlock); 312 308 313 309 /* free the list. */ -
trunk/src/VBox/Runtime/r0drv/nt/spinlock-r0drv-nt.cpp
r32463 r40806 72 72 uint32_t volatile u32Hack; 73 73 #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; 74 80 /** The NT spinlock structure. */ 75 81 KSPIN_LOCK Spinlock; … … 77 83 78 84 79 80 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock) 81 { 85 This code has changed and need testing!; 86 87 88 RTDECL(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 82 92 /* 83 93 * Allocate. 84 94 */ 85 95 Assert(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 86 PRTSPINLOCKINTERNAL p SpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));87 if (!p SpinlockInt)96 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); 97 if (!pThis) 88 98 return VERR_NO_MEMORY; 89 99 … … 91 101 * Initialize & return. 92 102 */ 93 p SpinlockInt->u32Magic= RTSPINLOCK_MAGIC;103 pThis->u32Magic = RTSPINLOCK_MAGIC; 94 104 #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; 102 113 return VINF_SUCCESS; 103 114 } … … 109 120 * Validate input. 110 121 */ 111 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;112 if (!p SpinlockInt)122 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 123 if (!pThis) 113 124 return VERR_INVALID_PARAMETER; 114 if (p SpinlockInt->u32Magic != RTSPINLOCK_MAGIC)125 if (pThis->u32Magic != RTSPINLOCK_MAGIC) 115 126 { 116 AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", p SpinlockInt, pSpinlockInt->u32Magic));127 AssertMsgFailed(("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic)); 117 128 return VERR_INVALID_PARAMETER; 118 129 } 119 130 120 ASMAtomicIncU32(&p SpinlockInt->u32Magic);121 RTMemFree(p SpinlockInt);131 ASMAtomicIncU32(&pThis->u32Magic); 132 RTMemFree(pThis); 122 133 return VINF_SUCCESS; 123 134 } 124 135 125 136 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 137 RTDECL(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 { 131 145 #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); 135 149 #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 174 RTDECL(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) 138 181 { 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 141 196 } 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 202 RTDECL(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); 161 207 #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 53 53 /** Spinlock magic value (RTSPINLOCK_MAGIC). */ 54 54 uint32_t volatile u32Magic; 55 /** Spinlock creation flags. */ 56 uint32_t fFlags; 55 57 /** The OS/2 spinlock structure. */ 56 58 SpinLock_t Spinlock; … … 58 60 59 61 60 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock )62 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName) 61 63 { 64 AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER); 65 62 66 /* 63 67 * Allocate. 64 68 */ 65 69 AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 66 PRTSPINLOCKINTERNAL p SpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pSpinlockInt));67 if (!p SpinlockInt)70 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); 71 if (!pThis) 68 72 return VERR_NO_MEMORY; 69 73 … … 71 75 * Initialize & return. 72 76 */ 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; 76 82 return VINF_SUCCESS; 77 83 } … … 83 89 * Validate input. 84 90 */ 85 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;86 if (!p SpinlockInt)91 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 92 if (!pThis) 87 93 return VERR_INVALID_PARAMETER; 88 AssertMsgReturn(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC,89 ("Invalid spinlock %p magic=%#x\n", p SpinlockInt, pSpinlockInt->u32Magic),94 AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC, 95 ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic), 90 96 VERR_INVALID_PARAMETER); 91 97 … … 93 99 * Make the lock invalid and release the memory. 94 100 */ 95 ASMAtomicIncU32(&p SpinlockInt->u32Magic);96 KernFreeSpinLock(&p SpinlockInt->Spinlock);97 RTMemFree(p SpinlockInt);101 ASMAtomicIncU32(&pThis->u32Magic); 102 KernFreeSpinLock(&pThis->Spinlock); 103 RTMemFree(pThis); 98 104 return VINF_SUCCESS; 99 105 } 100 106 101 107 102 RTDECL(void) RTSpinlockAcquire NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)108 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock) 103 109 { 104 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;105 AssertPtr(p SpinlockInt);106 Assert(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC);110 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 111 AssertPtr(pThis); 112 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 107 113 108 KernAcquireSpinLock(&p SpinlockInt->Spinlock);109 NOREF(pTmp);114 KernAcquireSpinLock(&pThis->Spinlock); 115 Assert(!ASMIntAreEnabled()); /** @todo verify that interrupts are disabled. */ 110 116 } 111 117 112 118 113 RTDECL(void) RTSpinlockRelease NoInts(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)119 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock) 114 120 { 115 PRTSPINLOCKINTERNAL p SpinlockInt= (PRTSPINLOCKINTERNAL)Spinlock;116 AssertPtr(p SpinlockInt);117 Assert(p SpinlockInt->u32Magic == RTSPINLOCK_MAGIC);121 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; 122 AssertPtr(pThis); 123 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 118 124 119 KernReleaseSpinLock(&pSpinlockInt->Spinlock); 120 NOREF(pTmp); 125 KernReleaseSpinLock(&pThis->Spinlock); 121 126 } 122 127 123 128 124 RTDECL(void) RTSpinlock Acquire(RTSPINLOCK Spinlock, PRTSPINLOCKTMP pTmp)129 RTDECL(void) RTSpinlockReleaseNoInts(RTSPINLOCK Spinlock) 125 130 { 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); 132 138 } 133 139 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 125 125 { 126 126 RTSPINLOCK Spinlock; 127 int rc = RTSpinlockCreate(&Spinlock );127 int rc = RTSpinlockCreate(&Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTTimerOS2"); 128 128 AssertRCReturn(rc, rc); 129 129 //bool fRc; … … 152 152 * Insert the timer into the list (LIFO atm). 153 153 */ 154 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 155 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 154 RTSpinlockAcquire(g_Spinlock); 156 155 g_u32ChangeNo++; 157 156 pTimer->pNext = g_pTimerHead; 158 157 g_pTimerHead = pTimer; 159 158 g_cTimers++; 160 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);159 RTSpinlockReleaseNoInts(g_Spinlock); 161 160 162 161 *ppTimer = pTimer; … … 190 189 * Remove it from the list. 191 190 */ 192 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 193 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 191 RTSpinlockAcquire(g_Spinlock); 194 192 g_u32ChangeNo++; 195 193 if (g_pTimerHead == pTimer) … … 203 201 if (RT_UNLIKELY(!pPrev)) 204 202 { 205 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);203 RTSpinlockReleaseNoInts(g_Spinlock); 206 204 return VERR_INVALID_HANDLE; 207 205 } … … 218 216 rtTimerOs2Dearm(); 219 217 } 220 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);218 RTSpinlockReleaseNoInts(g_Spinlock); 221 219 222 220 /* … … 241 239 u64First += RTTimeNanoTS(); 242 240 243 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 244 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 241 RTSpinlockAcquire(g_Spinlock); 245 242 g_u32ChangeNo++; 246 243 if (!g_cActiveTimers) … … 249 246 if (RT_FAILURE(rc)) 250 247 { 251 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);248 RTSpinlockReleaseNoInts(g_Spinlock); 252 249 return rc; 253 250 } … … 259 256 pTimer->u64StartTS = u64First; 260 257 pTimer->u64NextTS = u64First; 261 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);258 RTSpinlockReleaseNoInts(g_Spinlock); 262 259 263 260 return VINF_SUCCESS; … … 275 272 * Suspend the timer. 276 273 */ 277 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 278 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 274 RTSpinlockAcquire(g_Spinlock); 279 275 g_u32ChangeNo++; 280 276 pTimer->fSuspended = true; … … 283 279 if (!g_cActiveTimers) 284 280 rtTimerOs2Dearm(); 285 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);281 RTSpinlockReleaseNoInts(g_Spinlock); 286 282 287 283 return VINF_SUCCESS; … … 305 301 const uint64_t u64NanoTS = RTTimeNanoTS(); 306 302 307 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 308 RTSpinlockAcquireNoInts(g_Spinlock, &Tmp); 303 RTSpinlockAcquire(g_Spinlock); 309 304 310 305 /* … … 343 338 PFNRTTIMER pfnTimer = pTimer->pfnTimer; 344 339 void *pvUser = pTimer->pvUser; 345 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);340 RTSpinlockReleaseNoInts(g_Spinlock); 346 341 pfnTimer(pTimer, pvUser, pTimer->iTick); 347 342 348 RTSpinlockAcquire NoInts(g_Spinlock, &Tmp);343 RTSpinlockAcquire(g_Spinlock); 349 344 350 345 /* check if anything changed. */ … … 360 355 } 361 356 362 RTSpinlockReleaseNoInts(g_Spinlock , &Tmp);357 RTSpinlockReleaseNoInts(g_Spinlock); 363 358 } 364 359 -
trunk/src/VBox/Runtime/r0drv/powernotification-r0drv.c
r37211 r40806 89 89 PRTPOWERNOTIFYREG pCur; 90 90 RTSPINLOCK hSpinlock; 91 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;92 91 93 92 /* … … 114 113 if (hSpinlock == NIL_RTSPINLOCK) 115 114 return VERR_ACCESS_DENIED; 116 RTSpinlockAcquire(hSpinlock , &Tmp);115 RTSpinlockAcquire(hSpinlock); 117 116 118 117 /* Clear the bit. */ … … 133 132 void *pvUser = pCur->pvUser; 134 133 pCur = pCur->pNext; 135 RTSpinlockRelease(g_hRTPowerNotifySpinLock , &Tmp);134 RTSpinlockRelease(g_hRTPowerNotifySpinLock); 136 135 137 136 pfnCallback(enmEvent, pvUser); … … 141 140 if (hSpinlock == NIL_RTSPINLOCK) 142 141 return VERR_ACCESS_DENIED; 143 RTSpinlockAcquire(hSpinlock , &Tmp);142 RTSpinlockAcquire(hSpinlock); 144 143 if (ASMAtomicUoReadU32(&g_iRTPowerGeneration) != iGeneration) 145 144 break; … … 150 149 } while (pCur); 151 150 152 RTSpinlockRelease(hSpinlock , &Tmp);151 RTSpinlockRelease(hSpinlock); 153 152 return VINF_SUCCESS; 154 153 } … … 160 159 PRTPOWERNOTIFYREG pCur; 161 160 PRTPOWERNOTIFYREG pNew; 162 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;163 161 164 162 /* … … 169 167 RT_ASSERT_PREEMPTIBLE(); 170 168 171 RTSpinlockAcquire(g_hRTPowerNotifySpinLock , &Tmp);169 RTSpinlockAcquire(g_hRTPowerNotifySpinLock); 172 170 for (pCur = g_pRTPowerCallbackHead; pCur; pCur = pCur->pNext) 173 171 if ( pCur->pvUser == pvUser 174 172 && pCur->pfnCallback == pfnCallback) 175 173 break; 176 RTSpinlockRelease(g_hRTPowerNotifySpinLock , &Tmp);174 RTSpinlockRelease(g_hRTPowerNotifySpinLock); 177 175 AssertMsgReturn(!pCur, ("pCur=%p pfnCallback=%p pvUser=%p\n", pCur, pfnCallback, pvUser), VERR_ALREADY_EXISTS); 178 176 … … 189 187 memset(&pNew->bmDone[0], 0xff, sizeof(pNew->bmDone)); 190 188 191 RTSpinlockAcquire(g_hRTPowerNotifySpinLock , &Tmp);189 RTSpinlockAcquire(g_hRTPowerNotifySpinLock); 192 190 193 191 pCur = g_pRTPowerCallbackHead; … … 210 208 ASMAtomicIncU32(&g_iRTPowerGeneration); 211 209 212 RTSpinlockRelease(g_hRTPowerNotifySpinLock , &Tmp);210 RTSpinlockRelease(g_hRTPowerNotifySpinLock); 213 211 214 212 /* duplicate? */ … … 228 226 PRTPOWERNOTIFYREG pPrev; 229 227 PRTPOWERNOTIFYREG pCur; 230 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;231 228 232 229 /* … … 240 237 * Find and unlink the record from the list. 241 238 */ 242 RTSpinlockAcquire(g_hRTPowerNotifySpinLock , &Tmp);239 RTSpinlockAcquire(g_hRTPowerNotifySpinLock); 243 240 pPrev = NULL; 244 241 for (pCur = g_pRTPowerCallbackHead; pCur; pCur = pCur->pNext) … … 257 254 ASMAtomicIncU32(&g_iRTPowerGeneration); 258 255 } 259 RTSpinlockRelease(g_hRTPowerNotifySpinLock , &Tmp);256 RTSpinlockRelease(g_hRTPowerNotifySpinLock); 260 257 261 258 if (!pCur) … … 276 273 DECLHIDDEN(int) rtR0PowerNotificationInit(void) 277 274 { 278 int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTPowerNotifySpinLock );275 int rc = RTSpinlockCreate((PRTSPINLOCK)&g_hRTPowerNotifySpinLock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0Power"); 279 276 if (RT_SUCCESS(rc)) 280 277 { … … 293 290 { 294 291 PRTPOWERNOTIFYREG pHead; 295 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;296 292 RTSPINLOCK hSpinlock = g_hRTPowerNotifySpinLock; 297 293 AssertReturnVoid(hSpinlock != NIL_RTSPINLOCK); … … 300 296 301 297 /* pick up the list and the spinlock. */ 302 RTSpinlockAcquire(hSpinlock , &Tmp);298 RTSpinlockAcquire(hSpinlock); 303 299 ASMAtomicWriteHandle(&g_hRTPowerNotifySpinLock, NIL_RTSPINLOCK); 304 300 pHead = g_pRTPowerCallbackHead; 305 301 g_pRTPowerCallbackHead = NULL; 306 302 ASMAtomicIncU32(&g_iRTPowerGeneration); 307 RTSpinlockRelease(hSpinlock , &Tmp);303 RTSpinlockRelease(hSpinlock); 308 304 309 305 /* free the list. */ -
trunk/src/VBox/Runtime/r0drv/solaris/spinlock-r0drv-solaris.c
r40149 r40806 55 55 /** Spinlock magic value (RTSPINLOCK_MAGIC). */ 56 56 uint32_t volatile u32Magic; 57 /** Spinlock creation flags. */ 58 uint32_t fFlags; 59 /** Saved interrupt flag. */ 60 uint32_t volatile fIntSaved; 57 61 /** A Solaris spinlock. */ 58 62 kmutex_t Mtx; … … 67 71 68 72 69 70 RTDECL(int) RTSpinlockCreate(PRTSPINLOCK pSpinlock) 71 { 73 This code has changed and need testing!; 74 75 76 RTDECL(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 72 81 /* 73 82 * Allocate. 74 83 */ 75 RT_ASSERT_PREEMPTIBLE();76 84 AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *)); 77 85 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis)); … … 82 90 * Initialize & return. 83 91 */ 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. */ 85 96 mutex_init(&pThis->Mtx, "IPRT Spinlock", MUTEX_SPIN, (void *)ipltospl(PIL_MAX)); 86 97 *pSpinlock = pThis; … … 112 123 113 124 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) 125 RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock) 165 126 { 166 127 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 168 129 AssertPtr(pThis); 169 130 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 { 171 155 #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 } 180 165 181 166 RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis); … … 183 168 184 169 185 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock , PRTSPINLOCKTMP pTmp)170 RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock) 186 171 { 187 172 PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock; … … 191 176 Assert(pThis->u32Magic == RTSPINLOCK_MAGIC); 192 177 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 { 194 193 #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 203 204 RT_ASSERT_PREEMPT_CPUID(); 204 205 } 205 206 207 208 RTDECL(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 416 416 &pGVMM->aHostCpus[iCpu]); 417 417 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"); 419 419 if (RT_FAILURE(rc)) 420 420 { … … 2176 2176 * Do the house keeping. 2177 2177 */ 2178 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2179 RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp); 2178 RTSpinlockAcquire(pCpu->Ppt.hSpinlock); 2180 2179 2181 2180 if (++pCpu->Ppt.iTickHistorization >= pCpu->Ppt.cTicksHistoriziationInterval) … … 2197 2196 uHistMaxHz = pCpu->Ppt.aHzHistory[i]; 2198 2197 if (uHistMaxHz == pCpu->Ppt.uTimerHz) 2199 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2198 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2200 2199 else if (uHistMaxHz) 2201 2200 { … … 2214 2213 else 2215 2214 pCpu->Ppt.cTicksHistoriziationInterval = 1; 2216 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2215 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2217 2216 2218 2217 /*SUPR0Printf("Cpu%u: change to %u Hz / %u ns\n", pCpu->idxCpuSet, uHistMaxHz, cNsInterval);*/ … … 2227 2226 pCpu->Ppt.uTimerHz = 0; 2228 2227 pCpu->Ppt.cNsInterval = 0; 2229 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2228 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2230 2229 2231 2230 /*SUPR0Printf("Cpu%u: stopping (%u Hz)\n", pCpu->idxCpuSet, uHistMaxHz);*/ … … 2234 2233 } 2235 2234 else 2236 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2235 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2237 2236 } 2238 2237 #endif /* GVMM_SCHED_WITH_PPT */ … … 2281 2280 && !pCpu->Ppt.fStarting /* solaris paranoia */)) 2282 2281 { 2283 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 2284 RTSpinlockAcquireNoInts(pCpu->Ppt.hSpinlock, &Tmp); 2282 RTSpinlockAcquire(pCpu->Ppt.hSpinlock); 2285 2283 2286 2284 pCpu->Ppt.uDesiredHz = uHz; … … 2302 2300 } 2303 2301 2304 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2302 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2305 2303 2306 2304 if (cNsInterval) … … 2310 2308 AssertRC(rc); 2311 2309 2312 RTSpinlockAcquire NoInts(pCpu->Ppt.hSpinlock, &Tmp);2310 RTSpinlockAcquire(pCpu->Ppt.hSpinlock); 2313 2311 if (RT_FAILURE(rc)) 2314 2312 pCpu->Ppt.fStarted = false; 2315 2313 pCpu->Ppt.fStarting = false; 2316 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock , &Tmp);2314 RTSpinlockReleaseNoInts(pCpu->Ppt.hSpinlock); 2317 2315 } 2318 2316 } -
trunk/src/VBox/VMM/VMMR3/PDMBlkCache.cpp
r39515 r40806 657 657 /* The list is moved to a new header to reduce locking overhead. */ 658 658 RTLISTANCHOR ListDirtyNotCommitted; 659 RTSPINLOCKTMP Tmp;660 659 661 660 RTListInit(&ListDirtyNotCommitted); 662 RTSpinlockAcquire(pBlkCache->LockList , &Tmp);661 RTSpinlockAcquire(pBlkCache->LockList); 663 662 RTListMove(&ListDirtyNotCommitted, &pBlkCache->ListDirtyNotCommitted); 664 RTSpinlockRelease(pBlkCache->LockList , &Tmp);663 RTSpinlockRelease(pBlkCache->LockList); 665 664 666 665 if (!RTListIsEmpty(&ListDirtyNotCommitted)) … … 755 754 pEntry->fFlags |= PDMBLKCACHE_ENTRY_IS_DIRTY; 756 755 757 RTSPINLOCKTMP Tmp; 758 RTSpinlockAcquire(pBlkCache->LockList, &Tmp); 756 RTSpinlockAcquire(pBlkCache->LockList); 759 757 RTListAppend(&pBlkCache->ListDirtyNotCommitted, &pEntry->NodeNotCommitted); 760 RTSpinlockRelease(pBlkCache->LockList , &Tmp);758 RTSpinlockRelease(pBlkCache->LockList); 761 759 762 760 uint32_t cbDirty = ASMAtomicAddU32(&pCache->cbDirty, pEntry->cbData); … … 1220 1218 RTListInit(&pBlkCache->ListDirtyNotCommitted); 1221 1219 1222 rc = RTSpinlockCreate(&pBlkCache->LockList );1220 rc = RTSpinlockCreate(&pBlkCache->LockList, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "pdmR3BlkCacheRetain"); 1223 1221 if (RT_SUCCESS(rc)) 1224 1222 { -
trunk/src/VBox/VMM/VMMRZ/PGMRZDynMap.cpp
r39745 r40806 88 88 */ 89 89 # define PGMRZDYNMAP_SPINLOCK_ACQUIRE(pThis) \ 90 RTS PINLOCKTMP MySpinlockTmp = RTSPINLOCKTMP_INITIALIZER; \91 RTSpinlockAcquire((pThis)->hSpinlock, &MySpinlockTmp) 90 RTSpinlockAcquire((pThis)->hSpinlock) 91 92 92 /** 93 93 * Releases the spinlock. 94 94 */ 95 95 # define PGMRZDYNMAP_SPINLOCK_RELEASE(pThis) \ 96 RTSpinlockRelease((pThis)->hSpinlock , &MySpinlockTmp)96 RTSpinlockRelease((pThis)->hSpinlock) 97 97 98 98 /** … … 100 100 */ 101 101 # define PGMRZDYNMAP_SPINLOCK_REACQUIRE(pThis) \ 102 RTSpinlockAcquire((pThis)->hSpinlock , &MySpinlockTmp)102 RTSpinlockAcquire((pThis)->hSpinlock) 103 103 #else 104 104 # define PGMRZDYNMAP_SPINLOCK_ACQUIRE(pThis) do { } while (0) … … 408 408 if (RT_SUCCESS(rc)) 409 409 { 410 rc = RTSpinlockCreate(&pThis->hSpinlock );410 rc = RTSpinlockCreate(&pThis->hSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, "PGMR0DynMap"); 411 411 if (RT_SUCCESS(rc)) 412 412 {
Note:
See TracChangeset
for help on using the changeset viewer.