Index: /trunk/include/VBox/err.h
===================================================================
--- /trunk/include/VBox/err.h	(revision 45473)
+++ /trunk/include/VBox/err.h	(revision 45474)
@@ -1858,12 +1858,8 @@
 /** Invalid VMXON pointer. */
 #define VERR_VMX_INVALID_VMXON_PTR                  (-4002)
-/** Generic VMX failure. */
-#define VERR_VMX_GENERIC                            (-4003)
 /** Invalid CPU mode for VMX execution. */
 #define VERR_VMX_UNSUPPORTED_MODE                   (-4004)
 /** Unable to start VM execution. */
 #define VERR_VMX_UNABLE_TO_START_VM                 (-4005)
-/** Unable to resume VM execution. */
-#define VERR_VMX_UNABLE_TO_RESUME_VM                (-4006)
 /** Unable to switch due to invalid host state. */
 #define VERR_VMX_INVALID_HOST_STATE                 (-4007)
@@ -1894,4 +1890,6 @@
 /** Resume guest execution after injecting a double-fault. */
 #define VINF_VMX_DOUBLE_FAULT                       4020
+/** VMPTRLD failed; possibly because of invalid VMCS launch-state. */
+#define VERR_VMX_VMPTRLD_FAILED                     (-4021)
 /** @} */
 
Index: /trunk/include/VBox/err.mac
===================================================================
--- /trunk/include/VBox/err.mac	(revision 45473)
+++ /trunk/include/VBox/err.mac	(revision 45474)
@@ -682,5 +682,4 @@
 %define VERR_VMX_INVALID_VMCS_PTR    (-4001)
 %define VERR_VMX_INVALID_VMXON_PTR    (-4002)
-%define VERR_VMX_GENERIC    (-4003)
 %define VERR_VMX_UNSUPPORTED_MODE    (-4004)
 %define VERR_VMX_UNABLE_TO_START_VM    (-4005)
@@ -698,4 +697,7 @@
 %define VERR_VMX_UNEXPECTED_INTERRUPTION_EXIT_CODE    (-4017)
 %define VERR_VMX_NOT_IN_VMX_ROOT_MODE    (-4018)
+%define VERR_VMX_UNDEFINED_EXIT_CODE     (-4019)
+%define VINF_VMX_DOUBLE_FAULT              4020
+%define VERR_VMX_VMPTRLD_FAILED          (-4021)
 %define VERR_SVM_UNABLE_TO_START_VM    (-4050)
 %define VERR_SVM_ILLEGAL_EFER_MSR    (-4051)
Index: /trunk/include/VBox/vmm/hm_vmx.h
===================================================================
--- /trunk/include/VBox/vmm/hm_vmx.h	(revision 45473)
+++ /trunk/include/VBox/vmm/hm_vmx.h	(revision 45474)
@@ -1473,5 +1473,5 @@
        "jmp      2f                                             \n\t"
        "1:                                                      \n\t"
-       "movl     $"STR(VERR_VMX_GENERIC)", %0                   \n\t"
+       "movl     $"STR(VERR_VMX_VMXON_FAILED)", %0              \n\t"
        "2:                                                      \n\t"
        "add      $8, %%esp                                      \n\t"
@@ -1498,5 +1498,5 @@
 vmxon_good:
         jnz     the_end
-        mov     dword ptr [rc], VERR_VMX_GENERIC
+        mov     dword ptr [rc], VERR_VMX_VMXON_FAILED
 the_end:
         add     esp, 8
Index: /trunk/src/VBox/VMM/VMMR0/HMR0A.asm
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMR0A.asm	(revision 45473)
+++ /trunk/src/VBox/VMM/VMMR0/HMR0A.asm	(revision 45474)
@@ -567,5 +567,5 @@
 .good:
     jnz     .the_end
-    mov     eax, VERR_VMX_GENERIC
+    mov     eax, VERR_VMX_VMXON_FAILED
 
 .the_end:
Index: /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 45473)
+++ /trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp	(revision 45474)
@@ -387,5 +387,6 @@
  * @param    pVM        Pointer to the VM.
  * @param    pVCpu      Pointer to the VMCPU (can be NULL if @a rc is not
- *                      VERR_VMX_GENERIC).
+ *                      VERR_VMX_UNABLE_TO_START_VM or
+ *                      VERR_VMX_INVALID_VMCS_FIELD).
  * @param    rc         The error code.
  */
@@ -393,5 +394,6 @@
 {
     AssertPtr(pVM);
-    if (rc == VERR_VMX_GENERIC)
+    if (   rc == VERR_VMX_INVALID_VMCS_FIELD
+        || rc == VERR_VMX_UNABLE_TO_START_VM)
     {
         AssertPtrReturnVoid(pVCpu);
@@ -603,4 +605,6 @@
     /* Enter VMXON root mode. */
     int rc = VMXEnable(HCPhysCpuPage);
+    if (RT_FAILURE(rc))
+        ASMSetCR4(uCr4);
 
     /* Restore interrupts. */
@@ -1533,5 +1537,8 @@
     /* Enable the VMX preemption timer. */
     if (pVM->hm.s.vmx.fUsePreemptTimer)
+    {
+        Assert(pVM->hm.s.vmx.msr.vmx_pin_ctls.n.allowed1 & VMX_VMCS_CTRL_PIN_EXEC_CONTROLS_PREEMPT_TIMER);
         val |= VMX_VMCS_CTRL_PIN_EXEC_CONTROLS_PREEMPT_TIMER;
+    }
 
     if ((val & zap) != val)
@@ -1657,5 +1664,5 @@
      * Secondary processor-based VM-execution controls.
      */
-    if (pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL)
+    if (RT_LIKELY(pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL))
     {
         val = pVM->hm.s.vmx.msr.vmx_proc_ctls2.n.disallowed0;           /* Bits set here must be set in the VMCS. */
@@ -3741,7 +3748,6 @@
             AssertFailed();
             break;
-        case VINF_SUCCESS:      /* VMLAUNCH/VMRESUME succeeded but VM-entry failed... yeah, true story. */
-        case VERR_VMX_UNABLE_TO_START_VM:
-        case VERR_VMX_UNABLE_TO_RESUME_VM:
+        case VINF_SUCCESS:                  /* VMLAUNCH/VMRESUME succeeded but VM-entry failed... yeah, true story. */
+        case VERR_VMX_UNABLE_TO_START_VM:   /* VMLAUNCH/VMRESUME itself failed. */
         {
             int rc = VMXReadVmcs32(VMX_VMCS32_RO_EXIT_REASON, &pVCpu->hm.s.vmx.lasterror.u32ExitReason);
@@ -4099,5 +4105,5 @@
         ASMSetCR4(ASMGetCR4() & ~X86_CR4_VMXE);
         ASMSetFlags(uOldEFlags);
-        return VERR_VMX_VMXON_FAILED;
+        return rc2;
     }
 
@@ -6924,5 +6930,5 @@
 
 /**
- * VM-exit handler for WBINVD (VMX_EXIT_INVD). Unconditional VM-exit.
+ * VM-exit handler for INVD (VMX_EXIT_INVD). Unconditional VM-exit.
  */
 static DECLCALLBACK(int) hmR0VmxExitInvd(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, PVMXTRANSIENT pVmxTransient)
Index: /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp	(revision 45473)
+++ /trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp	(revision 45474)
@@ -179,5 +179,6 @@
 static void hmR0VmxCheckError(PVM pVM, PVMCPU pVCpu, int rc)
 {
-    if (rc == VERR_VMX_GENERIC)
+    if (   rc == VERR_VMX_UNABLE_TO_START_VM
+        || rc == VERR_VMX_INVALID_VMCS_FIELD)
     {
         RTCCUINTREG instrError;
@@ -535,5 +536,5 @@
                  */
                 pVM->hm.s.vmx.enmFlushEpt = VMX_FLUSH_EPT_NOT_SUPPORTED;
-                return VERR_VMX_GENERIC;
+                return VERR_HM_UNSUPPORTED_CPU_FEATURE_COMBO;
             }
         }
@@ -544,5 +545,5 @@
              */
             pVM->hm.s.vmx.enmFlushEpt = VMX_FLUSH_EPT_NOT_SUPPORTED;
-            return VERR_VMX_GENERIC;
+            return VERR_HM_UNSUPPORTED_CPU_FEATURE_COMBO;
         }
     }
@@ -5285,5 +5286,4 @@
 
         case VERR_VMX_UNABLE_TO_START_VM:
-        case VERR_VMX_UNABLE_TO_RESUME_VM:
         {
             int         rc2;
Index: /trunk/src/VBox/VMM/VMMR3/HM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/HM.cpp	(revision 45473)
+++ /trunk/src/VBox/VMM/VMMR3/HM.cpp	(revision 45474)
@@ -2634,10 +2634,4 @@
                 break;
 
-            case VERR_VMX_UNABLE_TO_RESUME_VM:
-                LogRel(("HM: VERR_VMX_UNABLE_TO_RESUME_VM:\n"));
-                LogRel(("HM: CPU%d instruction error %x\n", i, pVM->aCpus[i].hm.s.vmx.lasterror.u32InstrError));
-                LogRel(("HM: CPU%d exit reason       %x\n", i, pVM->aCpus[i].hm.s.vmx.lasterror.u32ExitReason));
-                break;
-
             case VERR_VMX_INVALID_VMXON_PTR:
                 break;
Index: /trunk/src/VBox/VMM/VMMRC/HMRCA.asm
===================================================================
--- /trunk/src/VBox/VMM/VMMRC/HMRCA.asm	(revision 45473)
+++ /trunk/src/VBox/VMM/VMMRC/HMRCA.asm	(revision 45474)
@@ -113,5 +113,5 @@
 .vmxon_success:
     jnz     .vmxon_success2
-    mov     rax, VERR_VMX_GENERIC
+    mov     rax, VERR_VMX_VMXON_FAILED
     jmp     .vmstart64_vmxon_failed
 
@@ -125,5 +125,5 @@
 .vmptrld_success:
     jnz     .vmptrld_success2
-    mov     rax, VERR_VMX_GENERIC
+    mov     rax, VERR_VMX_VMPTRLD_FAILED
     jmp     .vmstart64_vmxoff_end
 
Index: /trunk/src/VBox/VMM/include/EMHandleRCTmpl.h
===================================================================
--- /trunk/src/VBox/VMM/include/EMHandleRCTmpl.h	(revision 45473)
+++ /trunk/src/VBox/VMM/include/EMHandleRCTmpl.h	(revision 45474)
@@ -346,5 +346,4 @@
         case VERR_VMX_INVALID_GUEST_STATE:
         case VERR_VMX_UNABLE_TO_START_VM:
-        case VERR_VMX_UNABLE_TO_RESUME_VM:
             HMR3CheckError(pVM, rc);
             break;
