Index: trunk/include/VBox/vmm/hm.h
===================================================================
--- trunk/include/VBox/vmm/hm.h	(revision 74544)
+++ trunk/include/VBox/vmm/hm.h	(revision 74545)
@@ -150,4 +150,6 @@
 VMM_INT_DECL(int)               HMVmxEntryIntInfoInjectTrpmEvent(PVMCPU pVCpu, uint32_t uEntryIntInfo, uint32_t uErrCode,
                                                                  uint32_t cbInstr, RTGCUINTPTR GCPtrFaultAddress);
+VMM_INT_DECL(int)               HMVmxGetMsrPermission(void *pvMsrBitmap, uint32_t idMsr, PVMXMSREXITREAD penmRead,
+                                                      PVMXMSREXITWRITE penmWrite);
 /** @} */
 
Index: trunk/include/VBox/vmm/hm_vmx.h
===================================================================
--- trunk/include/VBox/vmm/hm_vmx.h	(revision 74544)
+++ trunk/include/VBox/vmm/hm_vmx.h	(revision 74545)
@@ -1051,4 +1051,29 @@
 /** @} */
 
+/**
+ * VMX MSR-bitmap read permissions.
+ */
+typedef enum VMXMSREXITREAD
+{
+    /** Reading this MSR causes a VM-exit. */
+    VMXMSREXIT_INTERCEPT_READ = 1,
+    /** Reading this MSR doesn't cause a VM-exit. */
+    VMXMSREXIT_PASSTHRU_READ
+} VMXMSREXITREAD;
+/** Pointer to MSR-bitmap read permissions. */
+typedef VMXMSREXITREAD* PVMXMSREXITREAD;
+
+/**
+ * VMX MSR-bitmap write permissions.
+ */
+typedef enum VMXMSREXITWRITE
+{
+    /** Writing to this MSR causes a VM-exit. */
+    VMXMSREXIT_INTERCEPT_WRITE = 3,
+    /** Writing to this MSR does not cause a VM-exit. */
+    VMXMSREXIT_PASSTHRU_WRITE
+} VMXMSREXITWRITE;
+/** Pointer to MSR-bitmap write permissions. */
+typedef VMXMSREXITWRITE* PVMXMSREXITWRITE;
 
 /**
Index: trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp	(revision 74544)
+++ trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp	(revision 74545)
@@ -878,2 +878,79 @@
 }
 
+
+/**
+ * Gets the permission bits for the specified MSR in the specified MSR bitmap.
+ *
+ * @returns VBox status code.
+ * @param   pvMsrBitmap     Pointer to the MSR bitmap.
+ * @param   idMsr           The MSR.
+ * @param   penmRead        Where to store the read permissions. Optional, can be
+ *                          NULL.
+ * @param   penmWrite       Where to store the write permissions. Optional, can be
+ *                          NULL.
+ */
+VMM_INT_DECL(int) HMVmxGetMsrPermission(void *pvMsrBitmap, uint32_t idMsr, PVMXMSREXITREAD penmRead,
+                                        PVMXMSREXITWRITE penmWrite)
+{
+    AssertPtrReturn(pvMsrBitmap, VERR_INVALID_PARAMETER);
+
+    int32_t iBit;
+    uint8_t *pbMsrBitmap = (uint8_t *)pvMsrBitmap;
+
+    /*
+     * MSR Layout:
+     *   Byte index            MSR range            Interpreted as
+     * 0x000 - 0x3ff    0x00000000 - 0x00001fff    Low MSR read bits.
+     * 0x400 - 0x7ff    0xc0000000 - 0xc0001fff    High MSR read bits.
+     * 0x800 - 0xbff    0x00000000 - 0x00001fff    Low MSR write bits.
+     * 0xc00 - 0xfff    0xc0000000 - 0xc0001fff    High MSR write bits.
+     *
+     * A bit corresponding to an MSR within the above range causes a VM-exit
+     * if the bit is 1 on executions of RDMSR/WRMSR.
+     *
+     * If an MSR falls out of the MSR range, it always cause a VM-exit.
+     *
+     * See Intel spec. 24.6.9 "MSR-Bitmap Address".
+     */
+    if (idMsr <= 0x00001fff)
+        iBit = idMsr;
+    else if (   idMsr >= 0xc0000000
+             && idMsr <= 0xc0001fff)
+    {
+        iBit = (idMsr - 0xc0000000);
+        pbMsrBitmap += 0x400;
+    }
+    else
+    {
+        if (penmRead)
+            *penmRead = VMXMSREXIT_INTERCEPT_READ;
+        if (penmWrite)
+            *penmWrite = VMXMSREXIT_INTERCEPT_WRITE;
+        Log(("HMVmxGetMsrPermission: Warning! Out of range MSR %#RX32\n", idMsr));
+        return VINF_SUCCESS;
+    }
+
+    /* Validate the MSR bit position. */
+    Assert(iBit <= 0x1fff);
+
+    /* Get the MSR read permissions. */
+    if (penmRead)
+    {
+        if (ASMBitTest(pbMsrBitmap, iBit))
+            *penmRead = VMXMSREXIT_INTERCEPT_READ;
+        else
+            *penmRead = VMXMSREXIT_PASSTHRU_READ;
+    }
+
+    /* Get the MSR write permissions. */
+    if (penmWrite)
+    {
+        if (ASMBitTest(pbMsrBitmap + 0x800, iBit))
+            *penmWrite = VMXMSREXIT_INTERCEPT_WRITE;
+        else
+            *penmWrite = VMXMSREXIT_PASSTHRU_WRITE;
+    }
+
+    return VINF_SUCCESS;
+}
+
Index: trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 74544)
+++ trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 74545)
@@ -310,30 +310,4 @@
 /** Pointer to VMX transient state. */
 typedef VMXTRANSIENT *PVMXTRANSIENT;
-
-/**
- * MSR-bitmap read permissions.
- */
-typedef enum VMXMSREXITREAD
-{
-    /** Reading this MSR causes a VM-exit. */
-    VMXMSREXIT_INTERCEPT_READ = 0xb,
-    /** Reading this MSR does not cause a VM-exit. */
-    VMXMSREXIT_PASSTHRU_READ
-} VMXMSREXITREAD;
-/** Pointer to MSR-bitmap read permissions. */
-typedef VMXMSREXITREAD* PVMXMSREXITREAD;
-
-/**
- * MSR-bitmap write permissions.
- */
-typedef enum VMXMSREXITWRITE
-{
-    /** Writing to this MSR causes a VM-exit. */
-    VMXMSREXIT_INTERCEPT_WRITE = 0xd,
-    /** Writing to this MSR does not cause a VM-exit. */
-    VMXMSREXIT_PASSTHRU_WRITE
-} VMXMSREXITWRITE;
-/** Pointer to MSR-bitmap write permissions. */
-typedef VMXMSREXITWRITE* PVMXMSREXITWRITE;
 
 /**
@@ -1202,9 +1176,17 @@
 
     /*
-     * Layout:
-     * 0x000 - 0x3ff - Low MSR read bits
-     * 0x400 - 0x7ff - High MSR read bits
-     * 0x800 - 0xbff - Low MSR write bits
-     * 0xc00 - 0xfff - High MSR write bits
+     * MSR Layout:
+     *   Byte index            MSR range            Interpreted as
+     * 0x000 - 0x3ff    0x00000000 - 0x00001fff    Low MSR read bits.
+     * 0x400 - 0x7ff    0xc0000000 - 0xc0001fff    High MSR read bits.
+     * 0x800 - 0xbff    0x00000000 - 0x00001fff    Low MSR write bits.
+     * 0xc00 - 0xfff    0xc0000000 - 0xc0001fff    High MSR write bits.
+     *
+     * A bit corresponding to an MSR within the above range causes a VM-exit
+     * if the bit is 1 on executions of RDMSR/WRMSR.
+     *
+     * If an MSR falls out of the MSR range, it always cause a VM-exit.
+     *
+     * See Intel spec. 24.6.9 "MSR-Bitmap Address".
      */
     if (uMsr <= 0x00001fff)
@@ -1229,52 +1211,4 @@
         ASMBitClear(pbMsrBitmap + 0x800, iBit);
 }
-
-
-#ifdef VBOX_STRICT
-/**
- * Gets the permission bits for the specified MSR in the MSR bitmap.
- *
- * @returns VBox status code.
- * @retval VINF_SUCCESS        if the specified MSR is found.
- * @retval VERR_NOT_FOUND      if the specified MSR is not found.
- * @retval VERR_NOT_SUPPORTED  if VT-x doesn't allow the MSR.
- *
- * @param   pVCpu           The cross context virtual CPU structure.
- * @param   uMsr            The MSR.
- * @param   penmRead        Where to store the read permissions.
- * @param   penmWrite       Where to store the write permissions.
- */
-static int hmR0VmxGetMsrPermission(PVMCPU pVCpu, uint32_t uMsr, PVMXMSREXITREAD penmRead, PVMXMSREXITWRITE penmWrite)
-{
-    AssertPtrReturn(penmRead,  VERR_INVALID_PARAMETER);
-    AssertPtrReturn(penmWrite, VERR_INVALID_PARAMETER);
-    int32_t iBit;
-    uint8_t *pbMsrBitmap = (uint8_t *)pVCpu->hm.s.vmx.pvMsrBitmap;
-
-    /* See hmR0VmxSetMsrPermission() for the layout. */
-    if (uMsr <= 0x00001fff)
-        iBit = uMsr;
-    else if (   uMsr >= 0xc0000000
-             && uMsr <= 0xc0001fff)
-    {
-        iBit = (uMsr - 0xc0000000);
-        pbMsrBitmap += 0x400;
-    }
-    else
-        AssertMsgFailedReturn(("hmR0VmxGetMsrPermission: Invalid MSR %#RX32\n", uMsr), VERR_NOT_SUPPORTED);
-
-    Assert(iBit <= 0x1fff);
-    if (ASMBitTest(pbMsrBitmap, iBit))
-        *penmRead = VMXMSREXIT_INTERCEPT_READ;
-    else
-        *penmRead = VMXMSREXIT_PASSTHRU_READ;
-
-    if (ASMBitTest(pbMsrBitmap + 0x800, iBit))
-        *penmWrite = VMXMSREXIT_INTERCEPT_WRITE;
-    else
-        *penmWrite = VMXMSREXIT_PASSTHRU_WRITE;
-    return VINF_SUCCESS;
-}
-#endif /* VBOX_STRICT */
 
 
@@ -1782,6 +1716,6 @@
             VMXMSREXITREAD  enmRead;
             VMXMSREXITWRITE enmWrite;
-            rc = hmR0VmxGetMsrPermission(pVCpu, pGuestMsr->u32Msr, &enmRead, &enmWrite);
-            AssertMsgReturnVoid(rc == VINF_SUCCESS, ("hmR0VmxGetMsrPermission! failed. rc=%Rrc\n", rc));
+            rc = HMVmxGetMsrPermission(pVCpu->hm.s.vmx.pvMsrBitmap, pGuestMsr->u32Msr, &enmRead, &enmWrite);
+            AssertMsgReturnVoid(rc == VINF_SUCCESS, ("HMVmxGetMsrPermission! failed. rc=%Rrc\n", rc));
             if (pGuestMsr->u32Msr == MSR_K6_EFER)
             {
@@ -12002,5 +11936,5 @@
             VMXMSREXITREAD  enmRead;
             VMXMSREXITWRITE enmWrite;
-            int rc2 = hmR0VmxGetMsrPermission(pVCpu, idMsr, &enmRead, &enmWrite);
+            int rc2 = HMVmxGetMsrPermission(pVCpu->hm.s.vmx.pvMsrBitmap, idMsr, &enmRead, &enmWrite);
             AssertRCReturn(rc2, rc2);
             if (enmRead == VMXMSREXIT_PASSTHRU_READ)
@@ -12134,5 +12068,5 @@
                         VMXMSREXITREAD  enmRead;
                         VMXMSREXITWRITE enmWrite;
-                        int rc2 = hmR0VmxGetMsrPermission(pVCpu, idMsr, &enmRead, &enmWrite);
+                        int rc2 = HMVmxGetMsrPermission(pVCpu->hm.s.vmx.pvMsrBitmap, idMsr, &enmRead, &enmWrite);
                         AssertRCReturn(rc2, rc2);
                         if (enmWrite == VMXMSREXIT_PASSTHRU_WRITE)
