From patchwork Fri Jun 9 17:41:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9779013 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 CA5A560318 for ; Fri, 9 Jun 2017 17:44:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AB5286E0 for ; Fri, 9 Jun 2017 17:44:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9944286E7; Fri, 9 Jun 2017 17:44:09 +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 58AAB286E0 for ; Fri, 9 Jun 2017 17:44:09 +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 1dJNv6-0003ai-2v; Fri, 09 Jun 2017 17:42:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJNv4-0003UA-Sc for xen-devel@lists.xenproject.org; Fri, 09 Jun 2017 17:41:58 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 1C/53-03557-6EDDA395; Fri, 09 Jun 2017 17:41:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTffZXat Igz+7mCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owdl/YxFTTzVzxZupi1gXEBTxcjF4eQwGZG ieaLs9khnOWMEv+27GXtYuTkYBPQldhx8zUziC0iECrxdMF3ZpAiZoHrjBKnd8xnA0kIC3hLn L6wDayBRUBV4lL3YxYQm1fAWuLsiydMILaEgJxEw/n7YIM4geLb9qwF6xUSsJJoOXSZfQIj9w JGhlWMGsWpRWWpRbqGZnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIE+ZgCCHYz 3NwYcYpTkYFIS5Z1WYBUpxJeUn1KZkVicEV9UmpNafIhRhoNDSYK35w5QTrAoNT21Ii0zBxhs MGkJDh4lEd4XJ4HSvMUFibnFmekQqVOMilLivE7AEBUSAElklObBtcEC/BKjrJQwLyPQIUI8B alFuZklqPKvGMU5GJWEeXeBbOfJzCuBm/4KaDET0OIl7yxAFpckIqSkGhi38Vqru64W+HlMVz ah/GTp8t2zezdVF2sbntq9jn/p95KAu3VvsznKq9gvddxp4vr6c7L0Ut5pL9NO7OBjad4/e+l BT5FrxiIaAVp2VU+WGlgteMPsqawwg5FxM+PsiRXKDyx3J9sE/Dp77/NMhyT5g9phmne6/zZc y+VY3/jyY4aOYEbLxU1KLMUZiYZazEXFiQDrTDLgawIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1497030117!107056690!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 9303 invoked from network); 9 Jun 2017 17:41:57 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-27.messagelabs.com with SMTP; 9 Jun 2017 17:41:57 -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 5562615BF; Fri, 9 Jun 2017 10:41:57 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D4823F578; Fri, 9 Jun 2017 10:41:55 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 9 Jun 2017 18:41:19 +0100 Message-Id: <20170609174141.5068-13-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170609174141.5068-1-andre.przywara@arm.com> References: <20170609174141.5068-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni , Manish Jaggi Subject: [Xen-devel] [PATCH v11 12/34] 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 Acked-by: Julien Grall --- 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 6f88616..546f412 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -62,11 +62,15 @@ 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->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;