Index: trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteDebugger-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteDebugger-r0drv-darwin.cpp	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteDebugger-r0drv-darwin.cpp	(revision 57228)
@@ -36,6 +36,7 @@
 RTDECL(void) RTLogWriteDebugger(const char *pch, size_t cb)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
     kprintf("%.*s", (int)cb, pch);
-    return;
+    IPRT_DARWIN_RESTORE_EFL_AC();
 }
 
Index: trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteStdOut-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteStdOut-r0drv-darwin.cpp	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/RTLogWriteStdOut-r0drv-darwin.cpp	(revision 57228)
@@ -36,6 +36,7 @@
 RTDECL(void) RTLogWriteStdOut(const char *pch, size_t cb)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
     printf("%.*s", (int)cb, pch);
-    return;
+    IPRT_DARWIN_RESTORE_EFL_AC();
 }
 
Index: trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp	(revision 57228)
@@ -68,4 +68,6 @@
 DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
+
     if (RT_UNLIKELY(fFlags & RTMEMHDR_FLAG_ANY_CTX))
         return VERR_NOT_SUPPORTED;
@@ -77,5 +79,8 @@
         int rc = RTR0MemObjAllocPage(&hMemObj, cb + sizeof(RTMEMDARWINHDREX), true /*fExecutable*/);
         if (RT_FAILURE(rc))
+        {
+            IPRT_DARWIN_RESTORE_EFL_AC();
             return rc;
+        }
         PRTMEMDARWINHDREX pExHdr = (PRTMEMDARWINHDREX)RTR0MemObjAddress(hMemObj);
         pExHdr->hMemObj = hMemObj;
@@ -88,11 +93,9 @@
     else
     {
-
-        IPRT_DARWIN_SAVE_EFL_AC();
         pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr));
-        IPRT_DARWIN_RESTORE_EFL_AC();
         if (RT_UNLIKELY(!pHdr))
         {
             printf("rtR0MemAllocEx(%#zx, %#x) failed\n", cb + sizeof(*pHdr), fFlags);
+            IPRT_DARWIN_RESTORE_EFL_AC();
             return VERR_NO_MEMORY;
         }
@@ -103,5 +106,7 @@
     pHdr->cb        = cb;
     pHdr->cbReq     = cb;
-    *ppHdr = pHdr;;
+    *ppHdr = pHdr;
+
+    IPRT_DARWIN_RESTORE_EFL_AC();
     return VINF_SUCCESS;
 }
@@ -113,4 +118,6 @@
 DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
+
     pHdr->u32Magic += 1;
     if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC)
@@ -121,9 +128,7 @@
     }
     else
-    {
-        IPRT_DARWIN_SAVE_EFL_AC();
         IOFree(pHdr, pHdr->cb + sizeof(*pHdr));
-        IPRT_DARWIN_RESTORE_EFL_AC();
-    }
+
+    IPRT_DARWIN_RESTORE_EFL_AC();
 }
 
Index: trunk/src/VBox/Runtime/r0drv/darwin/assert-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/assert-r0drv-darwin.cpp	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/assert-r0drv-darwin.cpp	(revision 57228)
@@ -43,8 +43,10 @@
 DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
     printf("\r\n!!Assertion Failed!!\r\n"
            "Expression: %s\r\n"
            "Location  : %s(%u) %s\r\n",
            pszExpr, pszFile, uLine, pszFunction);
+    IPRT_DARWIN_RESTORE_EFL_AC();
 }
 
@@ -52,4 +54,5 @@
 DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va)
 {
+    IPRT_DARWIN_SAVE_EFL_AC();
     char szMsg[256];
 
@@ -59,4 +62,5 @@
 
     NOREF(fInitial);
+    IPRT_DARWIN_RESTORE_EFL_AC();
 }
 
Index: trunk/src/VBox/Runtime/r0drv/darwin/spinlock-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/spinlock-r0drv-darwin.cpp	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/spinlock-r0drv-darwin.cpp	(revision 57228)
@@ -70,4 +70,5 @@
 {
     RT_ASSERT_PREEMPTIBLE();
+    IPRT_DARWIN_SAVE_EFL_AC();
     AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
 
@@ -77,24 +78,26 @@
     AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
     PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAlloc(sizeof(*pThis));
-    if (!pThis)
-        return VERR_NO_MEMORY;
+    if (pThis)
+    {
+        /*
+         * Initialize & return.
+         */
+        pThis->u32Magic  = RTSPINLOCK_MAGIC;
+        pThis->fIntSaved = 0;
+        pThis->fFlags    = fFlags;
+        pThis->pszName   = pszName;
+        Assert(g_pDarwinLockGroup);
+        pThis->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL);
+        if (pThis->pSpinLock)
+        {
+            *pSpinlock = pThis;
+            IPRT_DARWIN_RESTORE_EFL_AC();
+            return VINF_SUCCESS;
+        }
 
-    /*
-     * Initialize & return.
-     */
-    pThis->u32Magic  = RTSPINLOCK_MAGIC;
-    pThis->fIntSaved = 0;
-    pThis->fFlags    = fFlags;
-    pThis->pszName   = pszName;
-    Assert(g_pDarwinLockGroup);
-    pThis->pSpinLock = lck_spin_alloc_init(g_pDarwinLockGroup, LCK_ATTR_NULL);
-    if (!pThis->pSpinLock)
-    {
         RTMemFree(pThis);
-        return VERR_NO_MEMORY;
     }
-
-    *pSpinlock = pThis;
-    return VINF_SUCCESS;
+    IPRT_DARWIN_RESTORE_EFL_AC();
+    return VERR_NO_MEMORY;
 }
 
@@ -116,4 +119,5 @@
      */
     ASMAtomicIncU32(&pThis->u32Magic);
+    IPRT_DARWIN_SAVE_EFL_AC();
 
     Assert(g_pDarwinLockGroup);
@@ -122,4 +126,6 @@
 
     RTMemFree(pThis);
+
+    IPRT_DARWIN_RESTORE_EFL_AC();
     return VINF_SUCCESS;
 }
@@ -138,7 +144,12 @@
         lck_spin_lock(pThis->pSpinLock);
         pThis->fIntSaved = fIntSaved;
+        IPRT_DARWIN_RESTORE_EFL_ONLY_AC_EX(fIntSaved);
     }
     else
+    {
+        IPRT_DARWIN_SAVE_EFL_AC();
         lck_spin_lock(pThis->pSpinLock);
+        IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
+    }
 }
 
@@ -158,5 +169,9 @@
     }
     else
+    {
+        IPRT_DARWIN_SAVE_EFL_AC();
         lck_spin_unlock(pThis->pSpinLock);
+        IPRT_DARWIN_RESTORE_EFL_ONLY_AC();
+    }
 }
 
Index: trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h	(revision 57122)
+++ trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h	(revision 57228)
@@ -97,7 +97,8 @@
 #include <iprt/asm-amd64-x86.h>
 #include <iprt/x86.h>
-#define IPRT_DARWIN_SAVE_EFL_AC()           RTCCUINTREG fSavedEfl = ASMGetFlags();
-#define IPRT_DARWIN_RESTORE_EFL_AC()        ASMSetFlags(fSavedEfl)
-#define IPRT_DARWIN_RESTORE_EFL_ONLY_AC()   ASMSetFlags((ASMGetFlags() & ~X86_EFL_AC) | (fSavedEfl & X86_EFL_AC))
+#define IPRT_DARWIN_SAVE_EFL_AC()                       RTCCUINTREG const fSavedEfl = ASMGetFlags();
+#define IPRT_DARWIN_RESTORE_EFL_AC()                    ASMSetFlags(fSavedEfl)
+#define IPRT_DARWIN_RESTORE_EFL_ONLY_AC()               ASMChangeFlags(~X86_EFL_AC, fSavedEfl & X86_EFL_AC)
+#define IPRT_DARWIN_RESTORE_EFL_ONLY_AC_EX(a_fSavedEfl) ASMChangeFlags(~X86_EFL_AC, (a_fSavedEfl) & X86_EFL_AC)
 /** @} */
 
