kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4 v2] Introduce a common kvm requests handler
@ 2012-08-09  7:17 Bharat Bhushan
  2012-08-09  7:17 ` [PATCH 2/4 v2] KVM: PPC: booke: Add watchdog emulation Bharat Bhushan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bharat Bhushan @ 2012-08-09  7:17 UTC (permalink / raw)
  To: kvm-ppc, kvm, agraf; +Cc: Bharat Bhushan

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-09  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-09  7:17 [PATCH 1/4 v2] Introduce a common kvm requests handler Bharat Bhushan
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

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).