From: Bharat Bhushan <r65777@freescale.com>
To: <kvm-ppc@vger.kernel.org>, <kvm@vger.kernel.org>, <agraf@suse.de>
Cc: Bharat Bhushan <Bharat.Bhushan@freescale.com>
Subject: [PATCH 1/4 v2] Introduce a common kvm requests handler
Date: Thu, 9 Aug 2012 12:47:53 +0530 [thread overview]
Message-ID: <1344496676-32426-1-git-send-email-Bharat.Bhushan@freescale.com> (raw)
Added a common requests handler which is called before returning to guest.
This returns non zero value when some request demands exit to userspace.
Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
v2:
- checkpatch error removed
arch/powerpc/kvm/booke.c | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index d25a097..0e51102 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -412,18 +412,30 @@ static void update_timer_ints(struct kvm_vcpu *vcpu)
kvmppc_core_dequeue_dec(vcpu);
}
+/*
+ * This function handle all requests when returning to guest. This return
+ * non zero value when some request demands exit to userspace.
+ */
+static int kvmppc_handle_requests(struct kvm_vcpu *vcpu)
+{
+ int ret = 0;
+
+ if (!vcpu->requests)
+ return 0;
+
+ if (kvm_check_request(KVM_REQ_PENDING_TIMER, vcpu)) {
+ smp_mb();
+ update_timer_ints(vcpu);
+ }
+
+ return ret;
+}
+
static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu)
{
unsigned long *pending = &vcpu->arch.pending_exceptions;
unsigned int priority;
- if (vcpu->requests) {
- if (kvm_check_request(KVM_REQ_PENDING_TIMER, vcpu)) {
- smp_mb();
- update_timer_ints(vcpu);
- }
- }
-
priority = __ffs(*pending);
while (priority < BOOKE_IRQPRIO_MAX) {
if (kvmppc_booke_irqprio_deliver(vcpu, priority))
@@ -479,10 +491,15 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
}
if (signal_pending(current)) {
+ vcpu->run->exit_reason = KVM_EXIT_INTR;
r = 1;
break;
}
+ r = kvmppc_handle_requests(vcpu);
+ if (r)
+ break;
+
if (kvmppc_core_prepare_to_enter(vcpu)) {
/* interrupts got enabled in between, so we
are back at square 1 */
@@ -511,8 +528,10 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) {
- kvm_run->exit_reason = KVM_EXIT_INTR;
- ret = -EINTR;
+ if (kvm_run->exit_reason == KVM_EXIT_INTR)
+ ret = -EINTR;
+ else
+ ret = 0;
goto out;
}
@@ -972,9 +991,12 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
if (!(r & RESUME_HOST)) {
local_irq_disable();
if (kvmppc_prepare_to_enter(vcpu)) {
- run->exit_reason = KVM_EXIT_INTR;
- r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
- kvmppc_account_exit(vcpu, SIGNAL_EXITS);
+ if (run->exit_reason == KVM_EXIT_INTR) {
+ r = (-EINTR << 2) | RESUME_HOST |
+ (r & RESUME_FLAG_NV);
+ kvmppc_account_exit(vcpu, SIGNAL_EXITS);
+ } else
+ r = RESUME_HOST | (r & RESUME_FLAG_NV);
}
}
--
1.7.0.4
next reply other threads:[~2012-08-09 7:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 7:17 Bharat Bhushan [this message]
2012-08-09 7:17 ` [PATCH 2/4 v2] KVM: PPC: booke: Add watchdog emulation Bharat Bhushan
2012-08-09 7:17 ` [PATCH 3/4 v2] booke: Added ONE_REG interface for IAC/DAC debug registers Bharat Bhushan
2012-08-09 7:17 ` [PATCH 4/4 v2] KVM: PPC: booke: Allow multiple exception types Bharat Bhushan
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=1344496676-32426-1-git-send-email-Bharat.Bhushan@freescale.com \
--to=r65777@freescale.com \
--cc=Bharat.Bhushan@freescale.com \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).