Index: trunk/src/VBox/VMM/VMM.cpp
===================================================================
--- trunk/src/VBox/VMM/VMM.cpp	(revision 24580)
+++ trunk/src/VBox/VMM/VMM.cpp	(revision 24582)
@@ -448,48 +448,53 @@
 VMMR3DECL(int) VMMR3InitFinalize(PVM pVM)
 {
-    int rc = VINF_SUCCESS;
-
+    int rc;
+
+    /*
+     * Set page attributes to r/w for stack pages.
+     */
     for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     {
-        PVMCPU pVCpu = &pVM->aCpus[idCpu];
+        rc = PGMMapSetPage(pVM, pVM->aCpus[idCpu].vmm.s.pbEMTStackRC, VMM_STACK_SIZE,
+                           X86_PTE_P | X86_PTE_A | X86_PTE_D | X86_PTE_RW);
+        AssertRCReturn(rc, rc);
+    }
+
+    /*
+     * Create the EMT yield timer.
+     */
+    rc = TMR3TimerCreateInternal(pVM, TMCLOCK_REAL, vmmR3YieldEMT, NULL, "EMT Yielder", &pVM->vmm.s.pYieldTimer);
+    AssertRCReturn(rc, rc);
+
+    rc = TMTimerSetMillies(pVM->vmm.s.pYieldTimer, pVM->vmm.s.cYieldEveryMillies);
+    AssertRCReturn(rc, rc);
+
+#ifdef VBOX_WITH_NMI
+    /*
+     * Map the host APIC into GC - This is AMD/Intel + Host OS specific!
+     */
+    rc = PGMMap(pVM, pVM->vmm.s.GCPtrApicBase, 0xfee00000, PAGE_SIZE,
+                X86_PTE_P | X86_PTE_RW | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A | X86_PTE_D);
+    AssertRCReturn(rc, rc);
+#endif
 
 #ifdef VBOX_STRICT_VMM_STACK
-        /*
-         * Two inaccessible pages at each sides of the stack to catch over/under-flows.
-         */
-        memset(pVCpu->vmm.s.pbEMTStackR3 - PAGE_SIZE, 0xcc, PAGE_SIZE);
-        MMR3HyperSetGuard(pVM, pVCpu->vmm.s.pbEMTStackR3 - PAGE_SIZE, PAGE_SIZE, true /*fSet*/);
-
-        memset(pVCpu->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, 0xcc, PAGE_SIZE);
-        MMR3HyperSetGuard(pVM, pVCpu->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, true /*fSet*/);
-#endif
-
-        /*
-         * Set page attributes to r/w for stack pages.
-         */
-        rc = PGMMapSetPage(pVM, pVCpu->vmm.s.pbEMTStackRC, VMM_STACK_SIZE, X86_PTE_P | X86_PTE_A | X86_PTE_D | X86_PTE_RW);
-        AssertRC(rc);
-        if (RT_FAILURE(rc))
-            break;
-    }
-    if (RT_SUCCESS(rc))
-    {
-        /*
-         * Create the EMT yield timer.
-         */
-        rc = TMR3TimerCreateInternal(pVM, TMCLOCK_REAL, vmmR3YieldEMT, NULL, "EMT Yielder", &pVM->vmm.s.pYieldTimer);
-        if (RT_SUCCESS(rc))
-           rc = TMTimerSetMillies(pVM->vmm.s.pYieldTimer, pVM->vmm.s.cYieldEveryMillies);
-    }
-
-#ifdef VBOX_WITH_NMI
-    /*
-     * Map the host APIC into GC - This is AMD/Intel + Host OS specific!
-     */
-    if (RT_SUCCESS(rc))
-        rc = PGMMap(pVM, pVM->vmm.s.GCPtrApicBase, 0xfee00000, PAGE_SIZE,
-                    X86_PTE_P | X86_PTE_RW | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A | X86_PTE_D);
-#endif
-    return rc;
+    /*
+     * Setup the stack guard pages: Two inaccessible pages at each sides of the
+     * stack to catch over/under-flows.
+     */
+    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
+    {
+        uint8_t *pbEMTStackR3 = pVM->aCpus[idCpu].vmm.s.pbEMTStackR3;
+
+        memset(pbEMTStackR3 - PAGE_SIZE, 0xcc, PAGE_SIZE);
+        MMR3HyperSetGuard(pVM, pbEMTStackR3 - PAGE_SIZE, PAGE_SIZE, true /*fSet*/);
+
+        memset(pbEMTStackR3 + VMM_STACK_SIZE, 0xcc, PAGE_SIZE);
+        MMR3HyperSetGuard(pVM, pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, true /*fSet*/);
+    }
+    pVM->vmm.s.fStackGuardsStationed = true;
+#endif
+
+    return VINF_SUCCESS;
 }
 
@@ -699,8 +704,13 @@
      * Make the two stack guard pages present again.
      */
-    for (VMCPUID i = 0; i < pVM->cCpus; i++)
-    {
-        MMR3HyperSetGuard(pVM, pVM->aCpus[i].vmm.s.pbEMTStackR3 - PAGE_SIZE,      PAGE_SIZE, false /*fSet*/);
-        MMR3HyperSetGuard(pVM, pVM->aCpus[i].vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, false /*fSet*/);
+    if (pVM->vmm.s.fStackGuardsStationed)
+    {
+        for (VMCPUID i = 0; i < pVM->cCpus; i++)
+        {
+            uint8_t *pbEMTStackR3 = pVM->aCpus[i].vmm.s.pbEMTStackR3;
+            MMR3HyperSetGuard(pVM, pbEMTStackR3 - PAGE_SIZE,      PAGE_SIZE, false /*fSet*/);
+            MMR3HyperSetGuard(pVM, pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, false /*fSet*/);
+        }
+        pVM->vmm.s.fStackGuardsStationed = false;
     }
 #endif
Index: trunk/src/VBox/VMM/VMMInternal.h
===================================================================
--- trunk/src/VBox/VMM/VMMInternal.h	(revision 24580)
+++ trunk/src/VBox/VMM/VMMInternal.h	(revision 24582)
@@ -269,6 +269,9 @@
     /** Whether log flushing has been disabled or not. */
     bool                        fRCLoggerFlushingDisabled;
-    bool                        afAlignment[7]; /**< Alignment padding. */
+    bool                        afAlignment[6]; /**< Alignment padding. */
     /** @} */
+
+    /** Whether the stack guard pages have been stationed or not. */
+    bool                        fStackGuardsStationed;
 
     /** The EMT yield timer. */
Index: trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
===================================================================
--- trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp	(revision 24580)
+++ trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp	(revision 24582)
@@ -915,4 +915,5 @@
     GEN_CHECK_OFF(VMM, cbRCLogger);
     GEN_CHECK_OFF(VMM, fRCLoggerFlushingDisabled);
+    GEN_CHECK_OFF(VMM, fStackGuardsStationed);
     GEN_CHECK_OFF(VMM, pYieldTimer);
     GEN_CHECK_OFF(VMM, cYieldResumeMillies);
