@@ -525,18 +525,31 @@ static void update_timer_ints(struct kvm_vcpu *vcpu)
kvmppc_core_dequeue_watchdog(vcpu);
}
+static int kvmppc_handle_requests(struct kvm_run *run, 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);
+ }
+
+ if (kvm_check_request(KVM_REQ_WATCHDOG, vcpu)) {
+ run->exit_reason = KVM_EXIT_WATCHDOG;
+ ret = 1;
+ }
+
+ 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))
@@ -578,7 +591,7 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
*
* returns !0 if a signal is pending and check_signal is true
*/
-static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
+static int kvmppc_prepare_to_enter(struct kvm_run *run, struct kvm_vcpu *vcpu)
{
int r = 0;
@@ -593,9 +606,14 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
if (signal_pending(current)) {
r = 1;
+ run->exit_reason = KVM_EXIT_INTR;
break;
}
+ r = kvmppc_handle_requests(run, vcpu);
+ if (r)
+ break;
+
if (kvmppc_core_prepare_to_enter(vcpu)) {
/* interrupts got enabled in between, so we
are back at square 1 */
@@ -623,15 +641,11 @@ 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;
- goto out;
- }
-
- if (kvm_check_request(KVM_REQ_WATCHDOG, vcpu)) {
- kvm_run->exit_reason = KVM_EXIT_WATCHDOG;
- ret = 0;
+ if (kvmppc_prepare_to_enter(kvm_run, vcpu)) {
+ if (kvm_run->exit_reason == KVM_EXIT_INTR)
+ ret = -EINTR;
+ else
+ ret = 0;
goto out;
}
@@ -1090,18 +1104,15 @@ 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 (kvmppc_prepare_to_enter(run, vcpu)) {
+ 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);
}
}
- if (kvm_check_request(KVM_REQ_WATCHDOG, vcpu)) {
- run->exit_reason = KVM_EXIT_WATCHDOG;
- r = RESUME_HOST | (r & RESUME_FLAG_NV);
- }
-
return r;
}
I am sending this as a separate patch for easiness on review. Once reviewed I will merge this with watchdog patch. Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com> --- arch/powerpc/kvm/booke.c | 63 +++++++++++++++++++++++++++------------------- 1 files changed, 37 insertions(+), 26 deletions(-)