From patchwork Fri Aug 3 05:30:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 1268551 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EDA2E3FD56 for ; Fri, 3 Aug 2012 05:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919Ab2HCFad (ORCPT ); Fri, 3 Aug 2012 01:30:33 -0400 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12]:22324 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751087Ab2HCFa3 (ORCPT ); Fri, 3 Aug 2012 01:30:29 -0400 Received: from mail271-tx2-R.bigfish.com (10.9.14.248) by TX2EHSOBE007.bigfish.com (10.9.40.27) with Microsoft SMTP Server id 14.1.225.23; Fri, 3 Aug 2012 05:30:28 +0000 Received: from mail271-tx2 (localhost [127.0.0.1]) by mail271-tx2-R.bigfish.com (Postfix) with ESMTP id F09C9C032F; Fri, 3 Aug 2012 05:30:27 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zzzz1202h1082kzz8275bhz2dh2a8h668h839he5bhf0ah) Received: from mail271-tx2 (localhost.localdomain [127.0.0.1]) by mail271-tx2 (MessageSwitch) id 1343971826226683_9547; Fri, 3 Aug 2012 05:30:26 +0000 (UTC) Received: from TX2EHSMHS015.bigfish.com (unknown [10.9.14.247]) by mail271-tx2.bigfish.com (Postfix) with ESMTP id 2AC96900046; Fri, 3 Aug 2012 05:30:26 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS015.bigfish.com (10.9.99.115) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 3 Aug 2012 05:30:26 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.298.5; Fri, 3 Aug 2012 00:30:25 -0500 Received: from freescale.com ([10.232.15.72]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with SMTP id q735ULsg005433; Thu, 2 Aug 2012 22:30:22 -0700 Received: by freescale.com (sSMTP sendmail emulation); Fri, 03 Aug 2012 11:00:50 +0530 From: Bharat Bhushan To: , , CC: Bharat Bhushan Subject: [PATCH 2/2] Unified the kvm requests in one function Date: Fri, 3 Aug 2012 11:00:45 +0530 Message-ID: <1343971845-17995-2-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1343971845-17995-1-git-send-email-Bharat.Bhushan@freescale.com> References: <1343971845-17995-1-git-send-email-Bharat.Bhushan@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- arch/powerpc/kvm/booke.c | 63 +++++++++++++++++++++++++++------------------- 1 files changed, 37 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index a0f5922..68ed863 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -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; }