From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161407; cv=none; d=zoho.com; s=zohoarc; b=SX23sQkFGHY6YwMmAgZvPfuDT4FW88NQ9J+Oqpn3bDXK2iGG1PGB7XSf/01hU5aoaDf69dnl/716nicFUZLKnYAM6LZ0zJmH4PgC10oh43hfQWpuzjH7Wud/r4SPW5jLVanEH4fdNvf2OlmGEbZhm+QUIkVaR7ivV1eU7systw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fHdF9K4vWCF+kniiXZuxItpMjBplQ9lIiJrz2aR+2ro=; b=oThUxO9fDTDMfVeUNuv5gEsHx+xN6tpqkutnHMnac/LC5aw9foWH0NALWIu8guo7XSobLhRI45AgD9YWew2Rh+YVTF02AkZEWxA/fjfD3FWPYn9letqffMPA/M+CKEALdWh5cg8/5rfm2735174H7yUCDPNS/zgQ1n9VcdtRtMk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161407617505.21354062196633; Fri, 21 Jun 2019 16:56:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO9-0004WO-RY; Fri, 21 Jun 2019 23:56:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004V6-BZ for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 247e2e7d-9480-11e9-8980-bc764e045a96; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A0A29206B6; Fri, 21 Jun 2019 23:56:09 +0000 (UTC) X-Inumbo-ID: 247e2e7d-9480-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161369; bh=kGs74uz4c0uoAwjFV0wL1k7xd0I+FLY1Eo1BEY4gNTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBCDsBxKEkNiT35VCiO1UcIFmC5D/bs0khSuI57hwieLKlooqgNajjpN6kdFIxiEK 1cKIaOluFkQpjeT6s6qQqJueHLmPTwXaQUPLuSqqIWXcLCkY9pcDMgyaLv2bbB1eB7 StfMEk7Z3IxpQ8y/25DQfFlKy3zzc5yQTJuPvKYs= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:03 -0700 Message-Id: <20190621235608.2153-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 1/6] xen/arm: extend device_tree_for_each_node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add two new parameters to device_tree_for_each_node: node and depth. Node is the parent node to start the search from and depth is the min depth of the search (the depth of the parent node). Passing 0, 0 triggers the old behavior. We need this change because in follow-up patches we want to be able to use reuse device_tree_for_each_node to call a function for each children nodes of a provided node. Signed-off-by: Stefano Stabellini --- Changes in v3: - improve commit message - improve in-code comments - improve code style Changes in v2: - new --- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/arm/bootfdt.c | 12 ++++++------ xen/include/xen/device_tree.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769a10..cfc85c2b61 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -248,7 +248,7 @@ int __init acpi_boot_table_init(void) */ if ( param_acpi_off || ( !param_acpi_force && device_tree_for_each_node(device_tree_flat= tened, - dt_scan_depth1_nodes, N= ULL))) + 0, 0, dt_scan_depth1_nodes, NULL))) goto disable; =20 /* diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 891b4b66ff..2f9cb8878d 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -77,6 +77,8 @@ static u32 __init device_tree_get_u32(const void *fdt, in= t node, /** * device_tree_for_each_node - iterate over all device tree nodes * @fdt: flat device tree. + * @node: parent node to start the search from + * @depth: depth of the parent node * @func: function to call for each node. * @data: data to pass to @func. * @@ -86,17 +88,15 @@ static u32 __init device_tree_get_u32(const void *fdt, = int node, * returns a value different from 0, that value is returned immediately. */ int __init device_tree_for_each_node(const void *fdt, + int node, int depth, device_tree_node_func func, void *data) { - int node; - int depth; u32 address_cells[DEVICE_TREE_MAX_DEPTH]; u32 size_cells[DEVICE_TREE_MAX_DEPTH]; - int ret; + int ret, min_depth =3D depth; =20 - for ( node =3D 0, depth =3D 0; - node >=3D0 && depth >=3D 0; + for ( ; node >=3D 0 && depth >=3D min_depth; node =3D fdt_next_node(fdt, node, &depth) ) { const char *name =3D fdt_get_name(fdt, node, NULL); @@ -357,7 +357,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) =20 add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); =20 - device_tree_for_each_node((void *)fdt, early_scan_node, NULL); + device_tree_for_each_node((void *)fdt, 0, 0, early_scan_node, NULL); early_print_info(); =20 return fdt_totalsize(fdt); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 83156297e2..e1ec6cb88d 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -159,8 +159,9 @@ typedef int (*device_tree_node_func)(const void *fdt, extern const void *device_tree_flattened; =20 int device_tree_for_each_node(const void *fdt, - device_tree_node_func func, - void *data); + int node, int depth, + device_tree_node_func func, + void *data); =20 /** * dt_unflatten_host_device_tree - Unflatten the host device tree --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161405; cv=none; d=zoho.com; s=zohoarc; b=BM7iJUN53ipl+YKdI4ecCG1KO/t2YN25VjmMtXuaCF1rAKTg0MnggrqHzEh4xuhrCUTfEpbMvCXRrewaM57wZHK4tLHJNCxmTPhoBJN/NKzByMfByWu2qSMGeT38hlqrq5uXncbtlgFOxgZsaJcOda5osrdhjXsAH5tRVrG1T3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ELsJQ+9pFj5iAJdi4hByizFKwk+ChmBnuWjvASaQtzQ=; b=OW3LXYl4na0YxIAmes1iPSuLZyImWiCQnQKeNVVPfUnbU8vdk2+b83Q2MVxd524jcsGNcGaMsFoYfitsXvSRZMsayvhWKtZP4WO+xU7jM00bK8y25pheLgZz43nA7/Wpy6gMpxqQnSH/BtBwrgbnEChbf5fKdM4NUZFhmA6DRwc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161405864573.6285764112874; Fri, 21 Jun 2019 16:56:45 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004V7-6p; Fri, 21 Jun 2019 23:56:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO7-0004Ux-8K for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:11 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 24b97cbe-9480-11e9-b046-cb2c7ff3e318; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 098D1208C3; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) X-Inumbo-ID: 24b97cbe-9480-11e9-b046-cb2c7ff3e318 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161370; bh=sLXpdeS0tb/a6NC7NCOzf0ZkhpfS0D3SVKzk+8JxSUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H0SbDpzIjwqfn5Jhi4GLMSLhZS7G1IVuqlga66IVkVj7eQ5XtmjusCxZPiObi5O4l xM8ffLwVTkTuF4+YP1cdz1+SpfpNlsyGnZnS8/kwg04Q0+OIyCnKnYIm/b5AVhZU8+ fSrNiozfytPddVdFiw6XbWPhEskRL8OAUHv92dRs= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:04 -0700 Message-Id: <20190621235608.2153-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 2/6] xen/arm: make process_memory_node a device_tree_node_func X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Change the signature of process_memory_node to match device_tree_node_func. Thanks to this change, the next patch will be able to use device_tree_for_each_node to call process_memory_node on all the children of a provided node. Signed-off-by: Stefano Stabellini --- Changes in v3: - improve commit message - check return value of process_memory_node Changes in v2: - new --- xen/arch/arm/bootfdt.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 2f9cb8878d..611724433b 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -124,9 +124,10 @@ int __init device_tree_for_each_node(const void *fdt, return 0; } =20 -static void __init process_memory_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cells) +static int __init process_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cells, + void *data) { const struct fdt_property *prop; int i; @@ -139,14 +140,14 @@ static void __init process_memory_node(const void *fd= t, int node, { printk("fdt: node `%s': invalid #address-cells or #size-cells", name); - return; + return 0; } =20 prop =3D fdt_get_property(fdt, node, "reg", NULL); if ( !prop ) { printk("fdt: node `%s': missing `reg' property\n", name); - return; + return 0; } =20 cell =3D (const __be32 *)prop->data; @@ -161,6 +162,8 @@ static void __init process_memory_node(const void *fdt,= int node, bootinfo.mem.bank[bootinfo.mem.nr_banks].size =3D size; bootinfo.mem.nr_banks++; } + + return 0; } =20 static void __init process_multiboot_node(const void *fdt, int node, @@ -292,15 +295,18 @@ static int __init early_scan_node(const void *fdt, u32 address_cells, u32 size_cells, void *data) { + int rc =3D 0; + if ( device_tree_node_matches(fdt, node, "memory") ) - process_memory_node(fdt, node, name, address_cells, size_cells); + rc =3D process_memory_node(fdt, node, name, depth, + address_cells, size_cells, NULL); else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || device_tree_node_compatible(fdt, node, "multiboot,module" ))) process_multiboot_node(fdt, node, name, address_cells, size_cells); else if ( depth =3D=3D 1 && device_tree_node_matches(fdt, node, "chose= n") ) process_chosen_node(fdt, node, name, address_cells, size_cells); =20 - return 0; + return rc; } =20 static void __init early_print_info(void) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161408; cv=none; d=zoho.com; s=zohoarc; b=c3MNe6kh0alBy/mq3JPmclu3UKRWfD87+PZpOnk+lR2ATcoeSP/XcuZPrSGPjMdibJV4ALED/XXuLUajPvMvrgSnGIiSPUbsDw0ZOBdFfYyqGR5sN0K1jd7inV1UYA2tdcbLZye08Xk0DsvPXBSg1xMOHDh+2SnvowHfzeCLepI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qsIFOTrc/O7lhjvAUgOv64UtIWoKhknjRLrEr6pfq4A=; b=JvMlUJcppG0qQuv71brwKJDxON5xWSjNnWJGbtAFFAawnE6imObW5sowNAB0GH7IySowuFm7WonJ4A1nveCoT3dQd3gG+8B1GrfLZCTyutl07lUjuZRjqGf1sH55OsEIDOS/nU7dZNbVgloozoVDJ9n5Kc3a0NGSEeGImwMfqak= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161408491994.5018664525384; Fri, 21 Jun 2019 16:56:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO9-0004W4-Gz; Fri, 21 Jun 2019 23:56:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004V5-A9 for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 24f0bd46-9480-11e9-8980-bc764e045a96; Fri, 21 Jun 2019 23:56:11 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 627E6208CA; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) X-Inumbo-ID: 24f0bd46-9480-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161370; bh=ooUl19J+IJwZ1PqFUpcffEM0Og0dNRoOvPVOxh2NX3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYB9qNK6rDDwk6nE4MZoNevD99KLnTJytUfgd9JPYy5DK6Nz5jeBgbXBszCwrlF+A 1Y1DP9E7OItZjNzm0ynWBfjQ8EZVIqMOEaJLj533LcZPGW+se4G26WVsCidM5tCwz0 Usjf1J15+A6nwgjz7udwCtYDafiSM+alpLGyEbRQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:05 -0700 Message-Id: <20190621235608.2153-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 3/6] xen/arm: keep track of reserved-memory regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As we parse the device tree in Xen, keep track of the reserved-memory regions as they need special treatment (follow-up patches will make use of the stored information.) Reuse process_memory_node to add reserved-memory regions to the bootinfo.reserved_mem array. Refuse to continue once we reach the max number of reserved memory regions to avoid accidentally mapping any portions of them into a VM. Signed-off-by: Stefano Stabellini --- It is cleaner to avoid sharing the whole function process_memory_node between the normal memory case and the reserved-memory case. I'll do it in the next version once I understand the best way do to it. --- Changes in v3: - match only /reserved-memory - put the warning back in place for reg not present on a normal memory region - refuse to continue once we reach the max number of reserved memory regions Changes in v2: - call process_memory_node from process_reserved_memory_node to avoid duplication --- xen/arch/arm/bootfdt.c | 38 +++++++++++++++++++++++++++++++------ xen/include/asm-arm/setup.h | 1 + 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 611724433b..b24ab10cb9 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -135,6 +135,8 @@ static int __init process_memory_node(const void *fdt, = int node, const __be32 *cell; paddr_t start, size; u32 reg_cells =3D address_cells + size_cells; + struct meminfo *mem; + bool reserved =3D (bool)data; =20 if ( address_cells < 1 || size_cells < 1 ) { @@ -143,29 +145,49 @@ static int __init process_memory_node(const void *fdt= , int node, return 0; } =20 + if ( reserved ) + mem =3D &bootinfo.reserved_mem; + else + mem =3D &bootinfo.mem; + prop =3D fdt_get_property(fdt, node, "reg", NULL); if ( !prop ) { - printk("fdt: node `%s': missing `reg' property\n", name); + if ( !reserved ) + printk("fdt: node `%s': missing `reg' property\n", name); return 0; } =20 cell =3D (const __be32 *)prop->data; banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); =20 - for ( i =3D 0; i < banks && bootinfo.mem.nr_banks < NR_MEM_BANKS; i++ ) + for ( i =3D 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) { device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); if ( !size ) continue; - bootinfo.mem.bank[bootinfo.mem.nr_banks].start =3D start; - bootinfo.mem.bank[bootinfo.mem.nr_banks].size =3D size; - bootinfo.mem.nr_banks++; + mem->bank[mem->nr_banks].start =3D start; + mem->bank[mem->nr_banks].size =3D size; + mem->nr_banks++; } + /* + * We reached the max number of supported reserved-memory regions. + * Stop and refuse to continue. We don't want to risk Xen allocating + * those regions as normal memory to a VM. + */ + BUG_ON(reserved && mem->nr_banks =3D=3D NR_MEM_BANKS); =20 return 0; } =20 +static int __init process_reserved_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size= _cells) +{ + device_tree_for_each_node(fdt, node, depth, process_memory_node, (void= *)true); + return 0; +} + static void __init process_multiboot_node(const void *fdt, int node, const char *name, u32 address_cells, u32 size_cell= s) @@ -299,7 +321,11 @@ static int __init early_scan_node(const void *fdt, =20 if ( device_tree_node_matches(fdt, node, "memory") ) rc =3D process_memory_node(fdt, node, name, depth, - address_cells, size_cells, NULL); + address_cells, size_cells, (void*)false); + else if ( depth =3D=3D 1 && !strcmp(name, "reserved-memory") && + strlen(name) =3D=3D strlen("reserved-memory") ) + rc =3D process_reserved_memory_node(fdt, node, name, depth, + address_cells, size_cells); else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || device_tree_node_compatible(fdt, node, "multiboot,module" ))) process_multiboot_node(fdt, node, name, address_cells, size_cells); diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 8bf3d5910a..efcba545c2 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -66,6 +66,7 @@ struct bootcmdlines { =20 struct bootinfo { struct meminfo mem; + struct meminfo reserved_mem; struct bootmodules modules; struct bootcmdlines cmdlines; #ifdef CONFIG_ACPI --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161407; cv=none; d=zoho.com; s=zohoarc; b=jNmLgeYGwmHZ502pm7r+L/G+ffoOQvv4ebHQkXupLOPYliy978gceD/ZbTorM5SbVsy2HlRvt/D9hlA24EXILL32ywmBwfGkqG/pF4UyI6Q/CQIW+bJv7Q+ugKxwGNLi0/SI0FchBuD9xPcF48SZG3E/pFkuemLfo9JZN0SqyF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0S4ne/EG48OUnwTSzo20eGIc5ekrnyo0r+ojW/oo+xc=; b=ga06X2VoduZp2fkS5QkdRUbfIMEZWOd1RILs9C3H+yuJam9U99gxz18xadOLpV9q9CuySSaNmooBMFE/UrBhtbF49HxsgpHjAXbclJRD7yI6Q2zZIZ5sCSJ6kQE/kzZ4ccsRDlfLOycm+kmmBMUUIO0oYzgndp8WVl+QGJDNqW0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161407753151.3718905498905; Fri, 21 Jun 2019 16:56:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTOA-0004XO-JM; Fri, 21 Jun 2019 23:56:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004VI-Ff for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 252ef43a-9480-11e9-8a87-cb80762533cf; Fri, 21 Jun 2019 23:56:11 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C19A821530; Fri, 21 Jun 2019 23:56:10 +0000 (UTC) X-Inumbo-ID: 252ef43a-9480-11e9-8a87-cb80762533cf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161371; bh=xd6isYPxj9hWpPMW0MEOb61upETwKMmHwAnuRy4ymKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eXtwr+/C11Vjc0WAUnRweNCdcdrIhZqw5gzocJaWuTT9pjpsV30sVs2YTJ6eOM/Df zw5oKLWyW34Bwgyx660MY4fNlRXTapbJLa0spqszqrQJoGcwusZ1mAprGAyYaPm7E+ Yfbc672L8KrksFVn3fvKmcv3rEz9Qd6vW3bUAf1w= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:06 -0700 Message-Id: <20190621235608.2153-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 4/6] xen/arm: handle reserved-memory in consider_modules and dt_unreserved_regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) reserved-memory regions overlap with memory nodes. The overlapping memory is reserved-memory and should be handled accordingly: consider_modules and dt_unreserved_regions should skip these regions the same way they are already skipping mem-reserve regions. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v3: - coding style - in-code comments Changes in v2: - fix commit message: full overlap - remove check_reserved_memory - extend consider_modules and dt_unreserved_regions --- xen/arch/arm/setup.c | 53 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 215746a5c3..d9cfb1aa2f 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -206,6 +206,28 @@ void __init dt_unreserved_regions(paddr_t s, paddr_t e, } } =20 + /* + * i is the current bootmodule we are evaluating across all possible + * kinds. + * + * When retrieving the corresponding reserved-memory addresses + * below, we need to index the bootinfo.reserved_mem bank starting + * from 0, and only counting the reserved-memory modules. Hence, + * we need to use i - nr. + */ + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i+1); + dt_unreserved_regions(s, r_s, cb, i+1); + return; + } + } + cb(s, e); } =20 @@ -392,7 +414,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr= _t e, { const struct bootmodules *mi =3D &bootinfo.modules; int i; - int nr_rsvd; + int nr; =20 s =3D (s+align-1) & ~(align-1); e =3D e & ~(align-1); @@ -418,9 +440,9 @@ static paddr_t __init consider_modules(paddr_t s, paddr= _t e, =20 /* Now check any fdt reserved areas. */ =20 - nr_rsvd =3D fdt_num_mem_rsv(device_tree_flattened); + nr =3D fdt_num_mem_rsv(device_tree_flattened); =20 - for ( ; i < mi->nr_mods + nr_rsvd; i++ ) + for ( ; i < mi->nr_mods + nr; i++ ) { paddr_t mod_s, mod_e; =20 @@ -442,6 +464,31 @@ static paddr_t __init consider_modules(paddr_t s, padd= r_t e, return consider_modules(s, mod_s, size, align, i+1); } } + + /* + * i is the current bootmodule we are evaluating, across all + * possible kinds of bootmodules. + * + * When retrieving the corresponding reserved-memory addresses, we + * need to index the bootinfo.reserved_mem bank starting from 0, and + * only counting the reserved-memory modules. Hence, we need to use + * i - nr. + */ + nr +=3D mi->nr_mods; + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + r_e =3D consider_modules(r_e, e, size, align, i + 1); + if ( r_e ) + return r_e; + + return consider_modules(s, r_s, size, align, i + 1); + } + } return e; } #endif --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161408; cv=none; d=zoho.com; s=zohoarc; b=cG/TKp9/bNWCYXWkFS55tV+FCPguFZJ14CNZ7SmX01IguTKYG0Vt3PaBIj2cp6w1kxQMdZ3EwOaWWwRldvt4cNJaekvXMZMztDMWHuvOtBLLVYSWkVYJnVBphus2M4zj5G6V5BX4Vqt183e7/munQqTNUjhCnkeSPzm9D0LvYI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sT94KGWj8i7F4XKbJ9JM53vMynVFfysMR+l9Q85YZ7o=; b=nDnNRKL7PldZwM+27PsunEYLU+utINtgJbyBpZs/Y3F8RYJ6n4+0fghfwm/0ZNzP++fJamwbM+VjDxBwJMq07ZMJcqjmsZpCYhfnGv537YmwH5dzE200Fmmo7vfcxXAaFuChRk9mqIMW8zKe6H0WOdGpLLQMLwRZPpyZikhH8X0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561161408763893.5009426682307; Fri, 21 Jun 2019 16:56:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTOA-0004Ws-7d; Fri, 21 Jun 2019 23:56:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004VH-FM for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2569bcfa-9480-11e9-8576-6743c81f8809; Fri, 21 Jun 2019 23:56:11 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B2E221537; Fri, 21 Jun 2019 23:56:11 +0000 (UTC) X-Inumbo-ID: 2569bcfa-9480-11e9-8576-6743c81f8809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161371; bh=qHZHF64P4pb5q8gwpI51OTVazm0uZwlPIOGvXFN2SI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jfr+Z8RLU60vnjR6yNcGru8bI1x3EfZzAI8J64jYjRQ4RqOnQJaGAQ9m8lAPJVBjU fO4XC02r8mIonKy5VxA/Bef8GKLvoUv9jUDxLE3DcbD4BgRrYjcyvb6tRu8eV15I/X EnaA0zviB8kGsFohf2KvqxX/XjokN4pujtb3oBuk= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:07 -0700 Message-Id: <20190621235608.2153-5-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 5/6] xen/arm: don't iomem_permit_access for reserved-memory regions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Don't allow reserved-memory regions to be remapped into any guests, until reserved-memory regions are properly supported in Xen. For now, do not call iomem_permit_access for them. Signed-off-by: Stefano Stabellini --- Changes in v4: - new patch --- xen/arch/arm/domain_build.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d9836779d1..76dd4bf6f9 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1158,15 +1158,22 @@ static int __init map_range_to_domain(const struct = dt_device_node *dev, bool need_mapping =3D !dt_device_for_passthrough(dev); int res; =20 - res =3D iomem_permit_access(d, paddr_to_pfn(addr), - paddr_to_pfn(PAGE_ALIGN(addr + len - 1))); - if ( res ) + /* + * Don't give iomem permissions for reserved-memory ranges until + * reserved-memory support is complete. + */ + if ( strcmp(dt_node_name(dev), "reserved-memory") ) { - printk(XENLOG_ERR "Unable to permit to dom%d access to" - " 0x%"PRIx64" - 0x%"PRIx64"\n", - d->domain_id, - addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1); - return res; + res =3D iomem_permit_access(d, paddr_to_pfn(addr), + paddr_to_pfn(PAGE_ALIGN(addr + len - 1))= ); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit to dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + d->domain_id, + addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1); + return res; + } } =20 if ( need_mapping ) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Apr 19 02:34:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1561161409; cv=none; d=zoho.com; s=zohoarc; b=V9U1TurreKHjuQzxSLyme16ZQ+IT01iYEexT2YMFalVM57k60+eunVq6iF6mMReFmb8dccSSzSOK0pMFw1vzHrRRwMfAPVKD44B0rtXmQYdmoLpzXNLA3UimQuGsI6KhNx/GJQiKxIlGWMvur5apHPtmYG1mW10HWk3bCDnRVPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561161409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=eTKaqlYDBBjhSliAFBO9LJdSZAD8/wf0njIQDlRJ/xQ=; b=le0JxSZxKlNtKNClMmWtNupO56RtDDE1uPpSMg2baTbDsk4vc/Me2EraGXeyEFE5jb5VXRJHFWGmTetnbVPnYmR84tBp04ZskakDkn2jN1zvFBpWddRM0qOeqF/jR4bsZytaCtBc3kgyntBPDpNRkLchTi17h6ncVxp5Fj9jI5c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156116140940399.88936343886292; Fri, 21 Jun 2019 16:56:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTOA-0004Xu-Ul; Fri, 21 Jun 2019 23:56:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1heTO8-0004Vh-Lx for xen-devel@lists.xenproject.org; Fri, 21 Jun 2019 23:56:12 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 25a31d42-9480-11e9-85fb-0f3bc153b142; Fri, 21 Jun 2019 23:56:12 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 889D1215EA; Fri, 21 Jun 2019 23:56:11 +0000 (UTC) X-Inumbo-ID: 25a31d42-9480-11e9-85fb-0f3bc153b142 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561161371; bh=OsGLz72IL7w4kLE/mYGoRyRf+rKLUXKwExD8YZIlHy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wsczEblBUtdSGub7SY+SlIIxXX3HSx+EUJI4j7onjhTqkBp20j7xdu2yhmxyyFOWp mkRUzUKrPgkDC8eVP/gzqwissaFe128uuHzwELB+QobsDaxHlWoCii1xyY7jw3+3Yp YspDlTwmo1/zlP3OlFexshTdWSB6pbxdQpL8H0dA= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Fri, 21 Jun 2019 16:56:08 -0700 Message-Id: <20190621235608.2153-6-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 6/6] xen/arm: add reserved-memory regions to the dom0 memory node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reserved memory regions are automatically remapped to dom0. Their device tree nodes are also added to dom0 device tree. However, the dom0 memory node is not currently extended to cover the reserved memory regions ranges as required by the spec. This commit fixes it. Signed-off-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 76dd4bf6f9..5047eb4c28 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -643,7 +643,8 @@ static int __init make_memory_node(const struct domain = *d, { int res, i; int reg_size =3D addrcells + sizecells; - int nr_cells =3D reg_size*kinfo->mem.nr_banks; + int nr_cells =3D reg_size * (kinfo->mem.nr_banks + (is_hardware_domain= (d) ? + bootinfo.reserved_mem.nr_banks : 0)); __be32 reg[NR_MEM_BANKS * 4 /* Worst case addrcells + sizecells */]; __be32 *cells; =20 @@ -673,6 +674,20 @@ static int __init make_memory_node(const struct domain= *d, dt_child_set_range(&cells, addrcells, sizecells, start, size); } =20 + if ( is_hardware_domain(d) ) + { + for ( i =3D 0; i < bootinfo.reserved_mem.nr_banks; i++ ) + { + u64 start =3D bootinfo.reserved_mem.bank[i].start; + u64 size =3D bootinfo.reserved_mem.bank[i].size; + + dt_dprintk(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", + i, start, start + size); + + dt_child_set_range(&cells, addrcells, sizecells, start, size); + } + } + res =3D fdt_property(fdt, "reg", reg, nr_cells * sizeof(*reg)); if ( res ) return res; --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel