diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index e30a9510e..1b78a1321 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -668,7 +668,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RDTSCP(bxInstruction_c *i) #if BX_SUPPORT_X86_64 #if BX_SUPPORT_VMX - // RDTSCP will always #UD in legacy VMX mode + // RDTSCP will always #UD in legacy VMX mode, the #UD takes priority over any other exception the instruction may incur. if (BX_CPU_THIS_PTR in_vmx_guest) { if (! SECONDARY_VMEXEC_CONTROL(VMX_VM_EXEC_CTRL3_RDTSCP)) { BX_ERROR(("%s in VMX guest: not allowed to use instruction !", i->getIaOpcodeNameShort())); diff --git a/bochs/cpu/vmx.cc b/bochs/cpu/vmx.cc index 1fa1c9e90..3a9417a58 100644 --- a/bochs/cpu/vmx.cc +++ b/bochs/cpu/vmx.cc @@ -3626,25 +3626,27 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::INVVPID(bxInstruction_c *i) void BX_CPP_AttrRegparmN(1) BX_CPU_C::INVPCID(bxInstruction_c *i) { - if (v8086_mode()) { - BX_ERROR(("INVPCID: #GP - not recognized in v8086 mode")); - exception(BX_GP_EXCEPTION, 0); - } - #if BX_SUPPORT_VMX - // INVPCID will always #UD in legacy VMX mode + // INVPCID will always #UD in legacy VMX mode, the #UD takes priority over any other exception the instruction may incur. if (BX_CPU_THIS_PTR in_vmx_guest) { if (! SECONDARY_VMEXEC_CONTROL(VMX_VM_EXEC_CTRL3_INVPCID)) { BX_ERROR(("INVPCID in VMX guest: not allowed to use instruction !")); exception(BX_UD_EXCEPTION, 0); } + } +#endif + + if (v8086_mode()) { + BX_ERROR(("INVPCID: #GP - not recognized in v8086 mode")); + exception(BX_GP_EXCEPTION, 0); + } #if BX_SUPPORT_VMX >= 2 + // INVPCID will always #UD in legacy VMX mode + if (BX_CPU_THIS_PTR in_vmx_guest) { if (VMEXIT(VMX_VM_EXEC_CTRL2_INVLPG_VMEXIT)) { VMexit_Instruction(i, VMX_VMEXIT_INVPCID); } -#endif - } #endif