Index: /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp	(revision 30065)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp	(revision 30066)
@@ -1245,11 +1245,13 @@
 VMMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock)
 {
+    int rc = pgmLock(pVM);
+    AssertRCReturn(rc, rc);
+
 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
-
     /*
      * Find the page and make sure it's writable.
      */
     PPGMPAGE pPage;
-    int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhys, &pPage);
+    rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhys, &pPage);
     if (RT_SUCCESS(rc))
     {
@@ -1271,7 +1273,4 @@
 
 #else  /* IN_RING3 || IN_RING0 */
-    int rc = pgmLock(pVM);
-    AssertRCReturn(rc, rc);
-
     /*
      * Query the Physical TLB entry for the page (may fail).
@@ -1325,6 +1324,6 @@
     }
 
+#endif /* IN_RING3 || IN_RING0 */
     pgmUnlock(pVM);
-#endif /* IN_RING3 || IN_RING0 */
     return rc;
 }
@@ -1357,11 +1356,13 @@
 VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock)
 {
+    int rc = pgmLock(pVM);
+    AssertRCReturn(rc, rc);
+
 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
-
     /*
      * Find the page and make sure it's readable.
      */
     PPGMPAGE pPage;
-    int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhys, &pPage);
+    rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhys, &pPage);
     if (RT_SUCCESS(rc))
     {
@@ -1383,7 +1384,4 @@
 
 #else  /* IN_RING3 || IN_RING0 */
-    int rc = pgmLock(pVM);
-    AssertRCReturn(rc, rc);
-
     /*
      * Query the Physical TLB entry for the page (may fail).
@@ -1427,6 +1425,6 @@
     }
 
+#endif /* IN_RING3 || IN_RING0 */
     pgmUnlock(pVM);
-#endif /* IN_RING3 || IN_RING0 */
     return rc;
 }
