From patchwork Wed Apr 5 23:19:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9665889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15A1960352 for ; Wed, 5 Apr 2017 23:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07BFD2816B for ; Wed, 5 Apr 2017 23:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0D8C28584; Wed, 5 Apr 2017 23:23:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5B3E2816B for ; Wed, 5 Apr 2017 23:23:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvuEa-0004om-K8; Wed, 05 Apr 2017 23:21:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvuEZ-0004lY-5f for xen-devel@lists.xenproject.org; Wed, 05 Apr 2017 23:21:03 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id A1/AD-03648-EDB75E85; Wed, 05 Apr 2017 23:21:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTfdu9dM IgxevbSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyON99YCjoFKm4vmM/YwHiXp4uRi0NIYBOj xP+vM5ghnL2MEgcbrrJ3MXJysAnoSuy4+ZoZxBYRCJWY8/MRkM3BwSxQKdG9iB8kLCxgLXFt7 lxGEJtFQFWi9dF3VhCbV8BdYkvHXDaQcgkBOYkr/xJAwpxA4Zetx1hAbCEBN4lrE6eyTGDkXs DIsIpRvTi1qCy1SNdCL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LcMQLCDcfZ l/0OMkhxMSqK8Cj5PIoT4kvJTKjMSizPii0pzUosPMcpwcChJ8G6rehohJFiUmp5akZaZAwwy mLQEB4+SCO97kDRvcUFibnFmOkTqFKOilDjvJpCEAEgiozQPrg0W2JcYZaWEeRmBDhHiKUgty s0sQZV/xSjOwagkzCsDMoUnM68EbvoroMVMQIuf3HkIsrgkESEl1cDYt6PDlc/isU2/iG5/Zu J5b0aBCR6tbnaOOy76vu2wPcdz78M2phULjrGcrbQ5KDfnUfCu9JmPTr9+tl/yJ1943calChU pqZt+6q4Jf3Z1QbPgO8nIQ3cTeWL2ND15bbHvhH3MlfIHiXXCumbTtF2rrWaXa015/6X41MNj Hw5+uKhk/vFRx7o+JZbijERDLeai4kQAm85cbWcCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1491434461!95115808!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9488 invoked from network); 5 Apr 2017 23:21:01 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 5 Apr 2017 23:21:01 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4920E344; Wed, 5 Apr 2017 16:21:01 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 069233F4FF; Wed, 5 Apr 2017 16:20:59 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 6 Apr 2017 00:19:08 +0100 Message-Id: <1491434362-30310-17-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> References: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v5 16/30] ARM: vGICv3: handle disabled LPIs X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP If a guest disables an LPI, we do not forward this to the associated host LPI to avoid queueing commands to the host ITS command queue. So it may happen that an LPI fires nevertheless on the host. In this case we can bail out early, but have to save the pending state on the virtual side. We do this by storing the pending bit in struct pending_irq, which is assiociated with mapped LPIs. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v3-lpi.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c index d8baebc..7d20986 100644 --- a/xen/arch/arm/gic-v3-lpi.c +++ b/xen/arch/arm/gic-v3-lpi.c @@ -136,6 +136,22 @@ uint64_t gicv3_get_redist_address(unsigned int cpu, bool use_pta) return per_cpu(lpi_redist, cpu).redist_id << 16; } +static bool vgic_can_inject_lpi(struct vcpu *vcpu, uint32_t vlpi) +{ + struct pending_irq *p; + + p = vcpu->domain->arch.vgic.handler->lpi_to_pending(vcpu->domain, vlpi); + if ( !p ) + return false; + + if ( test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + return true; + + set_bit(GIC_IRQ_GUEST_LPI_PENDING, &p->status); + + return false; +} + /* * Handle incoming LPIs, which are a bit special, because they are potentially * numerous and also only get injected into guests. Treat them specially here, @@ -187,7 +203,15 @@ void gicv3_do_LPI(unsigned int lpi) /* Check if the VCPU is ready to receive LPIs. */ if ( vcpu->arch.vgic.flags & VGIC_V3_LPIS_ENABLED ) - vgic_vcpu_inject_irq(vcpu, hlpi.virt_lpi); + { + /* + * We keep all host LPIs enabled, so check if it's disabled on the + * guest side and just record this LPI in the virtual pending table + * in this case. The guest picks it up once it gets enabled again. + */ + if ( vgic_can_inject_lpi(vcpu, hlpi.virt_lpi) ) + vgic_vcpu_inject_irq(vcpu, hlpi.virt_lpi); + } rcu_unlock_domain(d); }