From patchwork Thu Aug 9 06:38:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 176002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AD0092C00E4 for ; Thu, 9 Aug 2012 16:38:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754739Ab2HIGio (ORCPT ); Thu, 9 Aug 2012 02:38:44 -0400 Received: from co1ehsobe006.messaging.microsoft.com ([216.32.180.189]:18422 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754712Ab2HIGin (ORCPT ); Thu, 9 Aug 2012 02:38:43 -0400 Received: from mail199-co1-R.bigfish.com (10.243.78.246) by CO1EHSOBE012.bigfish.com (10.243.66.75) with Microsoft SMTP Server id 14.1.225.23; Thu, 9 Aug 2012 06:38:43 +0000 Received: from mail199-co1 (localhost [127.0.0.1]) by mail199-co1-R.bigfish.com (Postfix) with ESMTP id 0C4C364023B; Thu, 9 Aug 2012 06:38:43 +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 mail199-co1 (localhost.localdomain [127.0.0.1]) by mail199-co1 (MessageSwitch) id 1344494321356477_8735; Thu, 9 Aug 2012 06:38:41 +0000 (UTC) Received: from CO1EHSMHS012.bigfish.com (unknown [10.243.78.237]) by mail199-co1.bigfish.com (Postfix) with ESMTP id 4B624B40044; Thu, 9 Aug 2012 06:38:41 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS012.bigfish.com (10.243.66.22) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 9 Aug 2012 06:38:41 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.298.5; Thu, 9 Aug 2012 01:38:40 -0500 Received: from freescale.com ([10.232.15.72]) by az84smr01.freescale.net (8.14.3/8.14.0) with SMTP id q796cZi4020240; Wed, 8 Aug 2012 23:38:37 -0700 Received: by freescale.com (sSMTP sendmail emulation); Thu, 09 Aug 2012 12:08:21 +0530 From: Bharat Bhushan To: , , CC: Bharat Bhushan Subject: [PATCH 1/4] Introduce a common kvm requests handler Date: Thu, 9 Aug 2012 12:08:18 +0530 Message-ID: <1344494301-29612-1-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 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 --- 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); } }