summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMR3/GIMKvm.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-06-07 11:35:23 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2018-06-07 11:35:23 +0000
commit06145ebc6f3dc7084349f942d0d2d79e84965810 (patch)
treed256445de017310ccdfe25ee7376098e7e3bd6ae /src/VBox/VMM/VMMR3/GIMKvm.cpp
parent1613254e0b92ec3615bb68f8bd2867ac8eddc01b (diff)
downloadVirtualBox-svn-06145ebc6f3dc7084349f942d0d2d79e84965810.tar.gz
GIM,IEM: Correctly hook up hypercalls thru IEM. bugref:9044
- IEM: Pass opcode and instruction length to GIM so it can do patching. - GIM: Introduced GIMHypercallEx API for receiving hypercalls with instruction opcode+length. Hooking this into the exiting #UD code paths. - GIM: Move the VMMPatchHypercall API into GIM and corrected the name to GIMQueryHypercallOpcodeBytes. - GIM/KVM: Use GIMQueryHypercallOpcodeBytes to decide which instruction is native and cache the opcode bytes for patching. - GIM/KVM: Check the VMCALL instruction encoding length rather than assuming its always 3 bytes when patching. git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@72469 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/VMM/VMMR3/GIMKvm.cpp')
-rw-r--r--src/VBox/VMM/VMMR3/GIMKvm.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/VBox/VMM/VMMR3/GIMKvm.cpp b/src/VBox/VMM/VMMR3/GIMKvm.cpp
index 84ed66e85f8..8c2d494fef8 100644
--- a/src/VBox/VMM/VMMR3/GIMKvm.cpp
+++ b/src/VBox/VMM/VMMR3/GIMKvm.cpp
@@ -157,25 +157,16 @@ VMMR3_INT_DECL(int) gimR3KvmInit(PVM pVM)
/*
* Setup hypercall and #UD handling.
+ * Note! We always need to trap VMCALL/VMMCALL hypercall using #UDs for raw-mode VMs.
*/
for (VMCPUID i = 0; i < pVM->cCpus; i++)
EMSetHypercallInstructionsEnabled(&pVM->aCpus[i], true);
- if (ASMIsAmdCpu())
- {
- pKvm->fTrapXcptUD = true;
- pKvm->uOpCodeNative = OP_VMMCALL;
- }
- else
- {
- Assert(ASMIsIntelCpu() || ASMIsViaCentaurCpu());
- pKvm->fTrapXcptUD = false;
- pKvm->uOpCodeNative = OP_VMCALL;
- }
-
- /* We always need to trap VMCALL/VMMCALL hypercall using #UDs for raw-mode VMs. */
- if (VM_IS_RAW_MODE_ENABLED(pVM))
- pKvm->fTrapXcptUD = true;
+ size_t cbHypercall = 0;
+ rc = GIMQueryHypercallOpcodeBytes(pVM, pKvm->abOpcodeNative, sizeof(pKvm->abOpcodeNative), &cbHypercall, &pKvm->uOpcodeNative);
+ AssertLogRelRCReturn(rc, rc);
+ AssertLogRelReturn(cbHypercall == sizeof(pKvm->abOpcodeNative), VERR_GIM_IPE_1);
+ pKvm->fTrapXcptUD = pKvm->uOpcodeNative != OP_VMCALL || VM_IS_RAW_MODE_ENABLED(pVM);
return VINF_SUCCESS;
}