From patchwork Tue Jan 10 11:37:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 9506965 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 9D44F601E9 for ; Tue, 10 Jan 2017 11:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DE4F27BFF for ; Tue, 10 Jan 2017 11:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81272283F1; Tue, 10 Jan 2017 11:39:11 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 13D3627BFF for ; Tue, 10 Jan 2017 11:39:11 +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 1cQujn-0007bS-4r; Tue, 10 Jan 2017 11:37:11 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQujl-0007aw-Ly for xen-devel@lists.xen.org; Tue, 10 Jan 2017 11:37:09 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 87/8B-15802-367C4785; Tue, 10 Jan 2017 11:37:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfS6s27y8ZI Ig3cX+S2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozP3csZC+YYVtzZ8IGxgbFPuYuRi0NIYCKj xJpnn9hBHBaBlywSl6eeBXI4OSQE+lklrv6phLBjJD4fOssKYRdLzLm6F8wWElCXOP1uBxuEP Z1JYtVMNRCbTcBEYu+fB0wgtoiAtMS1z5cZQWxmAV+JmzuPg8WFBSIkvvy8xAJiswioSqw79B 3M5hXwkDj74CnULjmJm+c6mUFsTgFPia/TFzBC7PKQWNVwmXUCo8ACRoZVjBrFqUVlqUW6hiZ 6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBgcUABDsYz572PMQoycGkJMp7fEJJ hBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3uJjQDnBotT01Iq0zBxgiMOkJTh4lER4X4OkeYsLE nOLM9MhUqcYLTmOzVr8lIlj2jMQuatzzVMmIZa8/LxUKXHeUJAGAZCGjNI8uHGwOLzEKCslzM sIdKAQT0FqUW5mCar8K0ZxDkYlYd5SkCk8mXklcFtfAR3EBHRQpF0xyEEliQgpqQbGHtudxzM cbzYVSV28Nt30y5NzzhxO37e4vN10snzdizzL7f2Me/9cirr7vLJu+gSDx68t5se6nH1xWq3k Yfah12/nX+pNFvDOjDt/9aKR5aTymLCNUqsvHq/4te1rrP9t1tV1h7RO2dfuL5cXLUtIvnRX4 pdrYoZGsscVf//kkywhXZ+OelzepMRSnJFoqMVcVJwIAEZ2bbO+AgAA X-Env-Sender: edgar.iglesias@gmail.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1484048226!79295077!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9841 invoked from network); 10 Jan 2017 11:37:07 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Jan 2017 11:37:07 -0000 Received: by mail-lf0-f67.google.com with SMTP id v186so8254261lfa.2 for ; Tue, 10 Jan 2017 03:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QOQg89PbUmJ57Y1CUaRJn1692YXmFArs+Xkub3RmFqo=; b=UBJzWKsF1FBHJuIdPPth2tgN5BD0fZaMqngEOcY8aX+pXT0eQ4/zn+HSB8WFEDrXPJ isxkeHl6H9a8r4u+2Joa8afMRBCjSmV5UeuS25Z9IfKs5+9VfVUNQtSRbgbDGvPymmP9 ZtQ5JfuRtdV0ZXNKIscczUYW5bpRlrmWjTZKxLq2qI85PMJMeUWzrVS3PqkxszTj/WZ2 Q/AYVi0tI2+GVlun3hIjUs5ENaWQ78pTNrUc+6ZEl1kCPswDM6hOKdaO0yaN0hi1Pf3q 5rWPZY4wQlHhpWEw3UHtTa2mw5X0D/1kGirzUpO+0/GadLJYn9QDWbwa0sFHhocrEYIA x/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QOQg89PbUmJ57Y1CUaRJn1692YXmFArs+Xkub3RmFqo=; b=PMXKDw93bSoLbLACmgweX5WqMiucQBnywhlEyLHjr493W+miJ5I5fNdaATGaH5T98m icztzeklU5p3McNiNpdvXJGbXuqeOhUfA/lKqN6tv6MeU1Ky//HuvkAxEwDJyCs8usdv r5z/MmQ1qplRN2kR4CWNnVTYr6XAUp6QrdLzOiNciEPRhq/b11NA9lewGq1FCaEXl3g4 aAcQ0t6nYEuflA8QSZFHD5IosqxFneECrQRuDkKgW0jcUmaa5jUSTJu1IYT+0lgdhEL0 uAptfPNoeZfS+iMf7q3UcroqS7+A0xZnDMoZbXrFK4ZhugN21mr3jU21O9Io9VK8oCqh NdZg== X-Gm-Message-State: AIkVDXJexXp/NOTwLx3RqCNrflHCJpSoWRp6VDPQKhT099NPVVSsP+jcOYPRr8MuqSqaOA== X-Received: by 10.46.6.1 with SMTP id 1mr1022933ljg.34.1484048226253; Tue, 10 Jan 2017 03:37:06 -0800 (PST) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id x10sm411945lja.15.2017.01.10.03.37.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 03:37:05 -0800 (PST) From: "Edgar E. Iglesias" To: xen-devel@lists.xen.org Date: Tue, 10 Jan 2017 12:37:03 +0100 Message-Id: <1484048223-27983-2-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484048223-27983-1-git-send-email-edgar.iglesias@gmail.com> References: <1484048223-27983-1-git-send-email-edgar.iglesias@gmail.com> Cc: edgar.iglesias@xilinx.com, julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [PATCH v1 1/1] xen/arm: Relax hw domain mapping attributes to p2m_mmio_direct_c 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 From: "Edgar E. Iglesias" Relax the hardware domains mapping attributes to p2m_mmio_direct_c. This will allow the hardware domain to fully control the attribtues via its S1 mappings. Signed-off-by: Edgar E. Iglesias --- xen/arch/arm/domain_build.c | 63 ++++++++++----------------------------------- 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 07b868d..a3521c7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -48,20 +48,6 @@ struct map_range_data p2m_type_t p2mt; }; -static const struct dt_device_match dev_map_attrs[] __initconst = -{ - { - __DT_MATCH_COMPATIBLE("mmio-sram"), - __DT_MATCH_PROP("no-memory-wc"), - .data = (void *) (uintptr_t) p2m_mmio_direct_dev, - }, - { - __DT_MATCH_COMPATIBLE("mmio-sram"), - .data = (void *) (uintptr_t) p2m_mmio_direct_nc, - }, - { /* sentinel */ }, -}; - //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -1005,8 +991,7 @@ static int map_range_to_domain(const struct dt_device_node *dev, u64 addr, u64 len, void *data) { - struct map_range_data *mr_data = data; - struct domain *d = mr_data->d; + struct domain *d = data; bool_t need_mapping = !dt_device_for_passthrough(dev); int res; @@ -1027,7 +1012,7 @@ static int map_range_to_domain(const struct dt_device_node *dev, _gfn(paddr_to_pfn(addr)), DIV_ROUND_UP(len, PAGE_SIZE), _mfn(paddr_to_pfn(addr)), - mr_data->p2mt); + p2m_mmio_direct_c); if ( res < 0 ) { @@ -1039,8 +1024,8 @@ static int map_range_to_domain(const struct dt_device_node *dev, } } - dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=%x\n", - addr, addr + len, mr_data->p2mt); + dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64"\n", + addr, addr + len); return 0; } @@ -1051,10 +1036,8 @@ static int map_range_to_domain(const struct dt_device_node *dev, * the child resources available to domain 0. */ static int map_device_children(struct domain *d, - const struct dt_device_node *dev, - p2m_type_t p2mt) + const struct dt_device_node *dev) { - struct map_range_data mr_data = { .d = d, .p2mt = p2mt }; int ret; if ( dt_device_type_is_equal(dev, "pci") ) @@ -1066,7 +1049,7 @@ static int map_device_children(struct domain *d, if ( ret < 0 ) return ret; - ret = dt_for_each_range(dev, &map_range_to_domain, &mr_data); + ret = dt_for_each_range(dev, &map_range_to_domain, d); if ( ret < 0 ) return ret; } @@ -1082,8 +1065,7 @@ static int map_device_children(struct domain *d, * - Assign the device to the guest if it's protected by an IOMMU * - Map the IRQs and iomem regions to DOM0 */ -static int handle_device(struct domain *d, struct dt_device_node *dev, - p2m_type_t p2mt) +static int handle_device(struct domain *d, struct dt_device_node *dev) { unsigned int nirq; unsigned int naddr; @@ -1149,7 +1131,6 @@ static int handle_device(struct domain *d, struct dt_device_node *dev, /* Give permission and map MMIOs */ for ( i = 0; i < naddr; i++ ) { - struct map_range_data mr_data = { .d = d, .p2mt = p2mt }; res = dt_device_get_address(dev, i, &addr, &size); if ( res ) { @@ -1158,36 +1139,20 @@ static int handle_device(struct domain *d, struct dt_device_node *dev, return res; } - res = map_range_to_domain(dev, addr, size, &mr_data); + res = map_range_to_domain(dev, addr, size, d); if ( res ) return res; } - res = map_device_children(d, dev, p2mt); + res = map_device_children(d, dev); if ( res ) return res; return 0; } -static p2m_type_t lookup_map_attr(struct dt_device_node *node, - p2m_type_t parent_p2mt) -{ - const struct dt_device_match *r; - - /* Search and if nothing matches, use the parent's attributes. */ - r = dt_match_node(dev_map_attrs, node); - - /* - * If this node does not dictate specific mapping attributes, - * it inherits its parent's attributes. - */ - return r ? (uintptr_t) r->data : parent_p2mt; -} - static int handle_node(struct domain *d, struct kernel_info *kinfo, - struct dt_device_node *node, - p2m_type_t p2mt) + struct dt_device_node *node) { static const struct dt_device_match skip_matches[] __initconst = { @@ -1275,8 +1240,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, "WARNING: Path %s is reserved, skip the node as we may re-use the path.\n", path); - p2mt = lookup_map_attr(node, p2mt); - res = handle_device(d, node, p2mt); + res = handle_device(d, node); if ( res) return res; @@ -1298,7 +1262,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, for ( child = node->child; child != NULL; child = child->sibling ) { - res = handle_node(d, kinfo, child, p2mt); + res = handle_node(d, kinfo, child); if ( res ) return res; } @@ -1330,7 +1294,6 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) { - const p2m_type_t default_p2mt = p2m_mmio_direct_dev; const void *fdt; int new_size; int ret; @@ -1350,7 +1313,7 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) fdt_finish_reservemap(kinfo->fdt); - ret = handle_node(d, kinfo, dt_host, default_p2mt); + ret = handle_node(d, kinfo, dt_host); if ( ret ) goto err;