From patchwork Fri Jun 3 13:29:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 9153065 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 9F6A96072B for ; Fri, 3 Jun 2016 13:31:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DA18282EE for ; Fri, 3 Jun 2016 13:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EE8D282E8; Fri, 3 Jun 2016 13:31:48 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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 40574282E8 for ; Fri, 3 Jun 2016 13:31:47 +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 1b8pAk-0005wY-7t; Fri, 03 Jun 2016 13:29:58 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8pAi-0005vG-Op for xen-devel@lists.xen.org; Fri, 03 Jun 2016 13:29:56 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id CA/64-06230-45681575; Fri, 03 Jun 2016 13:29:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRvkohvcFhh ucPKzjMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvG94Q5jwTn9ilV7LzE2MN5T7GLk4hASmMQo Mb1lISOIwyLwkkWiYf4lMEdCoJ9VomvjabYuRk4gJ0ZiffsJFgi7UuLfn7XMILaQgLrE6Xc72 CBGTWOS2PT+NztIgk3ARGLvnwdMILaIgLTEtc+XGUFsZgFfiZs7j4PFhQWiJd5P2ABmswioSl zYtQPM5hVwl/i//A7QAg6gZXISCy6kg4Q5BTwknp96yQYSFgIqeXZPbQKjwAJGhlWM6sWpRWW pRbqGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgWHFAAQ7GHc+dzrEKMnBpCTK e/5sQLgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV671sBwIcGi1PTUirTMHGCAw6QlOHiURHijQ NK8xQWJucWZ6RCpU4y6HFum3lvLJMSSl5+XKiXOqwhSJABSlFGaBzcCFm2XGGWlhHkZgY4S4i lILcrNLEGVf8UozsGoJMyrCzKFJzOvBG7TK6AjmICOKHjkD3JESSJCSqqBMVbmTsVtrSMBdvE cigbRD/puxj7t0Tz9s0L/Y+AceZaDwnMlL1/WLmVa2T2/5OfsF480K88e+eJyc6rOdembfge2 pHVe8op+xh0pfeTMP9WExxs+XD1+0f1it+EP25X1az8I5V67tvjV9EaH5LfarB+qOBg7gqf6K XCsYus7c0ahZL3w1JWpxkosxRmJhlrMRcWJAHhe7WKxAgAA X-Env-Sender: edgar.iglesias@gmail.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1464960595!17166093!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31635 invoked from network); 3 Jun 2016 13:29:55 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Jun 2016 13:29:55 -0000 Received: by mail-wm0-f68.google.com with SMTP id a136so23705462wme.0 for ; Fri, 03 Jun 2016 06:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IftHQ6gWmyNZpZmNNJS36oUSPvdNU7Z/zfZndhOGbgc=; b=r5YeC7KMpMPGCLX12MFsovIeeYtDYUriiK3sQ/dUAlWKhuijA9kYhv1sqZd3qa5lOz 3F1K+UaKP9lWx0b+RI6uMedUpVcteUIEWM1uTkBHjKdyGphjAZUqYLzu0XdWEWAtPi99 ObQQwlDEN1XNDKJMR6IWVDMFx90EXxH9M43Oh8zAl47VAH6kOjyYEF5k+VBcpA5HW7SY IrLR6pqODlCBfNSvESOMzw6oHG72Yf/RYtyCDe5tV+73WgLYkTsqc1NXpt40ZSZNJhAP Om98tCjvcF8T/D6VTHyskFUIyp4IC4yYtQVhSjezsRwrBlenQNkeRfJmAYN/pTyA+Upa /FkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IftHQ6gWmyNZpZmNNJS36oUSPvdNU7Z/zfZndhOGbgc=; b=LfWmqvmZ/hz1U1biHVsU46ftCaSycDLlAF+dnu68o9URwN6FX+XmjgI8qgcQ4QDnba a4yD6mOj7Adx6XXV/j9QuVKHx1GkJK8YDxs1sTkLZML9gOzvnJhHJx5AEiaEepGuNaRr CAdA28rlU8wAP7v5OK2qpD5l40xbnoX9s99tZUUvwb+NvnszP68RCD8JrijCeEFreocA ZI9B96SNSpOQQOvjKCZf6ln3Bi2L36IOwzjyiS+ElvU3bIe8R3tYtmEnr40R9u/vzajg 0L+X24SBW2p7fO9cMfdIwyjrETUMpFa2j0Szg7u6NjQ7R8WLm6YXTjVTLpS48lEDy9j3 5rKw== X-Gm-Message-State: ALyK8tLTxC1HdiXDkT+NhmtSwUpKqM21rMP+GuKEQkbHEzbk38KW633QwsFgP+o1ZcUXgg== X-Received: by 10.194.200.65 with SMTP id jq1mr4032393wjc.21.1464960588075; Fri, 03 Jun 2016 06:29:48 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id l9sm5814464wjm.0.2016.06.03.06.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jun 2016 06:29:47 -0700 (PDT) From: "Edgar E. Iglesias" To: xen-devel@lists.xen.org Date: Fri, 3 Jun 2016 15:29:10 +0200 Message-Id: <1464960552-6645-6-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1464960552-6645-1-git-send-email-edgar.iglesias@gmail.com> References: <1464960552-6645-1-git-send-email-edgar.iglesias@gmail.com> Cc: edgar.iglesias@xilinx.com, julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [RFC for-4.8 v2 5/7] xen/arm: domain_build: Plumb for different mapping attributes 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" Add plumbing for passing around mapping attributes. This is in preparation to allow us to differentiate the attributes for specific device nodes. We still use the same DEVICE mappings for all nodes so this patch has no functional change. Signed-off-by: Edgar E. Iglesias --- xen/arch/arm/domain_build.c | 57 +++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e4fed4b..064feb3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -42,6 +42,18 @@ static void __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); +struct map_attr +{ + unsigned int memattr; + p2m_access_t access; +}; + +struct map_range_data +{ + struct domain *d; + const struct map_attr *attr; +}; + //#define DEBUG_DT #ifdef DEBUG_DT @@ -1024,7 +1036,8 @@ static int map_range_to_domain(const struct dt_device_node *dev, u64 addr, u64 len, void *data) { - struct domain *d = data; + struct map_range_data *mr_data = data; + struct domain *d = mr_data->d; bool_t need_mapping = !dt_device_for_passthrough(dev); int res; @@ -1041,10 +1054,13 @@ static int map_range_to_domain(const struct dt_device_node *dev, if ( need_mapping ) { - res = map_mmio_regions(d, - paddr_to_pfn(addr), - DIV_ROUND_UP(len, PAGE_SIZE), - paddr_to_pfn(addr)); + res = map_regions(d, + paddr_to_pfn(addr), + DIV_ROUND_UP(len, PAGE_SIZE), + paddr_to_pfn(addr), + mr_data->attr->memattr, + mr_data->attr->access); + if ( res < 0 ) { printk(XENLOG_ERR "Unable to map 0x%"PRIx64 @@ -1055,7 +1071,8 @@ static int map_range_to_domain(const struct dt_device_node *dev, } } - DPRINT(" - MMIO: %010"PRIx64" - %010"PRIx64"\n", addr, addr + len); + DPRINT(" - MMIO: %010"PRIx64" - %010"PRIx64" MemAttr=%x\n", + addr, addr + len, mr_data->attr->memattr); return 0; } @@ -1066,8 +1083,10 @@ 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) + const struct dt_device_node *dev, + const struct map_attr *attr) { + struct map_range_data mr_data = { .d = d, .attr = attr }; int ret; if ( dt_device_type_is_equal(dev, "pci") ) @@ -1078,7 +1097,7 @@ static int map_device_children(struct domain *d, if ( ret < 0 ) return ret; - ret = dt_for_each_range(dev, &map_range_to_domain, d); + ret = dt_for_each_range(dev, &map_range_to_domain, &mr_data); if ( ret < 0 ) return ret; } @@ -1094,7 +1113,8 @@ 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) +static int handle_device(struct domain *d, struct dt_device_node *dev, + const struct map_attr *attr) { unsigned int nirq; unsigned int naddr; @@ -1160,6 +1180,7 @@ 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, attr = attr }; res = dt_device_get_address(dev, i, &addr, &size); if ( res ) { @@ -1168,12 +1189,12 @@ static int handle_device(struct domain *d, struct dt_device_node *dev) return res; } - res = map_range_to_domain(dev, addr, size, d); + res = map_range_to_domain(dev, addr, size, &mr_data); if ( res ) return res; } - res = map_device_children(d, dev); + res = map_device_children(d, dev, attr); if ( res ) return res; @@ -1181,7 +1202,8 @@ static int handle_device(struct domain *d, struct dt_device_node *dev) } static int handle_node(struct domain *d, struct kernel_info *kinfo, - struct dt_device_node *node) + struct dt_device_node *node, + const struct map_attr *attr) { static const struct dt_device_match skip_matches[] __initconst = { @@ -1268,7 +1290,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); - res = handle_device(d, node); + res = handle_device(d, node, attr); if ( res) return res; @@ -1290,7 +1312,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); + res = handle_node(d, kinfo, child, attr); if ( res ) return res; } @@ -1322,6 +1344,11 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) { + const struct map_attr default_attr = + { + .memattr = MATTR_DEV, + .access = d->arch.p2m.default_access, + }; const void *fdt; int new_size; int ret; @@ -1341,7 +1368,7 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) fdt_finish_reservemap(kinfo->fdt); - ret = handle_node(d, kinfo, dt_host); + ret = handle_node(d, kinfo, dt_host, &default_attr); if ( ret ) goto err;