public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Mohammed Gamal <m.gamal005@gmail.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org, mtosatti@redhat.com,
	Mohammed Gamal <m.gamal005@gmail.com>
Subject: [RFC PATCH v3 3/4] x86: Add kvm_inject_realmode_interrupt() wrapper
Date: Mon, 16 Aug 2010 00:47:02 +0300	[thread overview]
Message-ID: <1281908823-4505-4-git-send-email-m.gamal005@gmail.com> (raw)
In-Reply-To: <1281908823-4505-1-git-send-email-m.gamal005@gmail.com>

This adds a wrapper function kvm_inject_realmode_interrupt() around the
emulator function emulate_int_real() to allow real mode interrupt injection.

Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
 arch/x86/kvm/x86.c |   21 +++++++++++++++++++++
 arch/x86/kvm/x86.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f24e594..59b708c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3958,6 +3958,27 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
 	memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
 }
 
+int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq)
+{       
+	struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
+	int ret;
+
+	init_emulate_ctxt(vcpu);
+
+	ret = emulate_int_real(&vcpu->arch.emulate_ctxt, &emulate_ops, irq);
+
+	if (ret != X86EMUL_CONTINUE)
+		return EMULATE_FAIL;
+
+	vcpu->arch.emulate_ctxt.eip = c->eip;
+	memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
+	kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
+	kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
+
+	return EMULATE_DONE;
+}
+EXPORT_SYMBOL_GPL(kvm_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..8b83da5 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 kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq);
 
 #endif
-- 
1.7.0.4


  parent reply	other threads:[~2010-08-15 21:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-15 21:46 [RFC PATCH v3 0/4] Real mode interrupt injection Mohammed Gamal
2010-08-15 21:47 ` [RFC PATCH v3 1/4] x86 emulator: Expose emulate_int_real() Mohammed Gamal
2010-08-15 21:47 ` [RFC PATCH v3 2/4] x86: Separate emulation context initialization in a separate function Mohammed Gamal
2010-08-15 21:47 ` Mohammed Gamal [this message]
2010-08-15 21:47 ` [RFC PATCH v3 4/4] VMX: Emulated real mode interrupt injection Mohammed Gamal
2010-08-15 23:37 ` [RFC PATCH v3 0/4] Real " Mohammed Gamal
2010-08-16  8:51   ` Avi Kivity
2010-08-16 13:19   ` Avi Kivity
2010-08-16 13:28     ` Mohammed Gamal
2010-08-16 14:16       ` Avi Kivity
2010-08-16 14:29         ` Gleb Natapov
2010-08-16 14:47           ` Avi Kivity
2010-08-16 15:23             ` Mohammed Gamal
2010-08-16 15:31               ` Gleb Natapov
2010-08-16 15:33                 ` Avi Kivity
2010-08-16 15:43                 ` Mohammed Gamal
2010-08-16 10:14 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1281908823-4505-4-git-send-email-m.gamal005@gmail.com \
    --to=m.gamal005@gmail.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox