From nobody Fri Mar 29 00:42:11 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=1565648991; cv=none; d=zoho.com; s=zohoarc; b=XZ7ygcWqAm8dzXCtY8Rxl7F41ARzZb+tvG/ibe8zegfS0E6E0RGCUESam1ppE32awTTKyrObltVJGbGkvbFE3Dh+DFnsafZbiq5llZiZXFpAsg8N72XwTikCnW5vULSchiB03I0/Y46/hdAEaKMgVqK4XyYzBJruHAuHrXSNnmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565648991; 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=NttybGqBSB20w7sQPygOPCPjuHtPuYv5urSEQik7D+U=; b=FeVlZbCXNzXBGtpad8psVicG5WWHfgnRKS7V3UsIvwgiVjV/zoMbPJTU2jClfqbfERnfwS66JibRrOsVzwmk1ZqbaH4Gn56d16X9nPajaFJKU8OFlh9x5Hbb7bD/VN6Zm0Ew+eB6ka9DqZu1cYipgnljbRT09/COXsyCDjT+BII= 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 1565648991385131.72385565060915; Mon, 12 Aug 2019 15:29:51 -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 1hxIo5-00080Z-BH; Mon, 12 Aug 2019 22:28:49 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxIo4-00080P-89 for xen-devel@lists.xenproject.org; Mon, 12 Aug 2019 22:28:48 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 8c8f66ef-bd50-11e9-8980-bc764e045a96; Mon, 12 Aug 2019 22:28:46 +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 089F92067D; Mon, 12 Aug 2019 22:28:45 +0000 (UTC) X-Inumbo-ID: 8c8f66ef-bd50-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648926; bh=UC6LvtHz0La5PhFyme6nPaWtoN8dcNO0hkPM1VZBu9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+PYFyeyaQUdFnnBswsixog91D/rX1poxPvsEHh3cpu17S6tCHNhiiberwhQTzmd5 gXkVfsjlZ9TAiRGF+P1EnRpJ2qniPc/aZeVja/h2TOJXpyTrkslz5611sqHkgAiHoh 6pPt5zX8PZQT60vE+VH2iDk4Y2KbOaMpdKx/G7f4= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:38 -0700 Message-Id: <20190812222844.9636-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 1/7] 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. Passing 0 triggers the old behavior. Set min_depth to depth of the current node + 1 and replace the for loop with a do/while loop to avoid scanning siblings of the initial node passed as an argument. 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 and the node itself. Signed-off-by: Stefano Stabellini --- 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 | 19 ++++++++++--------- xen/include/xen/device_tree.h | 6 +++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769a10..d4957cca06 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..a872ea57d6 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -77,6 +77,7 @@ 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: node to start the search from * @func: function to call for each node. * @data: data to pass to @func. * @@ -85,20 +86,17 @@ 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; + int depth =3D fdt_node_depth(fdt, node); + int min_depth =3D depth + 1; 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 @@ -120,7 +118,10 @@ int __init device_tree_for_each_node(const void *fdt, 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 >=3D min_depth ); + return 0; } =20 @@ -357,7 +358,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 Fri Mar 29 00:42:11 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=1565648988; cv=none; d=zoho.com; s=zohoarc; b=CjBGOCJLUma0rQuBXZjlRjoCFD1whiif1LXHtbgHA2UIcDWJLrTWrIgd/Jp6cPzRp6gR8H7+hMnKMLtixOUrSC47JYW3/8nKzcQFvDWMESIBQAoVa7/351r7sUkkvXnyiFqLW7R5DupWUiQzxnW/49264jbIk7SppRq6JVFRNAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565648988; 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=KPy8rscFq8FKPU1My2ebvU0Mu328vBjwkgV2CfrOOoQ=; b=Hy74h+OEAD/czXQ5nIMbUsj4VcNK4oWmIC4hM5SPrmp7FiCV8no7EAomU0d7KmewGm4CF1N+RDZEmD+povWvGJ5P0AnpiCNDlOlUA+poJHMmlKUhnwqOIyH3yetmlFQ0OVmgf8BIRGESuxJtZ/1nDQZL33GfEnhQQadYTSOOHDU= 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 1565648988979368.66827717902083; Mon, 12 Aug 2019 15:29: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 1hxIo6-00080p-K2; Mon, 12 Aug 2019 22:28:50 +0000 Received: from [172.99.69.81] (helo=us1-rack-iad1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxIo4-00080U-Gz for xen-devel@lists.xenproject.org; Mon, 12 Aug 2019 22:28:48 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8ce32bd4-bd50-11e9-8735-73d23eebb1cc; Mon, 12 Aug 2019 22:28:47 +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 719A12075B; Mon, 12 Aug 2019 22:28:46 +0000 (UTC) X-Inumbo-ID: 8ce32bd4-bd50-11e9-8735-73d23eebb1cc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648926; bh=P666yZnne25GLg5lZi++w34Taeb+IzMw+T7KSxN3FRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhf9zT40pEJ0ex8Ohb6I/Dr0isaG5JQqMWmmjvzC/GLt0+VmPpz7R4thO3ze9Vg9T sWVZ5uYqhCJV49/EDWp63GrYs2dyE6fxP5RWNMIzO96tVL03B4HrUXjbeM5qaBdq+g gLJ+3HWGgTseU1LcELUmByPe73xHTNNeEt3ciqvs= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:39 -0700 Message-Id: <20190812222844.9636-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 2/7] 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. Signed-off-by: Stefano Stabellini --- 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, 15 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index a872ea57d6..590b14304c 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -125,9 +125,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; @@ -137,18 +138,11 @@ static void __init process_memory_node(const void *fd= t, int node, u32 reg_cells =3D address_cells + size_cells; =20 if ( address_cells < 1 || size_cells < 1 ) - { - printk("fdt: node `%s': invalid #address-cells or #size-cells", - name); - return; - } + return -ENOENT; =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)); @@ -162,6 +156,10 @@ 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++; } + + if ( bootinfo.mem.nr_banks =3D=3D NR_MEM_BANKS ) + return -ENOSPC; + return 0; } =20 static void __init process_multiboot_node(const void *fdt, int node, @@ -293,15 +291,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 Mar 29 00:42:11 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=1565678873; cv=none; d=zoho.com; s=zohoarc; b=dZu3INdZJ0g966k2jTUamLezXVaCTE6R7erbS4EVCRKJqpQXYrjgF3nQ3+JHgMCLoC9sXpdYUv37MR/R4kYsEre35VmB9UTy1n9r01faylsLYVy8ptpOCrsW6pw962wllimdZOP2o8jn+A3fsx+s+3R41UtfNCszEYXZbv2pbiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565678873; 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=UW/4vmQk4pHIF55J4prx3rTGQLXuAGTIBFj0YVo/x04=; b=H6LsfCGu/0Sr616HbcabzIcpG5UTtyfe5R/OA/I0YLrwKb+SwAxoaf9PMNsM+tAgM1DOUkaSO5smM5LMwATcyTFFHDfn6lzAwPcUGyuJdvVm4DcYmTVsxeFJ0D+wt1ynA7V+56dgWLNjc9amb91OzmwtrxjE5weaoJ+vncIjRzk= 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 156567887366092.95366137576991; Mon, 12 Aug 2019 23:47:53 -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 1hxQaY-0000Av-6P; Tue, 13 Aug 2019 06:47:22 +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 1hxQaX-0000Am-L0 for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 06:47:21 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8d23aee8-bd50-11e9-8c9b-d7f7162dcfcd; Mon, 12 Aug 2019 22:28:47 +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 E881820820; Mon, 12 Aug 2019 22:28:46 +0000 (UTC) X-Inumbo-ID: 8d23aee8-bd50-11e9-8c9b-d7f7162dcfcd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648927; bh=1csM4IPo06ByYY4SlciFz8edTx3fDto1QEZU0aSOS1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzpvlUAxJejiUTnOt2PJX2aoZnknnik7zTW9EcNV79o8X9ktB/dYdgx8HuHCh/nJe ByZtwjoX6MF1dkz+aQo8ue0iAH55QECLl2tfg7oG7seRnk0d6yHDVGk0npbW6dWiAV SO6QHU+WDhSvaaYzJpIXGvUAXhkZLfz8T+8V6rFM= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:40 -0700 Message-Id: <20190812222844.9636-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 3/7] 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 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 | 41 +++++++++++++++++++++++++++++++------ xen/include/asm-arm/setup.h | 1 + 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 590b14304c..0b0e22a3d0 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -136,6 +136,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 ) return -ENOENT; @@ -147,21 +148,46 @@ 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 ) 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++; } =20 - if ( bootinfo.mem.nr_banks =3D=3D NR_MEM_BANKS ) + if ( mem->nr_banks =3D=3D NR_MEM_BANKS ) return -ENOSPC; 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) @@ -295,7 +321,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 && !strcmp(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 Fri Mar 29 00:42:11 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=1565679005; cv=none; d=zoho.com; s=zohoarc; b=DsqIhaJmrjRl+0BIcdG7Ack5YCHER0/2ygICZVEfX4kcpw4cufGL/1JFTMfeTL18toaoQ0gx7E2uAOTp51DXW/lPPHELu/1nKaLauf02S410i9OGwMMOmKA2CTwfE7BMmiTaCXXBlohN7/V9Y5qjGGImIE9V/vXzeDrZ1VrrCzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565679005; 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=63d97u7zIoD+3FRyieCYUeaneYIuu1sm7z2UmwiKXzk=; b=WEHbJhmQKAp0Qp3oWvGyPOk7jdUKS0IMJAIzxrvt+VOEGmVQqlEwREwMHQggS1DdXDI66I3YZ1AZJLCjp+C+eB7pESZ71Zd2E+naIfzV3QMBnQarb5AtRdh4LekWN/u+DcAKI2S1UndNqP61smPbU3cvK8v8Z0mhy2src9u1eUo= 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 156567900513095.59679702273024; Mon, 12 Aug 2019 23:50:05 -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 1hxQcd-0000aL-Hn; Tue, 13 Aug 2019 06:49:31 +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 1hxQcc-0000a2-Gq for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 06:49:30 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8d5f054c-bd50-11e9-8922-d7f94c606f10; Mon, 12 Aug 2019 22:28:48 +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 5678420842; Mon, 12 Aug 2019 22:28:47 +0000 (UTC) X-Inumbo-ID: 8d5f054c-bd50-11e9-8922-d7f94c606f10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648927; bh=VI05y6ex9i5gksN6QIZvzvo6HHzPFLUgx4BeTPqM1KA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4Ao5wzxvPhCnR3oHHjNySCQ/Yx8DwbmgelcHv7oaMCjJHcJxUJc/HmIxZDLJ0A+Q +wnZGK0lsOXzO27xDE7doqxwfEJDR3K5m/sH10jrlStKlAK0PIIsH4KEuTLACtb2J/ m8P4uCGCDPnLW7Q45fqWfxTjoiikjiwOw9QrX5FQ= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:41 -0700 Message-Id: <20190812222844.9636-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 4/7] 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 Acked-by: Julien Grall --- 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 0b0e22a3d0..32153e6207 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -337,9 +337,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", @@ -361,9 +362,15 @@ static void __init early_print_info(void) continue; /* fdt_get_mem_rsv returns length */ e +=3D s; - printk(" RESVD[%d]: %"PRIpaddr" - %"PRIpaddr"\n", + 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++ ) printk("CMDLINE[%"PRIpaddr"]:%s %s\n", cmds->cmdline[i].start, --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Mar 29 00:42:11 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=1565648991; cv=none; d=zoho.com; s=zohoarc; b=OHkPBMQes2nvIvADDHaV915MWGsHs8UulX6vxrZTMSVdq26Ky+9kcH581xn9t5DaF/ckrhQrklNQG88odxTlKiucriApuArn+ctVLE6nD0S6zlD0s2aDmP1AfimN0cqKQzkNWjt992zDv/QWqbsvcLnHp9HC4u0YL53DeR81EUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565648991; 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=jJGY7A8rxw+Mk/AdilvzAbY4N6Lxp+AvjaeXjae1QE0k4ewa6tAAzTZBbSH++bCxY3/b5B/3Qy/rOcqQpm1aXys5mq7MZtJpPlefiNPEsv3M3Pd2d6x2DWRm2ydTyBrN/g4VBG1SDY5+F7+KEw+sOj0NXa5Vpxnv7WRL+nSX/QY= 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 1565648991579957.0347883143627; Mon, 12 Aug 2019 15:29:51 -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 1hxIo7-000815-0W; Mon, 12 Aug 2019 22:28:51 +0000 Received: from [172.99.69.81] (helo=us1-rack-iad1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxIo5-00080c-Fs for xen-devel@lists.xenproject.org; Mon, 12 Aug 2019 22:28:49 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8da07b26-bd50-11e9-a582-eb81d2f18907; Mon, 12 Aug 2019 22:28:48 +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 C18402085A; Mon, 12 Aug 2019 22:28:47 +0000 (UTC) X-Inumbo-ID: 8da07b26-bd50-11e9-a582-eb81d2f18907 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648928; bh=0bgcGpcMk+jFDiW7wNFctOouGU3NAg189hzDhO+IHyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yf5tA+bpmDFM8+lk/pwT2l2CBDePvmsJpV4hnClTCxnwEakY3mRi37Qz8uxvk/4AD Omwz5NFzscrbGYtRppDGvDJuIfzbSUiauo7ANiKWYz1DvGPNR2C6/NSRWnHljLwD0Q fqsOKkJiHdxloze3sEbnjKm5xdr2eGpSbhUt7TL0= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:42 -0700 Message-Id: <20190812222844.9636-5-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 5/7] 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 Fri Mar 29 00:42:11 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=1565679247; cv=none; d=zoho.com; s=zohoarc; b=MiQ7985mEYcJ05tQExHGUamqDNfquNUPlSn8bRGwZiFuR8rL0og7vdALcF1dm2czsqjJJr+ldkkdbDcF2wLjiu/WiK3SWn8cRE5BkHVlQWZ18O1Zyt/Go69eTFzY7e9iyNGIpUluFQdXz+qjA0qCnJoq4Uy4Kkgss0MyLt7W6cA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565679247; 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=pXAwmpFNwd2QqGnw98GDRGxMNQ315G7NE5NwCaWX8Nw=; b=LRHOvxQkmyb2qvu4YgwnP7Nzr9Egg4JBuVJJ5vUIwfz0JqLzl4pwkq/jQiYIkHXvfltHRX/aJuN9XbeuHrrZQpVcSD5ZEdRm7cFlsfwk2bn4fQT7l5oLcWEV3M9uOkWJpKuaz7RdM+0xiGxP6xEqKpS+J1MDthKILzX/VVp2ugg= 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 1565679247183231.23892339159545; Mon, 12 Aug 2019 23:54:07 -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 1hxQgc-00025p-HU; Tue, 13 Aug 2019 06:53:38 +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 1hxQgb-000258-2o for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 06:53:37 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8ddb8072-bd50-11e9-a84e-ebac4160b3f6; Mon, 12 Aug 2019 22:28:49 +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 37255208C2; Mon, 12 Aug 2019 22:28:48 +0000 (UTC) X-Inumbo-ID: 8ddb8072-bd50-11e9-a84e-ebac4160b3f6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648928; bh=YqKn8gmGY2dQjIORe3HXpvRI5Usi/ROP9j2EUde90d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oy5Hjrgx/ZBjk1flDZWZVYxubXVc2qRJUTkwuIa5I53oe/XLq5M3gRGy5GvQzDXtD 2MehBW9WBuKQTl5dLWflfxvPR8TPb7h9u5Bl79TguWzQ18VbI3rTprkhdaEwDS1L+S qwzzikybUOCxi/sK9vqM9sRz5H5KZsfFJeH2Pd3k= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:43 -0700 Message-Id: <20190812222844.9636-6-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 6/7] 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 --- 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 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4c8404155a..e0c0c01c88 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1155,15 +1155,23 @@ 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 to domUs + * until reserved-memory support is complete. + */ + 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 Fri Mar 29 00:42:11 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=1565648991; cv=none; d=zoho.com; s=zohoarc; b=fQeLBBFwrGDSBX72SFBgkeO1LDVM+hzWMwogZc9gQdaCFlYGJqvylVgpXNE+FW8E9JzBr0M1s+HzALblcdO4S74PLTNDgMzx5OqzMUafBg/X140oJIqG6SmUOEbX+s09oNTMFkk1Tko4JjLzZrd7wDHfd8f6QGLL0mTv7EkGk04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565648991; 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=ocBOKplbeOLOdlAjNHLc9H/UZTbtr8QQerjPk37HfKM=; b=c8/mVEs48WATJb2G0JuD/gqrAmWY4ht62SLhZ8noGPY81kaUwJA00ks9ODGyUKtRxcw/HK9iIlGpziyb1J0rz9N5Cb5MvgGgSyarKDdueFZUGMCC2/oJMSjxdVqv4v8/EzR98vu7Gx2vfGbyCQWKudp9kVnwHj53mNgs3CbOA9w= 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 1565648991625524.3114780507478; Mon, 12 Aug 2019 15:29:51 -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 1hxIo7-00081D-8c; Mon, 12 Aug 2019 22:28:51 +0000 Received: from [172.99.69.81] (helo=us1-rack-iad1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxIo6-00080k-Eq for xen-devel@lists.xenproject.org; Mon, 12 Aug 2019 22:28:50 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8e21cfc8-bd50-11e9-a3d8-2fe4f175137e; Mon, 12 Aug 2019 22:28:49 +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 98F69214C6; Mon, 12 Aug 2019 22:28:48 +0000 (UTC) X-Inumbo-ID: 8e21cfc8-bd50-11e9-a3d8-2fe4f175137e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565648928; bh=cvfIM7HCI2k93DqEsDgx9oqcpT+1cdTxV3hgbmZjMQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fb26qIV+PEDY3U8jqZlFVVrIDGp6ULbjQwBlC6j3V8lS6WToK77IIaDwwo6peNBn/ LKmES1Kv4/zw4WDWGs8O8TPnOcZp36gLBBFaKEJ+PpalWrNWBNFTEHS+JRyEy+CxjZ LRlMrYhVcL1cYHUxxB77Yh1zgtDLwf9j1xMxGyhM= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 15:28:44 -0700 Message-Id: <20190812222844.9636-7-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 7/7] 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 e0c0c01c88..d11cd40ba1 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); @@ -1485,10 +1485,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); @@ -1744,7 +1752,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