Index: /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 81236)
+++ /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 81237)
@@ -4672,6 +4672,27 @@
     if (ASMAtomicUoReadU64(&pVCpu->hm.s.fCtxChanged) & HM_CHANGED_VMX_ENTRY_EXIT_CTLS)
     {
-        PVMCC          pVM = pVCpu->CTX_SUFF(pVM);
-        PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo;
+        PVMCC        pVM            = pVCpu->CTX_SUFF(pVM);
+        PVMXVMCSINFO pVmcsInfo      = pVmxTransient->pVmcsInfo;
+        bool const   fGstInLongMode = CPUMIsGuestInLongModeEx(&pVCpu->cpum.GstCtx);
+
+        /*
+         * VMRUN function.
+         */
+        {
+            /* If the guest is in long mode, use the 64-bit guest handler, else the 32-bit guest handler.
+             * The host is always 64-bit since we no longer support 32-bit hosts.
+             */
+            if (fGstInLongMode)
+            {
+#ifndef VBOX_WITH_64_BITS_GUESTS
+                return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
+#else
+                Assert(pVM->hm.s.fAllow64BitGuests);                          /* Guaranteed by hmR3InitFinalizeR0(). */
+                pVmcsInfo->pfnStartVM = VMXR0StartVM64;
+#endif
+            }
+            else
+                pVmcsInfo->pfnStartVM = VMXR0StartVM32;
+        }
 
         /*
@@ -4700,5 +4721,5 @@
              * here rather than while merging the guest VMCS controls.
              */
-            if (CPUMIsGuestInLongModeEx(&pVCpu->cpum.GstCtx))
+            if (fGstInLongMode)
             {
                 Assert(pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_LME);
@@ -6517,38 +6538,4 @@
     }
 
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Selects up the appropriate function to run guest code.
- *
- * @returns VBox status code.
- * @param   pVCpu           The cross context virtual CPU structure.
- * @param   pVmxTransient   The VMX-transient structure.
- *
- * @remarks No-long-jump zone!!!
- */
-static int hmR0VmxSelectVMRunHandler(PVMCPUCC pVCpu, PCVMXTRANSIENT pVmxTransient)
-{
-    PCCPUMCTX    pCtx      = &pVCpu->cpum.GstCtx;
-    PVMXVMCSINFO pVmcsInfo = pVmxTransient->pVmcsInfo;
-
-    if (CPUMIsGuestInLongModeEx(pCtx))
-    {
-#ifndef VBOX_WITH_64_BITS_GUESTS
-        return VERR_PGM_UNSUPPORTED_SHADOW_PAGING_MODE;
-#else
-        Assert(pVCpu->CTX_SUFF(pVM)->hm.s.fAllow64BitGuests);    /* Guaranteed by hmR3InitFinalizeR0(). */
-        /* Guest is in long mode, use the 64-bit handler (host is 64-bit). */
-        pVmcsInfo->pfnStartVM = VMXR0StartVM64;
-#endif
-    }
-    else
-    {
-        /* Guest is not in long mode, use the 32-bit handler. */
-        pVmcsInfo->pfnStartVM = VMXR0StartVM32;
-    }
-    Assert(pVmcsInfo->pfnStartVM);
     return VINF_SUCCESS;
 }
@@ -9049,12 +9036,5 @@
      * Ideally, assert that the cross-dependent bits are up-to-date at the point of using it.
      */
-    /** @todo r=ramshankar: Move hmR0VmxSelectVMRunHandler inside
-     *        hmR0VmxExportGuestEntryExitCtls and do it conditionally. There shouldn't
-     *        be a need to evaluate this everytime since I'm pretty sure we intercept
-     *        all guest paging mode changes. */
-    int rc = hmR0VmxSelectVMRunHandler(pVCpu, pVmxTransient);
-    AssertLogRelMsgRCReturn(rc, ("rc=%Rrc\n", rc), rc);
-
-    rc = hmR0VmxExportGuestEntryExitCtls(pVCpu, pVmxTransient);
+    int rc = hmR0VmxExportGuestEntryExitCtls(pVCpu, pVmxTransient);
     AssertLogRelMsgRCReturn(rc, ("rc=%Rrc\n", rc), rc);
 
