From patchwork Wed Sep 28 18:24:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9354583 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 C7DBF60757 for ; Wed, 28 Sep 2016 18:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB323297A3 for ; Wed, 28 Sep 2016 18:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFCBE297A4; Wed, 28 Sep 2016 18:27:28 +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 51AFA297A7 for ; Wed, 28 Sep 2016 18:27:28 +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 1bpJXa-00024w-5v; Wed, 28 Sep 2016 18:25:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpJXZ-00021R-50 for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 18:25:09 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id C6/61-13924-40B0CE75; Wed, 28 Sep 2016 18:25:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTZeZ+02 4wdUDWhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bp1QcYCx6JVnQ3vWNvYJwn2MXIxSEksIlR 4mP/UXYIZzmjRM+z3YxdjJwcbAK6EjtuvmYGsUUEQiWeLvgOZjMLKEnsP3sNrEZYwFXi2JINL CA2i4CqxMb5l9hBbF4BG4kvZ7+ygtgSAnISDefvg/VyAsVXt/SC1QgJWEssXTqfdQIj9wJGhl WMGsWpRWWpRbpGlnpJRZnpGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIEermdgYNzBeHm L3yFGSQ4mJVHejtuvw4X4kvJTKjMSizPii0pzUosPMcpwcChJ8LZyvgkXEixKTU+tSMvMAYYa TFqCg0dJhFeQCyjNW1yQmFucmQ6ROsWoKCXOywqSEABJZJTmwbXBwvsSo6yUMC8jAwODEE9Ba lFuZgmq/CtGcQ5GJWFeIZApPJl5JXDTXwEtZgJavPTEC5DFJYkIKakGxnVFF1c6NAlxJ3/ZvG 9qYeqPUm/1m6VXTLp/X/XV2DJR5SJjnMLF92VsZfESyVMqvoXIlxntYzVx70qTDb79ZLbN1tS covhdYkZ3vz4Jjd+noLf00Q6BZtbwJ7YTvl8SfpLSYP7XItUg4qECt9yxyZM+CHLmlK3Lj+D3 vcA5J3/7PrsJZp+MlFiKMxINtZiLihMBIs57nmoCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1475087104!62148866!2 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65084 invoked from network); 28 Sep 2016 18:25:07 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-206.messagelabs.com with SMTP; 28 Sep 2016 18:25:07 -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 433C3687; Wed, 28 Sep 2016 11:25:06 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84E673F21A; Wed, 28 Sep 2016 11:25:05 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 28 Sep 2016 19:24:42 +0100 Message-Id: <20160928182457.12433-10-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160928182457.12433-1-andre.przywara@arm.com> References: <20160928182457.12433-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC PATCH 09/24] 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-its.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 6 ++++-- xen/include/asm-arm/irq.h | 8 ++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic-its.c b/xen/arch/arm/gic-its.c index bf1f5b5..b7aa918 100644 --- a/xen/arch/arm/gic-its.c +++ b/xen/arch/arm/gic-its.c @@ -77,6 +77,38 @@ static union host_lpi *gic_find_host_lpi(uint32_t lpi, struct domain *d) return hlpi; } +/* 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; + + WRITE_SYSREG32(lpi, ICC_EOIR1_EL1); + WRITE_SYSREG32(lpi, ICC_DIR_EL1); + + hlpip = gic_find_host_lpi(lpi, NULL); + if ( !hlpip ) + return; + + hlpi.data = hlpip->data; + + if ( !hlpi.virt_lpi ) + return; + + d = get_domain_by_id(hlpi.dom_id); + if ( !d ) + return; + + if ( hlpi.vcpu_id >= d->max_vcpus ) + return; + + vgic_vcpu_inject_irq(d->vcpu[hlpi.vcpu_id], hlpi.virt_lpi); +} + #define ITS_COMMAND_SIZE 32 static int its_send_command(struct host_its *hw_its, void *its_cmd) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index ebe4035..2fad2f1 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -697,8 +697,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 ( irq >= 8192 ) + { + 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);