From patchwork Fri Apr 7 17:32:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9670037 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 87F7D60364 for ; Fri, 7 Apr 2017 17:33:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A81F28497 for ; Fri, 7 Apr 2017 17:33:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F9792862E; Fri, 7 Apr 2017 17:33:58 +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 B8DB728497 for ; Fri, 7 Apr 2017 17:33:57 +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 1cwXj8-0005dv-R0; Fri, 07 Apr 2017 17:31:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwXj7-0005dY-Ip for xen-devel@lists.xenproject.org; Fri, 07 Apr 2017 17:31:13 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 7B/5A-27678-0ECC7E85; Fri, 07 Apr 2017 17:31:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTff+mec RBvOX2Fh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBm3rocWXDOpmHL3IWsD4xytLkYuDiGBTYwS x7cfYodwljNKzFl4nKWLkZODTUBXYsfN18wgtohAqMScn4/AbGaBSol/HzYxgdjCAuESq4+/Z wOxWQRUJa72/gayOTh4BawkvhyuAAlLCMhJNJy/D9bKKWAt8fX7FjBbCKhkxcaLjBMYuRcwMq xi1ChOLSpLLdI1MtZLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LgMQ7GD8Mz/ wEKMkB5OSKK+Cz5MIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8i04/jxASLEpNT61Iy8wBhhlM WoKDR0mEVwgYakK8xQWJucWZ6RCpU4y6HFdaP75nEmLJy89LlRLnbQSZIQBSlFGaBzcCFvKXG GWlhHkZgY4S4ilILcrNLEGVf8UozsGoJMw7B2QKT2ZeCdymV0BHMAEd4XPrKcgRJYkIKakGxq ltbRM9uLd+LNd9P3+h3MNjr5uu3VPq3R08+XaTxbqLk+rPBnwRnMf94sP73pb9ZR3pS26tP3I 7YlGnaVZhr0qKbOTrRkfL1snuNnHHWPcx3tS9197rkT/5pnNPzefPC75t83zv9m3dvad6RwKb 8+sX5h65km6Xxn5Kt+XmZobldsfF9724UKzEUpyRaKjFXFScCADF0W5cdAIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1491586271!43448201!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40427 invoked from network); 7 Apr 2017 17:31:11 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-27.messagelabs.com with SMTP; 7 Apr 2017 17:31:11 -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 1E0A3B16; Fri, 7 Apr 2017 10:31:11 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 177EC3F3E1; Fri, 7 Apr 2017 10:31:09 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Fri, 7 Apr 2017 18:32:32 +0100 Message-Id: <20170407173307.9788-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170407173307.9788-1-andre.przywara@arm.com> References: <20170407173307.9788-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijay Kilari , Shanker Donthineni Subject: [Xen-devel] [PATCH v6 01/36] ARM: GICv3 ITS: parse and store ITS subnodes from hardware DT 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 Parse the GIC subnodes in the device tree to find every ITS MSI controller the hardware offers. Store that information in a list to both propagate all of them later to Dom0, but also to be able to iterate over all ITSes. This introduces an ITS Kconfig option (as an EXPERT option), use XEN_CONFIG_EXPERT=y on the make command line to see and use the option. Signed-off-by: Andre Przywara Reviewed-by: Stefano Stabellini Reviewed-by: Julien Grall --- xen/arch/arm/Kconfig | 5 +++ xen/arch/arm/Makefile | 1 + xen/arch/arm/gic-v3-its.c | 77 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 10 +++--- xen/include/asm-arm/gic_v3_its.h | 65 +++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 xen/arch/arm/gic-v3-its.c create mode 100644 xen/include/asm-arm/gic_v3_its.h diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 43123e6..d46b98c 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -45,6 +45,11 @@ config ACPI config HAS_GICV3 bool +config HAS_ITS + bool + prompt "GICv3 ITS MSI controller support" if EXPERT = "y" + depends on HAS_GICV3 + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 0ce94a8..39c0a03 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -18,6 +18,7 @@ obj-$(EARLY_PRINTK) += early_printk.o obj-y += gic.o obj-y += gic-v2.o obj-$(CONFIG_HAS_GICV3) += gic-v3.o +obj-$(CONFIG_HAS_ITS) += gic-v3-its.o obj-y += guestcopy.o obj-y += hvm.o obj-y += io.o diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c new file mode 100644 index 0000000..6b02349 --- /dev/null +++ b/xen/arch/arm/gic-v3-its.c @@ -0,0 +1,77 @@ +/* + * xen/arch/arm/gic-v3-its.c + * + * ARM GICv3 Interrupt Translation Service (ITS) support + * + * Copyright (C) 2016,2017 - ARM Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#include +#include +#include + +/* + * No lock here, as this list gets only populated upon boot while scanning + * firmware tables for all host ITSes, and only gets iterated afterwards. + */ +LIST_HEAD(host_its_list); + +bool gicv3_its_host_has_its(void) +{ + return !list_empty(&host_its_list); +} + +/* Scan the DT for any ITS nodes and create a list of host ITSes out of it. */ +void gicv3_its_dt_init(const struct dt_device_node *node) +{ + const struct dt_device_node *its = NULL; + struct host_its *its_data; + + /* + * Check for ITS MSI subnodes. If any, add the ITS register + * frames to the ITS list. + */ + dt_for_each_child_node(node, its) + { + uint64_t addr, size; + + if ( !dt_device_is_compatible(its, "arm,gic-v3-its") ) + continue; + + if ( dt_device_get_address(its, 0, &addr, &size) ) + panic("GICv3: Cannot find a valid ITS frame address"); + + its_data = xzalloc(struct host_its); + if ( !its_data ) + panic("GICv3: Cannot allocate memory for ITS frame"); + + its_data->addr = addr; + its_data->size = size; + its_data->dt_node = its; + + printk("GICv3: Found ITS @0x%lx\n", addr); + + list_add_tail(&its_data->entry, &host_its_list); + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 695f01f..b626298 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1227,11 +1228,12 @@ static void __init gicv3_dt_init(void) */ res = dt_device_get_address(node, 1 + gicv3.rdist_count, &cbase, &csize); - if ( res ) - return; + if ( !res ) + dt_device_get_address(node, 1 + gicv3.rdist_count + 2, + &vbase, &vsize); - dt_device_get_address(node, 1 + gicv3.rdist_count + 2, - &vbase, &vsize); + /* Check for ITS child nodes and build the host ITS list accordingly. */ + gicv3_its_dt_init(node); } static int gicv3_iomem_deny_access(const struct domain *d) diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h new file mode 100644 index 0000000..721e1e2 --- /dev/null +++ b/xen/include/asm-arm/gic_v3_its.h @@ -0,0 +1,65 @@ +/* + * ARM GICv3 ITS support + * + * Andre Przywara + * Copyright (c) 2016,2017 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ + +#ifndef __ASM_ARM_ITS_H__ +#define __ASM_ARM_ITS_H__ + +#include + +/* data structure for each hardware ITS */ +struct host_its { + struct list_head entry; + const struct dt_device_node *dt_node; + paddr_t addr; + paddr_t size; +}; + + +#ifdef CONFIG_HAS_ITS + +extern struct list_head host_its_list; + +/* Parse the host DT and pick up all host ITSes. */ +void gicv3_its_dt_init(const struct dt_device_node *node); + +bool gicv3_its_host_has_its(void); + +#else + +static inline void gicv3_its_dt_init(const struct dt_device_node *node) +{ +} + +static inline bool gicv3_its_host_has_its(void) +{ + return false; +} + +#endif /* CONFIG_HAS_ITS */ + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */