From nobody Thu Apr 25 17:50:56 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=1565128233; cv=none; d=zoho.com; s=zohoarc; b=TNjmmsvjsrnjDJe7wwLe7oKUgSP0v2K9wByLiH7HO9DX5AOKscmiG9gEnKGKojCXy0VK1RmG1bej91f/cdZazssRqMiiiRiqdNy0u6DEi6Kg7Ko2fQ1QztrKRMKP4jYQOly5QcABLSRceJVNpKOtOxhcaewiRLHNjnZWSFevP2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128233; 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=Tks2jepAikCBlw+R4fukzlajtfWHLu1d5F4l7+PcPFI=; b=VnA5ubnU5MqMV9rwj+11fTtoFw5fSNEi+NctVV+cg2cMhp+MYpM2e2Xjden0JmHrsjS1hyGvmS7t9EMNVdLYMYVCz4txYFbeT0Qpdxkwjqh8wQopLXGcgW9df/nBjR0KsMmCiyhA/j9F5G7b4WMd2a3vzXHvNiIcs4D6tx3g+ac= 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 1565128233755540.2787153612378; Tue, 6 Aug 2019 14:50:33 -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 1hv7Kk-0000nO-HS; Tue, 06 Aug 2019 21:49:30 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hv7Ki-0000mU-Ha for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:28 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0fb69f05-b894-11e9-8980-bc764e045a96; Tue, 06 Aug 2019 21:49:27 +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 8D020216F4; Tue, 6 Aug 2019 21:49:26 +0000 (UTC) X-Inumbo-ID: 0fb69f05-b894-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128166; bh=/cdJ/95ioAx1rGxy/JK7oeuZhFY+qJKHa5QUcBv2k2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajkmDpBwVZx+/S2+vhQV5CybRTUP22vp8U3m8L5BKBXwrsYnRGqbtN0oOVsL3CEjY FVF5Xp+xtBM3YD5rQ8+OYOCcbII6H6wFbOvsvHwIXMDvLeea1qYG+/XRxT8Uo02+Az DnWLomEgnJtV5r+JTxTyzoc+ZlUiC37dIAEXCeig= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:19 -0700 Message-Id: <20190806214925.7534-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 1/7] xen/arm: extend device_tree_for_each_node X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add new parameters to device_tree_for_each_node: node, depth, address_cells, size_cells. Node is the parent node to start the search from; depth is the min depth of the search (the depth of the parent node); address_cells and size_cells are the respective parameters at the parent node. Passing 0, 0, 0, 0 triggers the old behavior. We need this change because in follow-up patches we want to be able to use reuse device_tree_for_each_node to call a function for each children nodes of a provided node. Signed-off-by: Stefano Stabellini --- Changes in v4: - add address_cells and size_cells parameters Changes in v3: - improve commit message - improve in-code comments - improve code style Changes in v2: - new --- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/arm/bootfdt.c | 21 +++++++++++++++------ xen/include/xen/device_tree.h | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 9b29769a10..d275f8c535 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -248,7 +248,7 @@ int __init acpi_boot_table_init(void) */ if ( param_acpi_off || ( !param_acpi_force && device_tree_for_each_node(device_tree_flat= tened, - dt_scan_depth1_nodes, N= ULL))) + 0, 0, 0, 0, dt_scan_depth1_nodes, NULL))) goto disable; =20 /* diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 891b4b66ff..dfce8c2bfe 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -77,6 +77,10 @@ static u32 __init device_tree_get_u32(const void *fdt, i= nt node, /** * device_tree_for_each_node - iterate over all device tree nodes * @fdt: flat device tree. + * @node: parent node to start the search from + * @depth: depth of the parent node + * @address_cells: address_cells at the parent node + * @size_cells: size_cells at the parent node * @func: function to call for each node. * @data: data to pass to @func. * @@ -86,17 +90,22 @@ static u32 __init device_tree_get_u32(const void *fdt, = int node, * returns a value different from 0, that value is returned immediately. */ int __init device_tree_for_each_node(const void *fdt, + int node, int depth, + u32 address_cells_p, u32 size_cells_p, device_tree_node_func func, void *data) { - int node; - int depth; u32 address_cells[DEVICE_TREE_MAX_DEPTH]; u32 size_cells[DEVICE_TREE_MAX_DEPTH]; - int ret; + int ret, min_depth =3D depth; + + if ( depth > 0 ) + { + address_cells[depth - 1] =3D address_cells_p; + size_cells[depth - 1] =3D size_cells_p; + } =20 - for ( node =3D 0, depth =3D 0; - node >=3D0 && depth >=3D 0; + for ( ; node >=3D 0 && depth >=3D min_depth; node =3D fdt_next_node(fdt, node, &depth) ) { const char *name =3D fdt_get_name(fdt, node, NULL); @@ -357,7 +366,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) =20 add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); =20 - device_tree_for_each_node((void *)fdt, early_scan_node, NULL); + device_tree_for_each_node((void *)fdt, 0, 0, 0, 0, early_scan_node, NU= LL); 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..358c67c912 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -159,8 +159,10 @@ typedef int (*device_tree_node_func)(const void *fdt, extern const void *device_tree_flattened; =20 int device_tree_for_each_node(const void *fdt, - device_tree_node_func func, - void *data); + int node, int depth, + u32 address_cells, u32 size_cells, + 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 Thu Apr 25 17:50:56 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=1565128230; cv=none; d=zoho.com; s=zohoarc; b=SbkDjIHMI50sTY3W+VFJpyZ5yIR68DvjmNYunww+//vXHCymHOjSG3R4xvM1sOnPv3couMt10a7Z3ELf1Z+rUTpgZXEBRCc0GaZ2y88iX0BkAJXLMGxrrgwHbWwejHfNPHMVqFHfp3SA2aGdqFuYheXxVs21wGLIRmq/4qIElsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128230; 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=Ui2KfCkwn36odCXsUJBdvR0DpnY90jYdfNnOQXwEZ20=; b=HjGnOVoa2LdpHsz0zTwEIPtz85h3WvXtq/SCDR0LjLrI1UEGdMoIfi0tOQIOpWxWoK6siQZ+LMb/3Rw6EqXN9wE93q9uqtwHuqf40xCibKQiDQqQ5W2VWfc0Mv6AUUSWPkHTsAdrBm7ZJzAA74TY/heQAycqVX7/Ar+AF/FtSs8= 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 1565128230215780.0226083058927; Tue, 6 Aug 2019 14:50:30 -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 1hv7Kk-0000nH-7q; Tue, 06 Aug 2019 21:49:30 +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 1hv7Ki-0000mL-7C for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:28 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0ff91112-b894-11e9-ae76-b7c10cabaa54; Tue, 06 Aug 2019 21:49:27 +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 F1FD02189F; Tue, 6 Aug 2019 21:49:26 +0000 (UTC) X-Inumbo-ID: 0ff91112-b894-11e9-ae76-b7c10cabaa54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128167; bh=USsYkWwxhXAv8mMADxfJLkSqnUQOcR6ldARnRRVbjAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMqgylygyswi7saDXw/PWVQiQjX6mN1oaBGT/A3sUfPFDnqAzyr19AerEKCNOfRTB gL1KPXE8EceiUik9k7CuPoZ1Xp1JzNal2uF2jRmQlu12udyYb1wt+tQUWvNA2H0vlx 7kXOSA+jEfLmMd4iwz3atIiqQPi3w29sHTAzFcQg= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:20 -0700 Message-Id: <20190806214925.7534-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 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, remove printk. Return error if nr_banks is reached. Signed-off-by: Stefano Stabellini --- 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 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index dfce8c2bfe..c22d57cd72 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -133,9 +133,10 @@ int __init device_tree_for_each_node(const void *fdt, return 0; } =20 -static void __init process_memory_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cells) +static int __init process_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cells, + void *data) { const struct fdt_property *prop; int i; @@ -148,15 +149,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 0; } =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)); @@ -170,6 +168,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, @@ -301,15 +303,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 Thu Apr 25 17:50:56 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=1565128233; cv=none; d=zoho.com; s=zohoarc; b=SlHZH9/pMaYA+rAcsHuoQa0wX4UP3YCCM2sKKcBKuAKCTAlMufFOIKtRgJOMjCELp8jehZcAkb28Fm1561jCaHfEgXTAwt3AJCRiZz4DydPaUF3ewAvM2bIRfIeNrtCim/Yef5wNw0qsqYr5W1ywXPxIR7P4OJ3kDNWdR4VWgPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128233; 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=UZgyJcyJ3kxxAaWF3p8VRDYaaOIbk/gNm06NVZr+TXA=; b=iKckI7P2a6aYttSY0jJIoO26IELNWDm5TEld62aJN9hClX4Lm1qRSSJ3OnWuBq9Gk/ZqD4cIIJcVsQL3RZPc0SO4QuQYZJ1oEf2pX0Dnb9uayQruEEHRrn1QzPVgCG5TrUz4SGgwAbKXF5YD6bLj6+tlwToWw1FKQzCUmLE/5FU= 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 1565128233330726.3437958436773; Tue, 6 Aug 2019 14:50:33 -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 1hv7Kl-0000pW-U0; Tue, 06 Aug 2019 21:49:31 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hv7Kj-0000mr-Rc for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:29 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1034bbe4-b894-11e9-8980-bc764e045a96; Tue, 06 Aug 2019 21:49:28 +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 60CE7218A3; Tue, 6 Aug 2019 21:49:27 +0000 (UTC) X-Inumbo-ID: 1034bbe4-b894-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128167; bh=RIE5Uq+VwgKOb50xrFjwCHCwzeOyLzPyzUh00upXqkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0mivJxuutZ2YZyw+6cn/gY+MIob/TWGr2J/oGoYM/tTdD3K/ahoO92QiVhhfFexV 1cxZbT+uT3epatqKD+DSMaranZcmxU/GmNow1ubye53QYt8WCX3tms1kyVefutKW1Q KDlN3/LHN1Cy9Z4xfedIVtR76AuSPB0FP3v+saeo= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:21 -0700 Message-Id: <20190806214925.7534-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 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 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 | 43 +++++++++++++++++++++++++++++++------ xen/include/asm-arm/setup.h | 1 + 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index c22d57cd72..3e6fd63b16 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -144,6 +144,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 (struct meminfo *)data; =20 if ( address_cells < 1 || size_cells < 1 ) { @@ -159,21 +160,47 @@ 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, depth + 1, + address_cells, size_cells, + 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) @@ -307,7 +334,11 @@ static int __init early_scan_node(const void *fdt, =20 if ( device_tree_node_matches(fdt, node, "memory") ) rc =3D process_memory_node(fdt, node, name, depth, - address_cells, size_cells, NULL); + address_cells, size_cells, &bootinfo.mem); + else if ( depth =3D=3D 1 && !strcmp(name, "reserved-memory") && + strlen(name) =3D=3D strlen("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 Thu Apr 25 17:50:56 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=1565128234; cv=none; d=zoho.com; s=zohoarc; b=Aa7hqk3gGC+DdgdVaBluEvz246VYiqJMr5jp06ZWcIOMITZOthhEz0z+H9PZ/woVq/RbsQeaFFIdlf4hB80uSDALGnVwc0CCxbh19z8I1hOZY30yteobaEE24mA0W4dMqgVq46XXu2u3cPyuerHvNeocN0UXuFCd35MVYI4ktA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128234; 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=xji41rSlPmwxZsaP2LBsfv0rdngTBtzq7xNmEDOreI0=; b=P9/t6mbGnBTznUqc9enyyBH32gT5bG8PrexQFQUQ46Qm6a3ajexFaoQWRw8jy6IivL8kmCafPOcfYbgxsKK9hzk6xH1nysmnc1bZran0T7eWjxz6WtbOzzlX5BAZu1rV3KzMsORWCb8uCe1cHKCRrXvzVfUnz6QtFeJ7ZsMZ28k= 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 1565128234464271.3529356263539; Tue, 6 Aug 2019 14:50:34 -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 1hv7Kl-0000ox-HA; Tue, 06 Aug 2019 21:49:31 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hv7Kj-0000mq-QO for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:29 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1071c9d8-b894-11e9-8980-bc764e045a96; Tue, 06 Aug 2019 21:49:28 +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 C6465218A4; Tue, 6 Aug 2019 21:49:27 +0000 (UTC) X-Inumbo-ID: 1071c9d8-b894-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128168; bh=y9qaBrnvPwIqnH9BwbE+aie3cznDazmION0N5Rxo5Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Udk/VybBB/xSAxqCY28VAaV+f77tzkYh69Z53aQ7yHQx7+qQP384dqVz8VDv/ia7L wL0mhE+Sd8P1lFUmcSRp0qeheiH3CIb4WuX4mx6joNFbYILES7iKk5DjDV2SN1em5T 3hZmg96Iu+ooeVLzaP+ekUO0IvR/Xzbzcre8g5j0= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:22 -0700 Message-Id: <20190806214925.7534-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 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. Signed-off-by: Stefano Stabellini --- Changes in v4: - new patch --- xen/arch/arm/bootfdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 3e6fd63b16..b8f2e53122 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -351,9 +351,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; + int i, j, nr_rsvd; =20 for ( i =3D 0; i < mi->nr_banks; i++ ) printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", @@ -378,6 +379,12 @@ static void __init early_print_info(void) printk(" RESVD[%d]: %"PRIpaddr" - %"PRIpaddr"\n", i, s, e); } + for ( j =3D 0; j < mem_resv->nr_banks; j++, i++ ) + { + printk(" RESVD[%d]: %"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 Thu Apr 25 17:50:56 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=1565128236; cv=none; d=zoho.com; s=zohoarc; b=oZdQdiGNAGpeNB8hhY0ZMhvcJ85i8NGdBZObRGBgHu+l3vC5ojtBMESM3bP/U84yxqPB0Q4SL0Tv4m7r+INDMv7YNL0fBmEgwbRhi8K2B8nS8mTqQM+xkfYWiwWg17jfS7P6huqCA7ttejdD7bAjAX6MJE0qcIxirCqk3IQ+bX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128236; 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=copmna0no9n/8tC9xabEHvR/7EJZCgV3rW7+xfqUWusJEh6Ie8Q8q1y1nUcl4kvmLdxLPNjZzuqc7Vo7xmxb1bET4Ft/xCs9ZkBvw99bCt34XDCtuTAzostXMC4DLgndd6UkGnmc8x6kj2LUdyBYprs5UhOnS5403rBjDt9p8hs= 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 1565128236157321.22193720686914; Tue, 6 Aug 2019 14:50:36 -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 1hv7Kk-0000no-Qj; Tue, 06 Aug 2019 21:49:30 +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 1hv7Kj-0000mi-E4 for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:29 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10b03a72-b894-11e9-8b93-7b1706821177; Tue, 06 Aug 2019 21:49:29 +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 332C32189E; Tue, 6 Aug 2019 21:49:28 +0000 (UTC) X-Inumbo-ID: 10b03a72-b894-11e9-8b93-7b1706821177 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128168; bh=0bgcGpcMk+jFDiW7wNFctOouGU3NAg189hzDhO+IHyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SjIbmYaKVCJ9zna4f5XtJuM7ld4rk+3aZR+sAyayjZfMeFWMz11M71S7ZQ/uBRPDA MqaxSIonoLrsNXvnAwYJi5he3us2iIVGABhSZO/PG8fniP2yaYK/vE1P8JiajkjqAn ZvQe1dnclwTx+a13ApI52G4ejSea4G1kIZXqfCYk= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:23 -0700 Message-Id: <20190806214925.7534-5-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 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 Thu Apr 25 17:50:56 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=1565128231; cv=none; d=zoho.com; s=zohoarc; b=APVed6gNGFLPpTsJSVKx5tu3+TnN/3KSv1/1egMprLTCnX7S8vmfX/P7m5siNaTyMtX3j21qJIJ0oe8q/crZdYkjI3Gb2B/UktCv606olY+Sr8UoId9lGP9uD1nRwEF6YGD3cdBR2CEnc1SoqGyeKW9RwjU7sOY/7dZfRaoWSGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128231; 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=AZpxNRn+9MbSLOum9CqMN4M5g5WZGGpw8cjhrETTlcA=; b=Hf+jgZuACX5Ataz4dVSoQ56CfV+8s/NjKA3PCep/4BYNo8QTF/abA1I2qjcK7Sr6SqDN4+TbLCOdNiMvCZKF3xUBk7bVKqhUiEPpOVVPyYLr1uBdS0t2yaLsLmvl3kFbKq2EYDTBWaueO66xeAZM7KeUVi+P0tbgkSND71rXHus= 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 1565128231291616.4663204934002; Tue, 6 Aug 2019 14:50:31 -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 1hv7Kl-0000oN-6Y; Tue, 06 Aug 2019 21: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 1hv7Kj-0000mp-Le for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:29 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10e667e6-b894-11e9-a110-bf1bed7548b1; Tue, 06 Aug 2019 21:49:29 +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 8C292218A6; Tue, 6 Aug 2019 21:49:28 +0000 (UTC) X-Inumbo-ID: 10e667e6-b894-11e9-a110-bf1bed7548b1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128168; bh=sZgajqit8qqVgB1Vr0FiUXVVgAwfUQFWMQOw4YHUJkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBOk+VirK5qYMkxIB1lK6i9Lqq37Fgw+nVRJAjCNDRWqlYWR+IwCrwHeMUWRdForR +GmP1oh/K1p9PttXqpaYNkpZ9oses9My9sqy9TJnSFk2ZUcJUxWK9Dykcn/EZBQ129 OWDsmVnO/JZ54Q2EFqBd4UtmMVtHWAeWPVM3FQfM= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:24 -0700 Message-Id: <20190806214925.7534-6-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Don't allow reserved-memory regions to be remapped into any guests, until reserved-memory regions are properly supported in Xen. For now, do not call iomem_permit_access for them. Signed-off-by: Stefano Stabellini --- Changes in v4: - 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..267e0549e2 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1153,17 +1153,25 @@ static int __init map_range_to_domain(const struct = dt_device_node *dev, struct map_range_data *mr_data =3D data; struct domain *d =3D mr_data->d; bool need_mapping =3D !dt_device_for_passthrough(dev); + const struct dt_device_node *parent =3D dt_get_parent(dev); int res; =20 - res =3D iomem_permit_access(d, paddr_to_pfn(addr), - paddr_to_pfn(PAGE_ALIGN(addr + len - 1))); - if ( res ) + /* + * Don't give iomem permissions for reserved-memory ranges until + * reserved-memory support is complete. + */ + if ( dt_node_cmp(dt_node_name(parent), "reserved-memory") =3D=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 Thu Apr 25 17:50:56 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=1565128232; cv=none; d=zoho.com; s=zohoarc; b=hs0PIDhEePSAX50ZgTfFrEnI231AdhZRAxMB92be6CBCb618WRaLkIChoXHtW7FFgO/0suRI4sNl2sufuDpcEoOYn3VGG/1kBqisQHVDhZixm9pzwlbaFLAModCClLmvxf/CJn7O3Z2DfgzBrixhmMs5EYvC8gwQDJX69y1qPgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565128232; 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=XgVDoY9ZpVqiHhkY/K6rhQqvWncvmECKzKH5BaDG5Co=; b=N17jteIzpVOE2gQPkkOWCxkETaB7OjDfPDbpGW9JQnCniqW2d7TubpdKWgOLgJdU7tXrGR/fcwPZEy9F9fdXk4NMFUStvXTQo2R4D6+jMl1e+PirlKWkcIveyF9p4yL0hNNW3qiVzexp20OgPYaCfwxJpzTNC7jod9ViI57c954= 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 1565128232022553.7782001480393; Tue, 6 Aug 2019 14:50:32 -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 1hv7Km-0000qT-HB; Tue, 06 Aug 2019 21:49:32 +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 1hv7Kk-0000np-TE for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 21:49:30 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1120c59e-b894-11e9-b687-4fda6d5a271e; Tue, 06 Aug 2019 21:49:29 +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 E4FEC218AD; Tue, 6 Aug 2019 21:49:28 +0000 (UTC) X-Inumbo-ID: 1120c59e-b894-11e9-b687-4fda6d5a271e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565128169; bh=czTdhJfgj/uZxfXPuiNN2cuptDBTZw/83Y1BKIpvvKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RFZrmE9/YzxBsWhoyx/5/9LlAhnf3eC5WVVD2bS0c0I5sqenHPw0rYuDCx7i2IHsy TOcXGULaFvDTreyyqA2xldHGqE9PohQYE5rFyh5YOiZEZG32iFSTRhQmLCmSINl32F qZvgPbz2Kti7s/rC++N5kEl4zc875pALhDftfcGE= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 14:49:25 -0700 Message-Id: <20190806214925.7534-7-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 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 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 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 267e0549e2..d0a96d62b0 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