From patchwork Mon Jan 30 18:31:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9545901 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 B50D760415 for ; Mon, 30 Jan 2017 18:33:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC4A927F7F for ; Mon, 30 Jan 2017 18:33:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1484281C3; Mon, 30 Jan 2017 18:33:18 +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 4E69427F7F for ; Mon, 30 Jan 2017 18:33:18 +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 1cYGj7-0007qc-2A; Mon, 30 Jan 2017 18:30:53 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYGj5-0007mo-OZ for xen-devel@lists.xenproject.org; Mon, 30 Jan 2017 18:30:51 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 7D/C2-00888-B568F885; Mon, 30 Jan 2017 18:30:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRWlGSWpSXmKPExsVysyfVTTeqrT/ CYN1rCYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaP5f0zBH7GK+4umMzUw9gh1MXJyCAlsZpS4 tFKxi5ELyF4OZLdsYgdJsAnoSuy4+ZoZxBYRCJWY8/MRkM3BwSzgJfHlvTdIWFjAUeLKpiNsI DaLgKrE75sfwVp5BWwk5r77DmZLCMhJNJy/DzaGEyg+e/NvJoi91hL/epYzTmDkXsDIsIpRvT i1qCy1SNdML6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0LP1DAyMOxivtDkfYpT kYFIS5e372BchxJeUn1KZkVicEV9UmpNafIhRhoNDSYJ3Tkt/hJBgUWp6akVaZg4wxGDSEhw8 SiK8n0HSvMUFibnFmekQqVOMilLivD9AEgIgiYzSPLg2WFhfYpSVEuZlZGBgEOIpSC3KzSxBl X/FKM7BqCTMexNkCk9mXgnc9FdAi5mAFru/6gNZXJKIkJJqYAxktX3D0iyQHu7jsuDcfflTf+ f/zzXmYDAMP3PS4HGPR3Uh58VEyRynFXqXi8w3zUtpn1HF4Vmm+3V6zS/H57JP2da+MEuuy1D 6cSKV7YNH0ew6sX0zuw50aRXq/K9d4lSfuumNiToX23PW6XqfAt8s33C+db0ln8JmuQcXzbTd PtxYt9L1mBJLcUaioRZzUXEiAE/MfB1mAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1485801049!83153436!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.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17583 invoked from network); 30 Jan 2017 18:30:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-31.messagelabs.com with SMTP; 30 Jan 2017 18:30:50 -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 9D76A14F6; Mon, 30 Jan 2017 10:30:49 -0800 (PST) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE0033F24D; Mon, 30 Jan 2017 10:30:48 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Mon, 30 Jan 2017 18:31:36 +0000 Message-Id: <20170130183153.28566-12-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170130183153.28566-1-andre.przywara@arm.com> References: <20170130183153.28566-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijay Kilari Subject: [Xen-devel] [PATCH 11/28] ARM: GICv3: forward pending LPIs to guests 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 Upon receiving an LPI, we need to find the right VCPU and virtual IRQ number to get this IRQ injected. Iterate our two-level LPI table to find this information quickly when the host takes an LPI. Call the existing injection function to let the GIC emulation deal with this interrupt. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-v3-lpi.c | 41 +++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 6 ++++-- xen/include/asm-arm/irq.h | 8 ++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c index 8f6e7f3..d270053 100644 --- a/xen/arch/arm/gic-v3-lpi.c +++ b/xen/arch/arm/gic-v3-lpi.c @@ -86,6 +86,47 @@ uint64_t gicv3_get_redist_address(int cpu, bool use_pta) return per_cpu(redist_id, cpu) << 16; } +/* + * Handle incoming LPIs, which are a bit special, because they are potentially + * numerous and also only get injected into guests. Treat them specially here, + * by just looking up their target vCPU and virtual LPI number and hand it + * over to the injection function. + */ +void do_LPI(unsigned int lpi) +{ + struct domain *d; + union host_lpi *hlpip, hlpi; + struct vcpu *vcpu; + + WRITE_SYSREG32(lpi, ICC_EOIR1_EL1); + + hlpip = gic_get_host_lpi(lpi); + if ( !hlpip ) + return; + + hlpi.data = read_u64_atomic(&hlpip->data); + + /* We may have mapped more host LPIs than the guest actually asked for. */ + if ( !hlpi.virt_lpi ) + return; + + d = get_domain_by_id(hlpi.dom_id); + if ( !d ) + return; + + if ( hlpi.vcpu_id >= d->max_vcpus ) + { + put_domain(d); + return; + } + + vcpu = d->vcpu[hlpi.vcpu_id]; + + put_domain(d); + + vgic_vcpu_inject_irq(vcpu, hlpi.virt_lpi); +} + uint64_t gicv3_lpi_allocate_pendtable(void) { uint64_t reg; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index bd3c032..7286e5d 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -700,8 +700,10 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) local_irq_enable(); do_IRQ(regs, irq, is_fiq); local_irq_disable(); - } - else if (unlikely(irq < 16)) + } else if ( is_lpi(irq) ) + { + do_LPI(irq); + } else if ( unlikely(irq < 16) ) { do_sgi(regs, irq); } diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h index 8f7a167..ee47de8 100644 --- a/xen/include/asm-arm/irq.h +++ b/xen/include/asm-arm/irq.h @@ -34,6 +34,14 @@ struct irq_desc *__irq_to_desc(int irq); void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq); +#ifdef CONFIG_HAS_ITS +void do_LPI(unsigned int irq); +#else +static inline void do_LPI(unsigned int irq) +{ +} +#endif + #define domain_pirq_to_irq(d, pirq) (pirq) bool_t is_assignable_irq(unsigned int irq);