From patchwork Fri Jan 4 17:36:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 209501 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 C37F52C008D for ; Sat, 5 Jan 2013 04:36:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755020Ab3ADRgq (ORCPT ); Fri, 4 Jan 2013 12:36:46 -0500 Received: from cantor2.suse.de ([195.135.220.15]:50394 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754307Ab3ADRgo (ORCPT ); Fri, 4 Jan 2013 12:36:44 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id E972FA3A78; Fri, 4 Jan 2013 18:36:43 +0100 (CET) From: Alexander Graf To: kvm-ppc@vger.kernel.org Cc: KVM list Subject: [PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests Date: Fri, 4 Jan 2013 18:36:37 +0100 Message-Id: <1357321000-31008-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1357321000-31008-1-git-send-email-agraf@suse.de> References: <1357321000-31008-1-git-send-email-agraf@suse.de> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external interrupt though. So we need to prepare the interrupt delivery to abort guest entry gracefully. Otherwise we'd delay the EPR request. Signed-off-by: Alexander Graf --- arch/powerpc/kvm/booke.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 69f1140..4ae83f9 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -554,14 +554,16 @@ static void update_timer_ints(struct kvm_vcpu *vcpu) kvmppc_core_dequeue_watchdog(vcpu); } -static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu) +static int kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu) { unsigned long *pending = &vcpu->arch.pending_exceptions; unsigned int priority; + int r = 0; priority = __ffs(*pending); while (priority < BOOKE_IRQPRIO_MAX) { - if (kvmppc_booke_irqprio_deliver(vcpu, priority)) + r = kvmppc_booke_irqprio_deliver(vcpu, priority); + if (r) break; priority = find_next_bit(pending, @@ -571,15 +573,19 @@ static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu) /* Tell the guest about our interrupt status */ vcpu->arch.shared->int_pending = !!*pending; + + return r > 1; } /* Check pending exceptions and deliver one, if possible. */ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu) { - int r = 0; + int r; WARN_ON_ONCE(!irqs_disabled()); - kvmppc_core_check_exceptions(vcpu); + r = kvmppc_core_check_exceptions(vcpu); + if (r) + return r; if (vcpu->arch.shared->msr & MSR_WE) { local_irq_enable();