Index: /trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h	(revision 79599)
+++ /trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h	(revision 79600)
@@ -2518,4 +2518,7 @@
     }
 
+    /* Paranoia. */
+    Assert(uExitReason != VMX_EXIT_XCPT_OR_NMI || VMX_EXIT_INT_INFO_IS_VALID(pVmcs->u32RoExitIntInfo));
+
     /*
      * Save the guest state back into the VMCS.
@@ -3420,58 +3423,16 @@
  *
  * @returns VBox strict status code.
- * @param   pVCpu               The cross context virtual CPU structure.
- * @param   pExitInfo           Pointer to the VM-exit information.
- * @param   pExitEventInfo      Pointer to the VM-exit event information.
+ * @param   pVCpu           The cross context virtual CPU structure.
+ * @param   pExitInfo       Pointer to the VM-exit information.
+ * @param   pExitEventInfo  Pointer to the VM-exit event information.
  */
 IEM_STATIC VBOXSTRICTRC iemVmxVmexitTaskSwitchWithInfo(PVMCPU pVCpu, PCVMXVEXITINFO pExitInfo,
                                                        PCVMXVEXITEVENTINFO pExitEventInfo)
 {
-    /* The Exit qualification is mandatory for all task-switch VM-exits. */
-    uint64_t const u64ExitQual = pExitInfo->u64Qual;
-    iemVmxVmcsSetExitQual(pVCpu, u64ExitQual);
-
-    /*
-     * Figure out if an instruction was the source of the task switch.
-     *
-     * If the task-switch was due to CALL/IRET/JMP instruction or due to the delivery
-     * of an event generated by a software interrupt (INT-N), privileged software
-     * interrupt (INT1/ICEBP) or software exception (INT3/INTO) then the CPU provides
-     * the instruction length.
-     */
-    bool fHasInstrLen;
-    if (VMX_EXIT_QUAL_TASK_SWITCH_TYPE(u64ExitQual) == VMX_EXIT_QUAL_TASK_SWITCH_TYPE_IDT)
-    {
-        /* Check if an event delivery through IDT caused a task switch VM-exit. */
-        uint32_t const uIdtVectInfo      = pExitEventInfo->uIdtVectoringInfo;
-        bool const     fIdtVectInfoValid = VMX_IDT_VECTORING_INFO_IS_VALID(uIdtVectInfo);
-        if (fIdtVectInfoValid)
-        {
-            iemVmxVmcsSetIdtVectoringInfo(pVCpu, uIdtVectInfo);
-            if (VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(uIdtVectInfo))
-                iemVmxVmcsSetIdtVectoringErrCode(pVCpu, pExitEventInfo->uIdtVectoringErrCode);
-
-            uint8_t const fIdtVectType = VMX_IDT_VECTORING_INFO_TYPE(uIdtVectInfo);
-            if (   fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_SW_INT
-                || fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT
-                || fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT)
-                fHasInstrLen = true;
-            else
-                fHasInstrLen = false;
-        }
-        else
-            fHasInstrLen = false;
-    }
-    else
-    {
-        /* CALL, IRET or JMP instruction caused the task switch VM-exit. */
-        fHasInstrLen = true;
-    }
-
-    if (fHasInstrLen)
-    {
-        Assert(pExitInfo->cbInstr > 0);
-        iemVmxVmcsSetExitInstrLen(pVCpu, pExitInfo->cbInstr);
-    }
-    return iemVmxVmexit(pVCpu, VMX_EXIT_TASK_SWITCH, u64ExitQual);
+    Assert(pExitInfo->uReason == VMX_EXIT_TASK_SWITCH);
+    iemVmxVmcsSetExitInstrLen(pVCpu, pExitInfo->cbInstr);
+    iemVmxVmcsSetIdtVectoringInfo(pVCpu, pExitEventInfo->uIdtVectoringInfo);
+    iemVmxVmcsSetIdtVectoringErrCode(pVCpu, pExitEventInfo->uIdtVectoringErrCode);
+    return iemVmxVmexit(pVCpu, VMX_EXIT_TASK_SWITCH, pExitInfo->u64Qual);
 }
 
