KVM: Allow emulation of syscalls instructions on #UD
Add the opcodes for syscall, sysenter and sysexit to the list of instructions handled by the undefined opcode handler. Signed-off-by: Christoph Egger <christoph.egger@amd.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
committed by
Avi Kivity
parent
229456fc34
commit
0cb5762ed2
@@ -2667,14 +2667,33 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
|
|||||||
|
|
||||||
r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
|
r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
|
||||||
|
|
||||||
/* Reject the instructions other than VMCALL/VMMCALL when
|
/* Only allow emulation of specific instructions on #UD
|
||||||
* try to emulate invalid opcode */
|
* (namely VMMCALL, sysenter, sysexit, syscall)*/
|
||||||
c = &vcpu->arch.emulate_ctxt.decode;
|
c = &vcpu->arch.emulate_ctxt.decode;
|
||||||
if ((emulation_type & EMULTYPE_TRAP_UD) &&
|
if (emulation_type & EMULTYPE_TRAP_UD) {
|
||||||
(!(c->twobyte && c->b == 0x01 &&
|
if (!c->twobyte)
|
||||||
(c->modrm_reg == 0 || c->modrm_reg == 3) &&
|
return EMULATE_FAIL;
|
||||||
c->modrm_mod == 3 && c->modrm_rm == 1)))
|
switch (c->b) {
|
||||||
return EMULATE_FAIL;
|
case 0x01: /* VMMCALL */
|
||||||
|
if (c->modrm_mod != 3 || c->modrm_rm != 1)
|
||||||
|
return EMULATE_FAIL;
|
||||||
|
break;
|
||||||
|
case 0x34: /* sysenter */
|
||||||
|
case 0x35: /* sysexit */
|
||||||
|
if (c->modrm_mod != 0 || c->modrm_rm != 0)
|
||||||
|
return EMULATE_FAIL;
|
||||||
|
break;
|
||||||
|
case 0x05: /* syscall */
|
||||||
|
if (c->modrm_mod != 0 || c->modrm_rm != 0)
|
||||||
|
return EMULATE_FAIL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EMULATE_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(c->modrm_reg == 0 || c->modrm_reg == 3))
|
||||||
|
return EMULATE_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
++vcpu->stat.insn_emulation;
|
++vcpu->stat.insn_emulation;
|
||||||
if (r) {
|
if (r) {
|
||||||
|
Reference in New Issue
Block a user