From: Mohammed Gamal Subject: [RFC PATCH 2/3] x86: Add inject_realmode_interrupt() wrapper Date: Sun, 8 Aug 2010 22:24:15 +0300 Message-ID: <1281295456-11114-3-git-send-email-m.gamal005@gmail.com> References: <1281295456-11114-1-git-send-email-m.gamal005@gmail.com> Cc: mtosatti@redhat.com, kvm@vger.kernel.org, Mohammed Gamal To: avi@redhat.com Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:40617 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754440Ab0HHTYl (ORCPT ); Sun, 8 Aug 2010 15:24:41 -0400 Received: by wyb39 with SMTP id 39so9282714wyb.19 for ; Sun, 08 Aug 2010 12:24:40 -0700 (PDT) In-Reply-To: <1281295456-11114-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: This adds a wrapper function inject_realmode_interrupt() around the emulator function emulate_int_real() to allow real mode interrupt injection. Signed-off-by: Mohammed Gamal --- arch/x86/kvm/x86.c | 14 ++++++++++++++ arch/x86/kvm/x86.h | 1 + 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1722d37..5915f2e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3936,6 +3936,20 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu) kvm_queue_exception(vcpu, ctxt->exception); } +int inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq) +{ + struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; + int rc; + + rc = emulate_int_real(ctxt, &emulate_ops, irq); + + if (rc != X86EMUL_CONTINUE) + return EMULATE_FAIL; + + return EMULATE_DONE; +} +EXPORT_SYMBOL_GPL(inject_realmode_interrupt); + static int handle_emulation_failure(struct kvm_vcpu *vcpu) { ++vcpu->stat.insn_emulation_fail; diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index b7a4047..c6e8a4d 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -67,5 +67,6 @@ static inline int is_paging(struct kvm_vcpu *vcpu) void kvm_before_handle_nmi(struct kvm_vcpu *vcpu); void kvm_after_handle_nmi(struct kvm_vcpu *vcpu); +int inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq); #endif -- 1.7.0.4