diff mbox

[1/4] Introduce a common kvm requests handler

Message ID 1344494301-29612-1-git-send-email-Bharat.Bhushan@freescale.com
State New, archived
Headers show

Commit Message

Bharat Bhushan Aug. 9, 2012, 6:38 a.m. UTC
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>
---
 arch/powerpc/kvm/booke.c |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

Comments

Bharat Bhushan Aug. 13, 2012, 4:40 a.m. UTC | #1
Hi Alex,

Can you please apply following patches:

[PATCH 1/4] Introduce a common kvm requests handler
[PATCH 2/4] KVM: PPC: booke: Add watchdog emulation
[PATCH 3/4] booke: Added ONE_REG interface for IAC/DAC debug registers
[PATCH 3/3] Enable kvm emulated watchdog
[PATCH 2/3] Registered timer reset handler
[PATCH 1/3] Synchronize the linux-headers

Thanks
-Bharat


> -----Original Message-----
> From: Bhushan Bharat-R65777
> Sent: Thursday, August 09, 2012 12:08 PM
> To: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; agraf@suse.de
> Cc: Bhushan Bharat-R65777
> Subject: [PATCH 1/4] Introduce a common kvm requests handler
> 
> 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>
> ---
>  arch/powerpc/kvm/booke.c |   45 +++++++++++++++++++++++++++++++++------------
>  1 files changed, 33 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
> d25a097..6ebff80 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,11 @@ 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


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf Aug. 13, 2012, 11:02 a.m. UTC | #2
On 09.08.2012, at 08:38, Bharat Bhushan wrote:

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

Thanks, applied patches 2 and 3 on top of the 2 patches I just sent out.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index d25a097..6ebff80 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,11 @@  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);
 		}
 	}