Commit d47f00a6 authored by Joerg Roedel's avatar Joerg Roedel Committed by Avi Kivity

KVM: X86: Propagate fetch faults

KVM currently ignores fetch faults in the instruction
emulator. With nested-npt we could have such faults. This
patch adds the code to handle these.
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent d4f8cf66
...@@ -1198,6 +1198,9 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt, ...@@ -1198,6 +1198,9 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt,
*(unsigned long *)dest = *(unsigned long *)dest =
(ctxt->eflags & ~change_mask) | (val & change_mask); (ctxt->eflags & ~change_mask) | (val & change_mask);
if (rc == X86EMUL_PROPAGATE_FAULT)
emulate_pf(ctxt);
return rc; return rc;
} }
......
...@@ -4247,6 +4247,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu, ...@@ -4247,6 +4247,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
vcpu->arch.emulate_ctxt.perm_ok = false; vcpu->arch.emulate_ctxt.perm_ok = false;
r = x86_decode_insn(&vcpu->arch.emulate_ctxt); r = x86_decode_insn(&vcpu->arch.emulate_ctxt);
if (r == X86EMUL_PROPAGATE_FAULT)
goto done;
trace_kvm_emulate_insn_start(vcpu); trace_kvm_emulate_insn_start(vcpu);
/* Only allow emulation of specific instructions on #UD /* Only allow emulation of specific instructions on #UD
...@@ -4305,6 +4308,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu, ...@@ -4305,6 +4308,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
return handle_emulation_failure(vcpu); return handle_emulation_failure(vcpu);
} }
done:
if (vcpu->arch.emulate_ctxt.exception >= 0) { if (vcpu->arch.emulate_ctxt.exception >= 0) {
inject_emulated_exception(vcpu); inject_emulated_exception(vcpu);
r = EMULATE_DONE; r = EMULATE_DONE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment