aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-02-01 09:32:04 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2011-03-17 12:08:28 -0400
commit4005996e428b0d3df10cd0eba389a14b9f5403e4 (patch)
tree2a91030c3c0f0f22120dccb0311fb7688e22d33c /arch/x86/kvm
parentd867162c6d1028d16358f4d2383d1833a849c74d (diff)
KVM: Drop ad-hoc vendor specific instruction restriction
Use the new support in the emulator, and drop the ad-hoc code in x86.c. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/x86.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dd8016d2efa9..8575d85202d7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4411,39 +4411,16 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
4411 vcpu->arch.emulate_ctxt.have_exception = false; 4411 vcpu->arch.emulate_ctxt.have_exception = false;
4412 vcpu->arch.emulate_ctxt.perm_ok = false; 4412 vcpu->arch.emulate_ctxt.perm_ok = false;
4413 4413
4414 vcpu->arch.emulate_ctxt.only_vendor_specific_insn
4415 = emulation_type & EMULTYPE_TRAP_UD;
4416
4414 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, insn, insn_len); 4417 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, insn, insn_len);
4415 4418
4416 trace_kvm_emulate_insn_start(vcpu); 4419 trace_kvm_emulate_insn_start(vcpu);
4417
4418 /* Only allow emulation of specific instructions on #UD
4419 * (namely VMMCALL, sysenter, sysexit, syscall)*/
4420 if (emulation_type & EMULTYPE_TRAP_UD) {
4421 if (!c->twobyte)
4422 return EMULATE_FAIL;
4423 switch (c->b) {
4424 case 0x01: /* VMMCALL */
4425 if (c->modrm_mod != 3 || c->modrm_rm != 1)
4426 return EMULATE_FAIL;
4427 break;
4428 case 0x34: /* sysenter */
4429 case 0x35: /* sysexit */
4430 if (c->modrm_mod != 0 || c->modrm_rm != 0)
4431 return EMULATE_FAIL;
4432 break;
4433 case 0x05: /* syscall */
4434 if (c->modrm_mod != 0 || c->modrm_rm != 0)
4435 return EMULATE_FAIL;
4436 break;
4437 default:
4438 return EMULATE_FAIL;
4439 }
4440
4441 if (!(c->modrm_reg == 0 || c->modrm_reg == 3))
4442 return EMULATE_FAIL;
4443 }
4444
4445 ++vcpu->stat.insn_emulation; 4420 ++vcpu->stat.insn_emulation;
4446 if (r) { 4421 if (r) {
4422 if (emulation_type & EMULTYPE_TRAP_UD)
4423 return EMULATE_FAIL;
4447 if (reexecute_instruction(vcpu, cr2)) 4424 if (reexecute_instruction(vcpu, cr2))
4448 return EMULATE_DONE; 4425 return EMULATE_DONE;
4449 if (emulation_type & EMULTYPE_SKIP) 4426 if (emulation_type & EMULTYPE_SKIP)