Messages in this thread Patch in this message | | | From | Joerg Roedel <> | Subject | [PATCH 7/9] KVM: SVM: Add intercept checks for one-byte instructions | Date | Wed, 24 Nov 2010 19:18:33 +0100 |
| |
This patch add intercept checks for emulated one-byte instructions to the KVM instruction emulation path.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> --- arch/x86/kvm/svm.c | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 77b344e..2a30b5b 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3668,6 +3668,35 @@ static void svm_check_group7(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) } } +static void svm_check_onebyte(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) +{ + struct decode_cache *c = &ctxt->decode; + + switch (c->b) { + case 0x90: /* PAUSE */ + if (c->rep_prefix == REPE_PREFIX) + vmcb->control.exit_code = SVM_EXIT_PAUSE; + break; + case 0x9c: /* PUSHF */ + break; + case 0x9d: /* POPF */ + vmcb->control.exit_code = SVM_EXIT_POPF; + break; + case 0xcd: /* INTn */ + vmcb->control.exit_code = SVM_EXIT_SWINT; + break; + case 0xcf: /* IRET */ + vmcb->control.exit_code = SVM_EXIT_IRET; + break; + case 0xf1: /* ICEBP */ + vmcb->control.exit_code = SVM_EXIT_ICEBP; + break; + case 0xf4: /* HLT */ + vmcb->control.exit_code = SVM_EXIT_HLT; + break; + } +} + static int svm_insn_intercepted(struct kvm_vcpu *vcpu, struct x86_emulate_ctxt *ctxt) { @@ -3681,8 +3710,10 @@ static int svm_insn_intercepted(struct kvm_vcpu *vcpu, ret = X86EMUL_CONTINUE; - if (!c->twobyte) + if (!c->twobyte) { + svm_check_onebyte(vmcb, ctxt); goto out; + } switch (c->b) { case 0x00: @@ -3799,14 +3830,13 @@ static int svm_insn_intercepted(struct kvm_vcpu *vcpu, break; } +out: vmcb->control.next_rip = ctxt->eip; vmexit = nested_svm_exit_handled(svm); ret = (vmexit == NESTED_EXIT_DONE) ? X86EMUL_INTERCEPTED : X86EMUL_CONTINUE; -out: - return ret; } -- 1.7.1
| |