diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-09-10 11:30:56 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:52:41 -0400 |
commit | d47f00a62b2e14b4a811b87bdb9ea1809693a377 (patch) | |
tree | 85f0697d0714818c8f0d92047905782f275c9ce3 | |
parent | d4f8cf664e4c1fd579df6b6e6378335c9f79d790 (diff) |
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: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/emulate.c | 3 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 2b08b78b6cab..aead72e141b4 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1198,6 +1198,9 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt, | |||
1198 | *(unsigned long *)dest = | 1198 | *(unsigned long *)dest = |
1199 | (ctxt->eflags & ~change_mask) | (val & change_mask); | 1199 | (ctxt->eflags & ~change_mask) | (val & change_mask); |
1200 | 1200 | ||
1201 | if (rc == X86EMUL_PROPAGATE_FAULT) | ||
1202 | emulate_pf(ctxt); | ||
1203 | |||
1201 | return rc; | 1204 | return rc; |
1202 | } | 1205 | } |
1203 | 1206 | ||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0281d920e9ed..3101060033ae 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4247,6 +4247,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu, | |||
4247 | vcpu->arch.emulate_ctxt.perm_ok = false; | 4247 | vcpu->arch.emulate_ctxt.perm_ok = false; |
4248 | 4248 | ||
4249 | r = x86_decode_insn(&vcpu->arch.emulate_ctxt); | 4249 | r = x86_decode_insn(&vcpu->arch.emulate_ctxt); |
4250 | if (r == X86EMUL_PROPAGATE_FAULT) | ||
4251 | goto done; | ||
4252 | |||
4250 | trace_kvm_emulate_insn_start(vcpu); | 4253 | trace_kvm_emulate_insn_start(vcpu); |
4251 | 4254 | ||
4252 | /* Only allow emulation of specific instructions on #UD | 4255 | /* Only allow emulation of specific instructions on #UD |
@@ -4305,6 +4308,7 @@ restart: | |||
4305 | return handle_emulation_failure(vcpu); | 4308 | return handle_emulation_failure(vcpu); |
4306 | } | 4309 | } |
4307 | 4310 | ||
4311 | done: | ||
4308 | if (vcpu->arch.emulate_ctxt.exception >= 0) { | 4312 | if (vcpu->arch.emulate_ctxt.exception >= 0) { |
4309 | inject_emulated_exception(vcpu); | 4313 | inject_emulated_exception(vcpu); |
4310 | r = EMULATE_DONE; | 4314 | r = EMULATE_DONE; |