From nobody Sat May 4 19:40:32 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=1566236684; cv=none; d=zoho.com; s=zohoarc; b=A1aTisAv164+co41sWJqKzHxZGvCxSz4tP/+YUU+nw4PlRuQjJe7UrvhsMIu7EslvlyFAefKfIlFqtN3brOFqtg3bTjQ7yAhsU0lzpmw/JRs2bl1HP4vq0pgMkwM4qiEcFETSDGk+i526twa+KroXQPsbrSEhLsAg7sHdWrOGMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236684; 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=qSybQxqmSIUUQ6EdJ7X6g4AnRu6aMCJ8NWcPRIFg8Vw=; b=PiP+oG4PPC+BrZezPLePs+r1C25b1ebr1BKecJw1y5GW3snfGPGc14MPjwFxJznsGlVW3bzobOYkWHsq5eIyjNkbBtpSRRt64mwoxOJbYZdV/rdAJZV7QWGTjtBMFkvxUaDopcQ4myVnYUXIbYIcQLs0nE0ztnnu6hlZDUyU45k= 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 1566236684744255.1746914682377; Mon, 19 Aug 2019 10:44:44 -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 1hzlh0-0007cG-3w; Mon, 19 Aug 2019 17:43:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzlgz-0007c9-DT for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:41 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e1768f58-c2a8-11e9-a661-bc764e2007e4; Mon, 19 Aug 2019 17:43:40 +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 E995822CE9; Mon, 19 Aug 2019 17:43:39 +0000 (UTC) X-Inumbo-ID: e1768f58-c2a8-11e9-a661-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236620; bh=844nyVFBsPArCfQb/Y6AXHrw7gwHIR98vGwgWYnfApo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zl/DCfADQSa0bYPxF4qS2YfSk6k1u5KP2BtGDcqeWXpTqLTmwIfMf1cCX6QV2oJDJ eo2sCr84I0ztezaa/Hc1lPjXEf9DjcLTgLs3FEkm1Rtgnx8WvqHpmN6m3tLPw/zyN2 76zLZzc72i8OQ2PAexA4kxGXoKSvge7wMkCCjMwo= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:31 -0700 Message-Id: <20190819174338.10466-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 1/8] xen/arm: pass node to 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, Volodymyr_Babchuk@epam.com 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 a new parameter to device_tree_for_each_node: node, the node to start the search from. To avoid scanning device tree, and given that we only care about relative increments of depth compared to the depth of the initial node, we set the initial depth to 0. Then, we call func() for every node with depth > 0. Don't call func() on the parent node passed as an argument. Clarify the change in the comment on top of the function. The current callers pass the root node as argument: it is OK to skip the root node because no relevant properties are in it, only subnodes. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v7: - fix commit message - use const - init depth and min_depth to 0 Changes in v6: - fix code style - don't call func() on the first node Changes in v5: - go back to v3 - code style improvement in acpi/boot.c - improve comments and commit message - increase min_depth to avoid parsing siblings - replace for with do/while loop and increase min_depth to avoid scanning siblings of the initial node - pass only node, calculate depth Changes in v3: - improve commit message - improve in-code comments - improve code style Changes in v2: - new --- xen/arch/arm/acpi/boot.c | 8 +++++--- xen/arch/arm/bootfdt.c | 38 ++++++++++++++++++++++------------- xen/include/xen/device_tree.h | 6 +++--- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769a10..bf9c78b02c 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -246,9 +246,11 @@ int __init acpi_boot_table_init(void) * - the device tree is not empty (it has more than just a /chosen nod= e) * and ACPI has not been force enabled (acpi=3Dforce) */ - if ( param_acpi_off || ( !param_acpi_force - && device_tree_for_each_node(device_tree_flat= tened, - dt_scan_depth1_nodes, N= ULL))) + if ( param_acpi_off) + goto disable; + if ( !param_acpi_force && + device_tree_for_each_node(device_tree_flattened, 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..0ca3c20f05 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -75,9 +75,10 @@ static u32 __init device_tree_get_u32(const void *fdt, i= nt node, } =20 /** - * device_tree_for_each_node - iterate over all device tree nodes + * device_tree_for_each_node - iterate over all device tree sub-nodes * @fdt: flat device tree. - * @func: function to call for each node. + * @node: parent node to start the search from + * @func: function to call for each sub-node. * @data: data to pass to @func. * * Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. @@ -85,20 +86,22 @@ static u32 __init device_tree_get_u32(const void *fdt, = int node, * Returns 0 if all nodes were iterated over successfully. If @func * returns a value different from 0, that value is returned immediately. */ -int __init device_tree_for_each_node(const void *fdt, +int __init device_tree_for_each_node(const void *fdt, int node, device_tree_node_func func, void *data) { - int node; - int depth; + /* + * We only care about relative depth increments, assume depth of + * node is 0 for simplicity. + */ + int depth =3D 0; + const int min_depth =3D depth; + const int first_node =3D node; u32 address_cells[DEVICE_TREE_MAX_DEPTH]; u32 size_cells[DEVICE_TREE_MAX_DEPTH]; int ret; =20 - for ( node =3D 0, depth =3D 0; - node >=3D0 && depth >=3D 0; - node =3D fdt_next_node(fdt, node, &depth) ) - { + do { const char *name =3D fdt_get_name(fdt, node, NULL); u32 as, ss; =20 @@ -117,10 +120,17 @@ int __init device_tree_for_each_node(const void *fdt, size_cells[depth] =3D device_tree_get_u32(fdt, node, "#size-cells", ss); =20 - ret =3D func(fdt, node, name, depth, as, ss, data); - if ( ret !=3D 0 ) - return ret; - } + /* skip the first node */ + if ( node !=3D first_node ) + { + ret =3D func(fdt, node, name, depth, as, ss, data); + if ( ret !=3D 0 ) + return ret; + } + + node =3D fdt_next_node(fdt, node, &depth); + } while ( node >=3D 0 && depth > min_depth ); + return 0; } =20 @@ -357,7 +367,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, 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..9a7a8f2dab 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -158,9 +158,9 @@ typedef int (*device_tree_node_func)(const void *fdt, =20 extern const void *device_tree_flattened; =20 -int device_tree_for_each_node(const void *fdt, - device_tree_node_func func, - void *data); +int device_tree_for_each_node(const void *fdt, int node, + 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 Sat May 4 19:40:32 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=1566236689; cv=none; d=zoho.com; s=zohoarc; b=jgPhAQQs3AeJz1mFor6e7Nc8uXaaEcwSrceNAjiMIL5J93mxz2v9oIP+NBc5+015YtYFTpTS7dWj35XK7uI52frgm5aNoT67MCC6lCHyMf+NR4QNVM/9J9x/GcsJAUhKqBh9LMRfI+Li9kHAS5tAB7HLS8I518X5BTm2UJfGZj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236689; 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=fTsKJnSrs7Rp9uaWYy8Xpdp0eL9CxNbwbWycx6DVKss=; b=lAN7ewyWWimrZZA+rdsjrR9imDaYmVKVNrlMh7BNXn6uFD2+z9kYzY7UwmBq+tYcJslD3boh3ZBjVJJ6JW0aFDhOENGtafhghLNf+uch5Kp7OGLoCe6Kal0rm77bgrEVrQXZxSCiH3l7JxiqVwLy00otvoaw5VYSaiNobzLLAUM= 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 1566236689471204.7196709965308; Mon, 19 Aug 2019 10:44: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 1hzlh4-0007gT-9e; Mon, 19 Aug 2019 17:43:46 +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 1hzlh1-0007dT-Ty for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:43 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e1b2072d-c2a8-11e9-8bf0-12813bfff9fa; Mon, 19 Aug 2019 17:43:43 +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 6701422CEB; Mon, 19 Aug 2019 17:43:40 +0000 (UTC) X-Inumbo-ID: e1b2072d-c2a8-11e9-8bf0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236620; bh=+OhH4fQuvbpJEq++K+sXjZqfc/fpAT1NdnkuaYtYDMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePs4PT/hz9h8U/HzG+Duq3C35kXnvW3PhdvxbGHx0dWT4WXfVK3UkYpgJaFfGeoWk LYYiSBMfx4wRn7n+uMkywdqE/O0Rcy/gKSLemSLeDGxcSctF/i8p3fIVkdb6fdj+FQ sfsZkBtN9GTUPbq1TdKTZaU3RwriNIJOKbUlBgkg= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:32 -0700 Message-Id: <20190819174338.10466-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 2/8] 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, Volodymyr_Babchuk@epam.com 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. Return error if there is no reg property or if nr_banks is reached. Let the caller deal with the error. Add a printk when device tree parsing fails. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v7: - use -EINVAL as return in case size is 0 Changes in v6: - fix out of space check - bring back printk when address_cells or size_cells are not properly set - return -EINVAL in that case (different from reg missing) - add printk when parsing fails - return -ENOENT when memory size is 0 Changes in v5: - return -ENOENT if address_cells or size_cells are not properly set Changes in v4: - return error if there is no reg propery, remove printk - return error if nr_banks is reached Changes in v3: - improve commit message - check return value of process_memory_node Changes in v2: - new --- xen/arch/arm/bootfdt.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 0ca3c20f05..320c9a16f4 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -134,9 +134,10 @@ int __init device_tree_for_each_node(const void *fdt, = int node, 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; @@ -149,15 +150,12 @@ 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 -EINVAL; } =20 prop =3D fdt_get_property(fdt, node, "reg", NULL); if ( !prop ) - { - printk("fdt: node `%s': missing `reg' property\n", name); - return; - } + return -ENOENT; =20 cell =3D (const __be32 *)prop->data; banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); @@ -166,11 +164,15 @@ static void __init process_memory_node(const void *fd= t, int node, { device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); if ( !size ) - continue; + return -EINVAL; bootinfo.mem.bank[bootinfo.mem.nr_banks].start =3D start; bootinfo.mem.bank[bootinfo.mem.nr_banks].size =3D size; bootinfo.mem.nr_banks++; } + + if ( i < banks ) + return -ENOSPC; + return 0; } =20 static void __init process_multiboot_node(const void *fdt, int node, @@ -302,15 +304,20 @@ 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; + if ( rc < 0 ) + printk("fdt: node `%s': parsing failed\n", name); + 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 Sat May 4 19:40:32 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=1566236690; cv=none; d=zoho.com; s=zohoarc; b=Y1Ehl/964RE8TeWQv8MZ1Tcrrkl55HiKTvPeaFVuw6kSGi6lfMbspkb8gKR5H5uVf/M4NzIE7hllxeQLXjUqD3K4ImX7mpFYc6i9n7SRbCMllWRxoQmpSgP65Ql7ywxmJTPLvfHgXgGC+9cLCkZ0NBjLgQWwenIrDf8kkNttoK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236690; 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=p9Cpgr5XlQH/WjWQk6hYm2MbbrfOGfdTlegbwCWHy/U=; b=Aq8oplvb/oI408BjVZBhsCbSYz5KWr/N69l+tMgU0slaaeLbSjsVq4WGL5sSwsC4GO0+7OktkRuXdKje7/h3PE4E0V7L7of6uNBEz32EHAryzUXbvSbzLRgsaUqCQN62R4zWgHOVgXigWzyIt/HVti2TjyF70+c1a5doYucBMPI= 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 1566236690160483.3173972232398; Mon, 19 Aug 2019 10:44:50 -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 1hzlh1-0007ct-D3; Mon, 19 Aug 2019 17:43:43 +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 1hzlh0-0007cF-4f for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:42 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e1d36391-c2a8-11e9-8bf0-12813bfff9fa; Mon, 19 Aug 2019 17:43:41 +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 CF86E22CEC; Mon, 19 Aug 2019 17:43:40 +0000 (UTC) X-Inumbo-ID: e1d36391-c2a8-11e9-8bf0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236621; bh=DGOsAbLGQLAwOGWOLGRNWazxDuJhxWMLjkYupXGPEZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yuhbtVN332NQdZN9YEWuHyyyRTnIcs12hp9m7Bhl4bbZIsKewXSFX8jPJlVMBitvO R7Vlv4JjX3m9ai/kW4Jzwg5GVAlVn5GgPER2DdfiRUKxK9LsxTYU0cSJ0/CXamgz1P OZbm1IbJ/zwI+OPMOhTplfu5pHKDZoZBthHZHqeE= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:33 -0700 Message-Id: <20190819174338.10466-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 3/8] 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, Volodymyr_Babchuk@epam.com 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 Acked-by: Julien Grall --- Changes in v6: - use dt_node_cmp - add acked-by Changes in v5: - remove unneeded cast - remove unneeded strlen check - don't pass address_cells, size_cells, depth to device_tree_for_each_node Changes in v4: - depth + 1 in process_reserved_memory_node - pass address_cells and size_cells to device_tree_for_each_node - pass struct meminfo * instead of a boolean to process_memory_node - improve in-code comment - use a separate process_reserved_memory_node (separate from process_memory_node) function wrapper to have different error handling 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 | 39 ++++++++++++++++++++++++++++++++----- xen/include/asm-arm/setup.h | 1 + 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 320c9a16f4..0a01963b0e 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -145,6 +145,7 @@ 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 =3D data; =20 if ( address_cells < 1 || size_cells < 1 ) { @@ -160,14 +161,14 @@ static int __init process_memory_node(const void *fdt= , int node, 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 ) return -EINVAL; - 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++; } =20 if ( i < banks ) @@ -175,6 +176,31 @@ static int __init process_memory_node(const void *fdt,= int node, 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, + void *data) +{ + int rc =3D process_memory_node(fdt, node, name, depth, address_cells, + size_cells, data); + + if ( rc =3D=3D -ENOSPC ) + panic("Max number of supported reserved-memory regions reached."); + else if ( rc !=3D -ENOENT ) + return rc; + return 0; +} + +static int __init process_reserved_memory(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cell= s) +{ + return device_tree_for_each_node(fdt, node, + process_reserved_memory_node, + &bootinfo.reserved_mem); +} + static void __init process_multiboot_node(const void *fdt, int node, const char *name, u32 address_cells, u32 size_cell= s) @@ -308,7 +334,10 @@ 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, &bootinfo.mem); + else if ( depth =3D=3D 1 && !dt_node_cmp(name, "reserved-memory") ) + rc =3D process_reserved_memory(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 Sat May 4 19:40:32 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=1566236690; cv=none; d=zoho.com; s=zohoarc; b=ZzjtgW4N0pao0TNU3TgWyzmUIZFbzzT0UQpBWP6IxDRV4AnAvJoP7npIGJLdoRL5ahwgN84Wf0K4WTBHyn8iVDvyJm9pSsXA8YYD8c41hEv61l9LAdi//Hp3js9DDyjVYH909YTIudVBN+tlHtdlBGReCqHlbE+5jXB5lrbInnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236690; 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=BC7rg8V4HfWcmXUK0YJ5A7hQ6pnxf83uSX8buoPZSiY=; b=OlyooptzZwVFwjCJ5UiTvTg0bCkWKouemhpOFJ9uSz4IVKeT8/royyHA/j+6L+iS1FJcNW1XX5qvhMbExMPFuHyHx9t4dZ/1l5dfHnTBS0zJMe3Q/Dhqyxuaq5P+eC4KAOnQTgUJvXZ0x/CZeCyn4OHx2HIdcbejJGsROgsM9/c= 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 1566236690907258.95108911677426; Mon, 19 Aug 2019 10:44:50 -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 1hzlh1-0007dJ-Lm; Mon, 19 Aug 2019 17:43:43 +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 1hzlh0-0007cO-Cv for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:42 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e23a9da8-c2a8-11e9-8bf0-12813bfff9fa; Mon, 19 Aug 2019 17:43:42 +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 4435622CED; Mon, 19 Aug 2019 17:43:41 +0000 (UTC) X-Inumbo-ID: e23a9da8-c2a8-11e9-8bf0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236621; bh=kZnHStPsKAt1cHn/u26Aj3ltEYDMRWNPwauPalpQ5kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sSs5Sy4LefyQIiQydCwmsj8KGl69iWVVhog0UAEWUlFLfj6OMIQ4515IA0Mn2hQ25 FBSAMyKLlxvlaHUYE2z2KqdtpcLc8uAJPomOkog0AoYAofKUSjSP8UAa2Wju1M8Twh r6urL+mofGGlIvslTSjlC9VvK7RLaBM/DeGC88hA= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:34 -0700 Message-Id: <20190819174338.10466-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 4/8] xen/arm: fix indentation in early_print_info 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, Volodymyr_Babchuk@epam.com 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) No functional changes. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/bootfdt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 0a01963b0e..eb3dc13b06 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -358,15 +358,15 @@ static void __init early_print_info(void) =20 for ( i =3D 0; i < mi->nr_banks; i++ ) printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", - mi->bank[i].start, - mi->bank[i].start + mi->bank[i].size - 1); + mi->bank[i].start, + mi->bank[i].start + mi->bank[i].size - 1); printk("\n"); for ( i =3D 0 ; i < mods->nr_mods; i++ ) printk("MODULE[%d]: %"PRIpaddr" - %"PRIpaddr" %-12s\n", - i, - mods->module[i].start, - mods->module[i].start + mods->module[i].size, - boot_module_kind_as_string(mods->module[i].kind)); + i, + mods->module[i].start, + mods->module[i].start + mods->module[i].size, + boot_module_kind_as_string(mods->module[i].kind)); =20 nr_rsvd =3D fdt_num_mem_rsv(device_tree_flattened); for ( i =3D 0; i < nr_rsvd; i++ ) @@ -376,8 +376,7 @@ static void __init early_print_info(void) continue; /* fdt_get_mem_rsv returns length */ e +=3D s; - printk(" RESVD[%d]: %"PRIpaddr" - %"PRIpaddr"\n", - i, s, e); + printk(" RESVD[%d]: %"PRIpaddr" - %"PRIpaddr"\n", i, s, e); } printk("\n"); for ( i =3D 0 ; i < cmds->nr_mods; i++ ) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 19:40:32 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=1566236692; cv=none; d=zoho.com; s=zohoarc; b=GhWHhN0o5t9BXjbPuwuHCf4Ez4+DezpWzF4GJyx/ukz+PR5ya4XYeBHyMIaO+PLYbsPpf6hm7RSjHjLIBpcdZECYEcGur6cuR1F2SrzZJNmn2s9dDQou2DkeoKBvEYkI2G6aZOxoiuNoqH6GzpaNnsF9p62tl/l4kZ3zRtQZZQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236692; 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=MrPFCBPdBGINSo0aYaj3To8+2tCpzBniKiSS9tfSkac=; b=QxJ9VbNJw1FW94FIClUpcdhpN3AaozLQwu4NZDAuvxOq1u5vUU0bvcQMKLHhtOilUHHwKAc2a60+O4/dvRjl2aZCARW0vDEclLS5LP+6yaUxJrXYihW6PL9bN2nhC4qK1J3MFFlVX7zZkgnj8WgfgSqYTDt3w0AK9eMBrf5ujqI= 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 1566236692032482.66556538082307; Mon, 19 Aug 2019 10:44:52 -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 1hzlh2-0007eA-7S; Mon, 19 Aug 2019 17:43:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzlh0-0007ce-VO for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:42 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e27c8ab0-c2a8-11e9-b90c-bc764e2007e4; Mon, 19 Aug 2019 17:43:42 +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 A9D4222CF4; Mon, 19 Aug 2019 17:43:41 +0000 (UTC) X-Inumbo-ID: e27c8ab0-c2a8-11e9-b90c-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236621; bh=5thd5wvD5iU/Igcl2ae2AdzNxU2d7IpJYwHOSpzdkK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j1Yicx2lw05Cdq7NdZrttN2ANagXVLNvWMwYElu5K6vPp57FLnR//C8TUSE9j453y co7/3B9AEuNYAJgPQHCXdHLjvNiWvkcDdT7uld1WewCQ6F0PV9AMH7W0mOHkme4TiF 9Qrpn2AW2DEHdbi4KBUUBBTZWEh2YWZxeyZtYNt4= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:35 -0700 Message-Id: <20190819174338.10466-5-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 5/8] xen/arm: early_print_info print reserved_mem 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, Volodymyr_Babchuk@epam.com 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) Improve early_print_info to also print the banks saved in bootinfo.reserved_mem. Print them right after RESVD, increasing the same index. Since we are at it, also switch the existing RESVD print to use unsigned int. Signed-off-by: Stefano Stabellini Reviewed-by: Volodymyr Babchuk Acked-by: Julien Grall --- Changes in v6: - add acked-by and reviewed-by - fix indentation Changes in v5: - switch to unsigned Changes in v4: - new patch --- xen/arch/arm/bootfdt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index eb3dc13b06..defd793f8f 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -352,9 +352,10 @@ static int __init early_scan_node(const void *fdt, static void __init early_print_info(void) { struct meminfo *mi =3D &bootinfo.mem; + struct meminfo *mem_resv =3D &bootinfo.reserved_mem; struct bootmodules *mods =3D &bootinfo.modules; struct bootcmdlines *cmds =3D &bootinfo.cmdlines; - int i, nr_rsvd; + unsigned int i, j, nr_rsvd; =20 for ( i =3D 0; i < mi->nr_banks; i++ ) printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", @@ -376,7 +377,13 @@ static void __init early_print_info(void) continue; /* fdt_get_mem_rsv returns length */ e +=3D s; - printk(" RESVD[%d]: %"PRIpaddr" - %"PRIpaddr"\n", i, s, e); + printk(" RESVD[%u]: %"PRIpaddr" - %"PRIpaddr"\n", i, s, e); + } + for ( j =3D 0; j < mem_resv->nr_banks; j++, i++ ) + { + printk(" RESVD[%u]: %"PRIpaddr" - %"PRIpaddr"\n", i, + mem_resv->bank[j].start, + mem_resv->bank[j].start + mem_resv->bank[j].size - 1); } printk("\n"); for ( i =3D 0 ; i < cmds->nr_mods; i++ ) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 19:40:32 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=1566236688; cv=none; d=zoho.com; s=zohoarc; b=drA8XHu1SUYAaVB4lo8FdXS/w5GURFyLyVTbMhZx0yHMpi/RHYsmVxp3ok+rwc4It7N5T2fywyEWhzdvxj/lbkawLZC6EO0zHtE0IMOCnNwe/FRbn9DxkBmRGsxsKjARjDYANDmgsnTeKz88EkX3UkV31QP1TGp2Oy0gardw9CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236688; 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=xbk2/wUkys01fN4xGuqdOvIp1h8CGGDBK4N7b70wx7I=; b=VOu0tNrMvsrIoFRHoKJ8zD6a1CJxe1N7ilghXOJe5C75U2ZNhOnEq/jKLGswceyrE62uFEjEZT7ZLrH1g6wGdlD54HOMay710hZ0vLy0+NY7vq/5ms/oq/bDRzcG2uZOuMoCYEz1rrmGvLH1QqTRt8LB3oUV8DgrVuut+RJpXko= 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 1566236688969487.81218395458245; Mon, 19 Aug 2019 10:44: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 1hzlh2-0007eh-HK; Mon, 19 Aug 2019 17:43:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzlh1-0007cv-FJ for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:43 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e2bb8e90-c2a8-11e9-a661-bc764e2007e4; Mon, 19 Aug 2019 17:43:43 +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 1AD8522CF5; Mon, 19 Aug 2019 17:43:42 +0000 (UTC) X-Inumbo-ID: e2bb8e90-c2a8-11e9-a661-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236622; bh=0bgcGpcMk+jFDiW7wNFctOouGU3NAg189hzDhO+IHyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOttv6gZLhEGuPKgKm5Quf8lEQZQr27m8DBc/6Y49CoaRwdMY4MagipthGRQQMRef SEgwyTbVoiTYKi5PEH4e2IHrXV8Hg0FWpDuMVOcth2RwDoweGlJRQ1MxOiYBxXUrnS 1ZUzw18dJloSlZ59haZBuVhsnWqr2WacNkOtgCpE= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:36 -0700 Message-Id: <20190819174338.10466-6-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 6/8] 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, Volodymyr_Babchuk@epam.com 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 v4: - code style - add acked-by 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..bc4082296e 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 Sat May 4 19:40:32 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=1566236686; cv=none; d=zoho.com; s=zohoarc; b=R6F5JF+yPH9ofGgxj71mJ0T7DWGKy7YmTzNyw7JkAx51pEt7fLoVehfUc7IYcacHNdLZrsJpeJPGneuhGWK5vJiI1Be6Bg7z0zo0uDZMCC1hrjoRrB4+uF/aGg0tt+rd9hmUsyout03dYfNWgHATaZb3Ug33x3XiQd1OzsaQPe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236686; 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=GihKnfCfLxrDvvx2/fNYzvfSpOnj/QX84rbz9bwZx9A=; b=nd1WjfliuaRpTT+FSdBpc6mvBGLCtLPPHV+8A3jnJRRNKuqIppmGi8PJsAWUy/00VR7e+sczJrbQN/GXLcjoHfUpcIFUvuea5RV8uve4VJyEzjglcudRDapZ7NmOnilfsQlUFudD64eQDYN+gxPlgyioPHembQ3aHWR4bGsqRL4= 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 156623668625130.359396317075948; Mon, 19 Aug 2019 10:44:46 -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 1hzlh3-0007g5-Te; Mon, 19 Aug 2019 17:43:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hzlh1-0007dN-QN for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:43 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e2fbe7ce-c2a8-11e9-b90c-bc764e2007e4; Mon, 19 Aug 2019 17:43:43 +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 8622B22CF6; Mon, 19 Aug 2019 17:43:42 +0000 (UTC) X-Inumbo-ID: e2fbe7ce-c2a8-11e9-b90c-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236622; bh=WJe3NZNzl8mWTGRxKT1hBPJIFxK3oQ4T6sjD8yfn4i4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1VyVhwG5mtANkR0J2DUZPylFwFS8MJK96pdqg8tRChsbKUWHajfTxhMFY7d7FY9V6 eLJa2XGcx2yWjkivZDvoBr+h2sOMvhVh77D0OncteX2YGGMG6rQJK5eZ7FPuHEPd88 kQdSsB+26hvkya9c0aDjTtYTkWNcNQzssQoUFneE= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:37 -0700 Message-Id: <20190819174338.10466-7-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 7/8] 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, Volodymyr_Babchuk@epam.com 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 unprivileged guests, until reserved-memory regions are properly supported in Xen. For now, do not call iomem_permit_access on them, because giving iomem_permit_access to dom0 means that the toolstack will be able to assign the region to a domU. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v7: - update in-code comment Changes in v6: - compare against "/reserved-memory/" Changes in v5: - fix check condition - use strnicmp - return error - improve commit message Changes in v4: - compare the parent name with reserved-memory - use dt_node_cmp Changes in v3: - new patch --- xen/arch/arm/domain_build.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4c8404155a..b4260f1fc2 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1155,15 +1155,24 @@ 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 ) + /* + * reserved-memory regions are RAM carved out for a special purpose. + * They are not MMIO and therefore a domain should not be able to + * manage them via the IOMEM interface. + */ + if ( strnicmp(dt_node_full_name(dev), "/reserved-memory/", + strlen("/reserved-memory/")) !=3D 0 ) { - 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 Sat May 4 19:40:32 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=1566236694; cv=none; d=zoho.com; s=zohoarc; b=j4aZz1D42l/6RlwUQ8y21UpArLi9/eM754YK0mSPJoWjqCcxto83JKsFP5V69h3VaHLGTrxbT3uEgCciuhojGSJu+79zyOKxr0GfCSGqpqFJ3Jlvdr/WNAY9ZEPM2DBEpY15Qf29jr7ytP44GUvAtNrdBb68mxrkvz+cQkB/USY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566236694; 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=3MCwWvcQ/fRnM6rdcpzNJiJAO7MaaSDEIIliaABhqfw=; b=Phvy4nsga3Jdhqoc78wMlc6qlbiDnvtca7SW1TytxCCwtVE/Rmaa2eEo1STGw4qHXoVc5SEase3pjHy9UOfW8X/V9jikYwq/eVDe12jRADXna+M6KUfLzfuKJB319KZEm+AANYVG+zfw3qRWX2yHij+T/qQgjYaApR1fLLxnsm8= 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 1566236694094958.5267821378532; Mon, 19 Aug 2019 10:44:54 -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 1hzlh4-0007h4-Lo; Mon, 19 Aug 2019 17:43:46 +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 1hzlh2-0007eF-Bg for xen-devel@lists.xenproject.org; Mon, 19 Aug 2019 17:43:44 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e336d9e2-c2a8-11e9-8bf0-12813bfff9fa; Mon, 19 Aug 2019 17:43:43 +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 EB45C22CEA; Mon, 19 Aug 2019 17:43:42 +0000 (UTC) X-Inumbo-ID: e336d9e2-c2a8-11e9-8bf0-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566236623; bh=l/0sKiyT7npfblaIXlMkEZPx0CU8Btu0RJgeGi/h1X8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1jCgKK6Jd0XV5ZyL6flarwiIbtsxAxL4TX/hOkDi+2AXIoP6/iPdXZrSF1SFGEBp QjJW3RXh5V/PaayOIzpumVzOpmytBepg2K7D0xjxmWvBZeqSkeWOhncfwYuLmfqjG5 efV3qqUpApliR0hAhW7iHa/EIU7vVc7vyhzh5lCY= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 19 Aug 2019 10:43:38 -0700 Message-Id: <20190819174338.10466-8-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v7 8/8] 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, Volodymyr_Babchuk@epam.com 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. Change make_memory_node to take a struct meminfo * instead of a kernel_info. Call it twice for dom0, once to create the first regular memory node, and the second time to create a second memory node with the ranges covering reserved-memory regions. Also, make a small code style fix in make_memory_node. Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v5: - add acked-by Changes in v4: - pass struct meminfo * to make_memory_node - call make_memory_node twice for dom0, once for normal memory, once for reserved-memory regions --- xen/arch/arm/domain_build.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b4260f1fc2..306180d8cb 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -639,11 +639,11 @@ static int __init fdt_property_interrupts(void *fdt, = gic_interrupt_t *intr, static int __init make_memory_node(const struct domain *d, void *fdt, int addrcells, int sizecells, - const struct kernel_info *kinfo) + struct meminfo *mem) { 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 * mem->nr_banks; __be32 reg[NR_MEM_BANKS * 4 /* Worst case addrcells + sizecells */]; __be32 *cells; =20 @@ -662,10 +662,10 @@ static int __init make_memory_node(const struct domai= n *d, return res; =20 cells =3D ®[0]; - for ( i =3D 0 ; i < kinfo->mem.nr_banks; i++ ) + for ( i =3D 0 ; i < mem->nr_banks; i++ ) { - u64 start =3D kinfo->mem.bank[i].start; - u64 size =3D kinfo->mem.bank[i].size; + u64 start =3D mem->bank[i].start; + u64 size =3D mem->bank[i].size; =20 dt_dprintk(" Bank %d: %#"PRIx64"->%#"PRIx64"\n", i, start, start + size); @@ -1486,10 +1486,18 @@ static int __init handle_node(struct domain *d, str= uct kernel_info *kinfo, if ( res ) return res; =20 - res =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, kinf= o); + res =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, &kin= fo->mem); if ( res ) return res; =20 + /* + * Create a second memory node to store the ranges covering + * reserved-memory regions. + */ + res =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, + &bootinfo.reserved_mem); + if ( res ) + return res; } =20 res =3D fdt_end_node(kinfo->fdt); @@ -1745,7 +1753,7 @@ static int __init prepare_dtb_domU(struct domain *d, = struct kernel_info *kinfo) if ( ret ) goto err; =20 - ret =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, kinfo); + ret =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, &kinfo->= mem); if ( ret ) goto err; =20 --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel