This patch adds code to check for IOIO intercepts on instructions decoded by the KVM instruction emulator. Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx> --- arch/x86/kvm/svm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2a30b5b..a2c513d 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3668,6 +3668,47 @@ static void svm_check_group7(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) } } +static void svm_check_ioio(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) +{ + struct decode_cache *c; + u32 bytes, seg; + u32 exit_info; + + c = &ctxt->decode; + /* Encode Port */ + exit_info = (c->regs[VCPU_REGS_RDX] & 0xffff) << 16; + seg = 0; + + /* Encode Address Size */ + exit_info |= (u32)c->ad_bytes << (SVM_IOIO_ASIZE_SHIFT - 1); + + if (c->rep_prefix) + exit_info |= SVM_IOIO_REP_MASK; + + if ((c->b & 0x06) == 0x06) { + /* OUT* Instruction */ + bytes = c->dst.bytes; + } else { + /* IN* Instruction */ + bytes = c->src.bytes; + exit_info |= SVM_IOIO_TYPE_MASK; + } + + /* Encode Data Size */ + bytes = min(bytes, 4u); + exit_info |= bytes << SVM_IOIO_SIZE_SHIFT; + + /* Check for the string variants */ + if ((c->b & 0xf0) == 0x60) { + exit_info |= SVM_IOIO_STR_MASK; + exit_info |= (seg & 0x07) << 10; + } + + vmcb->control.exit_info_1 = exit_info; + vmcb->control.exit_info_2 = ctxt->eip; + vmcb->control.exit_code = SVM_EXIT_IOIO; +} + static void svm_check_onebyte(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) { struct decode_cache *c = &ctxt->decode; @@ -3685,6 +3726,20 @@ static void svm_check_onebyte(struct vmcb *vmcb, struct x86_emulate_ctxt *ctxt) case 0xcd: /* INTn */ vmcb->control.exit_code = SVM_EXIT_SWINT; break; + case 0x6c: /* INS */ + case 0x6d: + case 0xe4: /* IN */ + case 0xe5: + case 0xec: + case 0xed: + case 0x6e: /* OUTS */ + case 0x6f: + case 0xe6: /* OUT */ + case 0xe7: + case 0xee: + case 0xef: + svm_check_ioio(vmcb, ctxt); + break; case 0xcf: /* IRET */ vmcb->control.exit_code = SVM_EXIT_IRET; break; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html