From patchwork Thu Mar 16 11:20:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9627915 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 D6C6260522 for ; Thu, 16 Mar 2017 11:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C923C285B5 for ; Thu, 16 Mar 2017 11:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBD3428604; Thu, 16 Mar 2017 11:20:26 +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 64178285B8 for ; Thu, 16 Mar 2017 11:20:26 +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 1coTQu-0007kF-Aw; Thu, 16 Mar 2017 11:19: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 1coTQt-0007hQ-AE for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:19:03 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 79/58-13095-6A47AC85; Thu, 16 Mar 2017 11:19:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXdZyak IgwsPBCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozO6XfYCuaKVyzd94CxgXGVUBcjF4eQwGZG iaZ7U1ggnOWMEidXzGXtYuTkYBPQldhx8zUziC0iECox5+cjMJtZoFLi4of9bCC2sICLxMnNC 9hBbBYBVYkFK3aD1fAK2Eh8+XUFzJYQkJNoOH8fzOYEinec3APWKyRgLfH56Gf2CYzcCxgZVj GqF6cWlaUW6RrrJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIE+pcBCHYwdvxzOsQ oycGkJMpb/uNEhBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3qcKJyOEBItS01Mr0jJzgIEGk5bg 4FES4T0CkuYtLkjMLc5Mh0idYlSUEuc9CZIQAElklObBtcGC+xKjrJQwLyPQIUI8BalFuZklq PKvGMU5GJWEea+CTOHJzCuBm/4KaDET0OK3H06ALC5JREhJNTB6s0wy2ML+4/+aBh2W76odFl ee32e7d/Ou57pLO9iEzp6T7/5Y4789QT70z5KF1rsF7SO3m6eayP2JOuOjsWui4L6sF9WCMts 3LDn17KhTLsf3KT9+VV0Vb141w2jdie1fnTykZ0TOPfJF3cRiS5OK5SOB81L8h7d+964QlX18 4ayjkJGE5YtTSizFGYmGWsxFxYkAyranBGkCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1489663141!92252979!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38859 invoked from network); 16 Mar 2017 11:19:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-27.messagelabs.com with SMTP; 16 Mar 2017 11:19:02 -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 8E2EE150C; Thu, 16 Mar 2017 04:19:01 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 87C383F5C9; Thu, 16 Mar 2017 04:19:00 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 16 Mar 2017 11:20:13 +0000 Message-Id: <20170316112030.20419-11-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170316112030.20419-1-andre.przywara@arm.com> References: <20170316112030.20419-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v2 10/27] 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 59d3ba4..0579976 100644 --- a/xen/arch/arm/gic-v3-lpi.c +++ b/xen/arch/arm/gic-v3-lpi.c @@ -104,6 +104,47 @@ uint64_t gicv3_get_redist_address(unsigned int cpu, bool use_pta) return per_cpu(lpi_redist, cpu).redist_id << 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); +} + static int gicv3_lpi_allocate_pendtable(uint64_t *reg) { uint64_t val; 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);