From patchwork Fri May 26 17:35:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9750937 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 B0D3F6032C for ; Fri, 26 May 2017 17:38:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A29C5283B9 for ; Fri, 26 May 2017 17:38:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96E3F283C8; Fri, 26 May 2017 17:38: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 49172281B7 for ; Fri, 26 May 2017 17:38: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 1dEJ9f-0005AY-CA; Fri, 26 May 2017 17:36:03 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dEJ9e-00052W-8d for xen-devel@lists.xenproject.org; Fri, 26 May 2017 17:36:02 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id CB/A3-03058-28768295; Fri, 26 May 2017 17:36:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTbcxXSP SYEKDksX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnFy9QTGggX8Fa9eL2drYNzK08XIxSEksIlR ovXSTxYIZzmjxO/vT1m7GDk52AR0JXbcfM0MYosIhEo8XfCdGaSIWWANo0T7J4giYQFvicNrD rGB2CwCqhIbTzaC2bwCNhLzHv9lB7ElBOQkGs7fBxvECRSfdfYzE4gtJGAt8Wbrd9YJjNwLGB lWMWoUpxaVpRbpGproJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIE+pgBCHYwXt8 YcIhRkoNJSZR3+jr1SCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvJPSNCKFBItS01Mr0jJzgMEG k5bg4FES4Z0HkuYtLkjMLc5Mh0idYlSUEucNAkkIgCQySvPg2mABfolRVkqYlxHoECGegtSi3 MwSVPlXjOIcjErCvEwgU3gy80rgpr8CWswEtNj3nDrI4pJEhJRUA2Nwb6KEq/e951sMv2ke3V 8e8X/J+2i9p867Xr18+ej8SYfj+5kijM4vyBNWZli/oFHjqOaiTYW7TzIe402vnb7Pb4lo2dl 3O9t/haUeLA6PCzculdy3d2G3qEljZH1P9PcNcxKYco30J2p+4FFk2bzjqnK6knTbOXbO2Jqv uqca9s1pfNj9YLsSS3FGoqEWc1FxIgBg8GWdawIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1495820161!70942438!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26032 invoked from network); 26 May 2017 17:36:01 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-21.messagelabs.com with SMTP; 26 May 2017 17:36: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 D1F2780D; Fri, 26 May 2017 10:36:00 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 978493F53D; Fri, 26 May 2017 10:35:59 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 26 May 2017 18:35:18 +0100 Message-Id: <20170526173540.10066-11-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170526173540.10066-1-andre.przywara@arm.com> References: <20170526173540.10066-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v10 10/32] ARM: vGIC: add LPI VCPU ID to struct pending_irq 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 The target CPU for an LPI is encoded in the interrupt translation table entry, so can't be easily derived from just an LPI number (short of walking *all* tables and find the matching LPI). To avoid this in case we need to know the VCPU (for the INVALL command, for instance), put the VCPU ID in the struct pending_irq, so that it is easily accessible. We use the remaining 8 bits of padding space for that to avoid enlarging the size of struct pending_irq. The number of VCPUs is limited to 127 at the moment anyway, which we also confirm with a BUILD_BUG_ON. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic.c | 4 ++++ xen/include/asm-arm/vgic.h | 1 + 2 files changed, 5 insertions(+) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 5872152..6b5c0b1 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -62,12 +62,16 @@ struct vgic_irq_rank *vgic_rank_irq(struct vcpu *v, unsigned int irq) void vgic_init_pending_irq(struct pending_irq *p, unsigned int virq) { + /* The lpi_vcpu_id field must be big enough to hold a VCPU ID. */ + BUILD_BUG_ON(BIT(sizeof(p->lpi_vcpu_id) * 8) < MAX_VIRT_CPUS); + memset(p, 0, sizeof(*p)); INIT_LIST_HEAD(&p->inflight); INIT_LIST_HEAD(&p->lr_queue); p->irq = virq; p->lr = GIC_INVALID_LR; + p->lpi_vcpu_id = INVALID_VCPU_ID; } static void vgic_rank_init(struct vgic_irq_rank *rank, uint8_t index, diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index d51e277..07b56dc 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -73,6 +73,7 @@ struct pending_irq uint8_t lr; uint8_t priority; uint8_t lpi_priority; /* Caches the priority if this is an LPI. */ + uint8_t lpi_vcpu_id; /* The VCPU for an LPI. */ /* inflight is used to append instances of pending_irq to * vgic.inflight_irqs */ struct list_head inflight;