diff options
author | Sean Christopherson <sean.j.christopherson@intel.com> | 2019-08-27 23:40:33 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-09-24 14:31:01 +0200 |
commit | c83fad65e2cae1aa570a519b33e8ebf00f6e7227 (patch) | |
tree | 03a35fb64cc436d1a8018abd592420c42b651471 /arch/x86/kvm/x86.c | |
parent | KVM: x86: Add explicit flag for forced emulation on #UD (diff) | |
download | linux-c83fad65e2cae1aa570a519b33e8ebf00f6e7227.tar.xz linux-c83fad65e2cae1aa570a519b33e8ebf00f6e7227.zip |
KVM: x86: Move #UD injection for failed emulation into emulation code
Immediately inject a #UD and return EMULATE done if emulation fails when
handling an intercepted #UD. This helps pave the way for removing
EMULATE_FAIL altogether.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | arch/x86/kvm/x86.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index eb2ed5c9a584..64d584d48c60 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5440,7 +5440,6 @@ EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); int handle_ud(struct kvm_vcpu *vcpu) { int emul_type = EMULTYPE_TRAP_UD; - enum emulation_result er; char sig[5]; /* ud2; .ascii "kvm" */ struct x86_exception e; @@ -5452,12 +5451,7 @@ int handle_ud(struct kvm_vcpu *vcpu) emul_type = EMULTYPE_TRAP_UD_FORCED; } - er = kvm_emulate_instruction(vcpu, emul_type); - if (er == EMULATE_USER_EXIT) - return 0; - if (er != EMULATE_DONE) - kvm_queue_exception(vcpu, UD_VECTOR); - return 1; + return kvm_emulate_instruction(vcpu, emul_type) != EMULATE_USER_EXIT; } EXPORT_SYMBOL_GPL(handle_ud); @@ -6630,8 +6624,10 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, ++vcpu->stat.insn_emulation; if (r != EMULATION_OK) { if ((emulation_type & EMULTYPE_TRAP_UD) || - (emulation_type & EMULTYPE_TRAP_UD_FORCED)) - return EMULATE_FAIL; + (emulation_type & EMULTYPE_TRAP_UD_FORCED)) { + kvm_queue_exception(vcpu, UD_VECTOR); + return EMULATE_DONE; + } if (reexecute_instruction(vcpu, cr2, write_fault_to_spt, emulation_type)) return EMULATE_DONE; |