diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-04-04 06:39:24 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-11 07:57:00 -0400 |
commit | 775fde8648ebc588d07de39457aadc7c2131df2e (patch) | |
tree | 56706d5d6eff4b5f02c911cbbbcf3b14648aee69 | |
parent | 3c6e276f22cf29188035535127c4c35aeeafcabc (diff) |
KVM: x86 emulator: Don't write-back cpu-state on X86EMUL_INTERCEPTED
This patch prevents the changed CPU state to be written back
when the emulator detected that the instruction was
intercepted by the guest.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 3 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 3 |
3 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 470ac54ca38d..1dbd0c736cd1 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -331,6 +331,7 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len); | |||
331 | #define EMULATION_FAILED -1 | 331 | #define EMULATION_FAILED -1 |
332 | #define EMULATION_OK 0 | 332 | #define EMULATION_OK 0 |
333 | #define EMULATION_RESTART 1 | 333 | #define EMULATION_RESTART 1 |
334 | #define EMULATION_INTERCEPTED 2 | ||
334 | int x86_emulate_insn(struct x86_emulate_ctxt *ctxt); | 335 | int x86_emulate_insn(struct x86_emulate_ctxt *ctxt); |
335 | int emulator_task_switch(struct x86_emulate_ctxt *ctxt, | 336 | int emulator_task_switch(struct x86_emulate_ctxt *ctxt, |
336 | u16 tss_selector, int reason, | 337 | u16 tss_selector, int reason, |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index c2260e57450a..a2c31e527a99 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -3592,6 +3592,9 @@ writeback: | |||
3592 | done: | 3592 | done: |
3593 | if (rc == X86EMUL_PROPAGATE_FAULT) | 3593 | if (rc == X86EMUL_PROPAGATE_FAULT) |
3594 | ctxt->have_exception = true; | 3594 | ctxt->have_exception = true; |
3595 | if (rc == X86EMUL_INTERCEPTED) | ||
3596 | return EMULATION_INTERCEPTED; | ||
3597 | |||
3595 | return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK; | 3598 | return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK; |
3596 | 3599 | ||
3597 | twobyte_insn: | 3600 | twobyte_insn: |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 36786bbb4c09..99bed74779d2 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4516,6 +4516,9 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, | |||
4516 | restart: | 4516 | restart: |
4517 | r = x86_emulate_insn(&vcpu->arch.emulate_ctxt); | 4517 | r = x86_emulate_insn(&vcpu->arch.emulate_ctxt); |
4518 | 4518 | ||
4519 | if (r == EMULATION_INTERCEPTED) | ||
4520 | return EMULATE_DONE; | ||
4521 | |||
4519 | if (r == EMULATION_FAILED) { | 4522 | if (r == EMULATION_FAILED) { |
4520 | if (reexecute_instruction(vcpu, cr2)) | 4523 | if (reexecute_instruction(vcpu, cr2)) |
4521 | return EMULATE_DONE; | 4524 | return EMULATE_DONE; |