From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240650; cv=pass; d=zohomail.com; s=zohoarc; b=bBXVOmwzJFR8vRaxq3OceYo7gweM6hMWZSFMiqADQ2FDmZS26zSU9bWXAUPedJ3aEfGqLzOlDgw0cZ79medTlFx0ua5c75+T6H6PHKq01F1cEdRa/geo5JJ9D58Zxl3Bz/AXQMsshKutHhztiqdxnsPq+auR6QgMZQFGnd1PkEo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240650; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=oBTT1YkY486IWn6yrseVBFe6ejNMaLA/UOHK1bPVBzoh4ejVT7p/7bj7FMr1uHPy4G2WDflvrWcNX7sPUpq19yKMswZH1LOOjEcqrCC4egQ2pWfTqJtwXzx4bxpzzRSzygJPjtLftPyUvSiLymXmxYChLGMgEmwlgaRl7aP4L9Q= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240650269410.96688127419304; Tue, 11 Apr 2023 12:17:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519770.806750 (Exim 4.92) (envelope-from ) id 1pmJUK-0005JE-Lj; Tue, 11 Apr 2023 19:17:08 +0000 Received: by outflank-mailman (output) from mailman id 519770.806750; Tue, 11 Apr 2023 19:17:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUK-0005J7-I8; Tue, 11 Apr 2023 19:17:08 +0000 Received: by outflank-mailman (input) for mailman id 519770; Tue, 11 Apr 2023 19:17:05 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUH-0004Ta-Dk for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:05 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061e.outbound.protection.outlook.com [2a01:111:f400:7e8a::61e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7003e71b-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:03 +0200 (CEST) Received: from MW3PR05CA0004.namprd05.prod.outlook.com (2603:10b6:303:2b::9) by MW6PR12MB8734.namprd12.prod.outlook.com (2603:10b6:303:249::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Tue, 11 Apr 2023 19:17:00 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::33) by MW3PR05CA0004.outlook.office365.com (2603:10b6:303:2b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:16:59 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:16:59 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:54 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:54 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:53 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7003e71b-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZoaxB4bFLbZgS5WHHZcc7Q2JNIUjaW6J+JCxA2fmYTW3nBQ2j9coBWisKiCfCXFOcjrFMTstSF0xWUGWtuCyep3JhovZ1XV5inwtQLmZy8uO+FYvx5mDwiBdcL6PLqd7EtB0GLquF5Pl5Hc3LXu3CAC5oEyM2rZxbBCL/58jxvE9aoxo740ZUVX9Rc6bvUJF38XrQzk2NUYrPSrAhccYEYaOVr9n8MtwIG5hYV9tJIj4yvzsJtJrwbmEeS+fC6IHFmMm/bvOdHFwjnL2/nqmODQhBwPEuwI8zon1FpL9EZrM/5fHWNQdLAd2OCFdQc3h07QoCzui9AlPZ6uYGsIPRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=RoZApb5D1WrOD7o9t5X9invczFFpM8bXTIFK1x6yv+3TUxNKFSmB3f68ySJc6moMrpmguITRrb8G1Z9Eg3iya5EzPRP+eX5XFexXisbGVyF8um0COhhoJ5Q60FEdFev7CbsZfo3Nt8rZxN01+IMhyockuz+HdWmLRaKZdG4XyuUd3nXoC0wL1cp5ZFD9k6A+Pj9kMr4J53LXAoFI4P4+WvAlcgIhu8ZwmNwQ1Jx2+AwSIRnLemwiCNYf5EGvOu9TFG08pVt9Vk2KQWMx6GV0rO1D1qq7YnJGeh4MRQV91Cifi3JAZig53CQDi60kteeemQDfNSWCOjT/oK5dr/GgKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=uG3yZ2q5CylqwilEN0w1lucY3u1hCuIw3gAflcKN2wFvTGJlsbJOVoocZsN62RVXs8md4ynK/i2EJD4Kd9n+L3YDixHpgt81Xdc+yDJdzoZagvx0OA/iP3eR6k6AmI+5qyCX8MgdbB80bE5ShP9n6Sk9LC4s8FzM/+ovwThwI8I= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 01/17] xen/arm/device: Remove __init from function type Date: Tue, 11 Apr 2023 12:16:02 -0700 Message-ID: <20230411191636.26926-2-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|MW6PR12MB8734:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ccc9639-ecdb-4de5-16fc-08db3ac152be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1nZdWlJL/siybVTnbTI1lAmr6TWeqSDLIc0m/tAf95v6A7UuW3OoeXSDRffUjaQ+5Y85O6S+9kI0qym75WjJBPFA7AizyTun88WjRujaWDHA08ihv7jXoXXTPfhDLoBmI1EgY09qrTQh7zlyBDJsJ2mnCieg7+TsGy668oLevSG4Hy2X76p+WPkuFVS0dJKrgQI3EGrduQCHwm160dyE/AUQmh60Ov4ohYORM3d6at/H+cokq0m+Lut5JFcFaeCMFqhv76PNthhld8VWHra1d3Wm9/WPWNdhH9HJklCuH7vg/nN6dzeua6f8bxzkardLfOQkV4xdccn9O7fop9mjDuIcnpKxZHls2hluVbFRGyv0c6xkcdni+fp5RlOq+mZzOS1YS5CfHNdfJHm63D1qY+qNCPo9OC3w+NI3qV+0ZRTPmF06wtM0tgBwmb3RN1D+jSL9QTlkGKZdgnSzntFKK0thEzDeObN3TdVFALa/KUNOdgEI2Ztmvhm1BGjBE93tWwGQk2Dy9C65WddhIJiWDP3SDLeQqrdt16CQQsvfp1flbBKBDKvx27Cs79UCsdWff/SMB7cUTwE6HvubGxEoi07+jeM8O+omQnrsvEzn6RuYUXjJOOIR4XvRy4wWhVMGGEM1r4O+H3y1MkVStWMMpexk67WObCUn+G3Zv84x+DcDNYbYuISH1tZWs8pZ1cPhATNDJY4+mD6sj31xuWqyuPbN6UsLH5H0ZsDIQh294sE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199021)(40470700004)(36840700001)(46966006)(30864003)(8936002)(8676002)(41300700001)(47076005)(81166007)(2616005)(2906002)(5660300002)(44832011)(356005)(4326008)(83380400001)(70586007)(6916009)(336012)(36860700001)(40460700003)(426003)(70206006)(6666004)(478600001)(316002)(36756003)(86362001)(40480700001)(82310400005)(1076003)(54906003)(186003)(82740400003)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:16:59.2939 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ccc9639-ecdb-4de5-16fc-08db3ac152be X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8734 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240652680100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove __init from following function to access during runtime: 1. map_irq_to_domain() 2. handle_device_interrupt() 3. map_range_to_domain() 4. unflatten_dt_node() 5. unflatten_device_tree() Move map_irq_to_domain() prototype from domain_build.h to setup.h. To avoid the breaking the build, following changes are also done: 1. Move map_irq_to_domain(), handle_device_interrupt() and map_range_to_dom= ain() to device.c. After removing __init type, these functions are not specific= to domain building, so moving them out of domain_build.c to device.c. 2. Remove static type from handle_device_interrupt(). Overall, these changes are done to support the dynamic programming of a nod= es where an overlay node will be added to fdt and unflattened node will be add= ed to dt_host. Furthermore, IRQ and mmio mapping will be done for the added node. Signed-off-by: Vikram Garhwal Reviewed-by: Michal Orzel --- xen/arch/arm/device.c | 145 ++++++++++++++++++++++++ xen/arch/arm/domain_build.c | 142 ----------------------- xen/arch/arm/include/asm/domain_build.h | 2 - xen/arch/arm/include/asm/setup.h | 6 + xen/common/device_tree.c | 16 +-- 5 files changed, 159 insertions(+), 152 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index ca8539dee5..fec6e29c42 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include =20 extern const struct device_desc _sdevice[], _edevice[]; extern const struct acpi_device_desc _asdevice[], _aedevice[]; @@ -75,6 +78,148 @@ enum device_class device_get_class(const struct dt_devi= ce_node *dev) return DEVICE_UNKNOWN; } =20 +int map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devname) +{ + int res; + + res =3D irq_permit_access(d, irq); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n", + d->domain_id, irq); + return res; + } + + if ( need_mapping ) + { + /* + * Checking the return of vgic_reserve_virq is not + * necessary. It should not fail except when we try to map + * the IRQ twice. This can legitimately happen if the IRQ is shared + */ + vgic_reserve_virq(d, irq); + + res =3D route_irq_to_guest(d, irq, irq, devname); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map IRQ%"PRId32" to dom%d\n", + irq, d->domain_id); + return res; + } + } + + dt_dprintk(" - IRQ: %u\n", irq); + return 0; +} + +int map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data) +{ + struct map_range_data *mr_data =3D data; + struct domain *d =3D mr_data->d; + int res; + + /* + * reserved-memory regions are RAM carved out for a special purpose. + * They are not MMIO and therefore a domain should not be able to + * manage them via the IOMEM interface. + */ + if ( strncasecmp(dt_node_full_name(dev), "/reserved-memory/", + strlen("/reserved-memory/")) !=3D 0 ) + { + 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; + } + } + + if ( !mr_data->skip_mapping ) + { + res =3D map_regions_p2mt(d, + gaddr_to_gfn(addr), + PFN_UP(len), + maddr_to_mfn(addr), + mr_data->p2mt); + + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map 0x%"PRIx64 + " - 0x%"PRIx64" in domain %d\n", + addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1, + d->domain_id); + return res; + } + } + + dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=3D%x\n", + addr, addr + len, mr_data->p2mt); + + return 0; +} + +/* + * handle_device_interrupts retrieves the interrupts configuration from + * a device tree node and maps those interrupts to the target domain. + * + * Returns: + * < 0 error + * 0 success + */ +int handle_device_interrupts(struct domain *d, + struct dt_device_node *dev, + bool need_mapping) +{ + unsigned int i, nirq; + int res; + struct dt_raw_irq rirq; + + nirq =3D dt_number_of_irq(dev); + + /* Give permission and map IRQs */ + for ( i =3D 0; i < nirq; i++ ) + { + res =3D dt_device_get_raw_irq(dev, i, &rirq); + if ( res ) + { + printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + /* + * Don't map IRQ that have no physical meaning + * ie: IRQ whose controller is not the GIC + */ + if ( rirq.controller !=3D dt_interrupt_controller ) + { + dt_dprintk("irq %u not connected to primary controller. Connec= ted to %s\n", + i, dt_node_full_name(rirq.controller)); + continue; + } + + res =3D platform_get_irq(dev, i); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to get irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + res =3D map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); + if ( res ) + return res; + } + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4f9d4f9d88..6ab18c53ab 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2256,41 +2256,6 @@ int __init make_chosen_node(const struct kernel_info= *kinfo) return res; } =20 -int __init map_irq_to_domain(struct domain *d, unsigned int irq, - bool need_mapping, const char *devname) -{ - int res; - - res =3D irq_permit_access(d, irq); - if ( res ) - { - printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n", - d->domain_id, irq); - return res; - } - - if ( need_mapping ) - { - /* - * Checking the return of vgic_reserve_virq is not - * necessary. It should not fail except when we try to map - * the IRQ twice. This can legitimately happen if the IRQ is shared - */ - vgic_reserve_virq(d, irq); - - res =3D route_irq_to_guest(d, irq, irq, devname); - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to map IRQ%"PRId32" to dom%d\n", - irq, d->domain_id); - return res; - } - } - - dt_dprintk(" - IRQ: %u\n", irq); - return 0; -} - static int __init map_dt_irq_to_domain(const struct dt_device_node *dev, const struct dt_irq *dt_irq, void *data) @@ -2322,57 +2287,6 @@ static int __init map_dt_irq_to_domain(const struct = dt_device_node *dev, return 0; } =20 -int __init map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, void *data) -{ - struct map_range_data *mr_data =3D data; - struct domain *d =3D mr_data->d; - int res; - - /* - * reserved-memory regions are RAM carved out for a special purpose. - * They are not MMIO and therefore a domain should not be able to - * manage them via the IOMEM interface. - */ - if ( strncasecmp(dt_node_full_name(dev), "/reserved-memory/", - strlen("/reserved-memory/")) !=3D 0 ) - { - 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; - } - } - - if ( !mr_data->skip_mapping ) - { - res =3D map_regions_p2mt(d, - gaddr_to_gfn(addr), - PFN_UP(len), - maddr_to_mfn(addr), - mr_data->p2mt); - - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to map 0x%"PRIx64 - " - 0x%"PRIx64" in domain %d\n", - addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1, - d->domain_id); - return res; - } - } - - dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=3D%x\n", - addr, addr + len, mr_data->p2mt); - - return 0; -} - /* * For a node which describes a discoverable bus (such as a PCI bus) * then we may need to perform additional mappings in order to make @@ -2400,62 +2314,6 @@ static int __init map_device_children(const struct d= t_device_node *dev, return 0; } =20 -/* - * handle_device_interrupts retrieves the interrupts configuration from - * a device tree node and maps those interrupts to the target domain. - * - * Returns: - * < 0 error - * 0 success - */ -static int __init handle_device_interrupts(struct domain *d, - struct dt_device_node *dev, - bool need_mapping) -{ - unsigned int i, nirq; - int res; - struct dt_raw_irq rirq; - - nirq =3D dt_number_of_irq(dev); - - /* Give permission and map IRQs */ - for ( i =3D 0; i < nirq; i++ ) - { - res =3D dt_device_get_raw_irq(dev, i, &rirq); - if ( res ) - { - printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - /* - * Don't map IRQ that have no physical meaning - * ie: IRQ whose controller is not the GIC - */ - if ( rirq.controller !=3D dt_interrupt_controller ) - { - dt_dprintk("irq %u not connected to primary controller. Connec= ted to %s\n", - i, dt_node_full_name(rirq.controller)); - continue; - } - - res =3D platform_get_irq(dev, i); - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to get irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - res =3D map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); - if ( res ) - return res; - } - - return 0; -} - /* * For a given device node: * - Give permission to the guest to manage IRQ and MMIO range diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include= /asm/domain_build.h index 34ceddc995..b9329c9ee0 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -4,8 +4,6 @@ #include #include =20 -int map_irq_to_domain(struct domain *d, unsigned int irq, - bool need_mapping, const char *devname); int make_chosen_node(const struct kernel_info *kinfo); void evtchn_allocate(struct domain *d); =20 diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index a926f30a2b..1d636e8a4a 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -163,9 +163,15 @@ void device_tree_get_reg(const __be32 **cell, u32 addr= ess_cells, u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); =20 +int handle_device_interrupts(struct domain *d, struct dt_device_node *dev, + bool need_mapping); + int map_range_to_domain(const struct dt_device_node *dev, u64 addr, u64 len, void *data); =20 +int map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devname); + extern const char __ro_after_init_start[], __ro_after_init_end[]; =20 struct init_info diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 6c9712ab7b..aed38ff63c 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1811,12 +1811,12 @@ int dt_count_phandle_with_args(const struct dt_devi= ce_node *np, * @allnextpp: pointer to ->allnext from last allocated device_node * @fpsize: Size of the node path up at the current depth. */ -static unsigned long __init unflatten_dt_node(const void *fdt, - unsigned long mem, - unsigned long *p, - struct dt_device_node *dad, - struct dt_device_node ***all= nextpp, - unsigned long fpsize) +static unsigned long unflatten_dt_node(const void *fdt, + unsigned long mem, + unsigned long *p, + struct dt_device_node *dad, + struct dt_device_node ***allnextpp, + unsigned long fpsize) { struct dt_device_node *np; struct dt_property *pp, **prev_pp =3D NULL; @@ -2056,8 +2056,8 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, * @fdt: The fdt to expand * @mynodes: The device_node tree created by the call */ -static void __init __unflatten_device_tree(const void *fdt, - struct dt_device_node **mynodes) +static void __unflatten_device_tree(const void *fdt, + struct dt_device_node **mynodes) { unsigned long start, mem, size; struct dt_device_node **allnextp =3D mynodes; --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240661; cv=pass; d=zohomail.com; s=zohoarc; b=PvE6e3rO7oxJbQVE5J37Q8dNtyCc0K+HTqNQHC0ZvwYU+vfkkrFYi7F/RF22X7HGl+XG8hRrxDIGacrCZb3IFSzV2KyoGtsr6GDXUCEsW0UjxH9Jh3G7WSlqhnnscIkbNOXR1g/Op6eRA3oPn30A2cq9xraFYTgw+wYz4dtEL28= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240661; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=K97Ei+VP5Q6KiWpx6quveV5rhnrUPQkOq3hh6rlKOIUAeF6V6KxCy8382mXwqsY+WfFoBsNMVApipxPlaPuub5+jq2QikXXBEqsISDvorJSvuj9w3Q+zN0gxZCKQxzHE3wORhfCCDkPQCaPdotPJK6vsIJf8IKZs6vUp8jGwywM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240661379704.1810936026982; Tue, 11 Apr 2023 12:17:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519784.806859 (Exim 4.92) (envelope-from ) id 1pmJUX-0008Ei-R9; Tue, 11 Apr 2023 19:17:21 +0000 Received: by outflank-mailman (output) from mailman id 519784.806859; Tue, 11 Apr 2023 19:17:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUW-00089U-B1; Tue, 11 Apr 2023 19:17:20 +0000 Received: by outflank-mailman (input) for mailman id 519784; Tue, 11 Apr 2023 19:17:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUT-0004DR-4C for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:17 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2062a.outbound.protection.outlook.com [2a01:111:f400:7eb2::62a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 771c4613-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:15 +0200 (CEST) Received: from BN9P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::26) by SA1PR12MB7104.namprd12.prod.outlook.com (2603:10b6:806:29e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:17:11 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::b5) by BN9P221CA0007.outlook.office365.com (2603:10b6:408:10a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:11 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:10 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:10 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 771c4613-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZCntpfDjlU7bvxwIp3bh4NQamhz8bpTDYo97gW0u+wMi4TyyzH24dA9vddIIPPPpGW+cmmXSixmLW4zjPrg/NPvfYyBrIuXJ4X+1d/Qu7HCDYvAGUWg0Hn6Hn/3/I3Du/SW4/Gz4Abm6XcoxgvuBA4qDNhEAAIgtyaKHkWMQ7niTiME8PeanhQvZKk4x9jZ5ogm7SQYyEWkpjWbxV/YAgRaIqkRVZ9+ZBgYbSayN33edDezxvJ7kHwWqGEu9WKYUcyf49eaF79C0Tr37lvbY/jlEjG5VlawA/YUe9MD0JNz5hu62XBbhyCHsfH/OJbglHeiO8jzx7fBaW78RJL2+Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=O9v0T+PyvauZzj/zb0BDPvK1AvsUjiy2Dz9Krp5DhRXqIBlwkRFYiyY8BcfRR+03rMFtVdmu56h3h56eiVquwNwVj6713IzFpnWcdkJ5Y+VlMgIKk4MIgwxGaqlQjcgb9fPDv9qkV1riewcBw+41QvJaCYI1aH+HYwTC0/ExJS+ehe5ywTsgY5fefTdnmb4me0WuD5tP3OyJwKf5Y42wKjvc/83dg1W5zj4KPf+LoBOloV1+F1xhwLOp0yhTyn8fOqCyerPsC0wmmDvh9jDCL3IWHUFtBWfp+7dZ0UH9iH5qR6hAmSc7gYXQULmKZE9V+qhyrfYhlrrjem2y0s642g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z2clB4UixcJGvwOZJ+XN0wD+kcnhi2QU+8ofkZ5Co48=; b=ThtM+MEUeVsRifpSzpg6l+6DHWGYRGYDH4jmJf5iAiBLQgXjj+inCmV1xKq7LBTQOGjbBMUITDSe6XVcGfge7MqfgphuprtLS6pCPNR9EZ5IKEnSBACZ16KGOCmexvC04LZr+imaKF5Rn9i4sEK+JFqzwa2XPLa92X9dUWZRe1s= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 01/17] xen/arm/device: Remove __init from function type Date: Tue, 11 Apr 2023 12:16:20 -0700 Message-ID: <20230411191636.26926-20-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|SA1PR12MB7104:EE_ X-MS-Office365-Filtering-Correlation-Id: 197fc178-d1c0-4c52-5cbb-08db3ac159dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q19Ab48E2BZeSHFpac25Yyrbd44cGvHmrkZcuJb1ggFsQuJyAmUF0Mfoz9A1OkKNuv3VLwy17kDisYJXBkp83av5cqnmHMCmGG0QLlueGm3YuCzXclIw5ncEXT6NRV0emnt3d/eqZ0E7qTokPVv7SzNahC1kFqx1gtEFsldwlVwpnGSTpkcmIwuxEE3M1TqMN7j9bCEl04I59de8LwUAp1bEjSz7nE9vm19mn9NyOuKJjLOxqiyowWp7jsCf2ukSVXUo+0cMkPgECL/Zkl0SpY2FYrH39zAxiO6nc7DJ1XZBfiVJIk/aG4qOoN57L7G78oKEsqeAHnWg1pBa4YsQDP2w1UWM9Hn9pAcVY63MnC/mzTcj2wgHhL5qRRPSlE/nFX7ISU0EeWrA6GUhSHE2NeXdnCMcXSPmqy9XypkVJPkFUR04KZD7x/SPgpNsY4M1RLMrrexW4HAoQPnT5gq6N3m4uH1xWRVwjLD8xKQycbw9zMuav0oQNxLKFf4OKJOjWKADUw/ELFvcd5WDXGWk+dCOE3EpDr1q4cgSASZEJGqMJh5z1FaSsONuCfd413w0DEX3/ExXhN579c4QoF9SH5jG1+e5NedsBz2abSlQoH7d44tYGOdJQOG5w3D2+reHs3TuS6unsPFXmSxkTzWnBgOgMmy1tyFfb+8/lpyy3VFYVd822KVxOBv3XJRHszY1tPuCpwZDJEEHcQ+4yfbz/vb6PGocrGp09G20EHEKjDM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(4326008)(70206006)(70586007)(1076003)(86362001)(26005)(316002)(6916009)(186003)(40460700003)(36756003)(6666004)(54906003)(47076005)(40480700001)(478600001)(36860700001)(8676002)(8936002)(2616005)(41300700001)(356005)(81166007)(5660300002)(2906002)(30864003)(83380400001)(44832011)(82310400005)(426003)(336012)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:11.3366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 197fc178-d1c0-4c52-5cbb-08db3ac159dd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7104 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240662611100034 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove __init from following function to access during runtime: 1. map_irq_to_domain() 2. handle_device_interrupt() 3. map_range_to_domain() 4. unflatten_dt_node() 5. unflatten_device_tree() Move map_irq_to_domain() prototype from domain_build.h to setup.h. To avoid the breaking the build, following changes are also done: 1. Move map_irq_to_domain(), handle_device_interrupt() and map_range_to_dom= ain() to device.c. After removing __init type, these functions are not specific= to domain building, so moving them out of domain_build.c to device.c. 2. Remove static type from handle_device_interrupt(). Overall, these changes are done to support the dynamic programming of a nod= es where an overlay node will be added to fdt and unflattened node will be add= ed to dt_host. Furthermore, IRQ and mmio mapping will be done for the added node. Signed-off-by: Vikram Garhwal --- xen/arch/arm/device.c | 145 ++++++++++++++++++++++++ xen/arch/arm/domain_build.c | 142 ----------------------- xen/arch/arm/include/asm/domain_build.h | 2 - xen/arch/arm/include/asm/setup.h | 6 + xen/common/device_tree.c | 16 +-- 5 files changed, 159 insertions(+), 152 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index ca8539dee5..fec6e29c42 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include =20 extern const struct device_desc _sdevice[], _edevice[]; extern const struct acpi_device_desc _asdevice[], _aedevice[]; @@ -75,6 +78,148 @@ enum device_class device_get_class(const struct dt_devi= ce_node *dev) return DEVICE_UNKNOWN; } =20 +int map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devname) +{ + int res; + + res =3D irq_permit_access(d, irq); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n", + d->domain_id, irq); + return res; + } + + if ( need_mapping ) + { + /* + * Checking the return of vgic_reserve_virq is not + * necessary. It should not fail except when we try to map + * the IRQ twice. This can legitimately happen if the IRQ is shared + */ + vgic_reserve_virq(d, irq); + + res =3D route_irq_to_guest(d, irq, irq, devname); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map IRQ%"PRId32" to dom%d\n", + irq, d->domain_id); + return res; + } + } + + dt_dprintk(" - IRQ: %u\n", irq); + return 0; +} + +int map_range_to_domain(const struct dt_device_node *dev, + u64 addr, u64 len, void *data) +{ + struct map_range_data *mr_data =3D data; + struct domain *d =3D mr_data->d; + int res; + + /* + * reserved-memory regions are RAM carved out for a special purpose. + * They are not MMIO and therefore a domain should not be able to + * manage them via the IOMEM interface. + */ + if ( strncasecmp(dt_node_full_name(dev), "/reserved-memory/", + strlen("/reserved-memory/")) !=3D 0 ) + { + 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; + } + } + + if ( !mr_data->skip_mapping ) + { + res =3D map_regions_p2mt(d, + gaddr_to_gfn(addr), + PFN_UP(len), + maddr_to_mfn(addr), + mr_data->p2mt); + + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map 0x%"PRIx64 + " - 0x%"PRIx64" in domain %d\n", + addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1, + d->domain_id); + return res; + } + } + + dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=3D%x\n", + addr, addr + len, mr_data->p2mt); + + return 0; +} + +/* + * handle_device_interrupts retrieves the interrupts configuration from + * a device tree node and maps those interrupts to the target domain. + * + * Returns: + * < 0 error + * 0 success + */ +int handle_device_interrupts(struct domain *d, + struct dt_device_node *dev, + bool need_mapping) +{ + unsigned int i, nirq; + int res; + struct dt_raw_irq rirq; + + nirq =3D dt_number_of_irq(dev); + + /* Give permission and map IRQs */ + for ( i =3D 0; i < nirq; i++ ) + { + res =3D dt_device_get_raw_irq(dev, i, &rirq); + if ( res ) + { + printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + /* + * Don't map IRQ that have no physical meaning + * ie: IRQ whose controller is not the GIC + */ + if ( rirq.controller !=3D dt_interrupt_controller ) + { + dt_dprintk("irq %u not connected to primary controller. Connec= ted to %s\n", + i, dt_node_full_name(rirq.controller)); + continue; + } + + res =3D platform_get_irq(dev, i); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to get irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + res =3D map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); + if ( res ) + return res; + } + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4f9d4f9d88..6ab18c53ab 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2256,41 +2256,6 @@ int __init make_chosen_node(const struct kernel_info= *kinfo) return res; } =20 -int __init map_irq_to_domain(struct domain *d, unsigned int irq, - bool need_mapping, const char *devname) -{ - int res; - - res =3D irq_permit_access(d, irq); - if ( res ) - { - printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n", - d->domain_id, irq); - return res; - } - - if ( need_mapping ) - { - /* - * Checking the return of vgic_reserve_virq is not - * necessary. It should not fail except when we try to map - * the IRQ twice. This can legitimately happen if the IRQ is shared - */ - vgic_reserve_virq(d, irq); - - res =3D route_irq_to_guest(d, irq, irq, devname); - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to map IRQ%"PRId32" to dom%d\n", - irq, d->domain_id); - return res; - } - } - - dt_dprintk(" - IRQ: %u\n", irq); - return 0; -} - static int __init map_dt_irq_to_domain(const struct dt_device_node *dev, const struct dt_irq *dt_irq, void *data) @@ -2322,57 +2287,6 @@ static int __init map_dt_irq_to_domain(const struct = dt_device_node *dev, return 0; } =20 -int __init map_range_to_domain(const struct dt_device_node *dev, - u64 addr, u64 len, void *data) -{ - struct map_range_data *mr_data =3D data; - struct domain *d =3D mr_data->d; - int res; - - /* - * reserved-memory regions are RAM carved out for a special purpose. - * They are not MMIO and therefore a domain should not be able to - * manage them via the IOMEM interface. - */ - if ( strncasecmp(dt_node_full_name(dev), "/reserved-memory/", - strlen("/reserved-memory/")) !=3D 0 ) - { - 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; - } - } - - if ( !mr_data->skip_mapping ) - { - res =3D map_regions_p2mt(d, - gaddr_to_gfn(addr), - PFN_UP(len), - maddr_to_mfn(addr), - mr_data->p2mt); - - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to map 0x%"PRIx64 - " - 0x%"PRIx64" in domain %d\n", - addr & PAGE_MASK, PAGE_ALIGN(addr + len) - 1, - d->domain_id); - return res; - } - } - - dt_dprintk(" - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=3D%x\n", - addr, addr + len, mr_data->p2mt); - - return 0; -} - /* * For a node which describes a discoverable bus (such as a PCI bus) * then we may need to perform additional mappings in order to make @@ -2400,62 +2314,6 @@ static int __init map_device_children(const struct d= t_device_node *dev, return 0; } =20 -/* - * handle_device_interrupts retrieves the interrupts configuration from - * a device tree node and maps those interrupts to the target domain. - * - * Returns: - * < 0 error - * 0 success - */ -static int __init handle_device_interrupts(struct domain *d, - struct dt_device_node *dev, - bool need_mapping) -{ - unsigned int i, nirq; - int res; - struct dt_raw_irq rirq; - - nirq =3D dt_number_of_irq(dev); - - /* Give permission and map IRQs */ - for ( i =3D 0; i < nirq; i++ ) - { - res =3D dt_device_get_raw_irq(dev, i, &rirq); - if ( res ) - { - printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - /* - * Don't map IRQ that have no physical meaning - * ie: IRQ whose controller is not the GIC - */ - if ( rirq.controller !=3D dt_interrupt_controller ) - { - dt_dprintk("irq %u not connected to primary controller. Connec= ted to %s\n", - i, dt_node_full_name(rirq.controller)); - continue; - } - - res =3D platform_get_irq(dev, i); - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to get irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - res =3D map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); - if ( res ) - return res; - } - - return 0; -} - /* * For a given device node: * - Give permission to the guest to manage IRQ and MMIO range diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include= /asm/domain_build.h index 34ceddc995..b9329c9ee0 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -4,8 +4,6 @@ #include #include =20 -int map_irq_to_domain(struct domain *d, unsigned int irq, - bool need_mapping, const char *devname); int make_chosen_node(const struct kernel_info *kinfo); void evtchn_allocate(struct domain *d); =20 diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index a926f30a2b..1d636e8a4a 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -163,9 +163,15 @@ void device_tree_get_reg(const __be32 **cell, u32 addr= ess_cells, u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt); =20 +int handle_device_interrupts(struct domain *d, struct dt_device_node *dev, + bool need_mapping); + int map_range_to_domain(const struct dt_device_node *dev, u64 addr, u64 len, void *data); =20 +int map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devname); + extern const char __ro_after_init_start[], __ro_after_init_end[]; =20 struct init_info diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 6c9712ab7b..aed38ff63c 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1811,12 +1811,12 @@ int dt_count_phandle_with_args(const struct dt_devi= ce_node *np, * @allnextpp: pointer to ->allnext from last allocated device_node * @fpsize: Size of the node path up at the current depth. */ -static unsigned long __init unflatten_dt_node(const void *fdt, - unsigned long mem, - unsigned long *p, - struct dt_device_node *dad, - struct dt_device_node ***all= nextpp, - unsigned long fpsize) +static unsigned long unflatten_dt_node(const void *fdt, + unsigned long mem, + unsigned long *p, + struct dt_device_node *dad, + struct dt_device_node ***allnextpp, + unsigned long fpsize) { struct dt_device_node *np; struct dt_property *pp, **prev_pp =3D NULL; @@ -2056,8 +2056,8 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, * @fdt: The fdt to expand * @mynodes: The device_node tree created by the call */ -static void __init __unflatten_device_tree(const void *fdt, - struct dt_device_node **mynodes) +static void __unflatten_device_tree(const void *fdt, + struct dt_device_node **mynodes) { unsigned long start, mem, size; struct dt_device_node **allnextp =3D mynodes; --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240649; cv=pass; d=zohomail.com; s=zohoarc; b=EzAFuMxG4Gq1aWBNP0A92/r8BcacO7WVjTCDJ2Ea685GqMWXtM9zgePt2WjqpWk5MCPZo8sY+7HNjKmt362sBEIu7BT/nTQILf+SzTi9RzfSzOwBnTd3RnB/pshhlsEUVJWkNcFLFnziNc6589ikteWPzRfs7Zyx0ua+KwhD1jg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240649; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=FJyFFBMpk/XJCXTQe6uE96vAONNDIuUMhgHj8LChqR6P/cPbWRMjaAAt9ftZabWB7O5a2GXvhAMiUyr6fbZRnHEAmhuPb1xEPUPvCt1FIbhXHpqnb17xEGp3N0qUwwAwBfz0lTFdHY5xYlu6qscmcViDs3d83kjORvZ5O+6ltcM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240649685319.96287063309967; Tue, 11 Apr 2023 12:17:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519767.806720 (Exim 4.92) (envelope-from ) id 1pmJUF-0004U6-Lt; Tue, 11 Apr 2023 19:17:03 +0000 Received: by outflank-mailman (output) from mailman id 519767.806720; Tue, 11 Apr 2023 19:17:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUF-0004Tx-Hx; Tue, 11 Apr 2023 19:17:03 +0000 Received: by outflank-mailman (input) for mailman id 519767; Tue, 11 Apr 2023 19:17:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUE-0004Ta-U4 for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:02 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20623.outbound.protection.outlook.com [2a01:111:f400:7e83::623]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6e0c351d-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:00 +0200 (CEST) Received: from BN9PR03CA0604.namprd03.prod.outlook.com (2603:10b6:408:106::9) by MW4PR12MB5601.namprd12.prod.outlook.com (2603:10b6:303:168::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:16:56 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::3) by BN9PR03CA0604.outlook.office365.com (2603:10b6:408:106::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 19:16:56 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:16:55 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:55 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:55 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:54 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6e0c351d-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5odVlwbleoZs5wA2Fen6R9qmt+TiYhz/GpyppkIzbqswKQkuXyCbkxlQkjB8nSBOC20onufEscuNKm8vNm/j8yfswu3WLAnPgPOmNfR0T9GpLsMwbeW08oSzC1XnlUtEyHEDQlWFwA0VgmbcWHu+8ImpdPqQNNPYJVB9kGOgqahApezPnCwhGAVm6Fk/gJlRBBaxRQU2dbVZQlrSGqFNw5ze+hpUvgkOqmrl0qa67NkZZzimM2in0Ulk6CErHvk43d48O/zoqDAx/6h/d2jN/HJ5cMTC0cdC4wsTytksf5KinwvIQS5rOH9t2nsVXBKrTq1ZGqTcEvHCDNupHfXYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=fR7WKLv54LP01SNa8MUepB3sId6Q718wi+GEOAuTATUVrbm5NmItXz521gJfoVce67ZdtDj3uDs+G6apBoBxTE+lCnDL+cIRrkpbDo+X29siGtAjog02PguifLjPmmhd8qYgMAvhHaDsn8UsmECzWKFzzUOhiLt4WhPPrKmffXvzcNBvFlzv6jZzite09ifNwof4EuwxN2kq2I3KKwQJaK/2yK/LxpPm5tIOOFf7NE7Y3kRp1BxBnxe34Tr9Stx0nbskob0ru6CJZf1I/vEDbXoZTHIrcEC4b542tPSX1IKI1PJ3H4zpeOLcL8feazxofP/zOOuTgyJ/MLkR38YXNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=Md5NgPnF/dZc6LSjpF9zQvCHu3SnY1fZQYKEa4Ctv2VO6o6TW+wqH6xsxLNdN88/nIjeb8ZQwPcGMwej8/143x3pPhkp5fPtJvG1Ou/G/K/OCJj1pfKEpnGaKFb417l4ClhSo/MkCvoC3HbxphnPRiypyMP4AOyNZm/zoYvzbgI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 02/17] common/device_tree: change __unflatten_device_tree() Date: Tue, 11 Apr 2023 12:16:03 -0700 Message-ID: <20230411191636.26926-3-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT052:EE_|MW4PR12MB5601:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a55ab8b-09ca-432d-daf6-08db3ac15098 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tRF8rJuNDr5YAn1IKIgQmYgV4Xg3sb4+bNUMt0OUvk/7+9ZimF1PYMvu+V9AR319u1kO/w+2FZjcOha9YM1YSyz8nG5g9SE5swyVF/F+bEKokoJeyZlCGBUMjnmu0lJE4JbCc3xzHtHKY5Ms/JgGqNJAt5aPewk/of/WaAL4Lj20+TsmvONcyw99ZcJdonUU5JqIXalTOBeCU6LUDFk2QU1Asw0Vm304GjCHVxWrqTSHrYN0E/jLVwB3f/+YW/1sPJuZeQNFvstg22Jw0OXhnltLLL2MXutboZ3A2s/JUu4+O14c7+3ikq0T0o1Vkeysarod4OYoIVZJaexZXZcmgJ3HapzUw5MVMbTil7/FvNupjYSq4qin63K9Xg/L/zSZqk5ZbWdqZTUCGXxCmlsIme6PMcpMpTSb1rJ73dYjHhzrz0da2vQtGwplOitZCAQm608CDDedenQ66kEZ+Bp31uBouNN4Ysj1zBuMIbCjBzgWSF5zGisvcxfBdidoqHKji3INiI+kzIbrWYl1yUso8UkOxMe+3AwCpH1jx0nxOTOxLi2WV3jUmxGgFs1fCcABD+iXeskYnd9CSFppMreCQiqmZixCd0zBtyd4oMmPL992mXabbPY4c872k51Exb4Q5U+9QvpVvdNU8vuDKrQsP4jufjckzAgiCd21astDPcag/QPqJbpZI2BGHExZBL57fhM9FJWIEbmXcPSsn+fF9vs/Emc8/qMF2RqBHC2Wlhc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(36860700001)(54906003)(2616005)(47076005)(478600001)(26005)(1076003)(6666004)(81166007)(82740400003)(356005)(41300700001)(316002)(4326008)(6916009)(186003)(336012)(83380400001)(426003)(70206006)(70586007)(2906002)(5660300002)(44832011)(36756003)(82310400005)(40460700003)(86362001)(40480700001)(8676002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:16:55.7882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a55ab8b-09ca-432d-daf6-08db3ac15098 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5601 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240650739100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Following changes are done to __unflatten_device_tree(): 1. __unflatten_device_tree() is renamed to unflatten_device_tree(). 2. Remove static function type. 3. Add handling of memory allocation. This will be useful in dynamic no= de programming when we unflatten the dt during runtime memory allocati= on can fail. Signed-off-by: Vikram Garhwal Reviewed-by: Michal Orzel --- xen/common/device_tree.c | 10 ++++++---- xen/include/xen/device_tree.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index aed38ff63c..bf847b2584 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -2047,7 +2047,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, } =20 /** - * __unflatten_device_tree - create tree of device_nodes from flat blob + * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens a device-tree, creating the * tree of struct device_node. It also fills the "name" and "type" @@ -2056,8 +2056,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, * @fdt: The fdt to expand * @mynodes: The device_node tree created by the call */ -static void __unflatten_device_tree(const void *fdt, - struct dt_device_node **mynodes) +void unflatten_device_tree(const void *fdt, struct dt_device_node **mynode= s) { unsigned long start, mem, size; struct dt_device_node **allnextp =3D mynodes; @@ -2079,6 +2078,9 @@ static void __unflatten_device_tree(const void *fdt, /* Allocate memory for the expanded device tree */ mem =3D (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_devic= e_node)); =20 + if ( !mem ) + panic("Cannot allocate memory for unflatten device tree\n"); + ((__be32 *)mem)[size / 4] =3D cpu_to_be32(0xdeadbeef); =20 dt_dprintk(" unflattening %lx...\n", mem); @@ -2179,7 +2181,7 @@ dt_find_interrupt_controller(const struct dt_device_m= atch *matches) =20 void __init dt_unflatten_host_device_tree(void) { - __unflatten_device_tree(device_tree_flattened, &dt_host); + unflatten_device_tree(device_tree_flattened, &dt_host); dt_alias_scan(); } =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 19a74909ce..58ac12abe3 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -178,6 +178,11 @@ int device_tree_for_each_node(const void *fdt, int nod= e, */ void dt_unflatten_host_device_tree(void); =20 +/** + * unflatten any device tree. + */ +void unflatten_device_tree(const void *fdt, struct dt_device_node **mynode= s); + /** * IRQ translation callback * TODO: For the moment we assume that we only have ONE --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240836; cv=pass; d=zohomail.com; s=zohoarc; b=H60jhBJx1+bnC7gOzeJMZN5e4WFHIHpjQkafL+cM+HJhs/8gZQIKwgfevq8mfEhX86VYUPtHAu0o5OzdW0no6Q1G4WebAtLRpJSNkj/3tbKEMwpthFgZj8fsGAvmDT3b/BR9TQgWKw5AHXuKt76199b8oSBY+XfPRv3mworIm0g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240836; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=mGmM6Vigx2SabM5HKcDdhJXcYPn2mk7atbcpwkf3McIVCkvudXiietiS3mPl24rEn+TDyECdsf1uDhmS5xzja/aoQEsVr6IcS8eaT6gTw2WXkOg/mtxqERPwFqUflCHW57QmQIEkY1e2htV/Yd77KqQmw8ZWTfMnNLoAankopQs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240836131762.0069491469432; Tue, 11 Apr 2023 12:20:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519884.807045 (Exim 4.92) (envelope-from ) id 1pmJXE-0003Sb-6Q; Tue, 11 Apr 2023 19:20:08 +0000 Received: by outflank-mailman (output) from mailman id 519884.807045; Tue, 11 Apr 2023 19:20:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJXD-0003Qd-T5; Tue, 11 Apr 2023 19:20:07 +0000 Received: by outflank-mailman (input) for mailman id 519884; Tue, 11 Apr 2023 19:20:06 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUU-0004Ta-0J for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:18 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20612.outbound.protection.outlook.com [2a01:111:f400:7e88::612]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7825769c-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:15 +0200 (CEST) Received: from BN9P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::32) by DM4PR12MB6541.namprd12.prod.outlook.com (2603:10b6:8:88::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Tue, 11 Apr 2023 19:17:12 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::f6) by BN9P221CA0020.outlook.office365.com (2603:10b6:408:10a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Tue, 11 Apr 2023 19:17:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:12 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:11 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:11 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7825769c-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nd9RHJF2398b5isOKaYdNprBPl/JNuJF6/ge3zT77zkGtEPFSzds6zzf69EGMJAgklQy0X2u3+v9EzkoUL8og3kVHQixgbWQ5Njigjp66elYLenh+J7QZEtnku2fMxbv6PBqSq6XIUj6sva/sCfwpP1PsxcwsbfWdY496muh8Z0FNB87I9udOfbP5c8smQ5H8CGbfH5c8V32AP2JJfi9boLHlUPpiFHk0Qj5HgGnWlTpfQLHfHGfKZoeheoD6EWHaF6sTHYHVSB6UxxLD5olg3jxzi0vdP4lQP8I1jTuxUMXF086TLemBhklKP1rC8U3EvYFa6TzY3yYcxuxpEoqJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=K3LK6ruFsTA4TPqFt/ammZSl/L8ggQ6E16nomQr5n3ta6K0P+pc/IVT5pkNN8uKuBfN33CHrxT49q9EbSeedM+cJ9eBr5YKtjSRzUXAS3ki2vEzEcU272lsMobTIFxbZ35sDe9X5OMw0QP19LbdEUNveyReAdEinT6VGWtcOt+sjJ9t7O+TOqVZif8yPg+IlNbIbZP8MPBIDycowyRdg/OKXXvmcDnzoQccPxD8YtsQm4XyAdJ4AkjRQYTqVnIMebgRyjh176UgkFlaschPgOCAyq6aJPbs4nOJl6xueJtw7xLSbE+NNKhSn8K67xZDLZt4Q8tdSLM3GSuEmGpXf+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0odwSwlZEbTJvdLLf27PaAsLK4pjjIm+Jsb7s8Lqv7g=; b=udgPt9YgeXZs+lWeAZV5aVlBBUqHsJP0l5aFIU9sPSKpCRYAo6zY4oeKvcTzYBmDZyLZotUsv/O38LNzRY1kN4j00nm0f0Ez1qkF7ftHoqc3b5GBw/5Fn7K2kCVzTaM+aOmAX1jvjcawQ5Tu8Dbr5fDa5Ck2tJ50YmouDiOODDY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 02/17] common/device_tree: change __unflatten_device_tree() Date: Tue, 11 Apr 2023 12:16:21 -0700 Message-ID: <20230411191636.26926-21-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|DM4PR12MB6541:EE_ X-MS-Office365-Filtering-Correlation-Id: 1db08cfe-55db-45a7-8ea6-08db3ac15a73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1doF2RKmkOdJFbpJzZWghxFTAGAl514VARfqJ35cis52xR+3+oTUWV7ecTA9tKoXEKyGmv7DeTyTrn1VDEGDx/kRtGkMVfurLAzr3fmJ4pBmQdekjSGNIDH1N0cXBF6OUke7faWga+sa998uw4TOw3DoQ/ToBFwAdRYVw3ORW2bCw3CKqlDTkeWUTabLkD3nWScqZzDjja/4LTm64WuivS6yhyYd/Ii3uNNf5ro+GxpN6ZiodW8WCjVqwatrM/UVGv08GLDQdWwzL+F4hvaWnOcy/j3DB0hvzRM3jtIHUQuwsZgoWE+Rqh3A+urm8gt6jYpvjBOASs0e/IipHUuMt+O86Qj77dCQYN1slyKzUHekyTJeOlZVP81zPuFoeYm8SsS+mTyp2K7gjE8urSEac5HkMpLitJBbkq42mBPwi1T9xdWWPNEk2iCCQ3Ubw2GcoX91M+l+OLegeqjPAu5lfbcOYUV+qHO37OZgHoxDn9rrWJlrwi5QWNUyIHhImMeIW/LOAcTTPcioLXZhjat6OP1f3QkWaloNc8AqDPrW27sxOojetd31kuyEfyfDg83pkXVS/zg0wsA2MstlSabqI+yKf9vWvPk6pVX1MhUJPmwEsOpNJOnMZG6t8sLnWaFCWf3GlT7WDsP/jknupLlnu68GqnnzU3JPq+AEY4WHEzSCD/IlHew1+8I+3eiEp0NrYGUzGLLZIh3bJM3hbhbusjnEhQ1sqMouBCmmovcEbDM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40480700001)(36860700001)(82740400003)(47076005)(336012)(426003)(83380400001)(8676002)(316002)(54906003)(478600001)(36756003)(1076003)(26005)(2616005)(6666004)(186003)(44832011)(4326008)(81166007)(5660300002)(2906002)(6916009)(40460700003)(356005)(70586007)(86362001)(70206006)(8936002)(82310400005)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:12.3366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1db08cfe-55db-45a7-8ea6-08db3ac15a73 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6541 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240837610100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Following changes are done to __unflatten_device_tree(): 1. __unflatten_device_tree() is renamed to unflatten_device_tree(). 2. Remove static function type. 3. Add handling of memory allocation. This will be useful in dynamic no= de programming when we unflatten the dt during runtime memory allocati= on can fail. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 10 ++++++---- xen/include/xen/device_tree.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index aed38ff63c..bf847b2584 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -2047,7 +2047,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, } =20 /** - * __unflatten_device_tree - create tree of device_nodes from flat blob + * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens a device-tree, creating the * tree of struct device_node. It also fills the "name" and "type" @@ -2056,8 +2056,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, * @fdt: The fdt to expand * @mynodes: The device_node tree created by the call */ -static void __unflatten_device_tree(const void *fdt, - struct dt_device_node **mynodes) +void unflatten_device_tree(const void *fdt, struct dt_device_node **mynode= s) { unsigned long start, mem, size; struct dt_device_node **allnextp =3D mynodes; @@ -2079,6 +2078,9 @@ static void __unflatten_device_tree(const void *fdt, /* Allocate memory for the expanded device tree */ mem =3D (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_devic= e_node)); =20 + if ( !mem ) + panic("Cannot allocate memory for unflatten device tree\n"); + ((__be32 *)mem)[size / 4] =3D cpu_to_be32(0xdeadbeef); =20 dt_dprintk(" unflattening %lx...\n", mem); @@ -2179,7 +2181,7 @@ dt_find_interrupt_controller(const struct dt_device_m= atch *matches) =20 void __init dt_unflatten_host_device_tree(void) { - __unflatten_device_tree(device_tree_flattened, &dt_host); + unflatten_device_tree(device_tree_flattened, &dt_host); dt_alias_scan(); } =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 19a74909ce..58ac12abe3 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -178,6 +178,11 @@ int device_tree_for_each_node(const void *fdt, int nod= e, */ void dt_unflatten_host_device_tree(void); =20 +/** + * unflatten any device tree. + */ +void unflatten_device_tree(const void *fdt, struct dt_device_node **mynode= s); + /** * IRQ translation callback * TODO: For the moment we assume that we only have ONE --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240760; cv=pass; d=zohomail.com; s=zohoarc; b=NfCEQHDMd1cw6KSy/BBSZCJNdWJSJKBMgk7gJ+Lqcj45NCzH1KG5qWaBXDXI1m8MCZmHL93DSr6q6iguszaEDWoNFn/hif82sKGvMG4Ta9lxS4MCvbGOtAJzX2e+vZ2PvBmJn/dAu2alVWjUYscCAOTBNG3XfK3SBdS7LBfOAKI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240760; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=LhhzmTOLMRAQ1ZjWOnIgnERKd0UBANjcvDhWqlSLPDonvtDH64mSQJPNSbFXinUXuWpMP6uODoAHHEu9r2FsDrBw8druI0CxkU5EAff8NIwjajRGRKStRfzRKP3Kwc5hSJLI13uXVD05x871WMYsXNy09lPnjeSDg4cI/gFUOpM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240760704178.88714710605302; Tue, 11 Apr 2023 12:19:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519806.806890 (Exim 4.92) (envelope-from ) id 1pmJWB-0005cQ-Pa; Tue, 11 Apr 2023 19:19:03 +0000 Received: by outflank-mailman (output) from mailman id 519806.806890; Tue, 11 Apr 2023 19:19:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWB-0005cJ-Kw; Tue, 11 Apr 2023 19:19:03 +0000 Received: by outflank-mailman (input) for mailman id 519806; Tue, 11 Apr 2023 19:19:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUW-0004Ta-0r for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:20 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20611.outbound.protection.outlook.com [2a01:111:f400:7e8b::611]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 78375fb9-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:16 +0200 (CEST) Received: from BN9PR03CA0142.namprd03.prod.outlook.com (2603:10b6:408:fe::27) by MW4PR12MB7166.namprd12.prod.outlook.com (2603:10b6:303:224::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Tue, 11 Apr 2023 19:17:13 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::68) by BN9PR03CA0142.outlook.office365.com (2603:10b6:408:fe::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:13 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:13 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:12 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:11 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 78375fb9-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P2ZtciHNQZJ1CW8HGjWQBQaYU9j7azTGq6d429aQHdzUVfNY+HEgTexkd1sVJO95biDcrw3hgcE8H0Nhfj6TVvlcjMKaZcfDuC/c9XeHnS9V6r9rSmjMYVn3FEsNiW1LtemPqHGo5qL25K31njuz1We61WKQV2YKzT+gP6pozm0ir/rloUptHimg11gAPZEhFFsHc+nx+vEEXyNLoujb5SteJ374nbnXx8ini/09XWbtmfiystSKJZmvIykJr3Rs+uqbEChCRx4bFKC9flyn2KIoTFOSeDWvCzM2mVwkBLUcHfeusV4036wQatGP8EOvvN/VmDXJw9KT8Zwq5O5V2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=YxFnbaNOWzAlnzIFiw5613yOUxX5R0jVPGMcq9tgF0BRy+RgiKllDzuhPiGZi4U/anDvOkAhTzSxfD32QfPw4G5qPtW0FMVYC6cLJXEYYBtqLhxaar+tvmo1OSPE11OsG1AC6NzIT/IZ8H72vJ/Dr3IQJ1BtAsnbw3q2jN5KnREaiSATqwdksWmYNidCxWdfIwd+2sry/2/Lw24edOu8VlR8AVk/1JZJbnXZIXfJLAvODKVdsolt14jiPzYuPgOjMmqdEonYpHHT+lkiovERI2trJrfi+11dpHvgsbzW7tWEcbXGzQoNmKnDllw7C86cqYxNHsQjlLPs0WPYuFrUew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=JQ/hU2P8vnyDzTVBSxNElxt8ZK5IT7TJQ8XEi+uUvWOa4YWebyhtS7WVkuVhxIIX8e3Dhu+yBATcGbf7wjzBLwILdKKGViPVecu7FoMITWx/tdHMCZz8NVhjbni0K1Nid5jHmBpNw7nTztLWeeA7mXUiK6oVmWGAoeWIeEJHmaM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Andrew Cooper" , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 03/17] xen/arm: Add CONFIG_OVERLAY_DTB Date: Tue, 11 Apr 2023 12:16:22 -0700 Message-ID: <20230411191636.26926-22-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|MW4PR12MB7166:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d21aa73-be46-49f3-61ab-08db3ac15aec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Ye5PZBaC4XZ9/w0ud9o+0cmn0rwEgLvLYNNpTFIOK1wvfkPHxko6LLG21O64/yuJ4XkFLLeJfgt07VWzZQ6JKyRwMV7YuL3ktryLnBiE5FbYWIA7nwElkY1UInIzC79O/6u/lKjWh8ae0Wl/YfBxRZ21t7APPccxvQJtL3b/kmbb2ZZEaNKP4TqZWcAIBEr+SUmZoRwFsAJZlY0sBjtdXR6SyXy7+A/BOiLmp+Ns3yYGXCxFgZ7SSbDIHVWxBS+gADFTtSP6IER7T6efdjCTiEmp5n2I3tCyZHGEdVphRHLZOqHuxM8PSDxE7aCaIOdjHhU3J0SDgNHSYN1u2uTeJNYYIdAXidar1rYAm1afauzkt34f7P7JagqmOLb23Ja0TKBHTZAReO9KhQfeHojhCjSr/YMWcVW7KHcbSiP4Ow4sbvKdO1RNWgUxmBl4xHWZrq+YQkPHZG36AO5bDuRBU3RTIQZgw71y0j9xIXjZ+CYlEIvpopbvkwurva+eKQoDtyJDbCHXvLPrX9wtJhv0AcDJWXM8B6ckzwg5rfgL9tX2ZlkZUuYxPpkUCnDlz+sxYQNy+OznMRmAlNwAzmgCRHeI6hNoH4l8jygKzfZCXmRvd8L9MrxbyG0abRgdFOT1JnQGMwv495pWlcqa63M4JWnGw49JDeL5fSLeLIWIzaaWbcCC1qUzZO0lgbhfbcImPt6/qXunohb3VRLPLFamNJ3L0x8obJ4/8DUowVr41s= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199021)(36840700001)(40470700004)(46966006)(186003)(8936002)(1076003)(26005)(40460700003)(478600001)(82310400005)(36860700001)(316002)(70206006)(54906003)(40480700001)(4326008)(6916009)(81166007)(6666004)(36756003)(86362001)(356005)(8676002)(70586007)(82740400003)(41300700001)(44832011)(2616005)(2906002)(47076005)(426003)(336012)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:13.1128 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d21aa73-be46-49f3-61ab-08db3ac15aec X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7166 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240761225100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a config option where the user can enable support for adding/remo= ving device tree nodes using a device tree binary overlay. Signed-off-by: Vikram Garhwal --- SUPPORT.md | 6 ++++++ xen/arch/arm/Kconfig | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/SUPPORT.md b/SUPPORT.md index aa1940e55f..0a31f40af4 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -822,6 +822,12 @@ No support for QEMU backends in a 16K or 64K domain. =20 Status: Supported =20 +### Device Tree Overlays + +Add/Remove device tree nodes using a device tree overlay binary(.dtbo). + + Status: Supported for ARM + ### ARM: Guest ACPI support =20 Status: Supported diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 239d3aed3c..1fe3d698a5 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -53,6 +53,11 @@ config HAS_ITS bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORT= ED depends on GICV3 && !NEW_VGIC && !ARM_32 =20 +config OVERLAY_DTB + bool "DTB overlay support (UNSUPPORTED)" if UNSUPPORTED + help + Dynamic addition/removal of Xen device tree nodes using a dtbo. + config HVM def_bool y =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240647; cv=pass; d=zohomail.com; s=zohoarc; b=Mnjn0Wf9fcgtsTrO4jbA2GDNxH7miapj054cNXpgcN2ZMex4qZ3pPHKhhaTJefeeZBffLvj4HbQni2gjImE8fgT93Ou4JP8mwVYvdnyR4h8kGkNGehv+Hp37KcVhwt0tzvBoV8Je8i1XUIj/Cosipod4lCRSh6i2L+NXirP/Tbc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240647; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=TvaNfasUWOSx9RCcoxiAibNNJo1kuDb6M5hotXw1B1Ski603G3yDWqzf6pQxf307NBgDYNg1BMsDBHxgT2PT+9bAMpAmys9pnCBX4Org5pUXueCCyv3/MyO+NqyWausKK9LQEn/H4VuUn3CWqM+iccLFKdG1G4k3XIPULP3TcvM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240647336428.16627951143494; Tue, 11 Apr 2023 12:17:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519771.806754 (Exim 4.92) (envelope-from ) id 1pmJUL-0005OG-0z; Tue, 11 Apr 2023 19:17:09 +0000 Received: by outflank-mailman (output) from mailman id 519771.806754; Tue, 11 Apr 2023 19:17:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUK-0005MU-SE; Tue, 11 Apr 2023 19:17:08 +0000 Received: by outflank-mailman (input) for mailman id 519771; Tue, 11 Apr 2023 19:17:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUI-0004DR-7o for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:06 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062b.outbound.protection.outlook.com [2a01:111:f400:fe59::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 70c37f42-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:04 +0200 (CEST) Received: from MW3PR05CA0004.namprd05.prod.outlook.com (2603:10b6:303:2b::9) by SJ2PR12MB7962.namprd12.prod.outlook.com (2603:10b6:a03:4c2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:01 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::87) by MW3PR05CA0004.outlook.office365.com (2603:10b6:303:2b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:01 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:01 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:56 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:56 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:55 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 70c37f42-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxpCf3u8aQhuKKrQ0T4SThXXP1/7rOEjefrnQSrBSTFBH+2vet0/BkN9/96BSOh7BRc29yBAuGPfWBrzsmO+z5fnIfCwZv+/W19BY/NV8YANilCikYT1V6SYpNidRCML6foQhvXzNpSPdoWeuYsSgXeXBoRcw30A9hLweGC05laY3bfZd0nKDfZygI2pHhb+DVTBGxMKHmbwxn5ZVbZ7WJk6S5aqZRc1vjlpRsq2ZVXjC8+8eeuht7v/iiIdbRQyVVxOlmpJIwUjwPmg0cum0s/L0CtRf+4gtmJkTKc71Q13em4p8IVwFzZY2HoSwbOnofwG8X+xRU252Zq5wh0tew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=J8chaI68GCgVd6yiVlsCc2D6W9f8W6rt3VGRxdijG5QkKl4XmOHnBv8yIOYI/Rgw6Klo5ZQhcfIdeK4P15dtOyfRXRvLNo/MftvzVHrbSeH/vaYcM9RFyEJ7NUhxXpfNqKRi+aR0qwKnJVPtlrB7QQh00GsQM9m0Rodu36ZTFZeAjjD47Mx2VrRjvv9dtW52pf3kcqkolch+iGosTYvrcT784CYrbxufSy0xOdAiTpXV1A0iS3ImLKKJp6281qCGzbhF9c9Xln6UIHd4NKB3CWweckTiIqaye45CAj0ZJkXf6BnGjxwtBMmifjilgQ5RjO+UazrA0bzcIwYk090FzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y5jE5w9tUBXYNb4GkaW66AGdvE8156w4aHYPgYkE7PU=; b=wxWB/BWXY2CO32y5vRS7236kub8VwKV+uQFpF+1OL7L0gNQP0NFpjSVE+5iJrM4LMKSlT0XcPeLcswieKsQ8nTGed5rjuOLbVuJXYhTiPU4/xfe0O9OCoYPR1oCufxMZ35hDCStB3gc6PZlfTqyQ9vA0Q0yoWaW96zC54AlnEGs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Andrew Cooper" , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 03/17] xen/arm: Add CONFIG_OVERLAY_DTB Date: Tue, 11 Apr 2023 12:16:04 -0700 Message-ID: <20230411191636.26926-4-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|SJ2PR12MB7962:EE_ X-MS-Office365-Filtering-Correlation-Id: 93a1cd42-a56c-4eb5-c800-08db3ac153f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XWH3oXWHqcZD9sTbyewkrsWBFCMU89fDJmR4pzMiPZW5pze/IlzoIeNqgMO+onWgXaj7kkAxDBoDLNVOcSQsC8idNUm+ugK7ePoigLJoBTkuI4LPtr6TpF1Hu96MhwTrlzVFaMa8sY/LwPPV4Jv9pxEySrnK4eUpkPnpbZIFmvfQwFd2u2XDDj5UI2KTlnkYAVF8I4WaxTvn1RsWJ01pNp1scH91N4EH6kjSdx9cp9nn4MhQKQyquijx0FvB96sd8lhRvXqKnGN4ej9l87xkd6gaBZFF2QDaWi/bx8h82ONNlZbn/6Bdf9FCl4EgW9/S3afztXOAIZr0zPtDkxpYUmdBxecv9dJ0AWU5e18XbD9auKVMJm/1NlaTK8CnG5SPzNnfl840lBkZdlL1otUt/ycx6XbjnQ8Pg18BFGRMa54ksmJgSg7RBkpYZ0ebggriUDOCaJTYHTG1iDX7k35EY/ACLzaqqPtlL8QkBkYeLj32xs5mlb5IuZUXzwgAMxGmvvp6TOPOE+EMrXpxYCmby1nAHtZ6i/vJHIVuc8xH9wvDpCtCcA1gw/nFOXZ0eiJaWGH/JmKExlvCImja4S1yoLikS/kf61uDhiWCluec1ISqzh7nToVQZBqAlEykzumK+3IM04rzaalN6zkN/upDRJ+JUwM+HvF/xC7nLvPig/jILnqLMs5OG7+4ucnYho7ogyInqZSxFbkoEr5V6l8vHITm7LFWVa+3ZtQdrpW0ie8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(36860700001)(70206006)(70586007)(8676002)(4326008)(6916009)(5660300002)(86362001)(186003)(426003)(336012)(40480700001)(41300700001)(6666004)(82310400005)(316002)(8936002)(478600001)(54906003)(2906002)(36756003)(40460700003)(26005)(44832011)(82740400003)(1076003)(2616005)(47076005)(356005)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:01.3563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93a1cd42-a56c-4eb5-c800-08db3ac153f8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7962 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240648946100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a config option where the user can enable support for adding/remo= ving device tree nodes using a device tree binary overlay. Signed-off-by: Vikram Garhwal --- SUPPORT.md | 6 ++++++ xen/arch/arm/Kconfig | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/SUPPORT.md b/SUPPORT.md index aa1940e55f..0a31f40af4 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -822,6 +822,12 @@ No support for QEMU backends in a 16K or 64K domain. =20 Status: Supported =20 +### Device Tree Overlays + +Add/Remove device tree nodes using a device tree overlay binary(.dtbo). + + Status: Supported for ARM + ### ARM: Guest ACPI support =20 Status: Supported diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 239d3aed3c..1fe3d698a5 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -53,6 +53,11 @@ config HAS_ITS bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORT= ED depends on GICV3 && !NEW_VGIC && !ARM_32 =20 +config OVERLAY_DTB + bool "DTB overlay support (UNSUPPORTED)" if UNSUPPORTED + help + Dynamic addition/removal of Xen device tree nodes using a dtbo. + config HVM def_bool y =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240650; cv=pass; d=zohomail.com; s=zohoarc; b=Z+m4vayv1gFDw44DYfonuck1XgahttMro0wLFpoNA2iSOhMcmjZDgdlK9FhCg+0Ky6oz/NwrXSag7kbeKI3J7OIEyJY6sTxtTiKdA2tyUECKV7hHpFuQcTE7BlAhWW3jFXQWBziuk5313zGAYRhCTdmC5xGrzM8ry0joDyS1z8w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240650; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=Kdb85gn082feipowh8sazKlB6Tb2TPFkKMt214u3VEs14cuXH0oCAKmv2gWckVCTRjMtFZE/9DXBQUe+NYy6Lk8t/88f58XReoquL8ZkRvyddG2wvXprocPD1nHk8kzAXM6DeKPDVKUWFaRr4h2zbURsTcEMQ7BIiryifgjP5Ow= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240650315184.15175967412392; Tue, 11 Apr 2023 12:17:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519768.806730 (Exim 4.92) (envelope-from ) id 1pmJUG-0004ji-Ui; Tue, 11 Apr 2023 19:17:04 +0000 Received: by outflank-mailman (output) from mailman id 519768.806730; Tue, 11 Apr 2023 19:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUG-0004jb-QV; Tue, 11 Apr 2023 19:17:04 +0000 Received: by outflank-mailman (input) for mailman id 519768; Tue, 11 Apr 2023 19:17:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUF-0004Ta-KC for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:03 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20601.outbound.protection.outlook.com [2a01:111:f400:fe5a::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6f89fd80-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:02 +0200 (CEST) Received: from BN9PR03CA0077.namprd03.prod.outlook.com (2603:10b6:408:fc::22) by DM6PR12MB4282.namprd12.prod.outlook.com (2603:10b6:5:223::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:16:59 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::5b) by BN9PR03CA0077.outlook.office365.com (2603:10b6:408:fc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:16:58 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:16:58 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:57 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:56 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6f89fd80-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqfHvUQkKRI+G1Rz6oofnKIRzyCknyLcK0EUyws71WyuEo6e0kx4wVRS09qucjTXA9EqkU8e+z63bCu/YkL+kfC8GOSrj7rwUj/hevwvj9CRfVNBXfSRMd26MnOj3P8VppZyJsbOp7oN9ULsAUdBY38gE9097qaUlMR1paZy56dBemNS5UHDTkVZOl1r3tGL1yoFI1mzVv0ozo9bM9zVFJZ/DRtGpVz1Qx60rijmc4vA9vapQqD+RSk23+p1T2rJWJbUrSzG8xgrWNwYoabwKn3Zx7YQvsbVjj6T73nkM0AEDfvtaOEkS0oh/1/GuMZ4JZyfsyyma955nur+H1rWYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=XVfer5z5EHUilHhV+QpewCTkSOCiPTyjg/flVMZDEAzRK7xS4U90MmLS2j6XCxJadMrTyfIFtqZgoV8tE5knDGCt9Oy0pJnHl/YgFH12ggxAV7MMV8Fr+WG99/NQCfuORKTWXweHXckRRu6Ghyd9EzVd+cdZhZgDEOTfJrOaND763U12ywlONjxb2o0xNbsw08P4nJPuYUvA34TqM5tdqXE4UKXbylbIoJu4mMYx3dg+VOB48TH9m8UNMBnMYOUnFMnaNJhPMSzo+GyHnp1zexnQxanpVOmx8/4ez4aN6AvQjfluvkCvSi4wU3+b/2iwK54aukTqwBjwLwEyLBAb8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=rl/f+0LCUCpB609QADltQg+rTxdAOrQiu8YujzkFf1OQB3AAg5ivux1ExrlGxmgNX4gA13RYWWZLejjd2CoSI8Y6BCICQIu+vn/vyCh/BDlKvHSYiFlDmHWaQLT2ceA64UDpUA/XJ+8ZOo+WqDeTLlbQI3mUA4YsgiIRfgsyJ2A= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 04/17] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB. Date: Tue, 11 Apr 2023 12:16:05 -0700 Message-ID: <20230411191636.26926-5-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT066:EE_|DM6PR12MB4282:EE_ X-MS-Office365-Filtering-Correlation-Id: a9c843cc-4c85-4c96-a8c6-08db3ac15246 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5mZY9arVfIz4R/AVfjqkQGX6I4NgpAdkIvjkuVZqz5BKhyPZEDL6b5Xq8b3aZ8yk9JU+rCdeveWZbPStUFbHz4rOiSVlz3wiAZwUYR0jRVcmHdSCANP2OdgfJgacMgBX58liZjifMHUHzC/32dEBes0dT/X0sVh0V0ClZ/pmvVNF2vnoktMpqFl7WQQ6/bzuXUT8t6RLcCdF1n/3N0pUtC3AMR9H2HHoI73W91MU1zSRQ9p3o//hEvudGpbf1Q/O9EyfgJP5cn6D5Wa+pOcUC+a0wuMf94oRCG6cfHd5p9GA/HhF+Rw7SezASSeL6IA6UysRg+9vzAPtm0ZN/6sMk48bGE1upLmFIspEKzE5Xx6I6Oa3iUBQemvUG0GRGf4bdhWntvbrDNu30WquTcxt+EoHMzvNBdW59Z2Q54ECfZK69MyfO0N3SILS823JJrSKR2I444zyf/CPE3tEfFHX91CO9QOXC+5ALFlZGMr2X28jaiAhNzEM19Os8Ea7kh5ySxKv0vuydLq5lJtnjoAQwr5BCuUnxCWZO7KKKfDzxM4jLQXG2exYJ7Yc61JwrHEHD0D39MpQ1pWsM0R7MGeR2RyYy8cukIRVhn2m5REcOmNb6w6YBFsOkQbj9rXjK4kFARvTQo2T2N1Y9AaR02BFnvB9oY1v1UmFgnOGiR1+Qql+LFy4XNhSrlWdx9PgLB67O/ky0Ps9USxEUlIXO9dY9kMQK7XS1nWTKovgA0R31I= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(396003)(376002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(36756003)(54906003)(86362001)(41300700001)(83380400001)(316002)(70586007)(4326008)(478600001)(70206006)(6916009)(8676002)(82310400005)(5660300002)(40480700001)(8936002)(2906002)(4744005)(44832011)(36860700001)(356005)(186003)(82740400003)(81166007)(6666004)(26005)(1076003)(426003)(336012)(2616005)(47076005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:16:58.6206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9c843cc-4c85-4c96-a8c6-08db3ac15246 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4282 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240651805100008 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is done to access fdt library function which are required for adding d= evice tree overlay nodes for dynamic programming of nodes. Signed-off-by: Vikram Garhwal Acked-by: Julien Grall --- xen/common/libfdt/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index 75aaefa2e3..d50487aa6e 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -1,7 +1,11 @@ include $(src)/Makefile.libfdt =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) + +# For CONFIG_OVERLAY_DTB, libfdt functionalities will be needed during run= time. +ifneq ($(CONFIG_OVERLAY_DTB),y) OBJCOPYFLAGS :=3D $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$= (s)) +endif =20 obj-y +=3D libfdt.o nocov-y +=3D libfdt.o --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240767; cv=pass; d=zohomail.com; s=zohoarc; b=HQz3DjKoTd5BAncxxxUu+VMoHChypxP/0UFt2LkMJHlKaPo6E1F8E21l4s9nlEjq0sBZ1f/rSKgcIqWCt+39KC5NdhPnl+TB/IdEcHQPU94Lf2osgCXJAGG+vS2oTyTu+AvH07qpFOYwaf982KPgDqaxZc1xKkOValqfbITb2Xg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240767; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=K5z6ij9uw0J+iXRLS3paesh9DKbqMdbGD/7NjGl/bCt7VPrpFK+UJ97b0VZTt29bQccqr6p+opBOAKJzjLmYGOMTtb7QwKJGO6jyfW+/wp7llbWJc9DOL7yuT11B1TBJzoNMLDxIyH9MtlHu7lo/zI7YSp6z2YYy+OHFy9DVY0A= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240767265311.193380517419; Tue, 11 Apr 2023 12:19:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519812.806899 (Exim 4.92) (envelope-from ) id 1pmJWI-0005v8-12; Tue, 11 Apr 2023 19:19:10 +0000 Received: by outflank-mailman (output) from mailman id 519812.806899; Tue, 11 Apr 2023 19:19:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWH-0005v1-U5; Tue, 11 Apr 2023 19:19:09 +0000 Received: by outflank-mailman (input) for mailman id 519812; Tue, 11 Apr 2023 19:19:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUX-0004Ta-0y for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:21 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20629.outbound.protection.outlook.com [2a01:111:f400:7e8d::629]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 799897a0-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:19 +0200 (CEST) Received: from MW4PR03CA0203.namprd03.prod.outlook.com (2603:10b6:303:b8::28) by BY5PR12MB4209.namprd12.prod.outlook.com (2603:10b6:a03:20d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:15 +0000 Received: from CO1NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::c5) by MW4PR03CA0203.outlook.office365.com (2603:10b6:303:b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:15 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT096.mail.protection.outlook.com (10.13.175.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:14 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:13 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:13 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 799897a0-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CXpPdrD59NHcZced6N+ReY2rzQPGHtm40Xv7ICsxIt/xl5azaRgbg/FpXDbBbgSewjJItDYzLHIs+vPw639QRQa7qwZH5zrduXWD9kv8CFmN8FKuRSH2JI9fBoSNFQjipdW6hobv15IL6dNzc4fAi+/pkD2phxqPTUkk+cL1b07NMwx3LkrgEZzfVRB041phzXLdlD0aq0pTOYaLhL1/dxxJwFvsA6R0gI6oXRThSiq2OovUzCLI0T4rPXDjmWhztfRLeVKHHDIzTttnJ6E3nEZtplNw5FpKxiJwi1W0BA2eMXUoxhPTMuHwgqLEqS6vaF9YVZDLmzu2PCq8DcBiMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=cksZoW0ks3716PsidDanbIitYQa+dR1UVj/3ZfkfzDYwBV4HM0p5HaJDaiJqjrwy0bWn7nx/Nj6IDIjqwMHEkw6PJVeyPnNpLs5kYAXMa4TxEVDe2C3mRj1IRSpGvprN3FJr26Kqy3IKvA51h3MLFZorE7J3CJ3DsOc+NOZ7GTklZciqfOUfZHF6RD40qsP7ijZncH4Z0dxPPiFf7rOaP7j/mis5HABhIf6WwiXpRFDWklw/SsdbeH2e1m0QVNH4y4mzzTG5a746gRPQKahAhxgNODv13BxfDsWfW+yG3EXtFKSwUN+DskgWMPoJLgDXrhriCkLT0fURLXudLW8psw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+aOH8wbfxJ3CDB9n8z4otIPVVDXaY3ZnHxlpPeTlbO8=; b=C8LnUlJK8/O5qvHp1MAOesiGzHauPP4chRPeau8EzNQHbWxjGd1E++r0vWFVvMOhDGikzO9d8m3aAWft9gjihUuvmmSU6xIL1/S78nTyco3qOZccbzYNHX2eoGMx9gyTdDz6XzcmGKhz+yyGfhMkjCaBQ735nslsas2Mn29N7io= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 04/17] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB. Date: Tue, 11 Apr 2023 12:16:23 -0700 Message-ID: <20230411191636.26926-23-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT096:EE_|BY5PR12MB4209:EE_ X-MS-Office365-Filtering-Correlation-Id: 778a1185-cf2d-464a-ab52-08db3ac15ba7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3+4G1HcuhJ+RiYvsVU7dkqReSPNLwMFDbQ/azTNjZysqNxtVxfff/YnYzEUt2wAkHB2yvZUfBol6uUCA4r0dblCaMB7aZcUX6OXNqj8fJ23o/K4lN4fYhO6BIh1VqCx9vJKsEmiQb+qYais8rHA0bggCJUVGcLbT5DroM5n7GRQhzx5yy3b09oKhcxmMgz80BjWkgo/1CfMPyJLEhwRC06Ayko9Rewr+r9Sfn317zCyy9tW0ia+3Sz2FyfDm57eL/7Tp8cZ2F+Pm11bL+AaKmrRIFgGTwyQlFeOMQOMVe6KEptapev+8/nihgkdFIRsC1EA3F82tXmJMt+jx6HsZXjSe1H7Jjo53Bw7nIu4yjp73lNm2x/lAARgP2o84IkduqpNNbvAOYDTc776rZToKOlZ3bMBuBrh8Wyzrmo34dnLD6J4jPG/HlKyhlnepVkCa51bOJ0GyWMKgjKjwj3xvQC8eH8BylFZMRL7MJLdVDb/b1rjNS2PP0zOZx1gpqPTo9EWrfEmR6QsoOSxoP3lIJFXmtjFhgd3Cz89gCybOFi3x93wPXGWFdV9olZjnviDD6iyTgvvgVeIh8uh4X/y3QD5dl6VwhV2W1+l69rIbCfmvPxveBsK0yHK0V64w6goLA8KgbGF+Fk4H1TgymT2xbnDR7GeIWhIJMk5YU8ihtkIJVRkWv/xmXEyN9yKt3BUr2IjGzAGzG9S7/v2awZJhCoA4NvTOQFaIqbDvKGVB6rA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(346002)(376002)(136003)(451199021)(36840700001)(46966006)(40470700004)(36756003)(86362001)(70586007)(41300700001)(70206006)(316002)(54906003)(478600001)(6916009)(6666004)(4326008)(40480700001)(83380400001)(82310400005)(4744005)(44832011)(8936002)(8676002)(2906002)(36860700001)(5660300002)(82740400003)(186003)(356005)(81166007)(1076003)(26005)(47076005)(336012)(2616005)(426003)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:14.2308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 778a1185-cf2d-464a-ab52-08db3ac15ba7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4209 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240769253100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is done to access fdt library function which are required for adding d= evice tree overlay nodes for dynamic programming of nodes. Signed-off-by: Vikram Garhwal Acked-by: Julien Grall --- xen/common/libfdt/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index 75aaefa2e3..d50487aa6e 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -1,7 +1,11 @@ include $(src)/Makefile.libfdt =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) + +# For CONFIG_OVERLAY_DTB, libfdt functionalities will be needed during run= time. +ifneq ($(CONFIG_OVERLAY_DTB),y) OBJCOPYFLAGS :=3D $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$= (s)) +endif =20 obj-y +=3D libfdt.o nocov-y +=3D libfdt.o --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240652; cv=pass; d=zohomail.com; s=zohoarc; b=N+vDIuPvzMnag7frxgR7KHle9IyfOOWBBnM9DbvVauxFEErr0vMQ48Shrp8oo5nGI8O+7FRexBlqKjpLNanToIazpDqhBd/mysOc4KWCBLtLE42polPzUJd4/bX0gnVmlYAppYS9Z/u/w4h6IBZszhdpM+W7Xh0OE8gXnbR6PzE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240652; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=QBOc27LZwMhh3PWoaez4SiUnWUIpQOWeiQmdBJdWSQDBfbJMTVaU4fPYFYJqoMoq/bYLwzYmmeLUXqjaM7Hia03d+24weczkdCUzbIIHGAMDSi5NzwzbaAC+OxE8DA8YZLaqYgcqP7ZRL+Ko0rVK16nuxKN4LTf7+y6dKTJe0z4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240652146237.23421287691008; Tue, 11 Apr 2023 12:17:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519769.806740 (Exim 4.92) (envelope-from ) id 1pmJUI-0004zv-8U; Tue, 11 Apr 2023 19:17:06 +0000 Received: by outflank-mailman (output) from mailman id 519769.806740; Tue, 11 Apr 2023 19:17:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUI-0004zo-5D; Tue, 11 Apr 2023 19:17:06 +0000 Received: by outflank-mailman (input) for mailman id 519769; Tue, 11 Apr 2023 19:17:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUG-0004Ta-DQ for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:04 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2062a.outbound.protection.outlook.com [2a01:111:f400:fe5b::62a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6f9ec66c-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:02 +0200 (CEST) Received: from BN9PR03CA0074.namprd03.prod.outlook.com (2603:10b6:408:fc::19) by DS0PR12MB7927.namprd12.prod.outlook.com (2603:10b6:8:147::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Tue, 11 Apr 2023 19:16:59 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::4b) by BN9PR03CA0074.outlook.office365.com (2603:10b6:408:fc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:16:59 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:16:59 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:58 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:57 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:57 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6f9ec66c-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hsnvahqefEJcrGbq8TaKoxKIRcJ8k6g3h4CnC8ViW6gsJNOkIj7iYXQL9Ii413JsBQybdidGJ6LrYp4fbkQfkCB+uk9G8JtQNGWQEg7I2zZVvPT0EekScDapJsrHJ2zroYwVXqobef3b6SibjN1W95m4XVNV8awgAgRxS+ctdQe76N96+hxiTZeE6koUtR3VImFtKbEN7dLGN9hrSzfE8pxKNgYKtUkx5df4BxHctIT+EYRqjZiKki1Ixz3dScKqCfPRWYYBMY/C9zXeYJx1kov8c46c5urOiOJlWKEhQzyGMoDaeydbYpyedbXcu8qGhtYFZ2jrveqP13TX74XUSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=L19PP9YIoz2ENayQ10udRQtImwhc0jGVL9fhd/yJy3oG4NYnKeU5Uo7S9PfQ9S8C1q+F4AwS7Y77NS815xEiRFBaNIOjsCyiACllRlkf8xpQYjufEogNI1/VWI9eg7Am75r3yQL14wxPA0vDfIwf8/6m9kPfVD1Vqw1QEzg7RC+e1UwfTZBxCjLz0wKU3mIcfVUrw0bJmuGMsNCCKlVGcwz2mvlqPpWHMLSxVYXyT6DuugcjRPXS2YanxJLXxvxMB+b8bGYlUNFrk6RRU3hRJjZHjJkQnbf1S2sz5s3uYyet8zguNevVPntPXjgvfXEy9umt/iGpNr6PZusNGspcJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=WEz5Ij5Kp8boEyjMUb91XSI7OHDNJpWmshSsP8z3y16orb5bMbZYN4Ifo6hwDNVLqS9pcLJn7M7tz6Hpl6WM6nVl3T2uL2+3WmAzWkPtgLlRVYNE7KBVjbwOq/kRR34spEH0g+H7ltXDphzhcRAXoKFJL30lTxKV8Cm8wEzuk5w= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Vikram Garhwal , David Gibson Subject: [XEN][PATCH v5 05/17] libfdt: overlay: change overlay_get_target() Date: Tue, 11 Apr 2023 12:16:06 -0700 Message-ID: <20230411191636.26926-6-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT066:EE_|DS0PR12MB7927:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f074106-fed4-47f9-7c35-08db3ac1529c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oC7YWE9imiHPDPvyBdq1PTLkB0ISDaGkF+VlhetZPVZnrzr6qM7i8dNDmV+QzgsOCOuzwqrGgKNhT6Gc22W0h6Jl/VO52RYpH5NKqj6nuXeOvhDgl5n1sZfailtvZQ88ra2YqPqoWwMRZ/ranbQZks7SlxvR9ZlSLAbrSFWtdAI34AOBnT71936i+XeHyBYcVEF/jOWTxjkh/+G45mkAZLAGk32lNWO7+a0YoA55yRJDH5xXnogPn3Oqx1XIFtciV347wsEzKAHR/q5xdxufvwgEuBDl0xOC5mxRQ+FOxXjsenAxKvYFPe5qgzV08T1nisxhvhRijfLnun7V25nvhtfCXFCf+A2UTc1DtYM6oe2k0vbMOqhnAYKnwVMNkHszSH897j6urVNiCCXBv+SeywRIahq1UOkE9rHubtMSbGU7Bgh3uczPNvtnDxuc9yjluZZ/3UFlw9ymuEWobZgLUULm812dpGF2tKKTCu7rUz6qRg0clEn/C4NfeKoeGw2eQnPQRcGNOBdoc38sFsycpXmByMev6cjJxEVKXcaLXzH48i3nRDdI57qPVYuvkt3zWy/ri3F6DbdkhSXIIX6EWE+EbF4BziXbNg/ovhq0lb891h54Gpe7MePtoE+87lj72BOYskDuhcpNVoO/NCN7u9vRlpXEi/C5sECMSM31b4uyhfDxhXHIaU8+69B/HAcsq73Pb+ALVezM4Jeq7j1OBL8v9Evy9xODkhsWbiLMfmw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(47076005)(82740400003)(36860700001)(40480700001)(2616005)(426003)(316002)(966005)(26005)(478600001)(6666004)(186003)(1076003)(54906003)(83380400001)(2906002)(336012)(81166007)(8676002)(5660300002)(4326008)(36756003)(356005)(40460700003)(44832011)(6916009)(41300700001)(70586007)(8936002)(82310400005)(70206006)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:16:59.1674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f074106-fed4-47f9-7c35-08db3ac1529c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7927 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240653703100015 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename overlay_get_target() to fdt_overlay_target_offset() and remove static function type. This is done to get the target path for the overlay nodes which is very use= ful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mappi= ng of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc. Signed-off-by: Vikram Garhwal Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com> Signed-off-by: David Gibson Origin: https://github.com/dgibson/dtc 45f3d1a095dd Signed-off-by: Vikram Garhwal Reviewed-by: Michal Orzel --- xen/common/libfdt/fdt_overlay.c | 29 +++++++---------------------- xen/common/libfdt/version.lds | 1 + xen/include/xen/libfdt/libfdt.h | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/xen/common/libfdt/fdt_overlay.c b/xen/common/libfdt/fdt_overla= y.c index 7b95e2b639..acf0c4c2a6 100644 --- a/xen/common/libfdt/fdt_overlay.c +++ b/xen/common/libfdt/fdt_overlay.c @@ -41,37 +41,22 @@ static uint32_t overlay_get_target_phandle(const void *= fdto, int fragment) return fdt32_to_cpu(*val); } =20 -/** - * overlay_get_target - retrieves the offset of a fragment's target - * @fdt: Base device tree blob - * @fdto: Device tree overlay blob - * @fragment: node offset of the fragment in the overlay - * @pathp: pointer which receives the path of the target (or NULL) - * - * overlay_get_target() retrieves the target offset in the base - * device tree of a fragment, no matter how the actual targeting is - * done (through a phandle or a path) - * - * returns: - * the targeted node offset in the base device tree - * Negative error code on error - */ -static int overlay_get_target(const void *fdt, const void *fdto, - int fragment, char const **pathp) +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp) { uint32_t phandle; const char *path =3D NULL; int path_len =3D 0, ret; =20 /* Try first to do a phandle based lookup */ - phandle =3D overlay_get_target_phandle(fdto, fragment); + phandle =3D overlay_get_target_phandle(fdto, fragment_offset); if (phandle =3D=3D (uint32_t)-1) return -FDT_ERR_BADPHANDLE; =20 /* no phandle, try path */ if (!phandle) { /* And then a path based lookup */ - path =3D fdt_getprop(fdto, fragment, "target-path", &path_len); + path =3D fdt_getprop(fdto, fragment_offset, "target-path", &path_len); if (path) ret =3D fdt_path_offset(fdt, path); else @@ -638,7 +623,7 @@ static int overlay_merge(void *fdt, void *fdto) if (overlay < 0) return overlay; =20 - target =3D overlay_get_target(fdt, fdto, fragment, NULL); + target =3D fdt_overlay_target_offset(fdt, fdto, fragment, NULL); if (target < 0) return target; =20 @@ -781,7 +766,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) return -FDT_ERR_BADOVERLAY; =20 /* get the target of the fragment */ - ret =3D overlay_get_target(fdt, fdto, fragment, &target_path); + ret =3D fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; @@ -803,7 +788,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) =20 if (!target_path) { /* again in case setprop_placeholder changed it */ - ret =3D overlay_get_target(fdt, fdto, fragment, &target_path); + ret =3D fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; diff --git a/xen/common/libfdt/version.lds b/xen/common/libfdt/version.lds index 7ab85f1d9d..cbce5d4a8b 100644 --- a/xen/common/libfdt/version.lds +++ b/xen/common/libfdt/version.lds @@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_target_offset; local: *; }; diff --git a/xen/include/xen/libfdt/libfdt.h b/xen/include/xen/libfdt/libfd= t.h index c71689e2be..fabddbee8c 100644 --- a/xen/include/xen/libfdt/libfdt.h +++ b/xen/include/xen/libfdt/libfdt.h @@ -2109,6 +2109,24 @@ int fdt_del_node(void *fdt, int nodeoffset); */ int fdt_overlay_apply(void *fdt, void *fdto); =20 +/** + * fdt_overlay_target_offset - retrieves the offset of a fragment's target + * @fdt: Base device tree blob + * @fdto: Device tree overlay blob + * @fragment_offset: node offset of the fragment in the overlay + * @pathp: pointer which receives the path of the target (or NULL) + * + * fdt_overlay_target_offset() retrieves the target offset in the base + * device tree of a fragment, no matter how the actual targeting is + * done (through a phandle or a path) + * + * returns: + * the targeted node offset in the base device tree + * Negative error code on error + */ +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp); + /**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/ --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240809; cv=pass; d=zohomail.com; s=zohoarc; b=I68vjdTFkO6nJGkkUXHwGCjdyfIZ7PEUK0iUPV/gHZrfXheTwxsXopuiSO7Gb4HJ2TO1h2E7TKaoCLQGIBNFl9r2FHYqK/OJ7XMDaz1MThOklqkqUuwuoutsdO8Md8JcABRTPZmwIP0neX2b3OGWHp4Um8XyGic5CP2kNGttjxw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240809; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=mTM4I44zL4Vjt8xp5fWhxyPnt9B60OJLm8IsC3p6jTOfjgf/93ySTcpbOJ03eWg5+tApEX6e0YiP59TB+vQmrXOffFx1/3ZD/tDvMLt1QiaCTkZRf4BbeU54Aur+rgJQgHmcP4Tm9Kz22ZLDaRnyDnZsnLfVRhVucCthGPKO7AY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240809881127.18407097050351; Tue, 11 Apr 2023 12:20:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519844.806950 (Exim 4.92) (envelope-from ) id 1pmJWx-0008My-SM; Tue, 11 Apr 2023 19:19:51 +0000 Received: by outflank-mailman (output) from mailman id 519844.806950; Tue, 11 Apr 2023 19:19:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWx-0008Mn-Nv; Tue, 11 Apr 2023 19:19:51 +0000 Received: by outflank-mailman (input) for mailman id 519844; Tue, 11 Apr 2023 19:19:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUV-0004DR-JA for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:19 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20623.outbound.protection.outlook.com [2a01:111:f400:fe5b::623]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 796fc584-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:17 +0200 (CEST) Received: from BN9PR03CA0130.namprd03.prod.outlook.com (2603:10b6:408:fe::15) by BL1PR12MB5873.namprd12.prod.outlook.com (2603:10b6:208:395::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:14 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::74) by BN9PR03CA0130.outlook.office365.com (2603:10b6:408:fe::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 19:17:14 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:14 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:14 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:14 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:13 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 796fc584-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bs1J3pf2zY4xwRkL2xusjQN+dy/Hb3CaMEHIoZ23NB46HoFsLYKnIIwlW0XBpwPCN7sBqHrLf1rhal5UYE17cMnksix5aN6nMbrkNv+6GmJ5qE6Uj2V6c4owe1QhxzF+plzdo56ixceaOUEADAn48uVrOvUxGe/8gwQd7g34rc6cYj7wio0UF4K0lnKZR06l9DojTR1D15uuLKKtytOGPEUeIXqhf8Sx8C1aqbmRLYFtBZYzmFR5F48AkQdQrv/laftAZcrj63fbiKIrPrOrv6s05wQbb/pqCWRTMoqCUYYgrPu9iN2oZ4GLTNTH+nujRbHFxLhI6ij6sTF2rC+xPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=dyMSY9mhc6T6gLBQ322vHVv2gtQ+FagNKnGJbC0oXLxhAW+OqmqmgtM1hUq9FTG6PNVRkzoe58KwtA/vmxD/ESwZ1JTgEYunaBP5t59JxcdCmdKOcVYrQnu3oB/KlXeX0FYiBgTTs35uN8/3UKbNZRs6FX1NUtZnv0go3t6Qw27Che+yW3qKUKNdY6YpdfzcNyhQ9jzRnERJjNe1k99DL1RmlD0P6RQmz5/u6BJADWhJ3glO2TBhAWUJkO4Oz1NwEk653E1Tau5l+VFx7AklCyjcwbn/SovfgCL4uQvoHODEgI/o5xqWQiCFFmSdagI+9yw3yz5w3W4UqLG4k+K6qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aXlXQRcv7U/T/rRXFeXTNVQL0ZVDEHTt5u8gFMIkdTA=; b=AWISUh6SBvJgSoIVRMU5xu4akTc/rzbLimZg/dOzu2AZQmrJyx/aPaQNUFlWQRm3lFXICp+ky2stwepnVeprzphrV52xhw71Tna0Mff4itrrZStzZyt4faOE08CRCKzPkYH6mOB3Fs3jzGw3qpm3+6CdtL4IZFKtCm8NVjQDxDs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Vikram Garhwal , David Gibson Subject: [XEN][PATCH v5 05/17] libfdt: overlay: change overlay_get_target() Date: Tue, 11 Apr 2023 12:16:24 -0700 Message-ID: <20230411191636.26926-24-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|BL1PR12MB5873:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cf27a4a-d6d4-4ebc-9f12-08db3ac15bf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UCHVU1GAWIXT5Vr+KAVVr/ta9BYbkCgoPqfm4WTdrU3RoPTLQlW5CXh242muGzIhtQJsutSR/AdTUTv3GXr9K6JpMHuCZpPgs666nQKZ+jyc2N657XVz/DG1JfeYyH+UcWG/zsLLdQIkR9TPf5QQxXO3KzR1KWAR9inkhIW9JVJhUmK7g+JsBobErTBk/ouoY2iADGrjzKIa89n5JoSdMp8yv7NSFZySqlc/CSKXAOrE1VgmQMTmNJqaeIhmt+UUnmPo7zeZweX7qfx977UfWyIXZUsLLcEPhXrEt9k8lE7sZFtW2nB8HFv6uqvC+9BvwEIHAHe7Z7xGvhZ6+ELaVxfIQuSP3JK0gHSS3V8Y59Yspvf3wWUjb/Y0B56ZRzLpTVXmfhlXFMa2BkSMfuxN2NV2Ro+nTR9LbuaBpgAamSXCmQcHDuUpz7CP4fK0zOvvqp/FHDM7cRViQi3HUNhjIssB/bUmhGW1BRrjzUDc/dUaTPibCgktd9ZIvqNZK6JWRogn5f1gE+KAf+2ZyFfozJ00rZ+4W7YBkJ7BUi4uzIl2qwfss4/iIU/tT2OunavEHSE4KsJW/6LdesyEcjRU03lv41GqBpdvagpa2C5kqBZQ5Qt7PGsPbiqQizXbrXcQPL0tIZkgJG/MxC4yoPPQxOGqcOQ9atH73lJKOpkeLX7PxcBtbNYX14FLELAG1txN4zzogOP1tuMTvoTYSpBCFl7eMflZIfm2eZXnK/bk8jk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199021)(36840700001)(46966006)(40470700004)(36756003)(86362001)(41300700001)(316002)(54906003)(8676002)(4326008)(966005)(70206006)(478600001)(6916009)(70586007)(82310400005)(5660300002)(40480700001)(36860700001)(2906002)(8936002)(44832011)(356005)(186003)(81166007)(82740400003)(6666004)(26005)(1076003)(336012)(2616005)(83380400001)(426003)(47076005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:14.8314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9cf27a4a-d6d4-4ebc-9f12-08db3ac15bf2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5873 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240811418100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename overlay_get_target() to fdt_overlay_target_offset() and remove static function type. This is done to get the target path for the overlay nodes which is very use= ful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mappi= ng of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc. Signed-off-by: Vikram Garhwal Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com> Signed-off-by: David Gibson Origin: https://github.com/dgibson/dtc 45f3d1a095dd Signed-off-by: Vikram Garhwal --- xen/common/libfdt/fdt_overlay.c | 29 +++++++---------------------- xen/common/libfdt/version.lds | 1 + xen/include/xen/libfdt/libfdt.h | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/xen/common/libfdt/fdt_overlay.c b/xen/common/libfdt/fdt_overla= y.c index 7b95e2b639..acf0c4c2a6 100644 --- a/xen/common/libfdt/fdt_overlay.c +++ b/xen/common/libfdt/fdt_overlay.c @@ -41,37 +41,22 @@ static uint32_t overlay_get_target_phandle(const void *= fdto, int fragment) return fdt32_to_cpu(*val); } =20 -/** - * overlay_get_target - retrieves the offset of a fragment's target - * @fdt: Base device tree blob - * @fdto: Device tree overlay blob - * @fragment: node offset of the fragment in the overlay - * @pathp: pointer which receives the path of the target (or NULL) - * - * overlay_get_target() retrieves the target offset in the base - * device tree of a fragment, no matter how the actual targeting is - * done (through a phandle or a path) - * - * returns: - * the targeted node offset in the base device tree - * Negative error code on error - */ -static int overlay_get_target(const void *fdt, const void *fdto, - int fragment, char const **pathp) +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp) { uint32_t phandle; const char *path =3D NULL; int path_len =3D 0, ret; =20 /* Try first to do a phandle based lookup */ - phandle =3D overlay_get_target_phandle(fdto, fragment); + phandle =3D overlay_get_target_phandle(fdto, fragment_offset); if (phandle =3D=3D (uint32_t)-1) return -FDT_ERR_BADPHANDLE; =20 /* no phandle, try path */ if (!phandle) { /* And then a path based lookup */ - path =3D fdt_getprop(fdto, fragment, "target-path", &path_len); + path =3D fdt_getprop(fdto, fragment_offset, "target-path", &path_len); if (path) ret =3D fdt_path_offset(fdt, path); else @@ -638,7 +623,7 @@ static int overlay_merge(void *fdt, void *fdto) if (overlay < 0) return overlay; =20 - target =3D overlay_get_target(fdt, fdto, fragment, NULL); + target =3D fdt_overlay_target_offset(fdt, fdto, fragment, NULL); if (target < 0) return target; =20 @@ -781,7 +766,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) return -FDT_ERR_BADOVERLAY; =20 /* get the target of the fragment */ - ret =3D overlay_get_target(fdt, fdto, fragment, &target_path); + ret =3D fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; @@ -803,7 +788,7 @@ static int overlay_symbol_update(void *fdt, void *fdto) =20 if (!target_path) { /* again in case setprop_placeholder changed it */ - ret =3D overlay_get_target(fdt, fdto, fragment, &target_path); + ret =3D fdt_overlay_target_offset(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; diff --git a/xen/common/libfdt/version.lds b/xen/common/libfdt/version.lds index 7ab85f1d9d..cbce5d4a8b 100644 --- a/xen/common/libfdt/version.lds +++ b/xen/common/libfdt/version.lds @@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_target_offset; local: *; }; diff --git a/xen/include/xen/libfdt/libfdt.h b/xen/include/xen/libfdt/libfd= t.h index c71689e2be..fabddbee8c 100644 --- a/xen/include/xen/libfdt/libfdt.h +++ b/xen/include/xen/libfdt/libfdt.h @@ -2109,6 +2109,24 @@ int fdt_del_node(void *fdt, int nodeoffset); */ int fdt_overlay_apply(void *fdt, void *fdto); =20 +/** + * fdt_overlay_target_offset - retrieves the offset of a fragment's target + * @fdt: Base device tree blob + * @fdto: Device tree overlay blob + * @fragment_offset: node offset of the fragment in the overlay + * @pathp: pointer which receives the path of the target (or NULL) + * + * fdt_overlay_target_offset() retrieves the target offset in the base + * device tree of a fragment, no matter how the actual targeting is + * done (through a phandle or a path) + * + * returns: + * the targeted node offset in the base device tree + * Negative error code on error + */ +int fdt_overlay_target_offset(const void *fdt, const void *fdto, + int fragment_offset, char const **pathp); + /**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/ --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240649; cv=pass; d=zohomail.com; s=zohoarc; b=BsGskS8C0QI5rNNX1JjkWqMzQsZy/KMC913SZSFaJejQNS2MjBxMmlTN69K5QWdXX4lnpmQS30wuB01x8VCttyqC5R5PYwYJhQaQQ6k880M0jyECxXGETCPhSxmRw71M4DwPf3ZkJ1/sNe/oI46vwaI13GU/4LhMiQVPD30uu3o= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240649; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=aF6uLUNmrIlqD45WjcAiUxPH9f9h9rgqwG+3iira5tNtjiBSML7gZAXFot+eW8YNugMcJjrl3MgLyrB3qQhzx4SqbhK5ok5GHoMkHWIoBbyeseHH06kO0alCl9UjmXHe66sn/BBAsiUy5aZ8UHAnmrjbXWk+mF0hSLUZvX8U/10= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168124064996540.294236076892275; Tue, 11 Apr 2023 12:17:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519772.806761 (Exim 4.92) (envelope-from ) id 1pmJUL-0005Uc-Hg; Tue, 11 Apr 2023 19:17:09 +0000 Received: by outflank-mailman (output) from mailman id 519772.806761; Tue, 11 Apr 2023 19:17:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUL-0005Si-A6; Tue, 11 Apr 2023 19:17:09 +0000 Received: by outflank-mailman (input) for mailman id 519772; Tue, 11 Apr 2023 19:17:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUJ-0004Ta-L8 for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:07 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20613.outbound.protection.outlook.com [2a01:111:f400:7eab::613]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7205330f-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:06 +0200 (CEST) Received: from MW3PR05CA0006.namprd05.prod.outlook.com (2603:10b6:303:2b::11) by DM4PR12MB5357.namprd12.prod.outlook.com (2603:10b6:5:39b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:03 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::94) by MW3PR05CA0006.outlook.office365.com (2603:10b6:303:2b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:02 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:02 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:58 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:58 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:58 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7205330f-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WSIe8IWtkogZDuJROEuyEa4L5qtz0r0ub7oLaSfO1oYNN6uZkXy/AYkEa3PeoOYonr9wYRQt+vHxHp+g/sYWlxHPL5FypP2L333pRjkvdOHBFru51nKqqPmtHjUq8o8GrG5y8yDBLzH8tnluod1ewfCDKM4wcoGOPGGStdCZjVWAwUNmZr5A9t2PuUIYrZjRaoSZUWNZTqyMP+OYSaGEH1hCgOgsJ3vJs2EyLcRAlUvGXsMRB0pozooPmglFCVbN34KWvZrvQUmwLSVu0nZ1ELhtlGW0nNHvKq6OCci9womzrMTovnYOKR2qZWd8RrqKtlTmvon+x8XhFJpGe+Fl9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=Q6QuNO/MJsxQ0Mfgmqv9Fc2TTQvDV0zliZG80oSqKGwzzpfT9J7UZ2FuPaiYfXU/qiOYHT7fHQP1t/QBxkf012+VIOerMfB3Dt6nDxwpI6myg11MXW+FBGeex1p/gIZzfUq33QTMvrNskEHqisXKNHnCX7jcmrseAw5RwEvaEafIOJ2EThr5w/RXlVXFLxiGBqOtb8NJBRHVXwuxBkFFg/2byl1vVO1ABs4TYzz0/3GqkGZZEFmVOoH2X8bA4bhzAOBAwZicx47pyOkjCng0OPhHTyoKK5D2zLgqyQj2e2lwqaorRkw+Gg9QI3UT3rfGtJroT25tHoWNkBIhp7696Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=KDu9AlO4fQb4RnMxIBoAkLNp+pI1dLaayOR4hzEGfRdnkwnBMysAjR/rLTC3LnlSxfeTfOoBcgV7J2cmTTfYIMihNqqMdDt0ekAxFiY2Rvo00w9cwKWP85ONIYg9S2Q4lQM+yFt67X9yvcEUyhncpYclWgTkKAv6Gp/j6YjnUoc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 06/17] xen/device-tree: Add device_tree_find_node_by_path() to find nodes in device tree Date: Tue, 11 Apr 2023 12:16:07 -0700 Message-ID: <20230411191636.26926-7-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|DM4PR12MB5357:EE_ X-MS-Office365-Filtering-Correlation-Id: 92748e6e-4e36-4f2d-f5b0-08db3ac154cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: POXz1WG1hmvtmv5RRF+iVjz+L8Z++hE0T36YgoND+tvNfXU/Rd6SPUicT57Mcps7aDrp6/TmvJJRrlH6FadTG1hn4VFTdykLIM4JnRdvcd1mf/i1lRmcPBSrHMP+Im8G8qLaN7BXyrxnrrH/yOOwAzOpRDrG8IOa12/TZkyjJadsajlTtO4WDHpR8O+nVF+NkYSTWfDzv7AqcPsvh9r3KCDIzHfBFurWQ6Kz3waGiXRtZtGZ8BDRDJ+Ehde4oNdx/Jhh5iuIEPauPu6juAmCzj6Jw07AJ4Bo6qvTPRfHt7AM6yIxi7U6+vVNDzyVZGYtuxhRP/MyQKl5wdkGY3Y/U/dGmoxFNMyNVRvKaL69tpU+m9J7iGTxkbbs+O/EIboBocgQrs2YE6q3MMpNR0pAw3av7s45/S2QnBRJgvfcYOxuvoT31hUUewjypoQ2OI+Ce+RbA6xziFmiOaE0XOWv5buUBnwRohqZZkALRJRtuUKYsDDDKs539xqAA86hV2ihzXiQzSAkL7GWAaMm5RBxEH96prsa3Ha9XE4D67wF6GK6vkDkzuLGzurXbz4rw7Q2wMTZdaihTT04kxLSPbswtunugHmQQB/eKBcU1LZr2dwByFx+JEfIIXiRF3SOmnEwaDeqK6nwrGqe0tmJoYnQ+rsI+rCoLcosJVnzaOchF7EnmLYwRMMP9ENiQhoAfopd2dzm2C63Ud1EGkJKAnjkzZXwSKT5coSqN2lJ962XuiXWU7p/NRVEOg94z+CrKbPrKEUI1p+5Ot9Zk6tZkaCHLg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(4326008)(478600001)(6916009)(54906003)(8676002)(70206006)(41300700001)(70586007)(316002)(86362001)(36756003)(83380400001)(426003)(2616005)(336012)(26005)(1076003)(6666004)(2906002)(8936002)(44832011)(40480700001)(5660300002)(82310400005)(36860700001)(82740400003)(356005)(186003)(81166007)(47076005)(37363002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:02.7468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92748e6e-4e36-4f2d-f5b0-08db3ac154cc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5357 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240651799100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add device_tree_find_node_by_path() to find a matching node with path for a dt_device_node. Reason behind this function: Each time overlay nodes are added using .dtbo, a new fdt(memcpy of device_tree_flattened) is created and updated with overlay nodes. This updated fdt is further unflattened to a dt_host_new. Next, we need to f= ind the overlay nodes in dt_host_new, find the overlay node's parent in dt_= host and add the nodes as child under their parent in the dt_host. Thus we n= eed this function to search for node in different unflattened device trees. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 5 +++-- xen/include/xen/device_tree.h | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index bf847b2584..507b4ac5b6 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -358,11 +358,12 @@ struct dt_device_node *dt_find_node_by_type(struct dt= _device_node *from, return np; } =20 -struct dt_device_node *dt_find_node_by_path(const char *path) +struct dt_device_node *device_tree_find_node_by_path(struct dt_device_node= *dt, + const char *path) { struct dt_device_node *np; =20 - dt_for_each_device_node(dt_host, np) + dt_for_each_device_node(dt, np) if ( np->full_name && (dt_node_cmp(np->full_name, path) =3D=3D 0) ) break; =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 58ac12abe3..998f972ebc 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -534,13 +534,26 @@ struct dt_device_node *dt_find_node_by_type(struct dt= _device_node *from, struct dt_device_node *dt_find_node_by_alias(const char *alias); =20 /** - * dt_find_node_by_path - Find a node matching a full DT path + * device_tree_find_node_by_path - Generic function to find a node matchin= g the + * full DT path for any given unflatten device tree + * @dt_node: The device tree to search * @path: The full path to match * * Returns a node pointer. */ -struct dt_device_node *dt_find_node_by_path(const char *path); +struct dt_device_node *device_tree_find_node_by_path(struct dt_device_node= *dt, + const char *path); =20 +/** + * dt_find_node_by_path - Find a node matching a full DT path in dt_host + * @path: The full path to match + * + * Returns a node pointer. + */ +static inline struct dt_device_node *dt_find_node_by_path(const char *path) +{ + return device_tree_find_node_by_path(dt_host, path); +} =20 /** * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240806; cv=pass; d=zohomail.com; s=zohoarc; b=SIkCem77aveV/06Gl3WB/O00E8d0o6KKb01cgKhdXUBe0Kwajfg/QrN4YUay3yhcNjgQ8+LKtN4DCuJyO8n5tN3vXYNDABVdbA53vc4UERHUwKH87vObLjvk7JVwfMHIGwCe/PLGf5G4NGFS8YjL9Qtf7ALGWoFkSYszCFT9piQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240806; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=Zvl7iSdjZiUafU+j5yeJ/NhQgL0rlK1ePWCigCyO/oiERajmuerQzICitgBXWPfYvszRW4p0M0GjaxWsCt58qnujdxv4/3id+mb76nn+tiFsL6fVqF4U/rjzv1Y1q8oTZC6aR1hq0GNiEquCr/4H7qAWWBvyXvbI1jNneripLfY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16812408066951009.8408757977235; Tue, 11 Apr 2023 12:20:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519832.806930 (Exim 4.92) (envelope-from ) id 1pmJWv-0007o6-3O; Tue, 11 Apr 2023 19:19:49 +0000 Received: by outflank-mailman (output) from mailman id 519832.806930; Tue, 11 Apr 2023 19:19:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWv-0007nz-0F; Tue, 11 Apr 2023 19:19:49 +0000 Received: by outflank-mailman (input) for mailman id 519832; Tue, 11 Apr 2023 19:19:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUX-0004DR-UL for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:21 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20605.outbound.protection.outlook.com [2a01:111:f400:fe5b::605]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7a02f9d4-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:19 +0200 (CEST) Received: from MW4PR03CA0193.namprd03.prod.outlook.com (2603:10b6:303:b8::18) by BY5PR12MB4082.namprd12.prod.outlook.com (2603:10b6:a03:212::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Tue, 11 Apr 2023 19:17:16 +0000 Received: from CO1NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::50) by MW4PR03CA0193.outlook.office365.com (2603:10b6:303:b8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:16 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT096.mail.protection.outlook.com (10.13.175.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:16 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:15 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:15 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:14 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a02f9d4-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0exrgxOsL3/n+mSGDHDH6/A5pjNuEf1TPtfLeN1YNCdk/0fcuZKfeBQ+kAUCR1oHXMjAPvE4GWoEgdLcUa5IXQSPdX3maD/MO6bq+CXTHU5LaU0IqsbKChtU0AktrZN5df86NdF3mDTlVhNjIcY41LV/rIZwWJLWlSjQRhxQB0isasO/zfTdo4LRCsid8vbMYikhwEtk4/933RhXZmxSNbei+shE8xh3yKyNkG0jhYwCaTFBEFaptQ8zIjLdzCvxToy6C8bW4lxVLJV5YKiItoUp/mGckp+lYgoZKKJT8bDmgYke5UlqVKgdukX8f/G4+27OvNAJDhnOJ7u4Df+Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=lrxwKTPqIWTKUtX/8wpDACNNInoA3QgYgqgmcAw+exLo9MtAX5xaaT3gL7prU8bDv23L70gZ55n1nXx+zfkcxjOVA23gHjB3oceDq7HyhmCQgBkKPmA+d/3KKyK1HDmR0RkbE95MoYRQ4EX1rra2gYqQfSuAPzvbKCMRpy3K0TyVlckDUw5BJBbXjQi4LNY/776Fwk1Ht3PhRqhjP2vSys3UfL0iKFekLlyDzUSyClKrvMAa0zXHOuq523iRvuiWLOAByCmBUeaRCIxa8QuahtSZCEshumzaxrAbHWEVRXZbPq9++7ZKY7hYrABhEj4Zk2EjecLRsBHCsbn96lcVCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPRvr0PydrbevxDRuC5bBe8hAAj8BLWppbzz+G6AD20=; b=qH59dc/ukbVX2ZGRfg7805zmZ0sNdHiS/3/rE6u+NrZ0/AfFAQfuPd9pdmWOSQ45slWxwf4a6PXicvYGdbvsLrV0wkn3Tbmrblpj4tSOH/+MOzHoEx4K4IWLyxnY8IS4TQkrGX57VadXkvNt3dnpjGsjO533SpnFoTsgNemL2Pc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 06/17] xen/device-tree: Add device_tree_find_node_by_path() to find nodes in device tree Date: Tue, 11 Apr 2023 12:16:25 -0700 Message-ID: <20230411191636.26926-25-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT096:EE_|BY5PR12MB4082:EE_ X-MS-Office365-Filtering-Correlation-Id: b7acaf12-230c-4e31-5eb6-08db3ac15cc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1MfYvPhUa7cLMUQI3UZmTwYyclh+2tL8706Z/bu7eT1dEfy1NAyms7VzyXY5KTCL7NL8JlCu0W1DTsziZzFOz1LkKWWz+hJvfclNY8rCnVN1x7MAjO8H6RhcfhfSJY6EpQLqpjqRpgkRrDTVxp/rhMbvVOWCJc5OzNmCp3dEopgFV44w2pd6ZMUe6EtR5Nu2NU1I7vpxMOs7P1FtgwpQRfP77kZwvanCXLNaI97U71brqvYCDejv6Sn/TJYD+HL4c8A6viwc1bO1W1rNtiJuGrJ8f7wyFIJJISfrqnjUZWXE4OmWJp4fDDk7JD0LTLc5og9uQgXZur+RGQmy9khxVVSklL22dU3GFR8EnsVLVJIb6KU6WogwgkaWgvfQBd2FJLbMRnNgUmL9vzQTwmHUcVU3jmw0cDjqLb7OrMNKOX4zpNpB9gfNQJ4t50f7XMYW+A1imJwbKNMM/lyEOY0Pu8R/ona/GRwnTilEsXuD0PQ8gQxA+Lx3UeLlrPQlix1s5OrdiwcW/AlBCdiDOLDkMPq4jLQOImaGCyrN48Ggk5tpeDYClOPsb1pC2l3ncx/npuVCUnBDsFJL0cTjRJweqVf0zi0Stb2shucwvX2ux25bQrD7r/PTfv3EoIw6ymXFqoTlQGQDqOR+q2Q8G2KUdg0tN6qIbWgz/jeVjII7nW8sl8vgtzC+kGsH8Bv9fw9aE5DTuLubkCAIz7nbgwIyPDGdG1H6YMM0ekmJ29YvqaezDp3wJZke+4Zf1TCiwCxfKW3M2hmkU4kbJk2kIuzQiw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(36840700001)(40470700004)(46966006)(478600001)(1076003)(26005)(316002)(186003)(44832011)(54906003)(2906002)(5660300002)(4326008)(70586007)(70206006)(8676002)(6916009)(6666004)(82310400005)(41300700001)(8936002)(81166007)(356005)(82740400003)(47076005)(40480700001)(83380400001)(86362001)(40460700003)(36756003)(2616005)(426003)(36860700001)(336012)(37363002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:16.0901 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7acaf12-230c-4e31-5eb6-08db3ac15cc3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4082 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240807399100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add device_tree_find_node_by_path() to find a matching node with path for a dt_device_node. Reason behind this function: Each time overlay nodes are added using .dtbo, a new fdt(memcpy of device_tree_flattened) is created and updated with overlay nodes. This updated fdt is further unflattened to a dt_host_new. Next, we need to f= ind the overlay nodes in dt_host_new, find the overlay node's parent in dt_= host and add the nodes as child under their parent in the dt_host. Thus we n= eed this function to search for node in different unflattened device trees. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 5 +++-- xen/include/xen/device_tree.h | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index bf847b2584..507b4ac5b6 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -358,11 +358,12 @@ struct dt_device_node *dt_find_node_by_type(struct dt= _device_node *from, return np; } =20 -struct dt_device_node *dt_find_node_by_path(const char *path) +struct dt_device_node *device_tree_find_node_by_path(struct dt_device_node= *dt, + const char *path) { struct dt_device_node *np; =20 - dt_for_each_device_node(dt_host, np) + dt_for_each_device_node(dt, np) if ( np->full_name && (dt_node_cmp(np->full_name, path) =3D=3D 0) ) break; =20 diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 58ac12abe3..998f972ebc 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -534,13 +534,26 @@ struct dt_device_node *dt_find_node_by_type(struct dt= _device_node *from, struct dt_device_node *dt_find_node_by_alias(const char *alias); =20 /** - * dt_find_node_by_path - Find a node matching a full DT path + * device_tree_find_node_by_path - Generic function to find a node matchin= g the + * full DT path for any given unflatten device tree + * @dt_node: The device tree to search * @path: The full path to match * * Returns a node pointer. */ -struct dt_device_node *dt_find_node_by_path(const char *path); +struct dt_device_node *device_tree_find_node_by_path(struct dt_device_node= *dt, + const char *path); =20 +/** + * dt_find_node_by_path - Find a node matching a full DT path in dt_host + * @path: The full path to match + * + * Returns a node pointer. + */ +static inline struct dt_device_node *dt_find_node_by_path(const char *path) +{ + return device_tree_find_node_by_path(dt_host, path); +} =20 /** * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240652; cv=pass; d=zohomail.com; s=zohoarc; b=T8OMBs8XMSAXQdM/bOTLEduQ3nw8QDQxOO/Ki7o6NjP3zZXZ4UZC8KZ0/ePWslO9tAKFyNUVVY4nhJnQgrWGQ9y67LOZzi9TElDIJpSNyPzhh1fzeaWhQD/6SysCrRg1UnA0sEQm5A36KL20tHDDqX2DTlpfgkDYrXuOFjukbPY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240652; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=hWOOJ+clFV+SMZGuCb5dDMSl1enzANMpJOdeLwf6oLRL9cJEAH+LynHzlkT6q6LyEaRS332k2FjabdlpZfEoy4xWpLHB/1f86DSJMELlWZma18COaE6WH9FOju7LfPkMBDAEiioZ2wbvfUbMZeV+V9H+BRRFn2Jvz5S0BjmsN+4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240652415375.0910379472758; Tue, 11 Apr 2023 12:17:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519774.806777 (Exim 4.92) (envelope-from ) id 1pmJUN-0005rE-2i; Tue, 11 Apr 2023 19:17:11 +0000 Received: by outflank-mailman (output) from mailman id 519774.806777; Tue, 11 Apr 2023 19:17:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUM-0005nZ-Kb; Tue, 11 Apr 2023 19:17:10 +0000 Received: by outflank-mailman (input) for mailman id 519774; Tue, 11 Apr 2023 19:17:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUL-0004DR-4f for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:09 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20600.outbound.protection.outlook.com [2a01:111:f400:7e89::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 727aca3a-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:07 +0200 (CEST) Received: from MW3PR05CA0015.namprd05.prod.outlook.com (2603:10b6:303:2b::20) by SA3PR12MB7975.namprd12.prod.outlook.com (2603:10b6:806:320::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:17:03 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::98) by MW3PR05CA0015.outlook.office365.com (2603:10b6:303:2b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.27 via Frontend Transport; Tue, 11 Apr 2023 19:17:03 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:03 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:16:59 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:16:59 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:16:59 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 727aca3a-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDZel6WEBGb2aTYAnYAotrmzVbZ3s3kcfUhLpszVA23+8sB6m7eS38UT9bYqoRo6RP23ED4kQur/HOYEtasxuVNCH2OINnUCwHgjJBrrPz/EQEzneYHUaMhiwE6tSOH7ZTDIbyopUVlTXoj1irUeAIHzr0qJa79iKrprkvfH0bGG478A723b3fPn0GdS2JgFHW8dj8i9FwM19w51JAtejG+N24Sw9LsGNC5yJy9IV8OiftA4AyouNKMQhf9HDP23SNhsv7wJqyAC+07IxAtkNBrK0996Ut17FGuOYWMYtSLrVwrJbwiG7C3759csDuFlp7vdsfzDkoqFHwGNTVXo8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=dw5LUMyKeF5kkahMH7yGjNK1hZL2dfKx4esYNnvJI8FmdkkhcX8LaD/tLlW+JYtNFKxonu4qD8NlSbJO9k7b6LEo5QMSpEznWwTFYdC8p/kK9JkcBBv0FPlcWd7M6PN6EdR1nuGk6dCABARmo33RFDXAM4OYiTXk16JNTyg6My8aoS8Im3Yae7e+z3VwdLecvoxpgiMWhUtLotEM8m3Nz7NxyCcrc031cS8qmdxC2SNOr6fGWaEv/VleGwn6A8tOwATNZKIvLo++UhVR8W5Az4qEAa+jS8kt6vu1yl8bi0nblYOPf1hMg3ZR2UXNdVip2ZhsluYEnJZb05efiLzOoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=37Bcs5BNxuIQA4OVW40raq+uSYlN3KhcoUpYSnVGbWlCEJDzDZYDouCqG/QsSbIcef6GSJ6TPWTkiNkRQPAYIrAAWmRrEtsOY9jdJolx4wj10djxsKpGqzim6xKu8aUSgLSfZDP8Av4z2wQDegFm51ZAjcZrZE1XNNQewGfi+1k= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Rahul Singh , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 07/17] xen/smmu: Add remove_device callback for smmu_iommu ops Date: Tue, 11 Apr 2023 12:16:08 -0700 Message-ID: <20230411191636.26926-8-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|SA3PR12MB7975:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f9a7f2f-a193-4b53-18b5-08db3ac15512 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DR+ixQxTfr4F1T81YK50UlMuZ859lngTVfX60KdhxnLbhinqY03bYxNAzFU/gcCZ5s6LA5Js9UQZcEl8RamVvLuIvh1Fuy6KKfhr4tsA2xxQrmnR08hnkxfJeGCQaSmDAXvL3eHxqgo1TiQqGaAV1Sf5feOZjPeIM9s0AHubsl1BRLMcTCi538v0w3WLCKKKH21Y9zPDunYZVpx/bkVQpu1bGxi01n8wb+H0DH84qci3sRFtGa7o/ertOi3A2igLGal3mDlIQGedktPkaa1iNb5KYb1iJYEH2FS7UkPknbiL2NV7vp6RMK4PA4czQjI3EgMKg+wM/nW42TYgAs7vbPx+ksJRTeFi2pxLPB7G74Y2ww+IfL8ViFTev06tC9+FGtaP8B+U/BujH+Lm8s6qUEJw6BFL/g6C3onBWcrDDLoObosYP1b7FqPX4DAxQA8jvl6pr94dAw3HavaHiH0nyxwAqpzt+mTUcyd7WUiu/roG43XjG0fPZilSbqr0EWEHdSvhx6L0+Sb+XDj1m6/5KzFkhYF5L/+q1dWSihWClC+4bTJaWvm1S48337U87hTkHZAn5ub1bE7WfIwFS+upjkIZkXWVPEryBw3ftrJKGuP93tx0y7xIebcj1aAyv87qSH5xcEcnMhr/r8Bz9ZTst5YYo21V6teKVAT1TEXOyPgmSE8SV3p1G79jpyQ+GLNHHubHTSA48X6q1d6MJ96hXiLDCfQWy3iPMYV9fhgAoLA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(70586007)(70206006)(4326008)(478600001)(6916009)(8676002)(41300700001)(316002)(36756003)(54906003)(86362001)(47076005)(426003)(336012)(2616005)(26005)(1076003)(6666004)(8936002)(44832011)(5660300002)(40480700001)(82310400005)(81166007)(2906002)(82740400003)(186003)(36860700001)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:03.1999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f9a7f2f-a193-4b53-18b5-08db3ac15512 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7975 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240654543100017 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add remove_device callback for removing the device entry from smmu-master u= sing following steps: 1. Find if SMMU master exists for the device node. 2. Remove the SMMU master Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu Reviewed-by: Michal Orzel --- xen/drivers/passthrough/arm/smmu.c | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index 0a514821b3..14e15f1bc6 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -816,6 +816,19 @@ static int insert_smmu_master(struct arm_smmu_device *= smmu, return 0; } =20 +static int remove_smmu_master(struct arm_smmu_device *smmu, + struct arm_smmu_master *master) +{ + if (!smmu->masters.rb_node) { + ASSERT_UNREACHABLE(); + return -ENOENT; + } + + rb_erase(&master->node, &smmu->masters); + + return 0; +} + static int arm_smmu_dt_add_device_legacy(struct arm_smmu_device *smmu, struct device *dev, struct iommu_fwspec *fwspec) @@ -853,6 +866,32 @@ static int arm_smmu_dt_add_device_legacy(struct arm_sm= mu_device *smmu, return insert_smmu_master(smmu, master); } =20 +static int arm_smmu_dt_remove_device_legacy(struct arm_smmu_device *smmu, + struct device *dev) +{ + struct arm_smmu_master *master; + struct device_node *dev_node =3D dev_get_dev_node(dev); + int ret; + + master =3D find_smmu_master(smmu, dev_node); + if (master =3D=3D NULL) { + dev_err(dev, + "No registrations found for master device %s\n", + dev_node->name); + return -EINVAL; + } + + ret =3D remove_smmu_master(smmu, master); + + if (ret) + return ret; + + dev_node->is_protected =3D false; + + kfree(master); + return 0; +} + static int register_smmu_master(struct arm_smmu_device *smmu, struct device *dev, struct of_phandle_args *masterspec) @@ -876,6 +915,22 @@ static int register_smmu_master(struct arm_smmu_device= *smmu, fwspec); } =20 +static int arm_smmu_dt_remove_device_generic(u8 devfn, struct device *dev) +{ + struct arm_smmu_device *smmu; + struct iommu_fwspec *fwspec; + + fwspec =3D dev_iommu_fwspec_get(dev); + if (fwspec =3D=3D NULL) + return -ENXIO; + + smmu =3D find_smmu(fwspec->iommu_dev); + if (smmu =3D=3D NULL) + return -ENXIO; + + return arm_smmu_dt_remove_device_legacy(smmu, dev); +} + static int arm_smmu_dt_add_device_generic(u8 devfn, struct device *dev) { struct arm_smmu_device *smmu; @@ -2858,6 +2913,7 @@ static const struct iommu_ops arm_smmu_iommu_ops =3D { .init =3D arm_smmu_iommu_domain_init, .hwdom_init =3D arch_iommu_hwdom_init, .add_device =3D arm_smmu_dt_add_device_generic, + .remove_device =3D arm_smmu_dt_remove_device_generic, .teardown =3D arm_smmu_iommu_domain_teardown, .iotlb_flush =3D arm_smmu_iotlb_flush, .assign_device =3D arm_smmu_assign_dev, --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240818; cv=pass; d=zohomail.com; s=zohoarc; b=hNi6SGjyzWuK5PWi73Rh76XvoyDG+1zaxY9E5n4wBEUFj5N+M0XVjdHy3PxzIBZBKsAiVBOstlEzeuXlk+NxDUqy0QyRoZZhRP9W0kiSfcBjKmJF3hH08hXKGo2ljQS8mONaYltD+YAjoByF9JSLn6t+M6VqlWfoUcffa+smkPE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240818; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=jy1QYWe6CgRQRwh91XFo/ggtgde2uTRTRIUM7h2Dz+gnceeEAof4rovYES+cmvy4CmjMHMpmPeID0EqWK4IKFtVW4j030aJTPiGXg2wm8w4EJmzibiRtCUDkZQXbC36ZmaIHF0HX/qH4DWdlS8sGEBTJqWCy5dHD/cODjJGl6BQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240818162617.2569881198665; Tue, 11 Apr 2023 12:20:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519874.807016 (Exim 4.92) (envelope-from ) id 1pmJX8-0001zM-Ch; Tue, 11 Apr 2023 19:20:02 +0000 Received: by outflank-mailman (output) from mailman id 519874.807016; Tue, 11 Apr 2023 19:20:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJX8-0001y6-0c; Tue, 11 Apr 2023 19:20:02 +0000 Received: by outflank-mailman (input) for mailman id 519874; Tue, 11 Apr 2023 19:20:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUY-0004Ta-1E for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:22 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20613.outbound.protection.outlook.com [2a01:111:f400:7e89::613]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7a4ad9dd-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:20 +0200 (CEST) Received: from BN8PR04CA0029.namprd04.prod.outlook.com (2603:10b6:408:70::42) by PH0PR12MB8029.namprd12.prod.outlook.com (2603:10b6:510:26c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:17 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::9a) by BN8PR04CA0029.outlook.office365.com (2603:10b6:408:70::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:16 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:16 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:15 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:15 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a4ad9dd-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BzNQr2SLdVAdJZYxI0PgizBtvdz3yZFN10NELXNrTWTkU1yT4d7zyT2qsaTk80El/bDeQAg3eLkaD6zK0YlyCxErvuB/hbDhLaivuG8jpOszKOszktekyI3kO8ueiyKjr7s5QNyI2rzQzJ+sXp6OSRorFiWNigWWaprbhjv3b/+vafq6IZpGAMksC4MW+YAg9Fmg7pJujgMRO7dKME+DIDnkp+Bnh95+Xlx/BShiu0fJ+tZBeSBo6n3ILgNw9CSpRaEAPUvaAtlMjZmoc8vFZ6MU0sGKeeJsfHT5Ho+zmWY6stgP0Bn6XxUhiF7gsBD+qrQwW71ya+Icczl+7tRoQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=nkBUXiMU6lIQQwpdxAbfbWFCZ6TYiWvoM8erBKwAbx7S7ytEd1CkM3YMbbLQHGkM+/D2+jQEt1iaI/Wh9ulQRjrDj+9WNz7nUgYw1JRrnBfgMBsUKx2YcgxX+jxfzRkFsiKuvv1A/BcAg0emVYelnD2g0leMjx+sVgecT7fJwv+tuNkr36z3t5wE3KYcIHOPIcWigW2ZZ+yU1/0AmdWv6xPczWDvFG21vHld3xEciPzBvKFR7bYDvB17YUmic+s2doVAodUrVQwedABB5GeLL/o6UdHMU+vZ3d+8VdnZ4138SitgcnGQcrvrhyaUTBIoamUCqGLJ5iO6VWITMa/kEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SvjprfsFjT2q+G0BBsMISOBPht18qx5Ov6rcUISgUjE=; b=Ly+lUQ0+M/IUp+B4OQS8qNOM8TYaB5uasdcrjoYspgz20WyS/UPD0htASwL6rO45lrVjKtv8zb6YxuNzTMM1uTmjU0flvEfsxmBavxHdB/ufDqqEZWLLSAFmnaLL+IjjgPzHVDv/wtlfuCX/w5b2upQNQONkaX8hn9CWp9zKrug= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Rahul Singh , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 07/17] xen/smmu: Add remove_device callback for smmu_iommu ops Date: Tue, 11 Apr 2023 12:16:26 -0700 Message-ID: <20230411191636.26926-26-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|PH0PR12MB8029:EE_ X-MS-Office365-Filtering-Correlation-Id: 50790be0-6352-4be7-7b8f-08db3ac15cdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mAFf3vbwh8xgKfEkCpsPWufkJqzgszk8dRjmBqwJbNWlxJ+4MaLJCrh3ccDNlcLfayxl9wcH/xmIKVAon8eO33lB0xgU9U/mor0WczGDwNKR83kQdcfRIWBJoTm5tvf676K0Yg5hTKLKUUHJo69ZZ60lOLw2LeRT1zUJC/d3aXabjaQ47+PkrR5xRMsAY9mxb4XXREnJS2IKVeE0zjlkyJOSrktcywagpler50PR5tZCgeGKw+16N/Nf9ynCTBAUzF0/7UOm+Ey8dTNW0WDjnsrkoj+h44NAWDnlQ/6Giwl4Y+7PwmCvUUR9Z0ZlMsEfcy+5aoGNqM3WESMk+CSupsa1o2EPANS9moVe/epI1meG7z4vn3CcSAdraj1xoP2gaXUcMGV1avcP46Wsj9MBpxB+6QuUIw16OGnTafMmWuyVeigwyN0+plpQAiOBvz5I7QNEJuQyymxLF7yjcmpG9mbkf6mb9WxpW16MF5cu/0GP04gsRdDyXHaK9gkGhQ71n+sVvZT9utYjYXMUoIZB+3S3BdHO/WE0p9hEtyUDthLPRqx+skjdOhOVdgMus8lxMtzsPFH/mlauhsMLCyXE5t0Xet9Kz8iQDLKEUlVzHK3LnZePD5pWg5QRmmoDnbwMkiIuylXMQdCnYMRUTPJ6lI69oxCT6V2edfu5EHECe2G7J58mNFTUsGGZjjRdvMaLqkljziga/kiAm/tydIdQBCPQSpD6whYnqMsIZgNgYFM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(2906002)(5660300002)(8936002)(41300700001)(47076005)(40460700003)(4326008)(8676002)(6916009)(70586007)(70206006)(6666004)(316002)(36756003)(44832011)(478600001)(54906003)(186003)(81166007)(86362001)(36860700001)(356005)(26005)(336012)(426003)(2616005)(1076003)(82740400003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:16.3575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50790be0-6352-4be7-7b8f-08db3ac15cdb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8029 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240818512100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add remove_device callback for removing the device entry from smmu-master u= sing following steps: 1. Find if SMMU master exists for the device node. 2. Remove the SMMU master Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu --- xen/drivers/passthrough/arm/smmu.c | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index 0a514821b3..14e15f1bc6 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -816,6 +816,19 @@ static int insert_smmu_master(struct arm_smmu_device *= smmu, return 0; } =20 +static int remove_smmu_master(struct arm_smmu_device *smmu, + struct arm_smmu_master *master) +{ + if (!smmu->masters.rb_node) { + ASSERT_UNREACHABLE(); + return -ENOENT; + } + + rb_erase(&master->node, &smmu->masters); + + return 0; +} + static int arm_smmu_dt_add_device_legacy(struct arm_smmu_device *smmu, struct device *dev, struct iommu_fwspec *fwspec) @@ -853,6 +866,32 @@ static int arm_smmu_dt_add_device_legacy(struct arm_sm= mu_device *smmu, return insert_smmu_master(smmu, master); } =20 +static int arm_smmu_dt_remove_device_legacy(struct arm_smmu_device *smmu, + struct device *dev) +{ + struct arm_smmu_master *master; + struct device_node *dev_node =3D dev_get_dev_node(dev); + int ret; + + master =3D find_smmu_master(smmu, dev_node); + if (master =3D=3D NULL) { + dev_err(dev, + "No registrations found for master device %s\n", + dev_node->name); + return -EINVAL; + } + + ret =3D remove_smmu_master(smmu, master); + + if (ret) + return ret; + + dev_node->is_protected =3D false; + + kfree(master); + return 0; +} + static int register_smmu_master(struct arm_smmu_device *smmu, struct device *dev, struct of_phandle_args *masterspec) @@ -876,6 +915,22 @@ static int register_smmu_master(struct arm_smmu_device= *smmu, fwspec); } =20 +static int arm_smmu_dt_remove_device_generic(u8 devfn, struct device *dev) +{ + struct arm_smmu_device *smmu; + struct iommu_fwspec *fwspec; + + fwspec =3D dev_iommu_fwspec_get(dev); + if (fwspec =3D=3D NULL) + return -ENXIO; + + smmu =3D find_smmu(fwspec->iommu_dev); + if (smmu =3D=3D NULL) + return -ENXIO; + + return arm_smmu_dt_remove_device_legacy(smmu, dev); +} + static int arm_smmu_dt_add_device_generic(u8 devfn, struct device *dev) { struct arm_smmu_device *smmu; @@ -2858,6 +2913,7 @@ static const struct iommu_ops arm_smmu_iommu_ops =3D { .init =3D arm_smmu_iommu_domain_init, .hwdom_init =3D arch_iommu_hwdom_init, .add_device =3D arm_smmu_dt_add_device_generic, + .remove_device =3D arm_smmu_dt_remove_device_generic, .teardown =3D arm_smmu_iommu_domain_teardown, .iotlb_flush =3D arm_smmu_iotlb_flush, .assign_device =3D arm_smmu_assign_dev, --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240655; cv=pass; d=zohomail.com; s=zohoarc; b=Qa6SgmHVtZ3zrxXmHYDn3/JWF3IiuzksH1jeaNM9H0kAIC6F3O/QSVgZkdezQtPH1CWgjMAcgWHsv4Qi2CAPko8h0WgcCC2e3AS7FjJGji6k5yltt6VhW6wZc4Sb+kyh6zwWFpPP8ECDBFv3IWwoLsmlZy74GuBOIR9Rrhp7qx8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240655; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=K6I2tqY1S4ombKf+zvw5d88my9uQ4RVKPPPEuODrvNsmjdzpbIdwddEL66Hhz0NH8lp7KcS0dkcBGV+D1u1EM9HAykbyLjS8DWzfgpi9rGqpjEmb/6Vbr3B7X1XEvkPMRuEUfzeSf2hWP7JxNzYJOOt/URGB3Zr4nBF8jMo3aK8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240655264557.1003368467403; Tue, 11 Apr 2023 12:17:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519777.806801 (Exim 4.92) (envelope-from ) id 1pmJUP-0006Pl-CE; Tue, 11 Apr 2023 19:17:13 +0000 Received: by outflank-mailman (output) from mailman id 519777.806801; Tue, 11 Apr 2023 19:17:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUO-0006LA-OY; Tue, 11 Apr 2023 19:17:12 +0000 Received: by outflank-mailman (input) for mailman id 519777; Tue, 11 Apr 2023 19:17:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUM-0004DR-4r for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:10 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20600.outbound.protection.outlook.com [2a01:111:f400:fe59::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7309f7e2-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:08 +0200 (CEST) Received: from BN9PR03CA0125.namprd03.prod.outlook.com (2603:10b6:408:fe::10) by BN9PR12MB5084.namprd12.prod.outlook.com (2603:10b6:408:135::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:05 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::84) by BN9PR03CA0125.outlook.office365.com (2603:10b6:408:fe::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:05 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:04 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:00 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:00 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:00 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7309f7e2-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5hwxHDiJ6cPXtGVi0oDhgGm3os2tvfuJk/rvPeOs5IMC2wLTyxhSHPzGdvuuRI/bYz0Ev6Rre1K2rIqyc6Ri59vS16WiVSCQ1l2QfFetjgsYV5Yff3j66E4dGWelns5JVGmuHmyH1IJ/kbG8OD8pCblaMZ0E+AZIamdZgxFL6/rMSeIGdzBgffGT18CcjFfcjPhq0SrSrarKjXWWlLoGAmgksCM4eUYqtYTTyJn79+PXiCL8X26kfGxK59CnhJuMs3jKTv4FM3xgKbn0JR2wtFqYfeAhFWUzF9AQNhkj4t7gwiq4fg9M5y2vc9uwGkqFYIy5rGppra40oH/rnLn+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=QNK9jA3ONnSE1MrYZppf2BKDWAJikpDz/GOU3l1M5GQWpOa3zeWUIQHywMUMYHK0RC5LhxeEzDXtfOIAQM0QmgHUemK4J03w6+oy55pd+1fcryOg5UQwJPlFbpsShvUrxOvN3WuucMqSP7vpnPTswMhoDr+e5riI0lrri1kXnMMExr7tbXY2OIjsGQRMoYLXtR0TaNRsThkS/pCIwVm+3tEDFUWCdgtZB+TMJ0Br/XCmGe3kqYmcHtx8/disPE18Rg/weHlFOUxiy8yaxbv3rxBSTJ1V5a/C6+kS0j+q55PYoyljRW2We6QxUC4N36NIpQdhyaeMVVjcoS/mlftlmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=auVQJ0UMG/mylausafR6rHAq+f0clyeouWECzrLAe+0FRFpwvUeGm/ek4sst6QIP7jQR4I5kTJUXKwX0yStFdEbrBAO1c2cp3KYtzvbqVOIAn8vSEU5dQerSPjGyH1T2jf7RtpXR85IyJQbGr+k7taprljIZT/DgVkW0Mua+GrE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 08/17] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Date: Tue, 11 Apr 2023 12:16:09 -0700 Message-ID: <20230411191636.26926-9-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|BN9PR12MB5084:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bc72af7-9755-4072-ca37-08db3ac155e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aesU9CuNguun7Fu2Zu/Im/OValFm4zDIlA3vKluqIupLhBGOIhKJzL3kOBw9pc+M1uTqxvlV8M2MTLGidHSoQ9QYcZBNx5MMH4dzfVw9fHu7qhFgBOaDdU8yRkB/fpClf7vqVCXPJ1Qxo4cxojToznqjQ/baIHSEtTZfQSWDudyCvjxHCPZFDwqNLaq+Ah60vqJm/EhkmqwcHG9R1XA9y0IpflLQMperCGb1aIxadYWQRdN5a4EH0mC1C8e+dYSNpSaKavZkUiA+V2EX9NmlJ12gA+grRZfQMeksLwPkOQ5FNG+v0wlI22li2TB2cRwLDpz1No5Ao1bKRC7zkV3QaTsndXFhkrek7dVSAIrr8hAAWVzEq9n0xupoLdEtcP9yRez/dnhChpBsKdBbThmlvePtmhEY94uxyHALWIqEehztR9Yg/vkejNFzOw6ZYDzEL+XYrOIS4550vkADN18wNBsXdqTyNbygFJLwD0Iv21Ur58i01+RybNF6VvAKeqE7L9W5hZ/WPTdbA40j54Ab4SO/tSnJEw7LtXld4XERgzT4obmEtWSRllwB7nDL1sHWdinxTBN9pzhsBq6l7qW5ow7vY+9M2nJo5yHXIC3C0zVcOX/O2eqxZCsYvMIV81j7AW3n92+55NFguWetyfdNr2sKQDUo1FM+r7ncCtaDSeoKVob3SxQQosMjKUzuebtDao5PsQKzn0dHOwcXMmUi5flVdoIVD7EJQkivGjwgH4g= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(36756003)(86362001)(478600001)(41300700001)(316002)(4326008)(6916009)(70586007)(70206006)(8676002)(54906003)(8936002)(40480700001)(82310400005)(44832011)(5660300002)(2906002)(36860700001)(356005)(186003)(82740400003)(81166007)(1076003)(26005)(2616005)(426003)(47076005)(336012)(83380400001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:04.7072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bc72af7-9755-4072-ca37-08db3ac155e9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5084 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240656684100023 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename iommu_dt_device_is_assigned() to iommu_dt_device_is_assigned_lock(). Moving spin_lock to caller was done to prevent the concurrent access to iommu_dt_device_is_assigned while doing add/remove/assign/deassign. Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu --- xen/drivers/passthrough/device_tree.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 1c32d7b50c..bb4cf7784d 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -83,16 +83,15 @@ fail: return rc; } =20 -static bool_t iommu_dt_device_is_assigned(const struct dt_device_node *dev) +static bool_t + iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev) { bool_t assigned =3D 0; =20 if ( !dt_device_is_protected(dev) ) return 0; =20 - spin_lock(&dtdevs_lock); assigned =3D !list_empty(&dev->domain_list); - spin_unlock(&dtdevs_lock); =20 return assigned; } @@ -213,27 +212,43 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, if ( (d && d->is_dying) || domctl->u.assign_device.flags ) break; =20 + spin_lock(&dtdevs_lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) + { + spin_unlock(&dtdevs_lock); + break; + } =20 ret =3D xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); if ( ret ) + { + spin_unlock(&dtdevs_lock); + break; + } =20 if ( domctl->cmd =3D=3D XEN_DOMCTL_test_assign_device ) { - if ( iommu_dt_device_is_assigned(dev) ) + + if ( iommu_dt_device_is_assigned_locked(dev) ) { printk(XENLOG_G_ERR "%s already assigned.\n", dt_node_full_name(dev)); ret =3D -EINVAL; } + + spin_unlock(&dtdevs_lock); + break; } =20 + spin_unlock(&dtdevs_lock); + if ( d =3D=3D dom_io ) return -EINVAL; =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240814; cv=pass; d=zohomail.com; s=zohoarc; b=NCd05T44viKMkD8xMLqvNVrgFEUAmHCMqTD6PzpmChqitt10xo+gzvmMFO/Y1Z3+f7iHDkUoSolUNsoWtxUbNr1kVumUZW0q6hT3PzgnvNk7cuhe2PSvrgIOKHtDEUC0O2Aa8qoxqEt8enuM56ILin7KOZ3L4GpeGoQIleYO7gU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240814; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=mabwNbPg6qITHiavmhMZs8NScLnLEnvxG8DFN2rMshdPFvFOHoVby1WbgHQXDnyJ6SDCnY/o0LW/eSwWmew1FRhmadKLOdZtYQmoekOBsoIZrbAHUGeQELMch13PMzQVnRJwnS/erFPXiIPMuSkSk6VAwW8CUtQHRrEkR93+vow= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168124081424397.40539548608149; Tue, 11 Apr 2023 12:20:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519853.806975 (Exim 4.92) (envelope-from ) id 1pmJX2-0000fQ-6Z; Tue, 11 Apr 2023 19:19:56 +0000 Received: by outflank-mailman (output) from mailman id 519853.806975; Tue, 11 Apr 2023 19:19:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJX1-0000da-S4; Tue, 11 Apr 2023 19:19:55 +0000 Received: by outflank-mailman (input) for mailman id 519853; Tue, 11 Apr 2023 19:19:54 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUa-0004Ta-1x for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:24 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7b2923f8-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:21 +0200 (CEST) Received: from BN8PR04CA0036.namprd04.prod.outlook.com (2603:10b6:408:70::49) by BY5PR12MB4259.namprd12.prod.outlook.com (2603:10b6:a03:202::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Tue, 11 Apr 2023 19:17:17 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::e1) by BN8PR04CA0036.outlook.office365.com (2603:10b6:408:70::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:17 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:17 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:16 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:16 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:16 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7b2923f8-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NrtgAUF9Ql0p+k/3sbtJEEchhDJAFMiITvM5wvWAKrtZSJIjO/6bQ2SPX+rz/sappAVESgdPQ90GX61i3lkvKAUVAagdoKWZ+qGhdSqDj+1W3M78hBsQRPDvQEuP0zOaiwjBa1WdLKRdDgiPhCNC7bL+7NzgG+8yC5lDDbPWYrska49kaV8IRd4vCiddB8YjwsNqIijO3tP21NPdOOWtFamZ7xcHO7lRokyVp79nclMttnFjF63ePo6t8QqOSnwmt1qqCp32NS001hcwr0hcwauDEZiLw26N0xIwN4FZd5VzUnZmjO5JK/NdRSiQBB0c0PYZbIfpLKjaVzyjr7nXhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=Y7u0NYxfZCHpmoCI6mcjMl+Z5AL5PPIYLf23plUFQFvxZIu8fvLzCeXV5nbGm35DbTKpGszQ380njpPIqH+SPu84vjpMPGsP7LCTf7YNv0nTs24ijswVw0zcB7DChv87DDhAVxByw1yAvt3xPi4/5bDP73uupyKAAj6V64XzqgDyJcnz+ZgJ2beVWBHqqHR69h6DqGA1+qRJZFk1u+AgQcy5s+Pa8KYdNOo3YrjOwskLAWPNMijG7j7YiIyj5wYE0BnbwynIwd0cBCzdLKd1Y+05b3Sxw1yj4tjsaztqB8JjZSBgYRDBej2dcQO+XyLqqC3pEHhQM7oQAXYWVeFebw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hbn+9h9tF7QZlww7kr6YoDzwWCRUPyZKofdb3QDs5Ls=; b=aXEeV2TDU5sVp4LNobPoDDRxdR0iWKUUyeDVrTIdLuz4fjJq/9AdC2FfmUKyk39Fvlf/pAaRkKeyUMtPzf90H3Z5+XN2xLCDyPoyuDGBQu8nyn3di2VJMCtHSSj6p5D+5sUEqjovHkYzqqu9cnKeNlQCvHRDKnORE8FF8B25tD4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 08/17] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Date: Tue, 11 Apr 2023 12:16:27 -0700 Message-ID: <20230411191636.26926-27-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|BY5PR12MB4259:EE_ X-MS-Office365-Filtering-Correlation-Id: 637928ec-8ec6-4807-adc7-08db3ac15d71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CajsAvd3Asi4MY6PTH9AjYDhGuRLyIwHjUjHGwBlOXg/mHrNQQ8RiN84aM42F9kCb8Cj4tDnawyfBdVqDnZ8RqIzMiOzOKHgvctzORSeTk02QwNr0WWCWp7/nipg+IxDjTM1PVxZgOek64p3GZ0ECZa8pxSl9dSzVyRsSenGOdKrYT4DC6h1nn4k6w6rrCZTkIaSdCbsnsa0asPmvRthqP53z3EhoNruocdb7RmDD0YKlDsCRs5PVM4wPG5M5Nut1WPFnjRKr6fhVbgKYMf0toL+bjgEG7nwQm24XGmapqg+w5fIaxNCNMj+kLSfSdtG+q/oV/FHmgD9h+v7orTiVklY6RNqzL7fBSMLZtdDStxtCgky06t2z3eGSkpWLSOyUMUryUkp4c1FyvhioYctp/DV9JSIAz/DhyHtQG933bmMtu9ltETVRF1TLmEzgawRqhVELxPcHcPwxGrHYQaRrEBynCvQk2Bx/Ak8dNiZEtMD71+2iudOjcviAcCCHLOqJu9sq1wvjj4JiYka0yl/3mS/39QJvuXBIJ0ivA6qLCGID6FXgVHONDH3fATNdTiUJ7ToRHGvX6qoWnp88Gxk7fREU2zwfTgn6vxhBnCkLjc6rIPWTGoiS4OEL0gKlqfZ5pO5PcqNV6ghDbqgdt9EnYT6lh4WDOlhMIL7GcOeCSM+p21BYtPi9saJs4TL50putv3/Xj+ZBrT6cvhG2ZejYl4ByzFU7356fVcMZZO6Fg4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(46966006)(40470700004)(36840700001)(478600001)(83380400001)(86362001)(40460700003)(40480700001)(36756003)(82740400003)(81166007)(356005)(47076005)(36860700001)(336012)(2616005)(426003)(2906002)(1076003)(26005)(316002)(54906003)(186003)(44832011)(5660300002)(82310400005)(8676002)(6666004)(6916009)(8936002)(41300700001)(4326008)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:17.3574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 637928ec-8ec6-4807-adc7-08db3ac15d71 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4259 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240815534100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename iommu_dt_device_is_assigned() to iommu_dt_device_is_assigned_lock(). Moving spin_lock to caller was done to prevent the concurrent access to iommu_dt_device_is_assigned while doing add/remove/assign/deassign. Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu --- xen/drivers/passthrough/device_tree.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 1c32d7b50c..bb4cf7784d 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -83,16 +83,15 @@ fail: return rc; } =20 -static bool_t iommu_dt_device_is_assigned(const struct dt_device_node *dev) +static bool_t + iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev) { bool_t assigned =3D 0; =20 if ( !dt_device_is_protected(dev) ) return 0; =20 - spin_lock(&dtdevs_lock); assigned =3D !list_empty(&dev->domain_list); - spin_unlock(&dtdevs_lock); =20 return assigned; } @@ -213,27 +212,43 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, if ( (d && d->is_dying) || domctl->u.assign_device.flags ) break; =20 + spin_lock(&dtdevs_lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) + { + spin_unlock(&dtdevs_lock); + break; + } =20 ret =3D xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); if ( ret ) + { + spin_unlock(&dtdevs_lock); + break; + } =20 if ( domctl->cmd =3D=3D XEN_DOMCTL_test_assign_device ) { - if ( iommu_dt_device_is_assigned(dev) ) + + if ( iommu_dt_device_is_assigned_locked(dev) ) { printk(XENLOG_G_ERR "%s already assigned.\n", dt_node_full_name(dev)); ret =3D -EINVAL; } + + spin_unlock(&dtdevs_lock); + break; } =20 + spin_unlock(&dtdevs_lock); + if ( d =3D=3D dom_io ) return -EINVAL; =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240650; cv=pass; d=zohomail.com; s=zohoarc; b=MnzC4gSz2WyHEsPfUUtl1dnmekx58XLcXNBScjJmchh/yJlOF+GW72hEJzY2fNXFvNC7MUqP/kSVA3wVxBEjgrelsLQhJnB41Z7ahJlzQZo42daetXFk5+cs0MHqLo0hN/jW89lk+XcmfaOpjlqxHJaT++isVOdVT9N3ZzuE7iI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240650; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=hB8txOECnz9Ccmg3Qd2Miv2ol1jQhROo5dNLqBu0uRYuLHb4IN9HjZ55VsY/Swi51t71pMLXzHF3wbspt1qlk0MLVwCU+vWfZL8lopTSSfBxgophTJxakEr/VUus7k/CNzxsiivowO9QFkkmZSKUD4phq+6ZvOcyGmP6OX9/feI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240650700948.3965851927313; Tue, 11 Apr 2023 12:17:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519775.806786 (Exim 4.92) (envelope-from ) id 1pmJUN-0005z6-O5; Tue, 11 Apr 2023 19:17:11 +0000 Received: by outflank-mailman (output) from mailman id 519775.806786; Tue, 11 Apr 2023 19:17:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUN-0005x3-4z; Tue, 11 Apr 2023 19:17:11 +0000 Received: by outflank-mailman (input) for mailman id 519775; Tue, 11 Apr 2023 19:17:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUL-0004DR-DB for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:09 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20606.outbound.protection.outlook.com [2a01:111:f400:7e8d::606]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72be6fba-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:07 +0200 (CEST) Received: from MW3PR05CA0009.namprd05.prod.outlook.com (2603:10b6:303:2b::14) by DS7PR12MB6360.namprd12.prod.outlook.com (2603:10b6:8:93::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:04 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::93) by MW3PR05CA0009.outlook.office365.com (2603:10b6:303:2b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.27 via Frontend Transport; Tue, 11 Apr 2023 19:17:04 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:04 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:01 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:00 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 72be6fba-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lDNOOUoUQrDMzJfKXlJfbBxfcLNE2ExFDTv865MP0/28SIEbvp9JnZjJDr5LiG2XgsPaddpgjmGypo4MdsgnlyvwAvcH5/tAVyON4tcV29yB5Ax5/rzMW6ngkXaB1UBKGYvq2j+aZVZmhrNwjVcuwB0KKYXqfz/ptE6F65s+mJEjq8G2VLHNZg4X4aI+pQhT+GVYB2esbpZP5Le+4vQaIRdvSESALv92/hOY2ohpeVzIb8GKRKbpFZlCAH/NKZEy8kHh6QD5+Iy7xS7PSL5SGScUzX7Q3pYlRuIDFqeQ8QY0Umpam1vCOps3ut4ieAid0xpteHShUAq767fEik0JzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=BLJ69mgmDOC4R6oelAOdYmiz7bsaXr3tCsp/n9jVQSfNwQkvbwB8mNzPAXedghQGVKl73r9eHZiXnJDEgi6/5PIi785YsAGhLn/NjQVkncwcrUtvIO3Ub6EdFenIHqnvqeDVN+21UtIh+Agwu3sYvQtHLFYcsiEX8fDmQ8SxvaMsHl2nIL8WKgr0dF1fefO9Zd3hLLl1qRtq0ONlThpsSekvWPCjEdCdGe18ABWfwzYnKYzMpFoX/bFTV5a9F1lWAvL7nMGpRo/DHrjB9bZ+Wq0GxePVPj7o0sU+FM9Jnt0wqPJ5dJ0WJKD0FQVylkqF6rg4pG5aaacy8nY5HFtxPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=ydjZWvY1P/SI3BwD6fN+ts4m/35w6s58norWJb8ajYjmOcxbz3+nrGWMPxgzBAof3asGEfFsqYqJX+24SJKCU0VWnbnkWYCLCKikt1G3NmUzCNGNO6RCVa+N34wH/DUa74ovVoxQDb1Q4ujmxsdoFPr8gxaJg5RL2qb538w68hc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 09/17] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Date: Tue, 11 Apr 2023 12:16:10 -0700 Message-ID: <20230411191636.26926-10-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|DS7PR12MB6360:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ab94d90-81ed-4d5a-7551-08db3ac1559c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qApyCw/eRhNKr9aze4U/rylhAkLcEqFW2qkkpLpyGUEdW2AgCK6S44/p2a67w1EuRCOHOm8BHUSpGgB9zXZ/Ac8aWvzxeFHcn+Gh5fQCW7wznN0MXMeYGWOr8xRnW2zrjSd8TadH8++Qaqe9vvGXNJaAcKZ5LNgkE/09f4wCEemxWSE/QVJ9HtFE9r9ehK/pb1HXoFwvHKYWhHgipn/QH/68Cj9kOEaQ9eIcIKU2DzYu/x3NWq8hbgQBJxAVoz1FRURZUtTkhzGZVW/DyKVMYu5NjzEBKekSLWPWvrIpLPAU45Acb1aQ/Q15gRkhEnUnPbe4UTxH3INxGJui8bfLeQ65cibYQCatpgNnCYr/08gyMg7prvQrE+8+41WLV4dXlHGSswThx20toJwjzJu0RaGii9JoQossCFqzOwXj3cNVH44tvvejdre2iIAhssiBRrApAzRdaNkLbd0kytp4OYeit8PRWwCskR4Xr7+qfYx1nPDzot+qTkZ31qz4oF5QYy1/VGAolU1Dh9dQSS7K3kF7fUiF+XrYB6Jjem6uybz2J0GNJQ28hMf6vMjeNx7Qj2S20XUxo7Fv+ofCyrSIBSz2JnN1IJvo7PBotlBZk8siV0EgvqNdK1qqC1eJIo3w4GJJ0m7IGxURagIbwE93lQ0DRC/u33VvRuxQlF48aqlSw0gUYORcOya+QbJs79vSJMyWczmowmgjZfg+dN6orTbpzeYxYKZjKFfO4LE+BQM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199021)(40470700004)(46966006)(36840700001)(1076003)(356005)(82740400003)(8936002)(8676002)(4326008)(86362001)(6666004)(5660300002)(6916009)(41300700001)(44832011)(40460700003)(82310400005)(36756003)(316002)(2906002)(478600001)(54906003)(70586007)(70206006)(40480700001)(47076005)(83380400001)(26005)(81166007)(186003)(36860700001)(2616005)(336012)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:04.1067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ab94d90-81ed-4d5a-7551-08db3ac1559c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6360 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240652562100011 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access= add. Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu Reviewed-by: Michal Orzel --- xen/drivers/passthrough/device_tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index bb4cf7784d..457df333a0 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -146,6 +146,8 @@ int iommu_add_dt_device(struct dt_device_node *np) if ( dev_iommu_fwspec_get(dev) ) return 0; =20 + spin_lock(&dtdevs_lock); + /* * According to the Documentation/devicetree/bindings/iommu/iommu.txt * from Linux. @@ -158,7 +160,10 @@ int iommu_add_dt_device(struct dt_device_node *np) * these callback implemented. */ if ( !ops->add_device || !ops->dt_xlate ) - return -EINVAL; + { + rc =3D -EINVAL; + goto fail; + } =20 if ( !dt_device_is_available(iommu_spec.np) ) break; @@ -189,6 +194,8 @@ int iommu_add_dt_device(struct dt_device_node *np) if ( rc < 0 ) iommu_fwspec_free(dev); =20 +fail: + spin_unlock(&dtdevs_lock); return rc; } =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240768; cv=pass; d=zohomail.com; s=zohoarc; b=RxRJ5uzY/rdK8gBmPlLxdWAdiFJm2BKmYpmopLLkko31VzzqhDTeMIdhcyt5HvJd7WDLQbY74TcRs8YVVDazOqRa5Rr64hayLpnaGqnqSHBU9oN22dG9lJ5zra0ysB4g3zGOxj8eYeD0NxSewstdHG5mdbDoi5RGBSwIx7fdbCg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240768; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=JxK/fdeqtmmVyzYTB4pI0I7uTgGUf2DAngalP3TNOmSJXihXJIdZQs246Ua8JjTSbvQWB/TWJYczHSe9eV7ZVREdXYMds2+tnjKyfYBZ4PXEc3coU7MkaHKu7JQgMOXT9wUND0NMuwRWzEyfcMIzDvYA0FkCbTfbG5gTeEmmOhQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240768707237.40082698386527; Tue, 11 Apr 2023 12:19:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519813.806904 (Exim 4.92) (envelope-from ) id 1pmJWI-0005xm-AO; Tue, 11 Apr 2023 19:19:10 +0000 Received: by outflank-mailman (output) from mailman id 519813.806904; Tue, 11 Apr 2023 19:19:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWI-0005x2-6M; Tue, 11 Apr 2023 19:19:10 +0000 Received: by outflank-mailman (input) for mailman id 519813; Tue, 11 Apr 2023 19:19:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUf-0004DR-BP for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:29 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20616.outbound.protection.outlook.com [2a01:111:f400:7eab::616]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7e5a69a4-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:26 +0200 (CEST) Received: from BN8PR04CA0032.namprd04.prod.outlook.com (2603:10b6:408:70::45) by BY1PR12MB8446.namprd12.prod.outlook.com (2603:10b6:a03:52d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:18 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::84) by BN8PR04CA0032.outlook.office365.com (2603:10b6:408:70::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:18 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:18 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:17 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:17 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7e5a69a4-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F51bULKW9b+g2uxlrVXvYKaoRY/BibCkb2SPb5ObheoJoI53wTk2aDI9+YohJii69KmGma19PCO3tW4tMnTXwVRBluuokfqiZBvHbDix5pAxbJkCPdGIZks3izhxcCg/FRDhnDNJ3UXX/IOp/0QeQ3BXuKu/SZr5c/FTmVDulC6JFE3uw6eUf7SOgl7lQpI/HoxiwWGC6RHH2eBjYOLKf1bYGiBhb3Fh6EJvskGhjE56TCzyHpQFn6ti2rK4E/vW7JD/RPalmCsxNhe8kw6+k7G/itVKHq8vFCxCqUMXg8eOk7jPmHah208vRKPqp4AoWBNBSnT/oWo9SYFr8TIcJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=GVHkLjWTfBaR1e9+F+dbVMwK2uPs8b88ZM46uVIzIjudv3ZNg96WWLSa45UoP0/uNAJuubbd04wbbqWC6cwzCsQOBwsVxaMBD51h4I2wWjJAca+nC56si7I1vHpQCn2CLfRof8p9kzafAbAKIl2fh6trQu5fSolcjQmEgVIIVwVK8CfDMLkLaRDZE9ooGA/Nziwh5MSwBbJes2JFzfHHstxsIuTrLDLAh99xsCijJiRte6+1KsyBLwCx3tTzppZz7Ki7Q+PzcUF7dmzdCnBAWBXsO4FfKq+pdP2F2FoZh/KFFM7eemF3P6yTRltC+HwNwejPVGZSSpkdSRy0XDiYIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qd0QFdZvzHUGWrw0BfIrEu3cWkp8jWSV4vPT9FURuHE=; b=UeV9rIjPsBcg+PwgcsDBTnzu7kPN8nOMhtQyadhmsSoW+nUgdraiApOXwmBYNc5z+TyS1KVrqcIj6Cw4BABNtfalpWqlmSOPwib3dFZ/lfKYtoGlgu2/tHWkNtX4WKoNmaUoLhzGDoycrB0cG3HCUXiHeQoyuq4WuEQ7pAphK6s= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 09/17] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Date: Tue, 11 Apr 2023 12:16:28 -0700 Message-ID: <20230411191636.26926-28-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|BY1PR12MB8446:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ccc8d77-ac1a-43f3-f466-08db3ac15dfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 87wQgUV/Rs/rhMoHDyAXQevmpXRLXB2USDKIB2K94zIe7mzQF4qIHmhhubJj04rWW2nT2FatrLn3Kt8TGmgFjqK8f+qmX2eM0pKIu79MzkElNpmXfWbrUaoiCeOaVjOVtpMTxwVQ/TVBMRz9BCMSQNuQD7Yggd5Mo+h21Ax/tfIZ+YiZBBX+9fdtphasJMnj3JRIzmTExGeWivt1ezYxPXs4F4xWL0+X5Yj9dWPCGKw+h3sHRw7bAPByNK58TZLfzTgYWIgW8luPcTV/oAwPC9JiFuoC777ounPNB5yFl5DJCz9C+JKqlYkaoedAk88jGQSLo8CW3pBpxb5am0CHJA80bu2hS4PZqD8NLGcxlKMCaJ+N0a5ddFyndjGV7vP5bWWVMGBJU8Hv25YMfG6TfRLhBGE0QnJkQfch2iPUPwmhw6Sn/hbNxmxJTrmk+636iDCuR22Iut9OGQHXPnzwZrKS7E3zemncGSI9VQ9Xs2DefUg0nQOVAKEM1MeuZ8yjZCO6OFasSOW47C3+i8oRpXXPQgLNzA3CxXZy5WpPWMC5y/2+lo0O6MVsOvvW2cLK61qnya3zCk204VPco9hwJ4jdelqsO1Dd7FvswYqso3rvOkQBKMVXIBwwf0X5IR0xnCtzvo8Uc+9JvpjbyurI9BjfqmKp6TrYNniNUyM0JMLWW3MpsYSijbeV0MgLrq2QriGdg3+sbqYIospL1ZsJLywJOiUaDKK+1yovMUWyhRw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(82740400003)(356005)(54906003)(36860700001)(81166007)(70206006)(70586007)(8676002)(86362001)(6916009)(478600001)(4326008)(336012)(47076005)(426003)(186003)(2616005)(26005)(316002)(41300700001)(36756003)(2906002)(1076003)(83380400001)(44832011)(40460700003)(40480700001)(8936002)(6666004)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:18.2324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ccc8d77-ac1a-43f3-f466-08db3ac15dfb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8446 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240770289100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Protect iommu_add_dt_device() with dtdevs_lock to prevent concurrent access= add. Signed-off-by: Vikram Garhwal Reviewed-by: Luca Fancellu --- xen/drivers/passthrough/device_tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index bb4cf7784d..457df333a0 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -146,6 +146,8 @@ int iommu_add_dt_device(struct dt_device_node *np) if ( dev_iommu_fwspec_get(dev) ) return 0; =20 + spin_lock(&dtdevs_lock); + /* * According to the Documentation/devicetree/bindings/iommu/iommu.txt * from Linux. @@ -158,7 +160,10 @@ int iommu_add_dt_device(struct dt_device_node *np) * these callback implemented. */ if ( !ops->add_device || !ops->dt_xlate ) - return -EINVAL; + { + rc =3D -EINVAL; + goto fail; + } =20 if ( !dt_device_is_available(iommu_spec.np) ) break; @@ -189,6 +194,8 @@ int iommu_add_dt_device(struct dt_device_node *np) if ( rc < 0 ) iommu_fwspec_free(dev); =20 +fail: + spin_unlock(&dtdevs_lock); return rc; } =20 --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240830; cv=pass; d=zohomail.com; s=zohoarc; b=YAVP4rS4+CbAsFXHcxK0+okQF9a+inzHRW7xm61qwBhP4bWiKap1oL3KkJDTZyufFkO5cstznkmmoPbE8O3aIQSKfZGsVJiRdhlOkwg2GOADQ3C/MliQNwEvoYSAagnyaDo8l9Fm2bdyBmgyncQjrK4FpIj0czKbzOaENJ8bpJo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240830; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=U/cY2KkR5yWNuXZLuzbGS4HqF4JKK63qENgM2hra2n2UDlkjuXqzq/4Vbg9oalF6hJ//fKVYUS+0ngogG+xKKyuGaxhB7Jd05Z+zr1UZZBr62Eta7myzxD7WVPxbE0+eWjU8u9Tdjo9EaHWXlo0B5mOgH1qaL1dZuDMQHPqUEQ4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240830189881.619612661192; Tue, 11 Apr 2023 12:20:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519877.807028 (Exim 4.92) (envelope-from ) id 1pmJXA-0002g0-Tq; Tue, 11 Apr 2023 19:20:04 +0000 Received: by outflank-mailman (output) from mailman id 519877.807028; Tue, 11 Apr 2023 19:20:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJXA-0002fC-Ko; Tue, 11 Apr 2023 19:20:04 +0000 Received: by outflank-mailman (input) for mailman id 519877; Tue, 11 Apr 2023 19:20:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUc-0004Ta-Ky for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:26 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20627.outbound.protection.outlook.com [2a01:111:f400:7e83::627]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7dc924f3-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:26 +0200 (CEST) Received: from MW4PR03CA0021.namprd03.prod.outlook.com (2603:10b6:303:8f::26) by PH0PR12MB5419.namprd12.prod.outlook.com (2603:10b6:510:e9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Tue, 11 Apr 2023 19:17:23 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::8e) by MW4PR03CA0021.outlook.office365.com (2603:10b6:303:8f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:22 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:18 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:18 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:17 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7dc924f3-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mc7+AWllmzix4mhii1U8rnfn6L8ASn96uvHv2soW2G7oS/3cPcG/WPHUuDLB+gHbOMNpDcX5jRXZqCgLhpusyEg1R0n+mz/yllTm5QaeY4RI32zVz4/gYMdFKTJKM1aSfofl01QwWJ60BIb5tzqUHYHmw2+LokFw44QIaOMTEccm+xh/MP4D6Mr2c0WftqUjLDtMZuFXUbW1dP573ft+kB+iOw8Uec9EU+SgqOkjEmleM400hkhMhM1xTVs1yzcTwh8cv/23Fibu5oHI/h5g6ToYlPm1PWlzi/cXlBbGWYHRZTJ4Et9UEnxpUwGWGtm91S/vxOibgh5Reu43WmfIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=ZzvG+mK/iy4AgUZDTYFPIQYPZO+KAPqS1wjw2S3ySjkMCrDPW/p7P0Pb9tYbfao7N2wXlSB+GOhajUT1r93LBMrYMaOStDb2tWPzI1R0WOlD2uNAFRdBX/nd4IY8s/4ELcLxSCcTfOUBOWR8olwMUeKCZ12nCKQlN2Z/0tPfdDw05IlQHVJA5ojUFqjObsvOzDxxicj2mBS9V+asAN7T7vGq1+42BEvVUnrPd3H8jN/pln2atHXnmNF6xB57s6Oz0oW80KFunQ8oA34qGYuswx/4ZWg52NjAa/27D57vY+zFiyoq9ZOx5T/F1ZoYLY9KF5aDQg10Mv/Dn3cK+QCDVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=KVktFdAFizbAL/V23oXfjwGQ1VwQmvuLOLNg9ydmkLqePyqfEfZtuz9SgQnQ3IGivyHAElCOHj9+oLQza55PUBKSr1IglMdUNBPbvmbJZ0zY59ftKxbgf49iWnuXKBY0p2zGrDCylHIKyzQ/gfZDtc+nt8cYRs7fhLIAcfwjGUk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN][PATCH v5 10/17] xen/iommu: Introduce iommu_remove_dt_device() Date: Tue, 11 Apr 2023 12:16:29 -0700 Message-ID: <20230411191636.26926-29-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|PH0PR12MB5419:EE_ X-MS-Office365-Filtering-Correlation-Id: 6efa7f57-ca98-45af-4f83-08db3ac160c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9q1fBSp1v32ZaZSlxWE5iV198r5t8GU1JGK5iYoab7v6pemY0mVsLrBfn3g3VIFB+ZSQeujLUZ9GW0FrxRlTMlchWsvewHOZF8yrhIrEucnfpn4+KA9W2R5ZvXMlIfrd8QPZzs2Gck1ubm3WL0SbOe5FbHeVHi5DFRWO0LRfN8m1oKh6WguUgZF19ZQ8yjHqSmHEpt7WnWGL9OSUamL9m9t9z53G88xg96P6nnkUCkjLmhyBq/lA8gflXEfMAXNgI6BSWXo0817OFAar17z0qEkXP0siB+Jittc3yAtJPsLuihLnllrhjOjZzttP4/NaUCOShrajkPSXmVEMM2zaqnUWZ5EufNFS4NVEqqutDC7y+m8ILU4iLtPdq5CTFf51CrrXc+eaxZKyx1UghtgQOqucUCkY8lgDEv3Mjpy0zVCb2n5cgoWDtSUNYcEGdqzow+n6uVl38+8AEoWXjMdEsd0Z8kz4NJ6guUKHMgmEk4uOj1lG339ZbES9JzzTqfoJWqExFGTlNBk00PGOs15RDv2ArSC/ZjN61mGL56Bu77qclZqQqIwZN3c03bJCo0AjvIQl9OSx7UJPGoqclZEsRfVrpNz+5MYCSvEStuGF0HAgwqGcU6smopMuGzBx4N6dUNB1H0DMqDnDqH/CmkOhJSPcCkAbasO1aeOr9qiXSZOO5yTaz/aAV/1180qKkVw4BCdR74iZ4fR4pPPZn0njt3mA1CNd+NPtSbNRVLB8YOk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(70206006)(478600001)(54906003)(70586007)(4326008)(6916009)(8676002)(41300700001)(316002)(86362001)(36756003)(83380400001)(426003)(2616005)(336012)(26005)(1076003)(6666004)(8936002)(2906002)(44832011)(40480700001)(5660300002)(82310400005)(36860700001)(82740400003)(356005)(186003)(81166007)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:22.7966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6efa7f57-ca98-45af-4f83-08db3ac160c0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5419 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240831563100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove master device from the IOMMU. This will be helpful when removing the overlay nodes using dynamic programming during run time. Signed-off-by: Vikram Garhwal --- xen/drivers/passthrough/device_tree.c | 38 +++++++++++++++++++++++++++ xen/include/xen/iommu.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 457df333a0..a77a217f3d 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -126,6 +126,44 @@ int iommu_release_dt_devices(struct domain *d) return 0; } =20 +int iommu_remove_dt_device(struct dt_device_node *np) +{ + const struct iommu_ops *ops =3D iommu_get_ops(); + struct device *dev =3D dt_to_dev(np); + int rc; + + if ( !ops ) + return -EOPNOTSUPP; + + spin_lock(&dtdevs_lock); + + if ( iommu_dt_device_is_assigned_locked(np) ) + { + rc =3D -EBUSY; + goto fail; + } + + /* + * The driver which supports generic IOMMU DT bindings must have + * these callback implemented. + */ + if ( !ops->remove_device ) + { + rc =3D -EOPNOTSUPP; + goto fail; + } + + /* Remove master device from the IOMMU if latter is present and availa= ble. */ + rc =3D ops->remove_device(0, dev); + + if ( !rc ) + iommu_fwspec_free(dev); + +fail: + spin_unlock(&dtdevs_lock); + return rc; +} + int iommu_add_dt_device(struct dt_device_node *np) { const struct iommu_ops *ops =3D iommu_get_ops(); diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 405db59971..079c06321e 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -218,6 +218,8 @@ int iommu_deassign_dt_device(struct domain *d, struct d= t_device_node *dev); int iommu_dt_domain_init(struct domain *d); int iommu_release_dt_devices(struct domain *d); =20 +int iommu_remove_dt_device(struct dt_device_node *np); + /* * Helper to add master device to the IOMMU using generic IOMMU DT binding= s. * --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240659; cv=pass; d=zohomail.com; s=zohoarc; b=Vu3DvMDSuDXcdcUnKBuxJ3dhQhFwYsS0q0vT1uvcEqeogzuwG3jmjBJpVESgk/F9nEpI6YWWtGQMuwpYSy+JDFbhraeg+M5Y0XmNTbXMtLo6besK2/+xJg25vTqZQFB0+nSfX6iROKBom4vAiDMde8dpzhR9g1I/Xvuk/26tfRQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240659; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=cvEEUS2RqfZ1i6yjjkkAEm+kD2ybfEfvMQYaVBpEspBjBhGCQVr3Vm1nydZG0Ul8MNopiQGUVcm1pCQld27wlyk6LOxovGDvVtmi+h/GIbFECuWA5PrOeuzsQQDFo+9IT/vvFcq0BCXMjt6JbXPHV9P00Rda1HEAT3z3Q0S53uI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240659618832.0388880536744; Tue, 11 Apr 2023 12:17:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519778.806807 (Exim 4.92) (envelope-from ) id 1pmJUQ-0006fJ-99; Tue, 11 Apr 2023 19:17:14 +0000 Received: by outflank-mailman (output) from mailman id 519778.806807; Tue, 11 Apr 2023 19:17:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUP-0006dJ-LC; Tue, 11 Apr 2023 19:17:13 +0000 Received: by outflank-mailman (input) for mailman id 519778; Tue, 11 Apr 2023 19:17:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUN-0004DR-58 for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:11 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20625.outbound.protection.outlook.com [2a01:111:f400:fe5a::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73919cc7-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:09 +0200 (CEST) Received: from BN9PR03CA0142.namprd03.prod.outlook.com (2603:10b6:408:fe::27) by DM4PR12MB7526.namprd12.prod.outlook.com (2603:10b6:8:112::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34; Tue, 11 Apr 2023 19:17:05 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::a2) by BN9PR03CA0142.outlook.office365.com (2603:10b6:408:fe::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:05 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:05 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:02 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:02 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:01 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 73919cc7-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvRZFbWVxaHzD4dC4eg10s+JGeIh41RGjpq+bd3XY0t9hcciIFmAIf/xunvaYze63VcqaP8lDQIBoG0ArOGN3q0ezmZKBrhNS2VJPfRvLgWOtBxvXk3wP/Y5hb2gRua+HQqpFQyZBbhT3GPys5oZctzZiNmO07UsUtWReK6Cg2TnoZSShhAhjMNYMANyre5ctqTUhJ168r8N2bb4rLzUQpDH5ymPpE4a5xQlb6SGLgwEOJ48CAgd5flxzlaA7xH6uelUGpzk4lPdrhLlBwtJRfy529sag0IAv2JGcwAaMlK8rPanjPldyLK9auTZUvD4AY9kEDEfTcPAtisaOwrzdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=KxsI1IgHe4kyjJTYgsFZFWdpdnVOjddPLs48Hx2uUh+5zs2jS8/T0oe6xPIASt4IeeHSuiDMdecDtOM2c7WT0UFmNL2oWFvv3Ifeptc6jTvcwgO7xzganDpzZ3AKixd0P+QFPSA8SQ5lvbGx0E5bM3eQ6c5kZZvKd1mhKIdHtOp1utdCrQjJDiLbtRVo/tw8/cfAQAm9l7W+Nj+aiee3nWIK4QxyTi0SOcGq5aXtKKn3rjqDqpIrtT2tZECCubVI5sByrivWKtBTUXFTBWcJFerV0eQF8yZGMvGwmBdH3hx6kc80uQLYkaQp1XyV12Inde5nQdIAuMlDKkvw42GQUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gLWShZkghSoju5aCTSrHjPTktEFI3gdZrQ2ShX60hx0=; b=NWggMp+NbZSoS74+iEW/lnwNxS/0+U45dx/xyGra3jRZCZ/dfkfv8fv3DPfx3rxJ7FZc8iSwFmlouf7C98Zy+LTDNBg0U7IISXWuutersEy7dJTx5zPfo0BU9grO+Uy/1sa/8XNWxNOd/BoFskPRKMLnF063zd0vUd3Kc6RMoNs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Jan Beulich , Paul Durrant , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN][PATCH v5 10/17] xen/iommu: Introduce iommu_remove_dt_device() Date: Tue, 11 Apr 2023 12:16:11 -0700 Message-ID: <20230411191636.26926-11-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|DM4PR12MB7526:EE_ X-MS-Office365-Filtering-Correlation-Id: e678d25e-8dd0-4fed-c468-08db3ac15646 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4SMf3AeZxBcqMh+wCIuBWx4KpJmrSvC3Q6Fd/cdWCkn2sVjgyyZjynVpyRRCVplD4p7cX1bmJX8PzrHIYXpPfTZBmYKZFLRIbVNsdcPSiwHAsvtxVPdMUM3rYt0uBAwi3CbZQtanTiEDypOO3bHozVcvs9edN4GDqQayKQwrdlpZwqTUM7Dn3xGqLlQjth+k/NrdL3/fDAT75zeiPZn8Jrrw1aU29UNz+QImHUOTkkhEa2r0uyHUvWdT59Z1M/kyzQwOOJyqOGY4pbrxq6ZMYFAzX7k03In/TlaL+uXrLnDZnZ82Xxbw+g/mtEHlci2wm4JJNySUal8bPXdhEiLRZVDNqiA28f5E3FCAKaTbohv+nRaWhpKe8E3tTKFTC1KAFtngaI+KOaUHNdYMqtmeErZCaWnzMeWVTWhD81JubVi20aQviby1gBWMXZ/YVTAlSn2+ghFDMRKzziSt/jLbRI0sdUpQxNtpe6VHYWGTXv6FTuDmejueMdxSLoobwU01xwNiRaAgBSvoNF3kSyxmrWV3CX/sXLvkFqDPZ7g/uX4vjREiVIhb9XJb8XMnMNyWqNK+Zf4tCGCRxenOxYvbIlc/2jKxVc4sw/ojHVzauZE11kuFcpV1MVUZB7L8aigy5lElgLw7MIX696Bg9wmTK9ASSE9XBvuEaUsBOS8eGAgK1d6KhQJg2qzZqbpOVRPGpAsIA4UWS08+78bJnaCz4M6SNCLP5vfAGm5WdPlqAho= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(40470700004)(36840700001)(46966006)(478600001)(40480700001)(47076005)(36756003)(83380400001)(86362001)(40460700003)(81166007)(356005)(82740400003)(426003)(2616005)(2906002)(316002)(1076003)(336012)(36860700001)(54906003)(44832011)(26005)(186003)(8676002)(8936002)(6666004)(6916009)(82310400005)(41300700001)(5660300002)(70586007)(4326008)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:05.3322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e678d25e-8dd0-4fed-c468-08db3ac15646 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7526 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240661666100031 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove master device from the IOMMU. This will be helpful when removing the overlay nodes using dynamic programming during run time. Signed-off-by: Vikram Garhwal Reviewed-by: Michal Orzel --- xen/drivers/passthrough/device_tree.c | 38 +++++++++++++++++++++++++++ xen/include/xen/iommu.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 457df333a0..a77a217f3d 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -126,6 +126,44 @@ int iommu_release_dt_devices(struct domain *d) return 0; } =20 +int iommu_remove_dt_device(struct dt_device_node *np) +{ + const struct iommu_ops *ops =3D iommu_get_ops(); + struct device *dev =3D dt_to_dev(np); + int rc; + + if ( !ops ) + return -EOPNOTSUPP; + + spin_lock(&dtdevs_lock); + + if ( iommu_dt_device_is_assigned_locked(np) ) + { + rc =3D -EBUSY; + goto fail; + } + + /* + * The driver which supports generic IOMMU DT bindings must have + * these callback implemented. + */ + if ( !ops->remove_device ) + { + rc =3D -EOPNOTSUPP; + goto fail; + } + + /* Remove master device from the IOMMU if latter is present and availa= ble. */ + rc =3D ops->remove_device(0, dev); + + if ( !rc ) + iommu_fwspec_free(dev); + +fail: + spin_unlock(&dtdevs_lock); + return rc; +} + int iommu_add_dt_device(struct dt_device_node *np) { const struct iommu_ops *ops =3D iommu_get_ops(); diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 405db59971..079c06321e 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -218,6 +218,8 @@ int iommu_deassign_dt_device(struct domain *d, struct d= t_device_node *dev); int iommu_dt_domain_init(struct domain *d); int iommu_release_dt_devices(struct domain *d); =20 +int iommu_remove_dt_device(struct dt_device_node *np); + /* * Helper to add master device to the IOMMU using generic IOMMU DT binding= s. * --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240655; cv=pass; d=zohomail.com; s=zohoarc; b=k2h5UEkSL6AFV5K4yqFZjySJraj583TfNbQ1x1tnyUsbGO2ANeWhHIvbqPr4g5GjDDmKJxHw1eGV/+e/i5LdvaqYHt8ao1cIz39eDvDf3ZgYzGopHJxt47fmvvFzi00eYxCkygH/hUHopOLM08IbsxIniGBD3MilRX8qqITNgVM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240655; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=Ry7VCjnocNU8V0A5my/gEJfv0D4byML/mpiFttBb3EqKba0QtJ9jcVuB3xTqsQZCv8gUOiIFod/xEzu2Zg4mAAJnIteRYUP9q77uJ1YkYxq7wZ8KL4iD82+YW3wIcIebJKfbj6tpGK8kRw2R5BxOH/pWl9fB0GP6wHZFSgkuoTk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240655009701.6879178866046; Tue, 11 Apr 2023 12:17:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519776.806793 (Exim 4.92) (envelope-from ) id 1pmJUO-0006Fq-JH; Tue, 11 Apr 2023 19:17:12 +0000 Received: by outflank-mailman (output) from mailman id 519776.806793; Tue, 11 Apr 2023 19:17:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUO-0006DA-3H; Tue, 11 Apr 2023 19:17:12 +0000 Received: by outflank-mailman (input) for mailman id 519776; Tue, 11 Apr 2023 19:17:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUL-0004Ta-UB for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:09 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20611.outbound.protection.outlook.com [2a01:111:f400:fe59::611]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 73e6f7e9-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:09 +0200 (CEST) Received: from BN9PR03CA0142.namprd03.prod.outlook.com (2603:10b6:408:fe::27) by SA0PR12MB4461.namprd12.prod.outlook.com (2603:10b6:806:9c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:06 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::68) by BN9PR03CA0142.outlook.office365.com (2603:10b6:408:fe::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:06 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:05 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:03 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:02 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:02 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 73e6f7e9-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EE2Ctn9GNlCFsItgMw8F9HmYXg17oJOdiP9I9XI4gGGOLXsCtSbDBSqC61H+Dq+MLsM7lxptVaIo+tOpPZPzzMDUlCj/wE4F6cekg2BKBn6/Lo9J9ZDhfqwtpK/9IY1089A9Q867ER7/LITYmQibC71RbKQVmwQGce9+X5tjUYl3mShbhsOu8sRmoCVk/82SwIkHBA0S/pxssD5JCg+BWCV4HX/8NOUZm+GqDJPV/BsZhURrKd9nJXFRya41E9vv9DuOzNDjwYbJ5xo+9I8FY/BzeL3GPEYu4G6QlZSHWIXlZp5tfgNRPLpwRbKvetPtBqkQF/6ytR5INCV8dx6KlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=jaL9+qOMzRad5tarJg4rEj4AKXrLNbMCDZlevdOeN1RNicT0Vj4aGC2TpobcwtvzX7YLo5mFaIpM/8ulm1opSE0QM2dTfcTf+xjX0o/MfWBBCLKrIfMG4b3D39A3YuA0fhCjqtpKPBGsMN/cjpUibFTkyhbO+SToa+IxsW4Vu2rS7dD6RbdMLXSMN3IF1G05npHhRVG9BabpwY7H+D6HQI0DUuznXWTDFXOS2Tx//5JnZtFgOpDe9Ck2R9xUkNMQmOz+Y2p0ORVooRxFOIzonSG/hvi6aJR7+oABL/WNh62YxFEGv7Frl7HiY+NUrkun81OMteRtRID/tKwmaCyugw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=utGqqoXglk4yU5u11TW967K8k1NpxM1j7Bmkllm4Bn7wCTX1ogO1oSrTPEHf13ml2qCcv7EmB00zIOviy+PnFtwWVV26CjjThzvZrLhKh2848DLvyL841LgU937KVR6dXT4JeV+TpyfgP5FucG/R6tH+0XCreVFnWdWGjbUzCDM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 11/17] asm/smp.h: Fix circular dependency for device_tree.h and rwlock.h Date: Tue, 11 Apr 2023 12:16:12 -0700 Message-ID: <20230411191636.26926-12-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|SA0PR12MB4461:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c464d7b-9522-41af-e4d2-08db3ac156aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T1rYiXDUh4QnttGRazlOfWqjXoFP74k7bGx8YZ1wWb56PmvEsA86NABuo8umFlX5ixEi3YYq+E2xjZP6eBbWnvYB8jxJWUKeG79Av4TW3jJB0aDKOibhxbA8op9ZEslTO2VsDBJsW4puJuLQF7PNsVPhHaCsz5gSEg86dt60nC2ol7cScOcmegiDeOXY+tXSJiIhUvybYfmsyq869lb3lyUcRji4lT2SPZkgGwlhtMALVu5CEvyb4OD12v3OB56KM6iv8RWFhILrbyKWRqnCZ8PzKzi/TvS9SiFw0ahr+L4ptt3IZFsM19tr9C3tZrfGcKox5W6ERt+1bkk5UtbxL53hbKEx4hQyEZ/9oV76ao9yEIiAK6As55jinHTIfSUmYt/NK1WegBul9N/cwFSkVrvI6svGFAWb6w9labchneUXBergLWfB3IMNsYi0urR6/e0DNYLNxyZrf0Oukje6aAbxrhkjmnEDG+zm2iyCshjIIYqYIoQI9aZ/nxZMUfWlQiKtFnaRJj0554loeuyY/TkoOT4sXNZeygfCwwjgY9UgFvt8oxTkAmwMW/Lizz5BqYQSUsCa4r6xDDcLKsHV/YDmBTYJ89hw78Le2RG7Ls5rR68UcuQHYCXuNRbn9NHVB0APiSi70L1uADioPmuqiUCXQ/o8LtHvjZWYSeM5OZ8GxB3fuIZB6BJujSECBgvXC/F8hNVXBAFgT6WhzWUjtt7RdHucICoh2uh3QgMCCbk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(4326008)(6916009)(8676002)(54906003)(70586007)(70206006)(478600001)(41300700001)(316002)(36756003)(86362001)(336012)(47076005)(2616005)(426003)(6666004)(1076003)(26005)(83380400001)(44832011)(5660300002)(2906002)(36860700001)(8936002)(82310400005)(40480700001)(356005)(186003)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:05.9727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c464d7b-9522-41af-e4d2-08db3ac156aa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4461 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240655685100021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dynamic programming ops will modify the dt_host and there might be other function which are browsing the dt_host at the same time. To avoid the race conditions, adding rwlock for browsing the dt_host. But adding rwlock in device_tree.h causes following circular dependency: device_tree.h->rwlock.h->smp.h->asm/smp.h->device_tree.h To fix this, removed the "#include and forward declared "struct dt_device_node". Signed-off-by: Vikram Garhwal Reviewed-by: Henry Wang Reviewed-by: Michal Orzel --- xen/arch/arm/include/asm/smp.h | 3 ++- xen/arch/arm/smpboot.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h index 8133d5c295..afe6129276 100644 --- a/xen/arch/arm/include/asm/smp.h +++ b/xen/arch/arm/include/asm/smp.h @@ -3,13 +3,14 @@ =20 #ifndef __ASSEMBLY__ #include -#include #include #endif =20 DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask); DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask); =20 +struct dt_device_node; + #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) =20 #define smp_processor_id() get_processor_id() diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 412ae22869..336a7d418b 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240811; cv=pass; d=zohomail.com; s=zohoarc; b=nOw9Bhl1XP0GbdZSM/3F7iCn7iFlObQI/OWe0NC7o2wzxR451IGUp5/UoDRnP476zjZU71QCm3/CfZrdDwqCE+sAFRWh8d11bgEMa0x63VsPF5+w3cvRjUHWzTBECiOPHpErl7kM1ksBxd/NM4IC7Fhc9z9T8qFJmEmGfh+baSU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240811; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=bin7koWXb/pWa0vKnCjyL8uyBvVKxJkNJSINxg8+vAX+HrSAiGEh3G9HawW0HotExnMgXG1KekmppOv+u9NDTKZhsrsKtYR44XhWbz74AqUc4vki96HPx79sNfhYQMwRiCEP1jGktgh4O515Gjg2t0XMGN/t5AZ3Nh+6zzdSsDw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240811755489.504342471883; Tue, 11 Apr 2023 12:20:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519846.806960 (Exim 4.92) (envelope-from ) id 1pmJWz-0000Cy-4q; Tue, 11 Apr 2023 19:19:53 +0000 Received: by outflank-mailman (output) from mailman id 519846.806960; Tue, 11 Apr 2023 19:19:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWz-0000Cp-1c; Tue, 11 Apr 2023 19:19:53 +0000 Received: by outflank-mailman (input) for mailman id 519846; Tue, 11 Apr 2023 19:19:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUb-0004DR-Au for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:25 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060f.outbound.protection.outlook.com [2a01:111:f400:7eab::60f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7c43909a-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:23 +0200 (CEST) Received: from BN8PR04CA0065.namprd04.prod.outlook.com (2603:10b6:408:d4::39) by MW5PR12MB5598.namprd12.prod.outlook.com (2603:10b6:303:193::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:20 +0000 Received: from BN8NAM11FT069.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::d) by BN8PR04CA0065.outlook.office365.com (2603:10b6:408:d4::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Tue, 11 Apr 2023 19:17:20 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT069.mail.protection.outlook.com (10.13.176.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:19 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:19 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:19 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:18 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7c43909a-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTkfvHMw4fwZfUXsGYwMWqNK9TBfbtOjNei/7m39xnNYGph1NAu8DmaU7G6RySe+rPUyKwHKLe99naA3atslI4+AtkslwbNRuNPYKKLdJofW3MMmOnpzeJGo5XiutQUte1DlFCfhFhdj87Gq49q4IuDy+mjjnfUTiAwGt/o5zZ5/X7mij/jUiRVQ/ypK4xXSK93zZTk3/8P6pzHFzO8Mz8QipY2YO5nk4KY2Qz+AsD8VOFDR84tsR6FIQhSvNDNrtx8rgi8WPHsHHO+VA4ZP2zTUMxJMFUnRfG64qCT0S3ZwpNR+Qdc+W0XXbvCxXDG3/qaB0QWPh0Jl+kbHQyfRDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=FFOrj0o6TWzAcl90jAx+ZHpRzHGwNIn49bwTOzhpxT9xczQKuC+bOv3XbPGefV2DAUNjs8LPXlSJl7eeFxcl3Js77kcXAsjSpBo/pZ4FoAXUZluAod0dSF+4iK/AuJ9jqq+FZ5F+2w0CfPVA7EZ4T4KfIah77GdUw1DS5OspoVVRjpfVj6GivPDwnhiMA3xRShQrR80etqXS8yQrlNOZTaQGIE8hgoTJY2lTkLjnOa5fqC2hGR0lXlxwWyZmiVfUaHtO1lh3TN7b+FkSX04YJucGOjqJ0o2GNVZbQy75ZPPjLf2LMYA+6320fVpyHymJTLTV9G0wLwN/smWITJA8og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x1PNAnqijXbZmLbaJTz/bnk2u6mRzrBSQaqCUQeSU5s=; b=wuntfbt/6RBi8we1bEE2MT1iJltEJu3U0H+EIy9i2cz6kFGZok1kVKid9tZJ9YA4toycLlEjO+CWZBRQ5Ip6Z+OBgVQZJU7x0141SchJob5+X1IMGwlxoqatul6fHZdmGPXqUhYG7EPBT0MeLCz1tnHGX9EHSUVraItI7oKzduE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN][PATCH v5 11/17] asm/smp.h: Fix circular dependency for device_tree.h and rwlock.h Date: Tue, 11 Apr 2023 12:16:30 -0700 Message-ID: <20230411191636.26926-30-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT069:EE_|MW5PR12MB5598:EE_ X-MS-Office365-Filtering-Correlation-Id: 65b4fc63-54fd-44d5-795c-08db3ac15eef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6qps8HEQfzg6wg3LtuU3NpVWgiVYlUptzQkTg/BZ9Gx9WDs1l6HDyz8G0SoDMCc7LRHWlB2Y195o8IxiFIGfe00rQ/Y3jE/uWYyf5hxB27tMEFxn1Fdd6XND800/0MYjrtNWAW/Ufrmiu+8+pVwS4GhBT71kAKdVlGPP0YQpQDVJdpnZQecPzZY7fnz0onN5GjRImXxLG4hsGswv9MCwizwqJSUGDHRyT37u9jW3d+zqsh58sUrcN42JdNpKAqqehq9UeUx+7oEyEg3VF0kkwlLlJCSooQC/+ltMLVfVL4683p2wWl0i3tyVPCV8kwcWlNj6jUBwmN56BB0sZRFDgNRhER5ttELBJ4ZW2773SZmdfgy5USZsnKt8GKjAULUjv+j7lw4iCNNri/oMGPQkPKBRdRRZ5Rj0VzcaJJsWKtXhIzIGNXUXDO2AuoJtI8NLFbnEI/S48bTKGPUdapAW+VBlIm/h/G70ED2XUZKdmmGkDdyxYKDk3l8+05eGdoSl962L8Vn6Cb3L7fvK5ZuzulOuPd2l8cho+UpIXAZQ3fwTJ3Of0NqHKN19SEO3kOS6bENVhoHroexpz2sOI75rMGp8cu/JSihG39ZB7hrL/WfXleR3Gc/hGE2a7d6jqMSK6Q8WHI6/L/kSKmd2JiJ/N3XGO02+YbtfE3pOn2KgsnxTSMlHFHGilsOflgK3M9qWL5Q3XQCshZtJ5/VRIvbzztT0cU2B2oSekLyp1Hqb1Q0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(36756003)(44832011)(82310400005)(40460700003)(2906002)(5660300002)(8936002)(86362001)(40480700001)(8676002)(26005)(6666004)(1076003)(36860700001)(54906003)(478600001)(2616005)(47076005)(336012)(426003)(83380400001)(186003)(70206006)(70586007)(81166007)(82740400003)(41300700001)(356005)(4326008)(6916009)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:19.8440 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65b4fc63-54fd-44d5-795c-08db3ac15eef X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT069.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5598 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240812582100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dynamic programming ops will modify the dt_host and there might be other function which are browsing the dt_host at the same time. To avoid the race conditions, adding rwlock for browsing the dt_host. But adding rwlock in device_tree.h causes following circular dependency: device_tree.h->rwlock.h->smp.h->asm/smp.h->device_tree.h To fix this, removed the "#include and forward declared "struct dt_device_node". Signed-off-by: Vikram Garhwal --- xen/arch/arm/include/asm/smp.h | 3 ++- xen/arch/arm/smpboot.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h index 8133d5c295..afe6129276 100644 --- a/xen/arch/arm/include/asm/smp.h +++ b/xen/arch/arm/include/asm/smp.h @@ -3,13 +3,14 @@ =20 #ifndef __ASSEMBLY__ #include -#include #include #endif =20 DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask); DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask); =20 +struct dt_device_node; + #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) =20 #define smp_processor_id() get_processor_id() diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 412ae22869..336a7d418b 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include --=20 2.17.1 From nobody Mon Feb 9 08:47:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240648; cv=pass; d=zohomail.com; s=zohoarc; b=ZAZMFUf7ekwePek0Wc8DNvEP1U8F6YMEgTYI9btxH+LqC+gEM4EeVnvbOMaRD019ZzZobWDV0RR3DX2+maWKHPbriOcDbh6y2FtEZZHTVowa+0zpXVhx204Q4MOf5IStE69q1XCkRMAuOHawItI1N9Vnzt2iOT2qSRAD19Z/m2o= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240648; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=Vf5lItaavw8Rn8H8U3VbwWYLYrrMa19ZwxQG3CTe6t/dQ/tkbdmXeLxs5LVPdos6nVKSWdSKcYC7VPGnv9KOP2dvhwfQiuUD2RAv2eAbIAZ0fs400gSxmmQIIbsnxK8EM5z5UY5u/SuOK8kdlZkWPfkp6h5zvMyGze2g8pTqOzA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240648635313.8643528340284; Tue, 11 Apr 2023 12:17:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519773.806769 (Exim 4.92) (envelope-from ) id 1pmJUM-0005hl-A9; Tue, 11 Apr 2023 19:17:10 +0000 Received: by outflank-mailman (output) from mailman id 519773.806769; Tue, 11 Apr 2023 19:17:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUM-0005gq-4P; Tue, 11 Apr 2023 19:17:10 +0000 Received: by outflank-mailman (input) for mailman id 519773; Tue, 11 Apr 2023 19:17:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUK-0004Ta-Pp for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:08 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20611.outbound.protection.outlook.com [2a01:111:f400:fe59::611]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 739189b0-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:08 +0200 (CEST) Received: from MW3PR05CA0017.namprd05.prod.outlook.com (2603:10b6:303:2b::22) by BN9PR12MB5257.namprd12.prod.outlook.com (2603:10b6:408:11e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:17:05 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::4a) by MW3PR05CA0017.outlook.office365.com (2603:10b6:303:2b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.27 via Frontend Transport; Tue, 11 Apr 2023 19:17:05 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:04 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:04 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:03 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:03 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 739189b0-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RnOWGfhR+alOXtb1kEbH7mY9GHTUEb4Fh/Fq5W+ejuEBGScgkN+8M1kOzS1mFU4cA3rfTYuCUVidDnhaZwcIb3yH4MUbng3sDhlaGnQNs2bLeLWU+QLALHyOh6CCJhJQ35Fv0tfwvwbfL/RVHk4qdplIJ6NK9iWXfIv59MjOsILUtV/+MaRpY9HuwnDQh1R2S+1WxwGgc2i6+DPVMRL9v6qFUU46v4NtKiUIhGPHgtmRxH0AoZsyJEY9Kjj3m1REYDdpCUA4+p4qwj21PDv3c+9WAoLdNmEiTWZ1c2zIcG7SesZD2zVy+jc545NHBmf4mtQzOAGaAOrGiljWyw30fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=AfQz2DOlaIMvQKAfoj502N6k0Jzk3taYs6o6qwigXCHpwW9phuQL1ITtRk4IU4J3E9NW7amG3/ALbGXLT5qtSR/E78kmN0/SGnoIuH3ZklgOvT69Vgiste+lkcBBzOTpqZnmNqJHaI8nvqy9GkgQxNOezhqE18ZkBNOVddwf1TgIaJuwB4/MVqX7ZryKA4OXdowle9i35wq0g55QFrE2CaAXwmnFk7yQ5C72gzfecJg05Z8FViqa9a0TieJdOuPJzwaF3XJoql9riQPR7cpExcFwxk7tSvAArFJhJxJ0qDJhDi7kFBDo9XCjVSBw5u7OLEOkT5yS6dCv/wG+WRmLgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=yxZPsIxPbBZxAQRHbKz6JQv92aqGSLAVhz9iyCR72zNrtSEZDD/8sdBXFUVIUlg8q8cq3Nz60IlR1Gp2e7TcV6+htFinDnkGslGbL1h/edwWvv6KV5dmwrIBDYGlYaMPQ0QtCijJ0IRHkCLQQn4cHAy94E8McblhaOHAsSIB5ng= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 12/17] common/device_tree: Add rwlock for dt_host Date: Tue, 11 Apr 2023 12:16:13 -0700 Message-ID: <20230411191636.26926-13-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|BN9PR12MB5257:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c5bf8b1-3ea5-4fb3-321a-08db3ac1561d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QhfFyki35SJbRekBupI7TtH1V3WKYpDwoOfoHKrgY+p0KezPSeQt3siAWShc/QMBXA+1E2Alz5IVPwpto5fOu0pPF3dg1ZSOaysK/53rpx8PXrCDgOKlLGXLzMl8nR5wlJhLoHzmvG5bzi9shRnWClX6oAJRfKsSZqE0A27pLeOMJFcig7YwOd73TTCH37VmFh46V9uY66e3pWOZlm2pVv9ABTpMJaVcnRqtq4BgYqR9JGyCzuZB7H+vxmxoUyKdi97Z+bfAdJJsOVB7yamKBwyS9FLGOG0h8OnvnH8/3VudTqh0TaoRqhhZ/tSALeKw7cxetA1NkG8gKfCuzfpd1NtSfEbHB452W64YVPYrmtr7OrMaw4uga/aqEPeRRmt+eJ6TC1BXum2xBhu0eofYNTIYXg6SROb8t0CxYbPKCVGfqeu9h/XgTaLv5SGd9MTUR/3R8aENWmMrHhHESYCIj9aTFP0KjIV9WgU6hcZ2Ovhx3N6sVjA4W7XY3cwbsif9JTp08qjzIFanvRRZ011vcEKrCxhDKupQ9WbDjejzxoo35ggY0btzTNQDAYe83SgaIc0SH516ef74Kb1MN+zPK+Ozu3pZtoeYCOOPjp4tS+ZqjZjKTs/Pi3VJ7go13Q4q04+vWqTU1Jzarorqoku8E5LYWnFcWulNlnjo1UB6k8qMLAZqBSt3LAjT4QccAqgXz8W3GGqRfz8aLuVruJQvuzgBavv9/PZa4GCONwDeNHg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(40470700004)(36840700001)(46966006)(478600001)(40480700001)(47076005)(36756003)(83380400001)(86362001)(40460700003)(81166007)(356005)(82740400003)(426003)(2616005)(2906002)(316002)(1076003)(336012)(36860700001)(54906003)(44832011)(26005)(186003)(8676002)(8936002)(6666004)(6916009)(82310400005)(41300700001)(5660300002)(70586007)(4326008)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:04.9504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c5bf8b1-3ea5-4fb3-321a-08db3ac1561d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5257 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240650848100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dynamic programming ops will modify the dt_host and there might be other function which are browsing the dt_host at the same time. To avoid the race conditions, adding rwlock for browsing the dt_host during runtime. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 3 +++ xen/drivers/passthrough/device_tree.c | 39 +++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 6 +++++ 3 files changed, 48 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 507b4ac5b6..b330e6a013 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -2098,6 +2098,9 @@ void unflatten_device_tree(const void *fdt, struct dt= _device_node **mynodes) *allnextp =3D NULL; =20 dt_dprintk(" <- unflatten_device_tree()\n"); + + /* Init r/w lock for host device tree. */ + rwlock_init(&dt_host->lock); } =20 static void dt_alias_add(struct dt_alias_prop *ap, diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index a77a217f3d..74f994b9da 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -112,6 +112,8 @@ int iommu_release_dt_devices(struct domain *d) if ( !is_iommu_enabled(d) ) return 0; =20 + read_lock(&dt_host->lock); + list_for_each_entry_safe(dev, _dev, &hd->dt_devices, domain_list) { rc =3D iommu_deassign_dt_device(d, dev); @@ -119,10 +121,14 @@ int iommu_release_dt_devices(struct domain *d) { dprintk(XENLOG_ERR, "Failed to deassign %s in domain %u\n", dt_node_full_name(dev), d->domain_id); + + read_unlock(&dt_host->lock); return rc; } } =20 + read_unlock(&dt_host->lock); + return 0; } =20 @@ -259,11 +265,15 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, =20 spin_lock(&dtdevs_lock); =20 + read_lock(&dt_host->lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) { + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -272,6 +282,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struc= t domain *d, ret =3D xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); if ( ret ) { + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -287,6 +299,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struc= t domain *d, ret =3D -EINVAL; } =20 + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -295,22 +309,31 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, spin_unlock(&dtdevs_lock); =20 if ( d =3D=3D dom_io ) + { + read_unlock(&dt_host->lock); return -EINVAL; + } =20 ret =3D iommu_add_dt_device(dev); if ( ret < 0 ) { printk(XENLOG_G_ERR "Failed to add %s to the IOMMU\n", dt_node_full_name(dev)); + + read_unlock(&dt_host->lock); break; } =20 ret =3D iommu_assign_dt_device(d, dev); =20 if ( ret ) + { printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \"%s\= "" " to dom%u failed (%d)\n", dt_node_full_name(dev), d->domain_id, ret); + } + + read_unlock(&dt_host->lock); break; =20 case XEN_DOMCTL_deassign_device: @@ -322,25 +345,41 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, if ( domctl->u.assign_device.flags ) break; =20 + read_lock(&dt_host->lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) + { + read_unlock(&dt_host->lock); break; + } =20 ret =3D xsm_deassign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); + if ( ret ) + { + read_unlock(&dt_host->lock); break; + } =20 if ( d =3D=3D dom_io ) + { + read_unlock(&dt_host->lock); return -EINVAL; + } =20 ret =3D iommu_deassign_dt_device(d, dev); =20 if ( ret ) + { printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \"%s\= "" " to dom%u failed (%d)\n", dt_node_full_name(dev), d->domain_id, ret); + } + + read_unlock(&dt_host->lock); break; =20 default: diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 998f972ebc..b7272bbccc 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -18,6 +18,7 @@ #include #include #include +#include =20 #define DEVICE_TREE_MAX_DEPTH 16 =20 @@ -106,6 +107,11 @@ struct dt_device_node { struct list_head domain_list; =20 struct device dev; + + /* + * Lock that protects r/w updates to unflattened device tree i.e. dt_h= ost. + */ + rwlock_t lock; }; =20 #define dt_to_dev(dt_node) (&(dt_node)->dev) --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240813; cv=pass; d=zohomail.com; s=zohoarc; b=P6++UQvRolaxSFLnKrhjY43lkVdNv+9k4tRQu+tPv+sibV9bmPoolL0QziXK4ch1/23P7lvue+gVkGrXsRr5tg8eOJ8VHKRRyt7IokA5prrZ/ud+IKGh5B6WWnIU/ZbgTanItZj30yo2uzkZKUAF0if74QPuDoGdWdqY/lSohSs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240813; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=mIaTNcqNz4GflGouwDlIvVjlOLHzhbGgIS75DNdvMyhFI5Xdo0tpCiJtMnvVRxdIot4vM9AypNgU2h3uXfcAwi7aSxdzuiQE4PGyPFKqOv6sOgYPrJfCsuqZfpkosvWtWtzQ8GGlLwM8QQ/1TZK7lt0Qbfsi5R2hjQw+Rr1Iil8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240813426612.4202053070923; Tue, 11 Apr 2023 12:20:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519849.806970 (Exim 4.92) (envelope-from ) id 1pmJX1-0000ZH-HL; Tue, 11 Apr 2023 19:19:55 +0000 Received: by outflank-mailman (output) from mailman id 519849.806970; Tue, 11 Apr 2023 19:19:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJX1-0000Yx-Am; Tue, 11 Apr 2023 19:19:55 +0000 Received: by outflank-mailman (input) for mailman id 519849; Tue, 11 Apr 2023 19:19:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUf-0004Ta-7y for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:29 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20620.outbound.protection.outlook.com [2a01:111:f400:7eb2::620]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7f308f27-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:28 +0200 (CEST) Received: from MW4PR03CA0028.namprd03.prod.outlook.com (2603:10b6:303:8f::33) by CH3PR12MB8996.namprd12.prod.outlook.com (2603:10b6:610:170::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:24 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::e) by MW4PR03CA0028.outlook.office365.com (2603:10b6:303:8f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:20 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:20 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:19 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7f308f27-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=THcWC/giHtyMgrprcuU0OA3pwHxXNMdUgtgLjl6l1LPlqw6WBVt+khXjjWFhmDAgzqUF7UiMdv4dI7KWtb5aoVLa/2a1Y+jNT54qVZqUfaryLTfy3bcXNi4WS7eBXNJQuMazFGshN/GyCG3iZjEDyRotCMcyl8OIon1WyMhHg3d3vSGUw7gPuRUi6ZhWQ8rrE8c/S0AnJjHAENIq/CR2R77j2thE+wXaZMe3J2JXbPoL7aTEG1RQInihHjKdcDSKDJ37nDlLMAnlAfv6ruLrQhgvrW/w4t+/8YX2QUEsp20mea+4gQ/4C9/BJmUWKVscO92M0C/s1VhjpNku0TiJ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=Imta5BSur4SKHpXK1OWAg6ScqRx0I/4QXi5mKvt+7uUc4PMTlrEaF+jP8s2QdCGY3pC2xjOm9jxiv/buyrsEa6FtMTjHl5AAEsMQhlXhltPJXnRQgqUMILcl8g0Q+GKiRz0imGZl257O4n9t9aPcExhjDLkTorHq7p5aL1iMQdjfAnb5iXP8Eyoo4Tr9D7V1xSoxINEhabj8mGrEd2xiU+HEL+/AiZADEq7U5y63LFYzH1pA3M5wx5WcX+fGNnJFMng58wqLLP2z0AQ16WAaoUsa1xOveF6d9rojy4kmPJV9c5NwSpaPoiV4h391VR63Gwy/Mhd9G3UsDszCym8MjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zOQW4Omju1dTUno8ADGoDg+I28lOLIV01naa3ZWrW1o=; b=bVqMaj/2byuHZk9KB58ch3tZUaCTDN6A8dmi21o0MZKHRB5YR1KnXT41/CI674SqlxxK0rfv06M811p4s2tWNoY1hIV3e0C1gugQoMlb6HPEbuMlMZlO0SSLbZL2uzlxhMaMLJrfz0I6wimh4GqV1YGKtSiADK/XtU1PLmOxWl8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" Subject: [XEN][PATCH v5 12/17] common/device_tree: Add rwlock for dt_host Date: Tue, 11 Apr 2023 12:16:31 -0700 Message-ID: <20230411191636.26926-31-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|CH3PR12MB8996:EE_ X-MS-Office365-Filtering-Correlation-Id: a4eb61d8-5ff6-40fc-bc5e-08db3ac16151 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HiPueW2wg3jaIMtd+UEEbXnwFPVrbmrZrGMl75Sfc/2DQnY7SCJkWLuxxLohuemFBARCMfBdCO3U3IKWJOCpKJWbUHFo+lZKF72rRQ7WmHKrCm1nrPV6jU+39VpsKIH783g/qXfZ+K3ys6k/BoC6AbXcd+5EAO5kuDLUKnEbxa5F1k9w4aYebEYTImOag5DUi50X8oVWYwtC0a9bzzVs3n+dhyRWokbof6EQ2XFh+BewN+4alARJcaE8xKzioSXJ9N9UZPKmA3E0SwyqRaZwKi+nl+aFHCaRQoHKW8VmEPfa4lTKVyjhWBQqHjOYmJ5QlKWqPwZQ0ISt1xX6o/1rkW14LZoZPq0kuLNJQ1T9yV4ORenDnYbpjb4/RjLm4gYCHYrdVBObuS/Wo1iGmXMnSQvDA8/Ou9BOAiNvanNo/YWa810hFcOc1vXjS8Zk0YcZFCWQvUHgKn0/NY2JU84vZa+7+HrnLw18HEXqYn3olKpfUyR7OBPzirk2NkSOj3DQLJEjaU8xPB8wyK99m+x2zdYg4rCEj04nDf8IR1hTzrrLXNJIaG4vRYDxhYiBWJWnTavnTYirvpBL0pXGIvTBjuRyGwOe+aezVRNvoS7B3azuwZUVecMvdphTkQbLzOHcF27V5DSQ3qsWVZW7pVi+ePwvhN/npoFLtFZs4P3gtG4TRrxykQl4smaZOcPB/KmFBWmxubxnDS6D2+hoJRabj0hE7dyjPEeZ73+6TLpsBp8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(5660300002)(40460700003)(44832011)(8936002)(26005)(1076003)(40480700001)(6666004)(83380400001)(2906002)(47076005)(36756003)(186003)(426003)(2616005)(336012)(356005)(81166007)(82740400003)(86362001)(82310400005)(36860700001)(478600001)(41300700001)(6916009)(4326008)(70206006)(8676002)(70586007)(316002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:23.7496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4eb61d8-5ff6-40fc-bc5e-08db3ac16151 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8996 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240814508100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dynamic programming ops will modify the dt_host and there might be other function which are browsing the dt_host at the same time. To avoid the race conditions, adding rwlock for browsing the dt_host during runtime. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 3 +++ xen/drivers/passthrough/device_tree.c | 39 +++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 6 +++++ 3 files changed, 48 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 507b4ac5b6..b330e6a013 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -2098,6 +2098,9 @@ void unflatten_device_tree(const void *fdt, struct dt= _device_node **mynodes) *allnextp =3D NULL; =20 dt_dprintk(" <- unflatten_device_tree()\n"); + + /* Init r/w lock for host device tree. */ + rwlock_init(&dt_host->lock); } =20 static void dt_alias_add(struct dt_alias_prop *ap, diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index a77a217f3d..74f994b9da 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -112,6 +112,8 @@ int iommu_release_dt_devices(struct domain *d) if ( !is_iommu_enabled(d) ) return 0; =20 + read_lock(&dt_host->lock); + list_for_each_entry_safe(dev, _dev, &hd->dt_devices, domain_list) { rc =3D iommu_deassign_dt_device(d, dev); @@ -119,10 +121,14 @@ int iommu_release_dt_devices(struct domain *d) { dprintk(XENLOG_ERR, "Failed to deassign %s in domain %u\n", dt_node_full_name(dev), d->domain_id); + + read_unlock(&dt_host->lock); return rc; } } =20 + read_unlock(&dt_host->lock); + return 0; } =20 @@ -259,11 +265,15 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, =20 spin_lock(&dtdevs_lock); =20 + read_lock(&dt_host->lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) { + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -272,6 +282,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struc= t domain *d, ret =3D xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); if ( ret ) { + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -287,6 +299,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struc= t domain *d, ret =3D -EINVAL; } =20 + read_unlock(&dt_host->lock); + spin_unlock(&dtdevs_lock); =20 break; @@ -295,22 +309,31 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, spin_unlock(&dtdevs_lock); =20 if ( d =3D=3D dom_io ) + { + read_unlock(&dt_host->lock); return -EINVAL; + } =20 ret =3D iommu_add_dt_device(dev); if ( ret < 0 ) { printk(XENLOG_G_ERR "Failed to add %s to the IOMMU\n", dt_node_full_name(dev)); + + read_unlock(&dt_host->lock); break; } =20 ret =3D iommu_assign_dt_device(d, dev); =20 if ( ret ) + { printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \"%s\= "" " to dom%u failed (%d)\n", dt_node_full_name(dev), d->domain_id, ret); + } + + read_unlock(&dt_host->lock); break; =20 case XEN_DOMCTL_deassign_device: @@ -322,25 +345,41 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, str= uct domain *d, if ( domctl->u.assign_device.flags ) break; =20 + read_lock(&dt_host->lock); + ret =3D dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path, domctl->u.assign_device.u.dt.size, &dev); if ( ret ) + { + read_unlock(&dt_host->lock); break; + } =20 ret =3D xsm_deassign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev)); + if ( ret ) + { + read_unlock(&dt_host->lock); break; + } =20 if ( d =3D=3D dom_io ) + { + read_unlock(&dt_host->lock); return -EINVAL; + } =20 ret =3D iommu_deassign_dt_device(d, dev); =20 if ( ret ) + { printk(XENLOG_G_ERR "XEN_DOMCTL_assign_dt_device: assign \"%s\= "" " to dom%u failed (%d)\n", dt_node_full_name(dev), d->domain_id, ret); + } + + read_unlock(&dt_host->lock); break; =20 default: diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 998f972ebc..b7272bbccc 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -18,6 +18,7 @@ #include #include #include +#include =20 #define DEVICE_TREE_MAX_DEPTH 16 =20 @@ -106,6 +107,11 @@ struct dt_device_node { struct list_head domain_list; =20 struct device dev; + + /* + * Lock that protects r/w updates to unflattened device tree i.e. dt_h= ost. + */ + rwlock_t lock; }; =20 #define dt_to_dev(dt_node) (&(dt_node)->dev) --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240772; cv=pass; d=zohomail.com; s=zohoarc; b=J4uRwhUiczMzIXDe2ZwV2DGHeXfPMtlJS0Q5CciCO0Q/kznlY6m//dv2kiYk/npxfRM6LU7eid5NYWNF+gf/00ornKnjU/qHowpzA+JKeTmxNFr6/7TXAnT1vP2CFwW159cbvSLl9erYPg2dFCoKmqEA921mbkuDNHBugIxGfCw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240772; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=QhLYhtPZOLIQjXHOj6qNck7A9cZDZeAQwqiJIRqCfgtRTqqYbL1yUgqUdlRFZ6qDlMA4cRX5OOGGUd6NgjhI/RGJvPFgk18JU8k1lq4vWvecuo3RH3ygT/Fh19kXB6WFIPBePhO8F6x4T0ZA921p8OkDUNavDmi79k0LfxLOOHo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240772936692.1507855960808; Tue, 11 Apr 2023 12:19:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519817.806920 (Exim 4.92) (envelope-from ) id 1pmJWL-0006Tw-Jp; Tue, 11 Apr 2023 19:19:13 +0000 Received: by outflank-mailman (output) from mailman id 519817.806920; Tue, 11 Apr 2023 19:19:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWL-0006Td-FF; Tue, 11 Apr 2023 19:19:13 +0000 Received: by outflank-mailman (input) for mailman id 519817; Tue, 11 Apr 2023 19:19:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUe-0004DR-BM for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:28 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7d49f6a6-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:25 +0200 (CEST) Received: from BN9PR03CA0582.namprd03.prod.outlook.com (2603:10b6:408:10d::17) by CH2PR12MB5020.namprd12.prod.outlook.com (2603:10b6:610:65::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28; Tue, 11 Apr 2023 19:17:21 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::82) by BN9PR03CA0582.outlook.office365.com (2603:10b6:408:10d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:21 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:21 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:21 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:21 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:20 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7d49f6a6-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ibWlJlAzJCwMexqfvCpGmZ6XhEB8FJ4xNsD0SrVfgFoEotE23Ikc6A04vt89teQXMdxung1NIw2OB3J1E2TG0a3GkcgUlQwtq/vRkcVfrah6AK4wbnGxM60PLseV0s2c+yhXJgO5639NUb5Fsag58ZU2NVSnu7d1Fvh2Sc2cbQWt5+axFB/n+Tuux5Zchjd5UvLpYz9l+9azgN0KrgVEzk8qkKLxzq7Oav6ibp7NRr96ImmUxP9bkkSIPfbx2q7imNaFiXlWFfz0RbG20pT+5N4aNCeBTMth+tl7C+VljWZNO2y174I6iw9NtHTTQDER+B21Zz0/E/2BOQBkDhpPkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=ZvkD6tuYNHXuUPhrT56khdRe6Ep7R8oju15YD7KJv4EX+T8pUzFXntKFluORwoLvkWGQ2plxbfo22vg3Pq6SFlGdREoKquhLhFtl9XSnfWREcnAnoO9voaEdEZP3eVsIMMvScgIUnqAwW6Oi5ct/pGE3AP/0F3fBB2C2yRlgyNr4bAr6vLE7oFgekcky2j7Er8Y3V8fYSZ1+1AjV+d0si7A5SQMrTvyPTcc45u2RdonItJj0ybJo8sl9tzlgzE9UQFdvQmZ2ORmomNUOZDxkb4wHj0pWGx9P6RALJOZwnwdrLc3bgkA8xJVQKFcg7Jd2OBCDqXlEVR6Y4ygc/lOzbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=CvONxjfIyVRzv3f+Pmw+eh0tckqwwueTCTaLxtMjD31wLOLT4FyuVH5CVvxOyFx9QA2/AAlfmiJMzQKWBrePSawrUDnhNeOgvaWCo2UE1zMR2LTeKWVbhebCFPgiq4WiQ4VUcLiIGu67hq1yV3GJ52XKHwxpwG44HkKZPISip7s= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , "Jan Beulich" , Wei Liu Subject: [XEN][PATCH v5 13/17] xen/arm: Implement device tree node removal functionalities Date: Tue, 11 Apr 2023 12:16:32 -0700 Message-ID: <20230411191636.26926-32-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT020:EE_|CH2PR12MB5020:EE_ X-MS-Office365-Filtering-Correlation-Id: 6086e7bd-38a6-4ddc-2e3f-08db3ac16013 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5EE62jWduwEF8oWuL9B5C/JPyVk+v9e4sC11SOTrWWP4qxhUg/YVbv+PRzWrKGfCPvTY2ebYsCHKlRgYBxEeEgXxQILhwCj0OPERE8r52eSwUCLiTlPWXWeXqw4LyW7Sjnru5/hm2bY0ZW4DnUqbqXJndUY9VGXdwxgoJmtmXdfWnHX0d0vgoltkNFsRa+kC5qwwDkfpyINBZ6cXQ6qztXW/CuzreqH2RZTAk4UkecJ//4hzg9+jMxRWFVdQOfSLDlu1KjiNf7jCb4VPPHdKClS3GpPgCmyUFqB7QFdAHxNekab0fxJBjOw3tyIuTdT9//8GoYVW1wTPAlU+bwUcVQ79sAYukSB6vEqvbLspGDXSNODvvBbRFGoHa7+HLPTLowGoKB1lSCPNdeXwDhyMgedxMFHwqfTQb0b4QLwdingK5nbMCqBm6FyccgRFjTQ665yp7TJayFp9vQqE58lGLjWTttZKJFxaBWY//5moDHA1Bn0bUBem0TdLI7GknKTBJ5n1U3i0RWxPkCeSwO8qF1bm7/PUbECOuEqtWCMexCoYzszeCkEAkvsx8G1IpStAOiuUBlOA3Ml5JUJ2OnTdtaHBKniauYlb9RxURc0ndhHQ1VjXz1148hA+tRD6wTDnIC42ahHxEx4PGUSe1vkA5pBrNE+JNK7JQ12YTU04U0HcEtiFmCdauwN2rxRLlQcn7TPdXuhTFVIX1tdvi21Aiy/KVsnBgK30LF+YzTgI6BWGcQK5488luJvOtM8FPliibbSP4WQXKefS2HhseXVFXg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199021)(40470700004)(46966006)(36840700001)(1076003)(356005)(82740400003)(8936002)(8676002)(4326008)(86362001)(6666004)(5660300002)(6916009)(41300700001)(44832011)(40460700003)(82310400005)(36756003)(316002)(2906002)(30864003)(478600001)(54906003)(70586007)(70206006)(40480700001)(47076005)(83380400001)(26005)(81166007)(186003)(36860700001)(2616005)(336012)(426003)(403724002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:21.7557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6086e7bd-38a6-4ddc-2e3f-08db3ac16013 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5020 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240773207100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce sysctl XEN_SYSCTL_dt_overlay to remove device-tree nodes added us= ing device tree overlay. xl dt-overlay remove file.dtbo: Removes all the nodes in a given dtbo. First, removes IRQ permissions and MMIO accesses. Next, it finds the no= des in dt_host and delete the device node entries from dt_host. The nodes get removed only if it is not used by any of dom0 or domio. Also, added overlay_track struct to keep the track of added node through de= vice tree overlay. overlay_track has dt_host_new which is unflattened form of up= dated fdt and name of overlay nodes. When a node is removed, we also free the mem= ory used by overlay_track for the particular overlay node. Nested overlay removal is supported in sequential manner only i.e. if overlay_child nests under overlay_parent, it is assumed that user first rem= oves overlay_child and then removes overlay_parent. Signed-off-by: Vikram Garhwal --- xen/arch/arm/sysctl.c | 16 +- xen/common/Makefile | 1 + xen/common/dt_overlay.c | 415 +++++++++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 24 ++ xen/include/xen/dt_overlay.h | 59 +++++ 5 files changed, 514 insertions(+), 1 deletion(-) create mode 100644 xen/common/dt_overlay.c create mode 100644 xen/include/xen/dt_overlay.h diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c index b0a78a8b10..672db61650 100644 --- a/xen/arch/arm/sysctl.c +++ b/xen/arch/arm/sysctl.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 void arch_do_physinfo(struct xen_sysctl_physinfo *pi) { @@ -21,7 +22,20 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) long arch_do_sysctl(struct xen_sysctl *sysctl, XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { - return -ENOSYS; + long ret =3D 0; + + switch ( sysctl->cmd ) + { + case XEN_SYSCTL_dt_overlay: + ret =3D dt_sysctl(&sysctl->u.dt_overlay); + break; + + default: + ret =3D -ENOSYS; + break; + } + + return ret; } =20 /* diff --git a/xen/common/Makefile b/xen/common/Makefile index 46049eac35..be78c9a8c2 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device_tree.o obj-$(CONFIG_IOREQ_SERVER) +=3D dm.o obj-y +=3D domain.o +obj-$(CONFIG_OVERLAY_DTB) +=3D dt_overlay.o obj-y +=3D event_2l.o obj-y +=3D event_channel.o obj-y +=3D event_fifo.o diff --git a/xen/common/dt_overlay.c b/xen/common/dt_overlay.c new file mode 100644 index 0000000000..516e8010c5 --- /dev/null +++ b/xen/common/dt_overlay.c @@ -0,0 +1,415 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * xen/common/dt_overlay.c + * + * Device tree overlay support in Xen. + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. All Rights Reserved. + * Written by Vikram Garhwal + * + */ +#include +#include +#include +#include +#include + +static LIST_HEAD(overlay_tracker); +static DEFINE_SPINLOCK(overlay_lock); + +/* Find last descendants of the device_node. */ +static struct dt_device_node *find_last_descendants_node( + struct dt_device_node *device_= node) +{ + struct dt_device_node *child_node; + + for ( child_node =3D device_node->child; child_node->sibling !=3D NULL; + child_node =3D child_node->sibling ) + { + } + + /* If last child_node also have children. */ + if ( child_node->child ) + child_node =3D find_last_descendants_node(child_node); + + return child_node; +} + +static int dt_overlay_remove_node(struct dt_device_node *device_node) +{ + struct dt_device_node *np; + struct dt_device_node *parent_node; + struct dt_device_node *device_node_last_descendant =3D device_node->ch= ild; + + parent_node =3D device_node->parent; + + if ( parent_node =3D=3D NULL ) + { + dt_dprintk("%s's parent node not found\n", device_node->name); + return -EFAULT; + } + + np =3D parent_node->child; + + if ( np =3D=3D NULL ) + { + dt_dprintk("parent node %s's not found\n", parent_node->name); + return -EFAULT; + } + + /* If node to be removed is only child node or first child. */ + if ( !dt_node_cmp(np->full_name, device_node->full_name) ) + { + parent_node->child =3D np->sibling; + + /* + * Iterate over all child nodes of device_node. Given that we are + * removing parent node, we need to remove all it's descendants to= o. + */ + if ( device_node_last_descendant ) + { + device_node_last_descendant =3D + find_last_descendants_node(device_= node); + parent_node->allnext =3D device_node_last_descendant->allnext; + } + else + parent_node->allnext =3D np->allnext; + + return 0; + } + + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np->sib= ling ) + { + if ( !dt_node_cmp(np->sibling->full_name, device_node->full_name) ) + { + /* Found the node. Now we remove it. */ + np->sibling =3D np->sibling->sibling; + + if ( np->child ) + np =3D find_last_descendants_node(np); + + /* + * Iterate over all child nodes of device_node. Given that we = are + * removing parent node, we need to remove all it's descendant= s too. + */ + if ( device_node_last_descendant ) + device_node_last_descendant =3D + find_last_descendants_node(device_= node); + + if ( device_node_last_descendant ) + np->allnext =3D device_node_last_descendant->allnext; + else + np->allnext =3D np->allnext->allnext; + + break; + } + } + + return 0; +} + +/* Basic sanity check for the dtbo tool stack provided to Xen. */ +static int check_overlay_fdt(const void *overlay_fdt, uint32_t overlay_fdt= _size) +{ + if ( (fdt_totalsize(overlay_fdt) !=3D overlay_fdt_size) || + fdt_check_header(overlay_fdt) ) + { + printk(XENLOG_ERR "The overlay FDT is not a valid Flat Device Tree= \n"); + return -EINVAL; + } + + return 0; +} + +/* Count number of nodes till one level of __overlay__ tag. */ +static unsigned int overlay_node_count(void *fdto) +{ + unsigned int num_overlay_nodes =3D 0; + int fragment; + + fdt_for_each_subnode(fragment, fdto, 0) + { + int subnode; + int overlay; + + overlay =3D fdt_subnode_offset(fdto, fragment, "__overlay__"); + + /* + * overlay value can be < 0. But fdt_for_each_subnode() loop check= s for + * overlay >=3D 0. So, no need for a overlay>=3D0 check here. + */ + fdt_for_each_subnode(subnode, fdto, overlay) + { + num_overlay_nodes++; + } + } + + return num_overlay_nodes; +} + +static int handle_remove_irq_iommu(struct dt_device_node *device_node) +{ + int rc =3D 0; + struct domain *d =3D hardware_domain; + domid_t domid; + unsigned int naddr, len; + unsigned int i, nirq; + uint64_t addr, size; + + domid =3D dt_device_used_by(device_node); + + dt_dprintk("Checking if node %s is used by any domain\n", + device_node->full_name); + + /* Remove the node iff it's assigned to domain 0 or domain io. */ + if ( domid !=3D 0 && domid !=3D DOMID_IO ) + { + printk(XENLOG_ERR "Device %s as it is being used by domain %d. Rem= oving nodes failed\n", + device_node->full_name, domid); + return -EINVAL; + } + + dt_dprintk("Removing node: %s\n", device_node->full_name); + + nirq =3D dt_number_of_irq(device_node); + + /* Remove IRQ permission */ + for ( i =3D 0; i < nirq; i++ ) + { + rc =3D platform_get_irq(device_node, i);; + + if ( irq_access_permitted(d, rc) =3D=3D false ) + { + printk(XENLOG_ERR "IRQ %d is not routed to domain %d\n", rc, + domid); + return -EINVAL; + } + /* + * TODO: We don't handle shared IRQs for now. So, it is assumed th= at + * the IRQs was not shared with another devices. + */ + rc =3D irq_deny_access(d, rc); + if ( rc ) + { + printk(XENLOG_ERR "unable to revoke access for irq %u for %s\n= ", + i, device_node->full_name); + return rc; + } + } + + /* Check if iommu property exists. */ + if ( dt_get_property(device_node, "iommus", &len) ) + { + rc =3D iommu_remove_dt_device(device_node); + if ( rc !=3D 0 && rc !=3D -ENXIO ) + return rc; + } + + naddr =3D dt_number_of_address(device_node); + + /* Remove mmio access. */ + for ( i =3D 0; i < naddr; i++ ) + { + rc =3D dt_device_get_address(device_node, i, &addr, &size); + if ( rc ) + { + printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", + i, dt_node_full_name(device_node)); + return rc; + } + + rc =3D iomem_deny_access(d, paddr_to_pfn(addr), + paddr_to_pfn(PAGE_ALIGN(addr + size - 1))); + if ( rc ) + { + printk(XENLOG_ERR "Unable to remove dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + d->domain_id, + addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1); + return rc; + } + + } + + return rc; +} + +/* Removes all descendants of the given node. */ +static int remove_all_descendant_nodes(struct dt_device_node *device_node) +{ + int rc =3D 0; + struct dt_device_node *child_node; + + for ( child_node =3D device_node->child; child_node !=3D NULL; + child_node =3D child_node->sibling ) + { + if ( child_node->child ) + remove_all_descendant_nodes(child_node); + + rc =3D handle_remove_irq_iommu(child_node); + if ( rc ) + return rc; + } + + return rc; +} + +/* Remove nodes from dt_host. */ +static int remove_nodes(const struct overlay_track *tracker) +{ + int rc =3D 0; + struct dt_device_node *overlay_node; + unsigned int j; + + for ( j =3D 0; j < tracker->num_nodes; j++ ) + { + overlay_node =3D (struct dt_device_node *)tracker->nodes_address[j= ]; + if ( overlay_node =3D=3D NULL ) + { + printk(XENLOG_ERR "Device %s is not present in the tree. Remov= ing nodes failed\n", + overlay_node->full_name); + return -EINVAL; + } + + rc =3D remove_all_descendant_nodes(overlay_node); + + /* All children nodes are unmapped. Now remove the node itself. */ + rc =3D handle_remove_irq_iommu(overlay_node); + if ( rc ) + return rc; + + read_lock(&dt_host->lock); + + rc =3D dt_overlay_remove_node(overlay_node); + if ( rc ) + { + read_unlock(&dt_host->lock); + + return rc; + } + + read_unlock(&dt_host->lock); + } + + return rc; +} + +/* + * First finds the device node to remove. Check if the device is being use= d by + * any dom and finally remove it from dt_host. IOMMU is already being take= n care + * while destroying the domain. + */ +static long handle_remove_overlay_nodes(void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc =3D 0; + struct overlay_track *entry, *temp, *track; + bool found_entry =3D false; + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + return rc; + + if ( overlay_node_count(overlay_fdt) =3D=3D 0 ) + return -ENOMEM; + + spin_lock(&overlay_lock); + + /* + * First check if dtbo is correct i.e. it should one of the dtbo which= was + * used when dynamically adding the node. + * Limitation: Cases with same node names but different property are n= ot + * supported currently. We are relying on user to provide the same dtbo + * as it was used when adding the nodes. + */ + list_for_each_entry_safe( entry, temp, &overlay_tracker, entry ) + { + if ( memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) =3D= =3D 0 ) + { + track =3D entry; + found_entry =3D true; + break; + } + } + + if ( found_entry =3D=3D false ) + { + rc =3D -EINVAL; + + printk(XENLOG_ERR "Cannot find any matching tracker with input dtb= o." + " Removing nodes is supported for only prior added dtbo. Pl= ease" + " provide a valid dtbo which was used to add the nodes.\n"); + goto out; + + } + + rc =3D remove_nodes(entry); + + if ( rc ) + { + printk(XENLOG_ERR "Removing node failed\n"); + goto out; + } + + list_del(&entry->entry); + + xfree(entry->dt_host_new); + xfree(entry->fdt); + xfree(entry->overlay_fdt); + + xfree(entry->nodes_address); + + xfree(entry); + +out: + spin_unlock(&overlay_lock); + return rc; +} + +long dt_sysctl(struct xen_sysctl_dt_overlay *op) +{ + long ret; + void *overlay_fdt; + + if ( op->overlay_fdt_size <=3D 0 || op->overlay_fdt_size > KB(500) ) + return -EINVAL; + + overlay_fdt =3D xmalloc_bytes(op->overlay_fdt_size); + + if ( overlay_fdt =3D=3D NULL ) + return -ENOMEM; + + ret =3D copy_from_guest(overlay_fdt, op->overlay_fdt, op->overlay_fdt_= size); + if ( ret ) + { + gprintk(XENLOG_ERR, "copy from guest failed\n"); + xfree(overlay_fdt); + + return -EFAULT; + } + + switch ( op->overlay_op ) + { + case XEN_SYSCTL_DT_OVERLAY_REMOVE: + ret =3D handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_s= ize); + xfree(overlay_fdt); + + break; + + default: + xfree(overlay_fdt); + break; + } + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 2b24d6bfd0..1158c1efb3 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1057,6 +1057,25 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_= policy_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_policy_t); #endif =20 +#if defined(__arm__) || defined (__aarch64__) +#define XEN_SYSCTL_DT_OVERLAY_ADD 1 +#define XEN_SYSCTL_DT_OVERLAY_REMOVE 2 + +/* + * XEN_SYSCTL_dt_overlay + * Performs addition/removal of device tree nodes under parent node using = dtbo. + * This does in three steps: + * - Adds/Removes the nodes from dt_host. + * - Adds/Removes IRQ permission for the nodes. + * - Adds/Removes MMIO accesses. + */ +struct xen_sysctl_dt_overlay { + XEN_GUEST_HANDLE_64(void) overlay_fdt; /* IN: overlay fdt. */ + uint32_t overlay_fdt_size; /* IN: Overlay dtb size. */ + uint8_t overlay_op; /* IN: Add or remove. */ +}; +#endif + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -1087,6 +1106,7 @@ struct xen_sysctl { #define XEN_SYSCTL_livepatch_op 27 /* #define XEN_SYSCTL_set_parameter 28 */ #define XEN_SYSCTL_get_cpu_policy 29 +#define XEN_SYSCTL_dt_overlay 30 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -1117,6 +1137,10 @@ struct xen_sysctl { #if defined(__i386__) || defined(__x86_64__) struct xen_sysctl_cpu_policy cpu_policy; #endif + +#if defined(__arm__) || defined (__aarch64__) + struct xen_sysctl_dt_overlay dt_overlay; +#endif uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/dt_overlay.h b/xen/include/xen/dt_overlay.h new file mode 100644 index 0000000000..2cd975a070 --- /dev/null +++ b/xen/include/xen/dt_overlay.h @@ -0,0 +1,59 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * xen/dt_overlay.h + * + * Device tree overlay support in Xen. + * + * Copyright (c) 2022 AMD Inc. + * Written by Vikram Garhwal + * + */ +#ifndef __XEN_DT_SYSCTL_H__ +#define __XEN_DT_SYSCTL_H__ + +#include +#include +#include +#include + +/* + * overlay_node_track describes information about added nodes through dtbo. + * @entry: List pointer. + * @dt_host_new: Pointer to the updated dt_host_new unflattened 'updated f= dt'. + * @fdt: Stores the fdt. + * @nodes_fullname: Stores the full name of nodes. + * @nodes_irq: Stores the IRQ added from overlay dtb. + * @node_num_irq: Stores num of IRQ for each node in overlay dtb. + * @num_nodes: Stores total number of nodes in overlay dtb. + */ +struct overlay_track { + struct list_head entry; + struct dt_device_node *dt_host_new; + void *fdt; + void *overlay_fdt; + unsigned long *nodes_address; + unsigned int num_nodes; +}; + +struct xen_sysctl_dt_overlay; + +#ifdef CONFIG_OVERLAY_DTB +long dt_sysctl(struct xen_sysctl_dt_overlay *op); +#else +static inline long dt_sysctl(struct xen_sysctl_dt_overlay *op) +{ + return -ENOSYS; +} +#endif +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240658; cv=pass; d=zohomail.com; s=zohoarc; b=JQvYgjP2xEDSX8ApP+zs+MsfV2Xpt0Dz3Jp68zxyMlsGnoX2yM2QjBpiFWzehOHi3VCP+zGwDSY+tkCdwJsgynRKLvOMbt5Ay4f8kI8s8V2S1LZlhRijmngi8HExZnUaNK7T3VX2zRk0DiL5p2pDO6qaBC9/X5eA8jQAN1sR72U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240658; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=dq7HotbSjBGrZFNPkJHHB2r5DMGs7npluPiJTKRf967KSzVQm8+GsutvNYakiCWBeNI6nJZX8577hfS5901hlrbpkkIMKZ1pZRWjx1cH79DS5A/26HmsfMQidxFnYBTsF9y7gSpqqBF5C/4Vrmyngp4+8sR+HfiEGRS5C0gQZgY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240658231143.0307458179534; Tue, 11 Apr 2023 12:17:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519779.806822 (Exim 4.92) (envelope-from ) id 1pmJUS-0007Ds-DN; Tue, 11 Apr 2023 19:17:16 +0000 Received: by outflank-mailman (output) from mailman id 519779.806822; Tue, 11 Apr 2023 19:17:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUR-0007Bc-SA; Tue, 11 Apr 2023 19:17:15 +0000 Received: by outflank-mailman (input) for mailman id 519779; Tue, 11 Apr 2023 19:17:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUO-0004Ta-VA for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:13 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2060f.outbound.protection.outlook.com [2a01:111:f400:7e8d::60f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 75176950-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:11 +0200 (CEST) Received: from BN9PR03CA0140.namprd03.prod.outlook.com (2603:10b6:408:fe::25) by PH7PR12MB6717.namprd12.prod.outlook.com (2603:10b6:510:1b0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Tue, 11 Apr 2023 19:17:06 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::d5) by BN9PR03CA0140.outlook.office365.com (2603:10b6:408:fe::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:06 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.22 via Frontend Transport; Tue, 11 Apr 2023 19:17:06 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:05 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:04 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:04 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75176950-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fcX85IqJccCGBe/QojBYX98xNDGdabmYF+Zf31yQxBGDff6mnyC5036RjUc+vNeCVVM9gONrC9zUraMNMVOWRsNICeIxhzmjMi/dltGM84fA19Tq+ErybnmMlSpZje5r2zPQg3lnZazpNhNAdM+5KVJko8GlumURs0aXbNPQtBIFMvc5llhGsEaw/qXzVis6NlV9143xMNg0CpJBVPElRmu+5InH9K9uWE5t3fT9rokREVUnuFNcgMTf6rhWQ1sZl+Wgl+IiZLHkhAGzRErEIbNamxllm2/jsIyFYUc9TstI8SCMkZdJEQaf9wMixXzJSg03SrL2uwj0docX5gDAEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=EWdxnXZIHj9Q2jeSvYo16U1pFYbKoWoC2fSjscISmOZTKCjofhAH3otiYoq9EgsrwA7oblZnJxGTiwNVcX7lSLiGc3H5bUurk38eDYFOVRNcRk7s2yR/qbQl81SGxhUArMIPYIdeWuA31izTVpMFixl/s4VNKWmWLoN8XrlIId2tCMZ3YYXv66oiVEsbxVGOBOZGyNLdYFbP228nsgbfOrhFqjA1x1NSea8/ftLR42H7zjNHSoEhUa9th3DOONoNPMYD8eHNrxdwBEKR5PGU5RmRmyaxMxcg/OTlGzyesyf3oK3aSKRwHJB54fTKkTTtiXR5njZTFEy61ILRaFryRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vXy30MDq5H9lVjpDCmPPgeX6WY9DS2JY3kC1QKAn9No=; b=TB5K3tBM/Q6w1B75wjMitVnL7DqvAIonQ11xUEnWZ5E17YXNhU7YqMMxdEGzS9TQHnpD1Vsb/aAYnooiZvtNCkXG0+oiVFCsZAdOExBypXdAzv17r9OuhyxrTvcE1HGe9oEfHchBAULwoNvRClZ0Z0aFDHo7aXHqDF6EFdPgq6c= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Julien Grall" , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , "Jan Beulich" , Wei Liu Subject: [XEN][PATCH v5 13/17] xen/arm: Implement device tree node removal functionalities Date: Tue, 11 Apr 2023 12:16:14 -0700 Message-ID: <20230411191636.26926-14-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|PH7PR12MB6717:EE_ X-MS-Office365-Filtering-Correlation-Id: d0188860-8724-4ff4-1c1e-08db3ac156e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ETK2kqVrnWW6vEg7dU542k+8z7yWzf4PQnFPqlH3d7oKxJwQjx69chGqA9JIEedbE0LNWVxNifNQELyLIY0R87SVx+5b+Oekmwp0ETMWwHohlVZVHARguE611aybKX+R+jSUUm94ojGqd4OjisXeErDBqWU9cjnWHMs8ZmqE04qTAYIwSct1FVKl7eAbAiD6KqKORABiFkLCE3JEYLXTmYu0oO/wqQwEawVhzp+ChRYki4iaCE5Q+hT+CfgMn9hi1UMmMD2o+vAETEXv4HFthHlQdZnAxJZ3oYbNLBys9BR5EdWL/O1pHfmKHkEjbTkTC1WnwGcoMFW47DKP14ZDFdl1UFeeQvIsZ8m1ClthAer+yEdf1Tzbh8aspHgjfCjXXztApP3NSNvl6dYhPWR6AV6lW27C7NojPCzisjvsjn2N4w2sjdSBA046RzSXi+2/27ifxkgUhNY1e0BpghcuKuWjbzJ6aWcmMrE8aZwaRgudGzYCk4AqgX7UJLZK+MckPdx6fhtFQUh/S4GpSwWu3IyPapi78woFVIV1YtKesRTEXsU4Vsne6hSVkeHxVjxzPFeAu3a4KoC/52Gfp3FX3rDQfvFHRCeypuyHDGuGz2vFL8kNzTGr0udzCArpmC5/f1I7nv4L6MATLHOP0vh6LoKz7jGorLGWUfg4xhGSs7/+V2keNPsO/X/Pm8OAeUeBDpwO1SFBuOnpkpbwD+kI5rCbxUgdQF0zX+F4ENiuFksxwEUAkCEgwhX8byXjH3Ne5bDJoK6qJZdmMjhZQbgnCw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199021)(36840700001)(46966006)(40470700004)(86362001)(30864003)(186003)(5660300002)(44832011)(426003)(336012)(82310400005)(47076005)(356005)(1076003)(26005)(83380400001)(82740400003)(36860700001)(81166007)(316002)(8936002)(8676002)(54906003)(6666004)(40480700001)(478600001)(40460700003)(2616005)(70586007)(6916009)(70206006)(36756003)(41300700001)(4326008)(2906002)(403724002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:06.3633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0188860-8724-4ff4-1c1e-08db3ac156e4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6717 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240659691100028 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce sysctl XEN_SYSCTL_dt_overlay to remove device-tree nodes added us= ing device tree overlay. xl dt-overlay remove file.dtbo: Removes all the nodes in a given dtbo. First, removes IRQ permissions and MMIO accesses. Next, it finds the no= des in dt_host and delete the device node entries from dt_host. The nodes get removed only if it is not used by any of dom0 or domio. Also, added overlay_track struct to keep the track of added node through de= vice tree overlay. overlay_track has dt_host_new which is unflattened form of up= dated fdt and name of overlay nodes. When a node is removed, we also free the mem= ory used by overlay_track for the particular overlay node. Nested overlay removal is supported in sequential manner only i.e. if overlay_child nests under overlay_parent, it is assumed that user first rem= oves overlay_child and then removes overlay_parent. Signed-off-by: Vikram Garhwal --- xen/arch/arm/sysctl.c | 16 +- xen/common/Makefile | 1 + xen/common/dt_overlay.c | 415 +++++++++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 24 ++ xen/include/xen/dt_overlay.h | 59 +++++ 5 files changed, 514 insertions(+), 1 deletion(-) create mode 100644 xen/common/dt_overlay.c create mode 100644 xen/include/xen/dt_overlay.h diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c index b0a78a8b10..672db61650 100644 --- a/xen/arch/arm/sysctl.c +++ b/xen/arch/arm/sysctl.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 void arch_do_physinfo(struct xen_sysctl_physinfo *pi) { @@ -21,7 +22,20 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) long arch_do_sysctl(struct xen_sysctl *sysctl, XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { - return -ENOSYS; + long ret =3D 0; + + switch ( sysctl->cmd ) + { + case XEN_SYSCTL_dt_overlay: + ret =3D dt_sysctl(&sysctl->u.dt_overlay); + break; + + default: + ret =3D -ENOSYS; + break; + } + + return ret; } =20 /* diff --git a/xen/common/Makefile b/xen/common/Makefile index 46049eac35..be78c9a8c2 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device_tree.o obj-$(CONFIG_IOREQ_SERVER) +=3D dm.o obj-y +=3D domain.o +obj-$(CONFIG_OVERLAY_DTB) +=3D dt_overlay.o obj-y +=3D event_2l.o obj-y +=3D event_channel.o obj-y +=3D event_fifo.o diff --git a/xen/common/dt_overlay.c b/xen/common/dt_overlay.c new file mode 100644 index 0000000000..516e8010c5 --- /dev/null +++ b/xen/common/dt_overlay.c @@ -0,0 +1,415 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * xen/common/dt_overlay.c + * + * Device tree overlay support in Xen. + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. All Rights Reserved. + * Written by Vikram Garhwal + * + */ +#include +#include +#include +#include +#include + +static LIST_HEAD(overlay_tracker); +static DEFINE_SPINLOCK(overlay_lock); + +/* Find last descendants of the device_node. */ +static struct dt_device_node *find_last_descendants_node( + struct dt_device_node *device_= node) +{ + struct dt_device_node *child_node; + + for ( child_node =3D device_node->child; child_node->sibling !=3D NULL; + child_node =3D child_node->sibling ) + { + } + + /* If last child_node also have children. */ + if ( child_node->child ) + child_node =3D find_last_descendants_node(child_node); + + return child_node; +} + +static int dt_overlay_remove_node(struct dt_device_node *device_node) +{ + struct dt_device_node *np; + struct dt_device_node *parent_node; + struct dt_device_node *device_node_last_descendant =3D device_node->ch= ild; + + parent_node =3D device_node->parent; + + if ( parent_node =3D=3D NULL ) + { + dt_dprintk("%s's parent node not found\n", device_node->name); + return -EFAULT; + } + + np =3D parent_node->child; + + if ( np =3D=3D NULL ) + { + dt_dprintk("parent node %s's not found\n", parent_node->name); + return -EFAULT; + } + + /* If node to be removed is only child node or first child. */ + if ( !dt_node_cmp(np->full_name, device_node->full_name) ) + { + parent_node->child =3D np->sibling; + + /* + * Iterate over all child nodes of device_node. Given that we are + * removing parent node, we need to remove all it's descendants to= o. + */ + if ( device_node_last_descendant ) + { + device_node_last_descendant =3D + find_last_descendants_node(device_= node); + parent_node->allnext =3D device_node_last_descendant->allnext; + } + else + parent_node->allnext =3D np->allnext; + + return 0; + } + + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np->sib= ling ) + { + if ( !dt_node_cmp(np->sibling->full_name, device_node->full_name) ) + { + /* Found the node. Now we remove it. */ + np->sibling =3D np->sibling->sibling; + + if ( np->child ) + np =3D find_last_descendants_node(np); + + /* + * Iterate over all child nodes of device_node. Given that we = are + * removing parent node, we need to remove all it's descendant= s too. + */ + if ( device_node_last_descendant ) + device_node_last_descendant =3D + find_last_descendants_node(device_= node); + + if ( device_node_last_descendant ) + np->allnext =3D device_node_last_descendant->allnext; + else + np->allnext =3D np->allnext->allnext; + + break; + } + } + + return 0; +} + +/* Basic sanity check for the dtbo tool stack provided to Xen. */ +static int check_overlay_fdt(const void *overlay_fdt, uint32_t overlay_fdt= _size) +{ + if ( (fdt_totalsize(overlay_fdt) !=3D overlay_fdt_size) || + fdt_check_header(overlay_fdt) ) + { + printk(XENLOG_ERR "The overlay FDT is not a valid Flat Device Tree= \n"); + return -EINVAL; + } + + return 0; +} + +/* Count number of nodes till one level of __overlay__ tag. */ +static unsigned int overlay_node_count(void *fdto) +{ + unsigned int num_overlay_nodes =3D 0; + int fragment; + + fdt_for_each_subnode(fragment, fdto, 0) + { + int subnode; + int overlay; + + overlay =3D fdt_subnode_offset(fdto, fragment, "__overlay__"); + + /* + * overlay value can be < 0. But fdt_for_each_subnode() loop check= s for + * overlay >=3D 0. So, no need for a overlay>=3D0 check here. + */ + fdt_for_each_subnode(subnode, fdto, overlay) + { + num_overlay_nodes++; + } + } + + return num_overlay_nodes; +} + +static int handle_remove_irq_iommu(struct dt_device_node *device_node) +{ + int rc =3D 0; + struct domain *d =3D hardware_domain; + domid_t domid; + unsigned int naddr, len; + unsigned int i, nirq; + uint64_t addr, size; + + domid =3D dt_device_used_by(device_node); + + dt_dprintk("Checking if node %s is used by any domain\n", + device_node->full_name); + + /* Remove the node iff it's assigned to domain 0 or domain io. */ + if ( domid !=3D 0 && domid !=3D DOMID_IO ) + { + printk(XENLOG_ERR "Device %s as it is being used by domain %d. Rem= oving nodes failed\n", + device_node->full_name, domid); + return -EINVAL; + } + + dt_dprintk("Removing node: %s\n", device_node->full_name); + + nirq =3D dt_number_of_irq(device_node); + + /* Remove IRQ permission */ + for ( i =3D 0; i < nirq; i++ ) + { + rc =3D platform_get_irq(device_node, i);; + + if ( irq_access_permitted(d, rc) =3D=3D false ) + { + printk(XENLOG_ERR "IRQ %d is not routed to domain %d\n", rc, + domid); + return -EINVAL; + } + /* + * TODO: We don't handle shared IRQs for now. So, it is assumed th= at + * the IRQs was not shared with another devices. + */ + rc =3D irq_deny_access(d, rc); + if ( rc ) + { + printk(XENLOG_ERR "unable to revoke access for irq %u for %s\n= ", + i, device_node->full_name); + return rc; + } + } + + /* Check if iommu property exists. */ + if ( dt_get_property(device_node, "iommus", &len) ) + { + rc =3D iommu_remove_dt_device(device_node); + if ( rc !=3D 0 && rc !=3D -ENXIO ) + return rc; + } + + naddr =3D dt_number_of_address(device_node); + + /* Remove mmio access. */ + for ( i =3D 0; i < naddr; i++ ) + { + rc =3D dt_device_get_address(device_node, i, &addr, &size); + if ( rc ) + { + printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", + i, dt_node_full_name(device_node)); + return rc; + } + + rc =3D iomem_deny_access(d, paddr_to_pfn(addr), + paddr_to_pfn(PAGE_ALIGN(addr + size - 1))); + if ( rc ) + { + printk(XENLOG_ERR "Unable to remove dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + d->domain_id, + addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1); + return rc; + } + + } + + return rc; +} + +/* Removes all descendants of the given node. */ +static int remove_all_descendant_nodes(struct dt_device_node *device_node) +{ + int rc =3D 0; + struct dt_device_node *child_node; + + for ( child_node =3D device_node->child; child_node !=3D NULL; + child_node =3D child_node->sibling ) + { + if ( child_node->child ) + remove_all_descendant_nodes(child_node); + + rc =3D handle_remove_irq_iommu(child_node); + if ( rc ) + return rc; + } + + return rc; +} + +/* Remove nodes from dt_host. */ +static int remove_nodes(const struct overlay_track *tracker) +{ + int rc =3D 0; + struct dt_device_node *overlay_node; + unsigned int j; + + for ( j =3D 0; j < tracker->num_nodes; j++ ) + { + overlay_node =3D (struct dt_device_node *)tracker->nodes_address[j= ]; + if ( overlay_node =3D=3D NULL ) + { + printk(XENLOG_ERR "Device %s is not present in the tree. Remov= ing nodes failed\n", + overlay_node->full_name); + return -EINVAL; + } + + rc =3D remove_all_descendant_nodes(overlay_node); + + /* All children nodes are unmapped. Now remove the node itself. */ + rc =3D handle_remove_irq_iommu(overlay_node); + if ( rc ) + return rc; + + read_lock(&dt_host->lock); + + rc =3D dt_overlay_remove_node(overlay_node); + if ( rc ) + { + read_unlock(&dt_host->lock); + + return rc; + } + + read_unlock(&dt_host->lock); + } + + return rc; +} + +/* + * First finds the device node to remove. Check if the device is being use= d by + * any dom and finally remove it from dt_host. IOMMU is already being take= n care + * while destroying the domain. + */ +static long handle_remove_overlay_nodes(void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc =3D 0; + struct overlay_track *entry, *temp, *track; + bool found_entry =3D false; + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + return rc; + + if ( overlay_node_count(overlay_fdt) =3D=3D 0 ) + return -ENOMEM; + + spin_lock(&overlay_lock); + + /* + * First check if dtbo is correct i.e. it should one of the dtbo which= was + * used when dynamically adding the node. + * Limitation: Cases with same node names but different property are n= ot + * supported currently. We are relying on user to provide the same dtbo + * as it was used when adding the nodes. + */ + list_for_each_entry_safe( entry, temp, &overlay_tracker, entry ) + { + if ( memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) =3D= =3D 0 ) + { + track =3D entry; + found_entry =3D true; + break; + } + } + + if ( found_entry =3D=3D false ) + { + rc =3D -EINVAL; + + printk(XENLOG_ERR "Cannot find any matching tracker with input dtb= o." + " Removing nodes is supported for only prior added dtbo. Pl= ease" + " provide a valid dtbo which was used to add the nodes.\n"); + goto out; + + } + + rc =3D remove_nodes(entry); + + if ( rc ) + { + printk(XENLOG_ERR "Removing node failed\n"); + goto out; + } + + list_del(&entry->entry); + + xfree(entry->dt_host_new); + xfree(entry->fdt); + xfree(entry->overlay_fdt); + + xfree(entry->nodes_address); + + xfree(entry); + +out: + spin_unlock(&overlay_lock); + return rc; +} + +long dt_sysctl(struct xen_sysctl_dt_overlay *op) +{ + long ret; + void *overlay_fdt; + + if ( op->overlay_fdt_size <=3D 0 || op->overlay_fdt_size > KB(500) ) + return -EINVAL; + + overlay_fdt =3D xmalloc_bytes(op->overlay_fdt_size); + + if ( overlay_fdt =3D=3D NULL ) + return -ENOMEM; + + ret =3D copy_from_guest(overlay_fdt, op->overlay_fdt, op->overlay_fdt_= size); + if ( ret ) + { + gprintk(XENLOG_ERR, "copy from guest failed\n"); + xfree(overlay_fdt); + + return -EFAULT; + } + + switch ( op->overlay_op ) + { + case XEN_SYSCTL_DT_OVERLAY_REMOVE: + ret =3D handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_s= ize); + xfree(overlay_fdt); + + break; + + default: + xfree(overlay_fdt); + break; + } + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 2b24d6bfd0..1158c1efb3 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1057,6 +1057,25 @@ typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_= policy_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_policy_t); #endif =20 +#if defined(__arm__) || defined (__aarch64__) +#define XEN_SYSCTL_DT_OVERLAY_ADD 1 +#define XEN_SYSCTL_DT_OVERLAY_REMOVE 2 + +/* + * XEN_SYSCTL_dt_overlay + * Performs addition/removal of device tree nodes under parent node using = dtbo. + * This does in three steps: + * - Adds/Removes the nodes from dt_host. + * - Adds/Removes IRQ permission for the nodes. + * - Adds/Removes MMIO accesses. + */ +struct xen_sysctl_dt_overlay { + XEN_GUEST_HANDLE_64(void) overlay_fdt; /* IN: overlay fdt. */ + uint32_t overlay_fdt_size; /* IN: Overlay dtb size. */ + uint8_t overlay_op; /* IN: Add or remove. */ +}; +#endif + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -1087,6 +1106,7 @@ struct xen_sysctl { #define XEN_SYSCTL_livepatch_op 27 /* #define XEN_SYSCTL_set_parameter 28 */ #define XEN_SYSCTL_get_cpu_policy 29 +#define XEN_SYSCTL_dt_overlay 30 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -1117,6 +1137,10 @@ struct xen_sysctl { #if defined(__i386__) || defined(__x86_64__) struct xen_sysctl_cpu_policy cpu_policy; #endif + +#if defined(__arm__) || defined (__aarch64__) + struct xen_sysctl_dt_overlay dt_overlay; +#endif uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/dt_overlay.h b/xen/include/xen/dt_overlay.h new file mode 100644 index 0000000000..2cd975a070 --- /dev/null +++ b/xen/include/xen/dt_overlay.h @@ -0,0 +1,59 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * xen/dt_overlay.h + * + * Device tree overlay support in Xen. + * + * Copyright (c) 2022 AMD Inc. + * Written by Vikram Garhwal + * + */ +#ifndef __XEN_DT_SYSCTL_H__ +#define __XEN_DT_SYSCTL_H__ + +#include +#include +#include +#include + +/* + * overlay_node_track describes information about added nodes through dtbo. + * @entry: List pointer. + * @dt_host_new: Pointer to the updated dt_host_new unflattened 'updated f= dt'. + * @fdt: Stores the fdt. + * @nodes_fullname: Stores the full name of nodes. + * @nodes_irq: Stores the IRQ added from overlay dtb. + * @node_num_irq: Stores num of IRQ for each node in overlay dtb. + * @num_nodes: Stores total number of nodes in overlay dtb. + */ +struct overlay_track { + struct list_head entry; + struct dt_device_node *dt_host_new; + void *fdt; + void *overlay_fdt; + unsigned long *nodes_address; + unsigned int num_nodes; +}; + +struct xen_sysctl_dt_overlay; + +#ifdef CONFIG_OVERLAY_DTB +long dt_sysctl(struct xen_sysctl_dt_overlay *op); +#else +static inline long dt_sysctl(struct xen_sysctl_dt_overlay *op) +{ + return -ENOSYS; +} +#endif +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240811; cv=pass; d=zohomail.com; s=zohoarc; b=Hf5PfZn9Oh+BZEBxaKImI2uSfiSVHyl6KFaxL58890Cta0OLsRJ+2q2BtLkb/Sdo8kS90zuFo+jinLaxVcOGWVeF2gc2JfoMpgYKhEKs8A8J7RR4xUc8XFHEpzggxGa+PReqS4xXyMu9GWfh5gVY1MgB3aa7/WPje8jecb4JW0I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240811; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=Wd2NH7qGGi1Bla4QPAVQABDnz648eNDKXNPofiZh/JAt7jOf8t7LyvmuCMOp/q4HK4aOS395o16Pbi3HlnzxNlVBw6AeiPGC2tOxEw2bVmBIpDsK+z0n1ELK8YLcTIhVo75coTpGv3D/18YX0gZXd1fgZSQxKWbBoc1A6tB45xs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240811854629.7677234027364; Tue, 11 Apr 2023 12:20:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519837.806936 (Exim 4.92) (envelope-from ) id 1pmJWv-0007rh-Cz; Tue, 11 Apr 2023 19:19:49 +0000 Received: by outflank-mailman (output) from mailman id 519837.806936; Tue, 11 Apr 2023 19:19:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJWv-0007qt-87; Tue, 11 Apr 2023 19:19:49 +0000 Received: by outflank-mailman (input) for mailman id 519837; Tue, 11 Apr 2023 19:19:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUi-0004DR-CQ for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:32 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062f.outbound.protection.outlook.com [2a01:111:f400:7eab::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7f2d845c-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:28 +0200 (CEST) Received: from BN7PR02CA0013.namprd02.prod.outlook.com (2603:10b6:408:20::26) by DS7PR12MB6216.namprd12.prod.outlook.com (2603:10b6:8:94::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:17:23 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::c5) by BN7PR02CA0013.outlook.office365.com (2603:10b6:408:20::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:22 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:22 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:21 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7f2d845c-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QhVPwCHPBd0JqSv8CuQhxwh7IwEIlkz5sDOLIQoApkzz+fDG8H3ckb4RW2xe1A6GP/beE8nO6wLtzAfmVAyjvSEv2yKsT7X+dfjcEwyALwDkIEhJAaKQZNX+pgRXCcjHm6Yin/4G23Ar6Q41WxmcDxfHNDTh/1Ms2OU0xsm3CVtBRAY8uJLCCESO+dJRTRscHO2zUrsIPhhkEH6KlXV/jTocmaVYYctPPU1yKmmLKLnJFmlUUMT0x91+KDsGYQ5Hka3GEgFsMbgufym9BD8yAGDjMe8JeSxwjtdUgvpw2JpgbCsQy0UnwCaWBvxlQy1lg51N0sYsqW3S04xY8X5LBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=Kk7BuBTpE4tduXmrudfAI3Fo4DlKtKQFO3HrA+7ZlGTSCCpxvej7ika47IqM43+1FbEWwyXZAN0zQYxGhiTLgzHGAIdG89qtx4uPv6WBCRXaA0qt4RGCFNXIVCOVCrBA21Q3kNWn5ngbSH21DEqmfMnDx4uIdXm9N8fc/NAQbO4rLgoEX/4EX2So76MrlEV7zdBrE8evE9WcbLGW2KXgDXOka9w35ts4fUs3Ri6xQLUFcfRgK0UO/7Yppxwp3iZyC2/WqcOYiG8vPXG5bdOsp6fxc+G71x7n/cL5kr7OA/aY0KMQjMLNIOx6oyX5/IG4wpdxDV9YdOHEcfO6W9bO2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=QNeE23U21k2usTifMLPD62BNgxvVZhA1lzql9jc0s5JylFMBCkzq4iQprqGL78CJ8RdIwnwc0qLcCfZpRiTemKXkCSCsmFk+Pz6uya/t5QSBl1iXjj8zvEYXONR3FW93AGTHvk9wsBr1pXtR3BNbF+27jLtYwEfB1QvFIvGHKyw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Andrew Cooper" , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN][PATCH v5 14/17] xen/arm: Implement device tree node addition functionalities Date: Tue, 11 Apr 2023 12:16:33 -0700 Message-ID: <20230411191636.26926-33-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT012:EE_|DS7PR12MB6216:EE_ X-MS-Office365-Filtering-Correlation-Id: c115fdb8-a23b-44d5-3ea3-08db3ac160a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 25OgTU+pwi5Jek33LVmE9JLfv8q5jD3oVUA3yVVaKNM7y4JUV6U0EqP4k8B+1MCK9P2rVG/cY6Xdxlc9CiJCU8cSMFjnmRNdZ/WiZKy69MqXz4Jr0JayAYLw71fqiLZFzv1XlMO9hwvnQXPGh7I777aHghv9JNlvkkEes6o0qIk8MWIGGHe3+TjCfJpVbSz9IgAlptmWDajNadmQS9KwOIAshXbip0Jdhh9duBUDk3G0QVfKEIl3oYixSyO/WtTfeOhqf0PvoyDz3zTh9vdddKsNvZBVzHZD4FvZgvRIYt4P1pNTGkmiA6XN4vbXAtIxbL1zoXZJIUIIIYG0oyR+qa9ZoUC49zx7cDbG3Q1DtmcxFdApJ0aRXVOneqs9ikfEpQhKQowPwC04jy5QZ/OeZJoFmIpUc6vqCNSuTnxvS0Cf9bzBhA6H6mAcmLRYD1G1MSlaZuGlp+HyVNoceftO04G4vaOJ6VDfpU/TbzW8sSSfh9j4uCe5yWxZ5jfC1FOHCFSx/6XX/geZ2Sz4tIpWNY9XQ7FyC+cEhKZgNSGDCZzYVja4g381K1I/vE9Zk/LqPnMRreG8vnIU+flRUY5glwi4RqcqoJgX23ZHZw1ymY6iE/RRrRgfANX4HBGZveF7gYtuDyQjnVnV3EewXF2gXxt+BVPvJt6TcBaWWe/3ye0DVO6bPnPKcTClCMh/+g8BW5YSk+vdB2vAbRHiN8vq3zjGaNCtbz5hvRqBXpG6N20= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199021)(46966006)(40470700004)(36840700001)(478600001)(83380400001)(86362001)(40460700003)(40480700001)(36756003)(82740400003)(81166007)(356005)(47076005)(36860700001)(336012)(2616005)(426003)(30864003)(2906002)(1076003)(26005)(316002)(54906003)(186003)(44832011)(5660300002)(82310400005)(8676002)(6666004)(6916009)(8936002)(41300700001)(4326008)(70586007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:22.6958 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c115fdb8-a23b-44d5-3ea3-08db3ac160a0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6216 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240813399100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update sysctl XEN_SYSCTL_dt_overlay to enable support for dtbo nodes additi= on using device tree overlay. xl dt-overlay add file.dtbo: Each time overlay nodes are added using .dtbo, a new fdt(memcpy of device_tree_flattened) is created and updated with overlay nodes. This updated fdt is further unflattened to a dt_host_new. Next, it checks if= any of the overlay nodes already exists in the dt_host. If overlay nodes do= esn't exist then find the overlay nodes in dt_host_new, find the overlay node= 's parent in dt_host and add the nodes as child under their parent in the dt_host. The node is attached as the last node under target parent. Finally, add IRQs, add device to IOMMUs, set permissions and map MMIO f= or the overlay node. When a node is added using overlay, a new entry is allocated in the overlay_track to keep the track of memory allocation due to addition of ove= rlay node. This is helpful for freeing the memory allocated when a device tree n= ode is removed. The main purpose of this to address first part of dynamic programming i.e. making xen aware of new device tree node which means updating the dt_host w= ith overlay node information. Here we are adding/removing node from dt_host, and checking/setting IOMMU and IRQ permission but never mapping them to any dom= ain. Right now, mapping/Un-mapping will happen only when a new domU is created/destroyed using "xl create". Signed-off-by: Vikram Garhwal --- xen/common/dt_overlay.c | 482 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 482 insertions(+) diff --git a/xen/common/dt_overlay.c b/xen/common/dt_overlay.c index 516e8010c5..3344bad313 100644 --- a/xen/common/dt_overlay.c +++ b/xen/common/dt_overlay.c @@ -36,6 +36,25 @@ static struct dt_device_node *find_last_descendants_node( return child_node; } =20 +/* + * Returns next node to the input node. If node has children then return + * last descendant's next node. +*/ +static struct dt_device_node *dt_find_next_node(struct dt_device_node *dt, + const struct dt_device_node *n= ode) +{ + struct dt_device_node *np; + + dt_for_each_device_node(dt, np) + if ( np =3D=3D node ) + break; + + if ( np->child ) + np =3D find_last_descendants_node(np); + + return np->allnext; +} + static int dt_overlay_remove_node(struct dt_device_node *device_node) { struct dt_device_node *np; @@ -109,6 +128,72 @@ static int dt_overlay_remove_node(struct dt_device_nod= e *device_node) return 0; } =20 +static int dt_overlay_add_node(struct dt_device_node *device_node, + const char *parent_node_path) +{ + struct dt_device_node *parent_node; + struct dt_device_node *np, *np_last_descendant; + struct dt_device_node *next_node; + struct dt_device_node *device_node_last_descendant; + + parent_node =3D dt_find_node_by_path(parent_node_path); + + if ( parent_node =3D=3D NULL ) + { + dt_dprintk("Node not found. Overlay node will not be added\n"); + return -EINVAL; + } + + /* If parent has no child. */ + if ( parent_node->child =3D=3D NULL ) + { + next_node =3D parent_node->allnext; + device_node->parent =3D parent_node; + parent_node->allnext =3D device_node; + parent_node->child =3D device_node; + } + else + { + /* If parent has at least one child node. + * Iterate to the last child node of parent. + */ + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np-= >sibling ); + + /* Iterate over all child nodes of np node. */ + if ( np->child ) + { + np_last_descendant =3D find_last_descendants_node(np); + + next_node =3D np_last_descendant->allnext; + np_last_descendant->allnext =3D device_node; + } + else + { + next_node =3D np->allnext; + np->allnext =3D device_node; + } + + device_node->parent =3D parent_node; + np->sibling =3D device_node; + np->sibling->sibling =3D NULL; + } + + /* Iterate over all child nodes of device_node to add children too. */ + if ( device_node->child ) + { + device_node_last_descendant =3D find_last_descendants_node(device_= node); + /* Plug next_node at the end of last children of device_node. */ + device_node_last_descendant->allnext =3D next_node; + } + else + { + /* Now plug next_node at the end of device_node. */ + device_node->allnext =3D next_node; + } + + return 0; +} + /* Basic sanity check for the dtbo tool stack provided to Xen. */ static int check_overlay_fdt(const void *overlay_fdt, uint32_t overlay_fdt= _size) { @@ -148,6 +233,79 @@ static unsigned int overlay_node_count(void *fdto) return num_overlay_nodes; } =20 +/* + * overlay_get_nodes_info will get full name with path for all the nodes w= hich + * are in one level of __overlay__ tag. This is useful when checking node = for + * duplication i.e. dtbo tries to add nodes which already exists in device= tree. + */ +static int overlay_get_nodes_info(const void *fdto, char ***nodes_full_pat= h, + unsigned int num_overlay_nodes) +{ + int fragment; + + *nodes_full_path =3D xzalloc_bytes(num_overlay_nodes * sizeof(char *)); + + if ( *nodes_full_path =3D=3D NULL ) + return -ENOMEM; + + fdt_for_each_subnode(fragment, fdto, 0) + { + int target; + int overlay; + int subnode; + const char *target_path; + + target =3D fdt_overlay_target_offset(device_tree_flattened, fdto, + fragment, &target_path); + if ( target < 0 ) + return target; + + overlay =3D fdt_subnode_offset(fdto, fragment, "__overlay__"); + + /* + * overlay value can be < 0. But fdt_for_each_subnode() loop check= s for + * overlay >=3D 0. So, no need for a overlay>=3D0 check here. + */ + fdt_for_each_subnode(subnode, fdto, overlay) + { + const char *node_name =3D NULL; + int node_name_len; + unsigned int target_path_len =3D strlen(target_path); + unsigned int node_full_name_len; + unsigned int node_num =3D 0; + + node_name =3D fdt_get_name(fdto, subnode, &node_name_len); + + if ( node_name =3D=3D NULL ) + return node_name_len; + + /* + * Magic number 2 is for adding '/'. This is done to keep the + * node_full_name in the correct full node name format. + */ + node_full_name_len =3D target_path_len + node_name_len + 2; + + (*nodes_full_path)[node_num] =3D xmalloc_bytes(node_full_name_= len); + + if ( (*nodes_full_path)[node_num] =3D=3D NULL ) + return -ENOMEM; + + memcpy((*nodes_full_path)[node_num], target_path, target_path_= len); + + (*nodes_full_path)[node_num][target_path_len] =3D '/'; + + memcpy((*nodes_full_path)[node_num] + target_path_len + 1, + node_name, node_name_len); + + (*nodes_full_path)[node_num][node_full_name_len - 1] =3D '\0'; + + node_num++; + } + } + + return 0; +} + static int handle_remove_irq_iommu(struct dt_device_node *device_node) { int rc =3D 0; @@ -367,6 +525,322 @@ out: return rc; } =20 +/* + * Handles IRQ and IOMMU mapping for the overlay_node and all descendants = of the + * overlay_nodes. + */ +static int handle_add_irq_iommu(struct domain *d, + struct dt_device_node *overlay_node) +{ + int rc; + unsigned int naddr, i, len; + uint64_t addr, size; + struct dt_device_node *np; + + /* First let's handle the interrupts. */ + rc =3D handle_device_interrupts(d, overlay_node, false); + if ( rc < 0 ) + { + printk(XENLOG_ERR "Interrupt failed\n"); + return rc; + } + + /* Check if iommu property exists. */ + if ( dt_get_property(overlay_node, "iommus", &len) ) + { + + /* Add device to IOMMUs. */ + rc =3D iommu_add_dt_device(overlay_node); + if ( rc < 0 ) + { + printk(XENLOG_ERR "Failed to add %s to the IOMMU\n", + dt_node_full_name(overlay_node)); + return rc; + } + } + + /* Set permissions. */ + naddr =3D dt_number_of_address(overlay_node); + + dt_dprintk("%s passthrough =3D %d naddr =3D %u\n", + dt_node_full_name(overlay_node), false, naddr); + + /* Give permission for map MMIOs */ + for ( i =3D 0; i < naddr; i++ ) + { + /* + * For now, we skip_mapping which means it will only permit iomem = access + * to hardware_domain using iomem_permit_access() but will never m= ap as + * map_range_p2mt() will not be called. + */ + struct map_range_data mr_data =3D { .d =3D d, + .p2mt =3D p2m_mmio_direct_c, + .skip_mapping =3D true }; + + rc =3D dt_device_get_address(overlay_node, i, &addr, &size); + if ( rc ) + { + printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", + i, dt_node_full_name(overlay_node)); + return rc; + } + + rc =3D map_range_to_domain(overlay_node, addr, size, &mr_data); + if ( rc ) + return rc; + } + + /* Map IRQ and IOMMU for overlay_node's children. */ + for ( np =3D overlay_node->child; np !=3D NULL; np =3D np->sibling) + { + rc =3D handle_add_irq_iommu(d, np); + if ( rc ) + { + printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + return rc; + } + } + + return rc; +} + +/* + * Adds device tree nodes under target node. + * We use tr->dt_host_new to unflatten the updated device_tree_flattened. = This + * is done to avoid the removal of device_tree generation, iomem regions m= apping + * to hardware domain done by handle_node(). + */ +static long handle_add_overlay_nodes(void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc, j, i; + struct dt_device_node *overlay_node, *prev_node, *next_node; + struct domain *d =3D hardware_domain; + struct overlay_track *tr =3D NULL; + char **nodes_full_path =3D NULL; + unsigned int new_fdt_size; + + tr =3D xzalloc(struct overlay_track); + if ( tr =3D=3D NULL ) + return -ENOMEM; + + new_fdt_size =3D fdt_totalsize(device_tree_flattened) + + fdt_totalsize(overlay_fdt); + + tr->fdt =3D xzalloc_bytes(new_fdt_size); + if ( tr->fdt =3D=3D NULL ) + { + xfree(tr); + return -ENOMEM; + } + + tr->num_nodes =3D overlay_node_count(overlay_fdt); + if ( tr->num_nodes =3D=3D 0 ) + { + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + tr->nodes_address =3D xzalloc_bytes(tr->num_nodes * sizeof(unsigned lo= ng)); + if ( tr->nodes_address =3D=3D NULL ) + { + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + { + xfree(tr->nodes_address); + xfree(tr->fdt); + xfree(tr); + return rc; + } + + /* + * Keep a copy of overlay_fdt as fdt_overlay_apply will change the inp= ut + * overlay's content(magic) when applying overlay. + */ + tr->overlay_fdt =3D xzalloc_bytes(overlay_fdt_size); + if ( tr->overlay_fdt =3D=3D NULL ) + { + xfree(tr->nodes_address); + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + memcpy(tr->overlay_fdt, overlay_fdt, overlay_fdt_size); + + spin_lock(&overlay_lock); + + memcpy(tr->fdt, device_tree_flattened, + fdt_totalsize(device_tree_flattened)); + + /* Open tr->fdt with more space to accommodate the overlay_fdt. */ + fdt_open_into(tr->fdt, tr->fdt, new_fdt_size); + + /* + * overlay_get_nodes_info is called to get the node information from d= tbo. + * This is done before fdt_overlay_apply() because the overlay apply w= ill + * erase the magic of overlay_fdt. + */ + rc =3D overlay_get_nodes_info(overlay_fdt, &nodes_full_path, + tr->num_nodes); + if ( rc ) + { + printk(XENLOG_ERR "Getting nodes information failed with error %d\= n", + rc); + goto err; + } + + rc =3D fdt_overlay_apply(tr->fdt, overlay_fdt); + if ( rc ) + { + printk(XENLOG_ERR "Adding overlay node failed with error %d\n", rc= ); + goto err; + } + + /* + * Check if any of the node already exists in dt_host. If node already= exits + * we can return here as this overlay_fdt is not suitable for overlay = ops. + */ + for ( j =3D 0; j < tr->num_nodes; j++ ) + { + overlay_node =3D dt_find_node_by_path(nodes_full_path[j]); + if ( overlay_node !=3D NULL ) + { + printk(XENLOG_ERR "node %s exists in device tree\n", + nodes_full_path[j]); + rc =3D -EINVAL; + goto err; + } + } + + /* Unflatten the tr->fdt into a new dt_host. */ + unflatten_device_tree(tr->fdt, &tr->dt_host_new); + + for ( j =3D 0; j < tr->num_nodes; j++ ) + { + dt_dprintk("Adding node: %s\n", nodes_full_path[j]); + + /* Find the newly added node in tr->dt_host_new by it's full path.= */ + overlay_node =3D device_tree_find_node_by_path(tr->dt_host_new, + nodes_full_path[j]); + if ( overlay_node =3D=3D NULL ) + { + dt_dprintk("%s node not found\n", nodes_full_path[j]); + rc =3D -EFAULT; + goto remove_node; + } + + /* + * Find previous and next node to overlay_node in dt_host_new. We = will + * need these nodes to fix the dt_host_new mapping. When overlay_n= ode is + * take out of dt_host_new tree and added to dt_host, link between + * previous node and next_node is broken. We will need to refresh + * dt_host_new with correct linking for any other overlay nodes + * extraction in future. + */ + dt_for_each_device_node(tr->dt_host_new, prev_node) + if ( prev_node->allnext =3D=3D overlay_node ) + break; + + next_node =3D dt_find_next_node(tr->dt_host_new, overlay_node); + + read_lock(&dt_host->lock); + + /* Add the node to dt_host. */ + rc =3D dt_overlay_add_node(overlay_node, overlay_node->parent->ful= l_name); + if ( rc ) + { + read_unlock(&dt_host->lock); + + /* Node not added in dt_host. */ + goto remove_node; + } + + read_unlock(&dt_host->lock); + + prev_node->allnext =3D next_node; + + overlay_node =3D dt_find_node_by_path(overlay_node->full_name); + if ( overlay_node =3D=3D NULL ) + { + /* Sanity check. But code will never come here. */ + ASSERT_UNREACHABLE(); + goto remove_node; + } + + rc =3D handle_add_irq_iommu(d, overlay_node); + if ( rc ) + { + printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + return rc; + } + + /* Keep overlay_node address in tracker. */ + tr->nodes_address[j] =3D (unsigned long)overlay_node; + } + + INIT_LIST_HEAD(&tr->entry); + list_add_tail(&tr->entry, &overlay_tracker); + + spin_unlock(&overlay_lock); + + if ( nodes_full_path !=3D NULL ) + { + for ( i =3D 0; i < tr->num_nodes && nodes_full_path[i] !=3D NULL; + i++ ) + { + xfree(nodes_full_path[i]); + } + xfree(nodes_full_path); + } + + return rc; + +/* + * Failure case. We need to remove the nodes, free tracker(if tr exists) a= nd + * tr->dt_host_new. + */ +remove_node: + tr->num_nodes =3D j; + rc =3D remove_nodes(tr); + + if ( rc ) + { + /* If removing node fails, this may cause memory leaks. */ + printk(XENLOG_ERR "Removing node failed.\n"); + spin_unlock(&overlay_lock); + return rc; + } + +err: + spin_unlock(&overlay_lock); + + xfree(tr->dt_host_new); + xfree(tr->fdt); + xfree(tr->overlay_fdt); + xfree(tr->nodes_address); + + if ( nodes_full_path !=3D NULL ) + { + for ( i =3D 0; i < tr->num_nodes && nodes_full_path[i] !=3D NULL; + i++ ) + { + xfree(nodes_full_path[i]); + } + xfree(nodes_full_path); + } + + xfree(tr); + + return rc; +} + long dt_sysctl(struct xen_sysctl_dt_overlay *op) { long ret; @@ -391,6 +865,14 @@ long dt_sysctl(struct xen_sysctl_dt_overlay *op) =20 switch ( op->overlay_op ) { + case XEN_SYSCTL_DT_OVERLAY_ADD: + ret =3D handle_add_overlay_nodes(overlay_fdt, op->overlay_fdt_size= ); + + if ( ret ) + xfree(overlay_fdt); + + break; + case XEN_SYSCTL_DT_OVERLAY_REMOVE: ret =3D handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_s= ize); xfree(overlay_fdt); --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240657; cv=pass; d=zohomail.com; s=zohoarc; b=hiGPq4DFPjRYbCpNE/MU80QGBOKvdp7XVUqhXlxfJJSHWd5K1CKuLJjMO/YlabM9wx+M85R9EZ5M5Vki4D5MpqfSMnZ+7rDzg5+0zUvmxF1C3eveMiWkaeRpHYYbxmhxKYqDUhdhmzX4oie0kKpHQnE58+x7mLe8K+NndIoyUEI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240657; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=J1YxcmVCaNBFRN3LhozQwaaY5ZnYNdP5yjthcqlfziTRc7z77JjV3mV4HEMIzofN99TgHx9QigYFDif7P60m1tcbTSouydBYPS8uTa6PJ43i8aJY8xMh60FS37SOKz+NXicBhPgKkfL976IFs9gGOfeDkJtLLwDcFuO6vp8tAb8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240657507812.4888690529706; Tue, 11 Apr 2023 12:17:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519780.806829 (Exim 4.92) (envelope-from ) id 1pmJUT-0007Qi-98; Tue, 11 Apr 2023 19:17:17 +0000 Received: by outflank-mailman (output) from mailman id 519780.806829; Tue, 11 Apr 2023 19:17:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUS-0007Lm-LY; Tue, 11 Apr 2023 19:17:16 +0000 Received: by outflank-mailman (input) for mailman id 519780; Tue, 11 Apr 2023 19:17:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUP-0004Ta-VN for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:14 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20616.outbound.protection.outlook.com [2a01:111:f400:7e89::616]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 75148f5c-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:12 +0200 (CEST) Received: from MW4PR04CA0047.namprd04.prod.outlook.com (2603:10b6:303:6a::22) by MN2PR12MB4502.namprd12.prod.outlook.com (2603:10b6:208:263::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:07 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::73) by MW4PR04CA0047.outlook.office365.com (2603:10b6:303:6a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.39 via Frontend Transport; Tue, 11 Apr 2023 19:17:07 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:06 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:06 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:05 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:05 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75148f5c-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZdxqLJLgKXDWMojKmWYYz9UnYELtxncFWW4wx0bV5HcVbaJrpZBh04U5pSoVFPsQkFcKZDIq1Cg8njnRsZo6At6d4z/W7Zb556MDP3/UZ4X1Wb5wU8M5Er5sE3aE8e8e1aOyEtOXb76xht+yVKRN7MYBlIlizy+KTpDxKe4zd1CmkCF4sn+uCQ0yjObeHk7/SE6yLnGUgnlu68frNEVqHXGYkKu5drI0ZpXtqvO3qVhNk/rpBs+02yeuqTefgfStDVLs8Nuc0LaUnIWCzCro0vRIkBdCAavv7c2RUSxDWRs+0RhhYHkJuRPKWQPVvsr5gpIkF3+fZ5oLOfEcn4RWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=KJK2ygR2wbBhuVxFyoZFLe+hjdtRm5koMDZd9Oeof9o6Aryt6qAPXH4LSXA53BlJtoWTl7/QMpPB3rE1/jgDjcVx6BzJS2qm1j1Nzza7P1YhA10GSS0bJNqHNjNK7+g9BV0KMtvFYvDXV4I+yVf5/9R1o0iETEgk5CSteU9Iuq8c1w26r9xNQoxbwSH7Xf31WwyiYOFDY1Z8BWsfLWkNm4M35eIeZSkN2Px0Y9WJI6r1y6CaciDRh+ALhIi+01A2xtV+iMUUCCug8h1kLS0BerTPjTmiuO8KQzFu4jVy1oFWzmC8mSZ7Prz+LFeloL+VwtbV04/T7J/jbrAjQpbNMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3+cCBf3g6fBI4ES7DG61XJTRWpPAgPp5V0YvFzOd6Q8=; b=brYbKaGU8Q72lJSgTQfQSW8LmLDO7PvXt2hCa4KPGUB8MerKituz4Z9o0vpiMd3zauNzeTF9tRf/OkKJfza8PRinChP0AN4UqPhRxE7AF4B7Ohpaal8qYF6xk+4HuIFn2jQ6lgAMkQS8ir7ykY4Ws1ZcEeHGCpeoyIoCKF37Z+I= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , "Andrew Cooper" , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN][PATCH v5 14/17] xen/arm: Implement device tree node addition functionalities Date: Tue, 11 Apr 2023 12:16:15 -0700 Message-ID: <20230411191636.26926-15-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT085:EE_|MN2PR12MB4502:EE_ X-MS-Office365-Filtering-Correlation-Id: c6a6d862-d820-4db3-7343-08db3ac15750 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MmAyEa5oVIVl3CtWWYgdlvLVK6ewQoub2983E5bimxekYFO5Peb8HJsCasTmDKy/FzyLzXzOVomWOv2EFfH7ERRVTuHUGIYfKq54yrOp0jb8L+OG6ab/c/7eSpMtPAQeyXF1dyw7OlLUZV7gMQCeGsE2wKS6BmaFmzlBR80+wO7Z/IMmuca/CSfj4rCyJBtwSBtlAjnDlaJ6+5ulPhbbNEeddu0NNyXLzXtnhQgQo/sPjTEdQIlHQVC5wrJt+Q2dHRPbcLz90zCboCsQl5U+OcqJlPg6sZ0RLrXEdmqnEN7Ox3+7UupKtwwqmjgb34j4AyBqYsr1ZO7FWUP84f44ybjswyvoIlbJkiYcx5pyYDjerN7W4GaXoctw5xFMzz7eNNlzlGuTtURm1KSrhOEqnnnm1s9NU6n53DJuPYQL3njtUgGoQhYtMqFiXhYMXTKWLyBiaV8k5ew7WeCfLAFAR6y+YAc0EwCQYAcCemvz7YJKA1XGh7ygvZ6b+qrUXSH3W1iyKgQLTBD3h5gd+NdUHWzsVWQR9HfOajVGzAivWRoRRYkj2GMll49MUooNSHSWL5C5TAi7sj6hYuXl324GMIYIdayWJn4emzVeGGRfVyRYQZsXtk4BhqaF9SselyMrRpSuMC62XFvr1Q6AcaoQc5IZhXJXLs3UU5cTaVUeSB/uJgnQHukVeTC9TL4ycINQumm2Kk0n0lrIEEZJb8+WMESo8HpBytE9R4oFUgdIvk8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(36840700001)(46966006)(40470700004)(316002)(82310400005)(54906003)(82740400003)(36860700001)(356005)(81166007)(70586007)(8676002)(70206006)(4326008)(86362001)(6916009)(478600001)(426003)(336012)(47076005)(186003)(2616005)(26005)(41300700001)(36756003)(1076003)(2906002)(83380400001)(30864003)(40460700003)(44832011)(40480700001)(8936002)(6666004)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:06.9640 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6a6d862-d820-4db3-7343-08db3ac15750 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4502 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240659682100027 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update sysctl XEN_SYSCTL_dt_overlay to enable support for dtbo nodes additi= on using device tree overlay. xl dt-overlay add file.dtbo: Each time overlay nodes are added using .dtbo, a new fdt(memcpy of device_tree_flattened) is created and updated with overlay nodes. This updated fdt is further unflattened to a dt_host_new. Next, it checks if= any of the overlay nodes already exists in the dt_host. If overlay nodes do= esn't exist then find the overlay nodes in dt_host_new, find the overlay node= 's parent in dt_host and add the nodes as child under their parent in the dt_host. The node is attached as the last node under target parent. Finally, add IRQs, add device to IOMMUs, set permissions and map MMIO f= or the overlay node. When a node is added using overlay, a new entry is allocated in the overlay_track to keep the track of memory allocation due to addition of ove= rlay node. This is helpful for freeing the memory allocated when a device tree n= ode is removed. The main purpose of this to address first part of dynamic programming i.e. making xen aware of new device tree node which means updating the dt_host w= ith overlay node information. Here we are adding/removing node from dt_host, and checking/setting IOMMU and IRQ permission but never mapping them to any dom= ain. Right now, mapping/Un-mapping will happen only when a new domU is created/destroyed using "xl create". Signed-off-by: Vikram Garhwal --- xen/common/dt_overlay.c | 482 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 482 insertions(+) diff --git a/xen/common/dt_overlay.c b/xen/common/dt_overlay.c index 516e8010c5..3344bad313 100644 --- a/xen/common/dt_overlay.c +++ b/xen/common/dt_overlay.c @@ -36,6 +36,25 @@ static struct dt_device_node *find_last_descendants_node( return child_node; } =20 +/* + * Returns next node to the input node. If node has children then return + * last descendant's next node. +*/ +static struct dt_device_node *dt_find_next_node(struct dt_device_node *dt, + const struct dt_device_node *n= ode) +{ + struct dt_device_node *np; + + dt_for_each_device_node(dt, np) + if ( np =3D=3D node ) + break; + + if ( np->child ) + np =3D find_last_descendants_node(np); + + return np->allnext; +} + static int dt_overlay_remove_node(struct dt_device_node *device_node) { struct dt_device_node *np; @@ -109,6 +128,72 @@ static int dt_overlay_remove_node(struct dt_device_nod= e *device_node) return 0; } =20 +static int dt_overlay_add_node(struct dt_device_node *device_node, + const char *parent_node_path) +{ + struct dt_device_node *parent_node; + struct dt_device_node *np, *np_last_descendant; + struct dt_device_node *next_node; + struct dt_device_node *device_node_last_descendant; + + parent_node =3D dt_find_node_by_path(parent_node_path); + + if ( parent_node =3D=3D NULL ) + { + dt_dprintk("Node not found. Overlay node will not be added\n"); + return -EINVAL; + } + + /* If parent has no child. */ + if ( parent_node->child =3D=3D NULL ) + { + next_node =3D parent_node->allnext; + device_node->parent =3D parent_node; + parent_node->allnext =3D device_node; + parent_node->child =3D device_node; + } + else + { + /* If parent has at least one child node. + * Iterate to the last child node of parent. + */ + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np-= >sibling ); + + /* Iterate over all child nodes of np node. */ + if ( np->child ) + { + np_last_descendant =3D find_last_descendants_node(np); + + next_node =3D np_last_descendant->allnext; + np_last_descendant->allnext =3D device_node; + } + else + { + next_node =3D np->allnext; + np->allnext =3D device_node; + } + + device_node->parent =3D parent_node; + np->sibling =3D device_node; + np->sibling->sibling =3D NULL; + } + + /* Iterate over all child nodes of device_node to add children too. */ + if ( device_node->child ) + { + device_node_last_descendant =3D find_last_descendants_node(device_= node); + /* Plug next_node at the end of last children of device_node. */ + device_node_last_descendant->allnext =3D next_node; + } + else + { + /* Now plug next_node at the end of device_node. */ + device_node->allnext =3D next_node; + } + + return 0; +} + /* Basic sanity check for the dtbo tool stack provided to Xen. */ static int check_overlay_fdt(const void *overlay_fdt, uint32_t overlay_fdt= _size) { @@ -148,6 +233,79 @@ static unsigned int overlay_node_count(void *fdto) return num_overlay_nodes; } =20 +/* + * overlay_get_nodes_info will get full name with path for all the nodes w= hich + * are in one level of __overlay__ tag. This is useful when checking node = for + * duplication i.e. dtbo tries to add nodes which already exists in device= tree. + */ +static int overlay_get_nodes_info(const void *fdto, char ***nodes_full_pat= h, + unsigned int num_overlay_nodes) +{ + int fragment; + + *nodes_full_path =3D xzalloc_bytes(num_overlay_nodes * sizeof(char *)); + + if ( *nodes_full_path =3D=3D NULL ) + return -ENOMEM; + + fdt_for_each_subnode(fragment, fdto, 0) + { + int target; + int overlay; + int subnode; + const char *target_path; + + target =3D fdt_overlay_target_offset(device_tree_flattened, fdto, + fragment, &target_path); + if ( target < 0 ) + return target; + + overlay =3D fdt_subnode_offset(fdto, fragment, "__overlay__"); + + /* + * overlay value can be < 0. But fdt_for_each_subnode() loop check= s for + * overlay >=3D 0. So, no need for a overlay>=3D0 check here. + */ + fdt_for_each_subnode(subnode, fdto, overlay) + { + const char *node_name =3D NULL; + int node_name_len; + unsigned int target_path_len =3D strlen(target_path); + unsigned int node_full_name_len; + unsigned int node_num =3D 0; + + node_name =3D fdt_get_name(fdto, subnode, &node_name_len); + + if ( node_name =3D=3D NULL ) + return node_name_len; + + /* + * Magic number 2 is for adding '/'. This is done to keep the + * node_full_name in the correct full node name format. + */ + node_full_name_len =3D target_path_len + node_name_len + 2; + + (*nodes_full_path)[node_num] =3D xmalloc_bytes(node_full_name_= len); + + if ( (*nodes_full_path)[node_num] =3D=3D NULL ) + return -ENOMEM; + + memcpy((*nodes_full_path)[node_num], target_path, target_path_= len); + + (*nodes_full_path)[node_num][target_path_len] =3D '/'; + + memcpy((*nodes_full_path)[node_num] + target_path_len + 1, + node_name, node_name_len); + + (*nodes_full_path)[node_num][node_full_name_len - 1] =3D '\0'; + + node_num++; + } + } + + return 0; +} + static int handle_remove_irq_iommu(struct dt_device_node *device_node) { int rc =3D 0; @@ -367,6 +525,322 @@ out: return rc; } =20 +/* + * Handles IRQ and IOMMU mapping for the overlay_node and all descendants = of the + * overlay_nodes. + */ +static int handle_add_irq_iommu(struct domain *d, + struct dt_device_node *overlay_node) +{ + int rc; + unsigned int naddr, i, len; + uint64_t addr, size; + struct dt_device_node *np; + + /* First let's handle the interrupts. */ + rc =3D handle_device_interrupts(d, overlay_node, false); + if ( rc < 0 ) + { + printk(XENLOG_ERR "Interrupt failed\n"); + return rc; + } + + /* Check if iommu property exists. */ + if ( dt_get_property(overlay_node, "iommus", &len) ) + { + + /* Add device to IOMMUs. */ + rc =3D iommu_add_dt_device(overlay_node); + if ( rc < 0 ) + { + printk(XENLOG_ERR "Failed to add %s to the IOMMU\n", + dt_node_full_name(overlay_node)); + return rc; + } + } + + /* Set permissions. */ + naddr =3D dt_number_of_address(overlay_node); + + dt_dprintk("%s passthrough =3D %d naddr =3D %u\n", + dt_node_full_name(overlay_node), false, naddr); + + /* Give permission for map MMIOs */ + for ( i =3D 0; i < naddr; i++ ) + { + /* + * For now, we skip_mapping which means it will only permit iomem = access + * to hardware_domain using iomem_permit_access() but will never m= ap as + * map_range_p2mt() will not be called. + */ + struct map_range_data mr_data =3D { .d =3D d, + .p2mt =3D p2m_mmio_direct_c, + .skip_mapping =3D true }; + + rc =3D dt_device_get_address(overlay_node, i, &addr, &size); + if ( rc ) + { + printk(XENLOG_ERR "Unable to retrieve address %u for %s\n", + i, dt_node_full_name(overlay_node)); + return rc; + } + + rc =3D map_range_to_domain(overlay_node, addr, size, &mr_data); + if ( rc ) + return rc; + } + + /* Map IRQ and IOMMU for overlay_node's children. */ + for ( np =3D overlay_node->child; np !=3D NULL; np =3D np->sibling) + { + rc =3D handle_add_irq_iommu(d, np); + if ( rc ) + { + printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + return rc; + } + } + + return rc; +} + +/* + * Adds device tree nodes under target node. + * We use tr->dt_host_new to unflatten the updated device_tree_flattened. = This + * is done to avoid the removal of device_tree generation, iomem regions m= apping + * to hardware domain done by handle_node(). + */ +static long handle_add_overlay_nodes(void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc, j, i; + struct dt_device_node *overlay_node, *prev_node, *next_node; + struct domain *d =3D hardware_domain; + struct overlay_track *tr =3D NULL; + char **nodes_full_path =3D NULL; + unsigned int new_fdt_size; + + tr =3D xzalloc(struct overlay_track); + if ( tr =3D=3D NULL ) + return -ENOMEM; + + new_fdt_size =3D fdt_totalsize(device_tree_flattened) + + fdt_totalsize(overlay_fdt); + + tr->fdt =3D xzalloc_bytes(new_fdt_size); + if ( tr->fdt =3D=3D NULL ) + { + xfree(tr); + return -ENOMEM; + } + + tr->num_nodes =3D overlay_node_count(overlay_fdt); + if ( tr->num_nodes =3D=3D 0 ) + { + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + tr->nodes_address =3D xzalloc_bytes(tr->num_nodes * sizeof(unsigned lo= ng)); + if ( tr->nodes_address =3D=3D NULL ) + { + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + { + xfree(tr->nodes_address); + xfree(tr->fdt); + xfree(tr); + return rc; + } + + /* + * Keep a copy of overlay_fdt as fdt_overlay_apply will change the inp= ut + * overlay's content(magic) when applying overlay. + */ + tr->overlay_fdt =3D xzalloc_bytes(overlay_fdt_size); + if ( tr->overlay_fdt =3D=3D NULL ) + { + xfree(tr->nodes_address); + xfree(tr->fdt); + xfree(tr); + return -ENOMEM; + } + + memcpy(tr->overlay_fdt, overlay_fdt, overlay_fdt_size); + + spin_lock(&overlay_lock); + + memcpy(tr->fdt, device_tree_flattened, + fdt_totalsize(device_tree_flattened)); + + /* Open tr->fdt with more space to accommodate the overlay_fdt. */ + fdt_open_into(tr->fdt, tr->fdt, new_fdt_size); + + /* + * overlay_get_nodes_info is called to get the node information from d= tbo. + * This is done before fdt_overlay_apply() because the overlay apply w= ill + * erase the magic of overlay_fdt. + */ + rc =3D overlay_get_nodes_info(overlay_fdt, &nodes_full_path, + tr->num_nodes); + if ( rc ) + { + printk(XENLOG_ERR "Getting nodes information failed with error %d\= n", + rc); + goto err; + } + + rc =3D fdt_overlay_apply(tr->fdt, overlay_fdt); + if ( rc ) + { + printk(XENLOG_ERR "Adding overlay node failed with error %d\n", rc= ); + goto err; + } + + /* + * Check if any of the node already exists in dt_host. If node already= exits + * we can return here as this overlay_fdt is not suitable for overlay = ops. + */ + for ( j =3D 0; j < tr->num_nodes; j++ ) + { + overlay_node =3D dt_find_node_by_path(nodes_full_path[j]); + if ( overlay_node !=3D NULL ) + { + printk(XENLOG_ERR "node %s exists in device tree\n", + nodes_full_path[j]); + rc =3D -EINVAL; + goto err; + } + } + + /* Unflatten the tr->fdt into a new dt_host. */ + unflatten_device_tree(tr->fdt, &tr->dt_host_new); + + for ( j =3D 0; j < tr->num_nodes; j++ ) + { + dt_dprintk("Adding node: %s\n", nodes_full_path[j]); + + /* Find the newly added node in tr->dt_host_new by it's full path.= */ + overlay_node =3D device_tree_find_node_by_path(tr->dt_host_new, + nodes_full_path[j]); + if ( overlay_node =3D=3D NULL ) + { + dt_dprintk("%s node not found\n", nodes_full_path[j]); + rc =3D -EFAULT; + goto remove_node; + } + + /* + * Find previous and next node to overlay_node in dt_host_new. We = will + * need these nodes to fix the dt_host_new mapping. When overlay_n= ode is + * take out of dt_host_new tree and added to dt_host, link between + * previous node and next_node is broken. We will need to refresh + * dt_host_new with correct linking for any other overlay nodes + * extraction in future. + */ + dt_for_each_device_node(tr->dt_host_new, prev_node) + if ( prev_node->allnext =3D=3D overlay_node ) + break; + + next_node =3D dt_find_next_node(tr->dt_host_new, overlay_node); + + read_lock(&dt_host->lock); + + /* Add the node to dt_host. */ + rc =3D dt_overlay_add_node(overlay_node, overlay_node->parent->ful= l_name); + if ( rc ) + { + read_unlock(&dt_host->lock); + + /* Node not added in dt_host. */ + goto remove_node; + } + + read_unlock(&dt_host->lock); + + prev_node->allnext =3D next_node; + + overlay_node =3D dt_find_node_by_path(overlay_node->full_name); + if ( overlay_node =3D=3D NULL ) + { + /* Sanity check. But code will never come here. */ + ASSERT_UNREACHABLE(); + goto remove_node; + } + + rc =3D handle_add_irq_iommu(d, overlay_node); + if ( rc ) + { + printk(XENLOG_ERR "Adding IRQ and IOMMU failed\n"); + return rc; + } + + /* Keep overlay_node address in tracker. */ + tr->nodes_address[j] =3D (unsigned long)overlay_node; + } + + INIT_LIST_HEAD(&tr->entry); + list_add_tail(&tr->entry, &overlay_tracker); + + spin_unlock(&overlay_lock); + + if ( nodes_full_path !=3D NULL ) + { + for ( i =3D 0; i < tr->num_nodes && nodes_full_path[i] !=3D NULL; + i++ ) + { + xfree(nodes_full_path[i]); + } + xfree(nodes_full_path); + } + + return rc; + +/* + * Failure case. We need to remove the nodes, free tracker(if tr exists) a= nd + * tr->dt_host_new. + */ +remove_node: + tr->num_nodes =3D j; + rc =3D remove_nodes(tr); + + if ( rc ) + { + /* If removing node fails, this may cause memory leaks. */ + printk(XENLOG_ERR "Removing node failed.\n"); + spin_unlock(&overlay_lock); + return rc; + } + +err: + spin_unlock(&overlay_lock); + + xfree(tr->dt_host_new); + xfree(tr->fdt); + xfree(tr->overlay_fdt); + xfree(tr->nodes_address); + + if ( nodes_full_path !=3D NULL ) + { + for ( i =3D 0; i < tr->num_nodes && nodes_full_path[i] !=3D NULL; + i++ ) + { + xfree(nodes_full_path[i]); + } + xfree(nodes_full_path); + } + + xfree(tr); + + return rc; +} + long dt_sysctl(struct xen_sysctl_dt_overlay *op) { long ret; @@ -391,6 +865,14 @@ long dt_sysctl(struct xen_sysctl_dt_overlay *op) =20 switch ( op->overlay_op ) { + case XEN_SYSCTL_DT_OVERLAY_ADD: + ret =3D handle_add_overlay_nodes(overlay_fdt, op->overlay_fdt_size= ); + + if ( ret ) + xfree(overlay_fdt); + + break; + case XEN_SYSCTL_DT_OVERLAY_REMOVE: ret =3D handle_remove_overlay_nodes(overlay_fdt, op->overlay_fdt_s= ize); xfree(overlay_fdt); --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240834; cv=pass; d=zohomail.com; s=zohoarc; b=E3syKApymrHKaYPsqlCk3XXRH2tDFgtFcCdhJXfzA9HPmtA9yeOCbvMP/YK08+5yu+Zw0+zsHgGKXsRtAER15kCJXuS7kVrforcmnA3RnIVCRAX95NvpGb9lX+OxRpQyEh0GRrNWrv4yUneNPXOaqC71z6Eo+xFzzmLA1Qrh1+g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240834; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=eAfb4HvbNK/5EwicyfgCraVInDgPZWZORSLtEq7rCgZaCQy6VMS+mFjG0GfXsc3rcm3kArneob659vvNUFMyATop/2+YRHfsLRK6n7vj9NfJ+pveFa66z7TW3sywPtHRTwux/fcjxN9R5i87GwFLjNQ57zkn74EDyyAPkqafqsw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240834821711.3519656857932; Tue, 11 Apr 2023 12:20:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519885.807052 (Exim 4.92) (envelope-from ) id 1pmJXE-0003cy-Rs; Tue, 11 Apr 2023 19:20:08 +0000 Received: by outflank-mailman (output) from mailman id 519885.807052; Tue, 11 Apr 2023 19:20:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJXE-0003aE-GY; Tue, 11 Apr 2023 19:20:08 +0000 Received: by outflank-mailman (input) for mailman id 519885; Tue, 11 Apr 2023 19:20:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUg-0004DR-Bm for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:30 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20616.outbound.protection.outlook.com [2a01:111:f400:7e88::616]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7e6342f1-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:27 +0200 (CEST) Received: from BN7PR02CA0011.namprd02.prod.outlook.com (2603:10b6:408:20::24) by PH0PR12MB5607.namprd12.prod.outlook.com (2603:10b6:510:142::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:23 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::21) by BN7PR02CA0011.outlook.office365.com (2603:10b6:408:20::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:23 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:23 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:22 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7e6342f1-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYkT+9ybedTAThsa69OTF8pDiP0MapFqOpgACARH+6PwvEwplOikd1yK31DLgjqTQ+NwL2NhFM612qQn1Zk2T6REA9HurY0vIUfm6ASLw9cTfNiqAXo+zsYiW6NgkFbMtRVKKhWh4zBVeAkVUpov/tkhNshlfcm6pDULZyjl7BxJEuemGsbPWwSyfD6XE+czKIfu5bjD6FARRQyZ7BSQ/ScOW4mlS7kUXbzqxyUCsuuV4a9Jg+k+It3c1BmoiLLTyBBu747DBAhbcOA4ZtDg4TTTcsWT0QhuXgHC9nxog1Mu0qoXwfoBkK86oQvEyUwcSFZYZIitwdjyAhkTJ7lT7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=bFkwv0hRmgWPKHlPE78WePjeyze5djTM4XidulgttiHnANW6RcfIX235Ic4iOQ4EGGu2nm2KmYzhwCKpyv1ofZ5ALGFn+RObauX7gT5t745XCjHJ9bqBeA38DW350O8BXLiMRHHvlBc89Am8iYZW67l5N96Bc5fMa8BJmAf/jAccbFHW1rtmsF3iJvhcB/dHEj6H9a2PDFep+nPqawQo3qh46GeX5UaAw2jnFBFPp4gNMcTKkYm3f/R/mFy21DQhOYhAr38KHm6H1ibY158dC/TZRwmcN2ICQPNWbW3TUv+gnOVdtKLqXE41I1KX8TopAf2UKqG4E9XVt/sAwJhIrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=21/M39zzNkj6wIHkED3tJss5gecgEfRVwuaFUsyo+K3x1WdUj1VY+Ix1f+ggPHp698D1EViTsLUcnRtHqsqNJokVJHXZPoxBvyLa2VuGdBFmfVOkuwkwBiLs2e+dHETrO539r0RHzhgqZGOQUSD7Yh2xicGbe5d3/hZ3/KZT7Kg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD , Juergen Gross Subject: [XEN][PATCH v5 15/17] tools/libs/ctrl: Implement new xc interfaces for dt overlay Date: Tue, 11 Apr 2023 12:16:34 -0700 Message-ID: <20230411191636.26926-34-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT012:EE_|PH0PR12MB5607:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bb3dab3-66a2-4d94-0fae-08db3ac16115 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NjdL+dF7YtTYsdvEmz+gwZtMQejePwuqoUCxVtuOYQWysB0NMs9qEb+cfhvo6TJNzD/9vi69QT2fhp+OJDVPgfUkgVu1tn/qlZAYyWuVTf3N0cFFtJo0+Qx/bvE/w4ztWaOrlR/LK4EUmD9HZWW2Ty6fwF+EGqbSftprSFjA0H6RQ0+31wdLq+JOh4Lvz5Qk8XhjB7JOof5mawk2Vm9n5GJHTQmZUM0XZVb/FLLM3YKedjjhJ7lIt36Kr3VO8TDnbLJ7/aUA3ic4jmVm6ApUiUEZcumHQ/jubuNqi/Kb3NeQDu6KCmMYpYYV68o5Tti7/XfZ1i24vD2De9ayV9gEHlj7jKjNUFoHiifxaHbvGh6U6+T2zQE23AybgmDS/cbFmj4+XbtJauR6nf+e3wc231biL3TBFKbqW2zNtuEZpUYEan3mwwB5X4LJvnHctA5YPldL020mz4UjL0046VI2BorKesLR1Ssm9sqkz8EI5kZxExFETPQ3kOeNcrjqJiwHxl107F2ywBiqNv8UPmLLd3dmLWJmcgRO4nzQeWQ/1oxK6chL1Ec9vfiz7VemckQRV5zKIvroPRvvRjFCfQQOKrFcxUIP+ZcOI/7ZffJpIOW0jxZVakknuR3y4YWkzL4UhICB285ipDmmK59cQxfz7/GjtyTeuY3L1pK+xfCHtwUmmCkdNybWCEk8g6NdEFg/RQ2TRdGemRpmRCb4oJQ4qkxW7GWizOkLjuulhdFCLmhvzgZvWSIgztkxhXpne7E9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(82740400003)(356005)(54906003)(36860700001)(81166007)(70206006)(70586007)(8676002)(86362001)(6916009)(478600001)(4326008)(336012)(47076005)(426003)(186003)(2616005)(26005)(316002)(41300700001)(36756003)(2906002)(1076003)(44832011)(40460700003)(40480700001)(8936002)(6666004)(5660300002)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:23.4457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bb3dab3-66a2-4d94-0fae-08db3ac16115 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5607 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240835621100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" xc_dt_overlay() sends the device tree binary overlay, size of .dtbo and ove= rlay operation type i.e. add or remove to xen. Signed-off-by: Vikram Garhwal --- tools/include/xenctrl.h | 5 ++++ tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_dt_overlay.c | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tools/libs/ctrl/xc_dt_overlay.c diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 05967ecc92..b932589c8d 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2637,6 +2637,11 @@ int xc_livepatch_replace(xc_interface *xch, char *na= me, uint32_t timeout, uint32 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid, xen_pfn_t start_pfn, xen_pfn_t nr_pfns); =20 +#if defined(__arm__) || defined(__aarch64__) +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op); +#endif + /* Compat shims */ #include "xenctrl_compat.h" =20 diff --git a/tools/libs/ctrl/Makefile.common b/tools/libs/ctrl/Makefile.com= mon index 0a09c28fd3..247afbe5f9 100644 --- a/tools/libs/ctrl/Makefile.common +++ b/tools/libs/ctrl/Makefile.common @@ -24,6 +24,7 @@ OBJS-y +=3D xc_hcall_buf.o OBJS-y +=3D xc_foreign_memory.o OBJS-y +=3D xc_kexec.o OBJS-y +=3D xc_resource.o +OBJS-$(CONFIG_ARM) +=3D xc_dt_overlay.o OBJS-$(CONFIG_X86) +=3D xc_psr.o OBJS-$(CONFIG_X86) +=3D xc_pagetab.o OBJS-$(CONFIG_Linux) +=3D xc_linux.o diff --git a/tools/libs/ctrl/xc_dt_overlay.c b/tools/libs/ctrl/xc_dt_overla= y.c new file mode 100644 index 0000000000..202fc906f4 --- /dev/null +++ b/tools/libs/ctrl/xc_dt_overlay.c @@ -0,0 +1,48 @@ +/* + * + * Device Tree Overlay functions. + * Copyright (C) 2021 Xilinx Inc. + * Author Vikram Garhwal + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see . + */ + +#include "xc_private.h" + +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op) +{ + int err; + DECLARE_SYSCTL; + + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( (err =3D xc_hypercall_bounce_pre(xch, overlay_fdt)) ) + goto err; + + sysctl.cmd =3D XEN_SYSCTL_dt_overlay; + sysctl.u.dt_overlay.overlay_op =3D overlay_op; + sysctl.u.dt_overlay.overlay_fdt_size =3D overlay_fdt_size; + + set_xen_guest_handle(sysctl.u.dt_overlay.overlay_fdt, overlay_fdt); + + if ( (err =3D do_sysctl(xch, &sysctl)) !=3D 0 ) + PERROR("%s failed", __func__); + +err: + xc_hypercall_bounce_post(xch, overlay_fdt); + + return err; +} --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240661; cv=pass; d=zohomail.com; s=zohoarc; b=HeIbunsPB48qL16JTHkiwC8pJ7hkzQAjmVNDIbFisc1xOBesXUa7X2iMCuBZLZeiUytzkMgUi2x46OCU9Uog5+G28YSBudKsHAz9+72hodShgSB3J8eSBhDmtsEGAvb1niBrqxvsiBMjbrCmWoRUI+9BMgcTPvYn1qoFU5w9Ldk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240661; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=OX6eIkfwzrc9ZBRy5b+OcqL4H9wFGwz3fWtu8ixXYjpbPEoRanjbokUF0+aGnEvNtjnKF+F8TsLE4vh0/HsJMLANVlPoCcxaKmZeQ8il28sQkQAZUuZlkPu5a5B1IMOk8EzCLSkK7wTQC38iCIf3kVj0ipGmXTGRSzjMxIxxpgs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240661267452.2286829874797; Tue, 11 Apr 2023 12:17:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519783.806848 (Exim 4.92) (envelope-from ) id 1pmJUV-0007ww-RZ; Tue, 11 Apr 2023 19:17:19 +0000 Received: by outflank-mailman (output) from mailman id 519783.806848; Tue, 11 Apr 2023 19:17:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUV-0007uF-01; Tue, 11 Apr 2023 19:17:19 +0000 Received: by outflank-mailman (input) for mailman id 519783; Tue, 11 Apr 2023 19:17:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUR-0004DR-Q0 for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:15 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20606.outbound.protection.outlook.com [2a01:111:f400:7e8c::606]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 75bcde91-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:13 +0200 (CEST) Received: from MW4PR04CA0041.namprd04.prod.outlook.com (2603:10b6:303:6a::16) by IA1PR12MB6529.namprd12.prod.outlook.com (2603:10b6:208:3a6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.34; Tue, 11 Apr 2023 19:17:08 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::d0) by MW4PR04CA0041.outlook.office365.com (2603:10b6:303:6a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.40 via Frontend Transport; Tue, 11 Apr 2023 19:17:08 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:08 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:07 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:06 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:06 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75bcde91-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YpIDKdgdf7yz2eJTAnEtGnIAAnvHfpj3300VLO6iafBOlyg9uKGtWR8AlWLxZXP7jXq9z+MOemUrxotW3ALnTbYqRKLYnv4hTlBU7fOiISFawFTn2sfZGHNIb/LaE9ZO2I+2Qd/HNcuwn5+M8fnxdXlS6Bqmzr3N6eCnwFV/c9YZRm82uhULvb8h7wuS9Mip6Y5DUmuTbpTPaJGax/zVmWaporPWDtZGvPYZXRhakfjvF5Glz2cx6XgfjW78lAGD/6ddcqxVFNiG3vicbmGg0mYIVHVd7jMXYOiGlYnApFw9Vr1UlR226LBQIzbrDZb7A5rL6hhtY7hLB1EWpHlorQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=F5OZE8ajLmHZ/3smvtrG3B3WH5oV4QmrHteG/vHTRllwu508EHSaQPST7gJiFbgHoDWf/e2BCweqleNSWP9MHT+GLdqcgZK5AiBmzlg2os1366qXKVcQlnDk4JdYYrnROOe5Sy2X4NZVgweQrs5LGeNMPwrv8/9f4U0UI7nyceUS39HZ6pA7+XALE0/zSb90fv+KxfUmpme0YPQeuQrPeuVfI61ZaGeJM97fGAA/SZn+rC4m0cvg6C0lUtesgR/EQkCsDqHidnogKC/o+r6wpScV0HDwk2GrA1yn+zaL2Xc7m9py2DDfF9tBZfERXRPetcpYXqwXCxeV7y22lYa4UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nkwDgQcNvE9UkGiRuGgnKgAIS4K7kLAxiI7Z7Wg7YaY=; b=34B69AbRgoSes/U8YltA7jp1SIRw84uuhNt7TRQZNULohAXDZZhsPhgLOiVTgnRk+J/lfOOIctNDhuCdHAaPGqQfAc3uPDMpNjcUypQ3tyfJV2gzFGg9cZP7f0PTD/hRhQXzyre6jKZVAHVEzs9NDOUJMKcbR6jeo+riXyEmy8o= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD , Juergen Gross Subject: [XEN][PATCH v5 15/17] tools/libs/ctrl: Implement new xc interfaces for dt overlay Date: Tue, 11 Apr 2023 12:16:16 -0700 Message-ID: <20230411191636.26926-16-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT085:EE_|IA1PR12MB6529:EE_ X-MS-Office365-Filtering-Correlation-Id: 79fb94b7-2e1f-4cd8-dde2-08db3ac15800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: osc+4KnrjY/eXHRp/c21nvn18/PBqzgrfrXWovfYXG3QrplR0MgbJ72hALFCiEcxPhk3QCSjzTFO0dTXS6yY9bt/J8GQaZ3WYGZnBX2YGioCcALoBjUowaD5pS+r/sLI+L2YN/4s9DHwAJKZFS2+nLiYjL1EMqTc6AHTqNHVpeHyOcIaMNldU5M5EzDaASxUhO3oCEUMTi96Ba4RbWsjp3sMkNFeeKj7mdIpNg39NVoQtJJrexrczJ3CXJ4N5k3KSt8jbO0kW511tYq5p+Ahe7LLGnRU0SMi7baInhIHt0mb5n2gFKkRFvd0ht9LB96tkW4dWRFp3QKStHnhBh7nZG/l8PXpbqpgzp4viFw2WKasPQ5v0VkIlSn0xAafRSR/qj3De+tPh/fTVyxfhRntQdkTvcpxMSsXaIHjID7Nyxx24+li9JVuGCxeXyewaEMKOsrFzaQ4y+oj7CslTKxiL9D0SR+uWSi/EfyxI8TfNgnalPhnHrEZzPQOsBKxFrh0eaXeS/MW13vx6/MePibxA9oju6iZnUa+Hc80Zf2Dr5VbNvLe7Tl+P13UgrnjzYNyI9vQS+oO0EdP89r4GuGuwIdysUR9FW1yxvmTteTro8D60MVMkOZyS/XwStAp5xf8DPld7jEQcQpzt8I5BHTNI+rEq3SpHSmv7VEwN27rRCI+IUMoActsf1te3hUn69CJxWUpjJw0GHVSd/eNq7wywPqJvAYdGBddDOaD8uiSerCTHaw/TBAANLwczdGUStdu X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(70206006)(4326008)(478600001)(8676002)(54906003)(41300700001)(316002)(70586007)(6916009)(86362001)(36756003)(47076005)(2616005)(336012)(26005)(1076003)(426003)(6666004)(5660300002)(44832011)(2906002)(82310400005)(40480700001)(8936002)(356005)(82740400003)(186003)(81166007)(36860700001)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:08.1201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79fb94b7-2e1f-4cd8-dde2-08db3ac15800 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6529 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240662591100033 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" xc_dt_overlay() sends the device tree binary overlay, size of .dtbo and ove= rlay operation type i.e. add or remove to xen. Signed-off-by: Vikram Garhwal --- tools/include/xenctrl.h | 5 ++++ tools/libs/ctrl/Makefile.common | 1 + tools/libs/ctrl/xc_dt_overlay.c | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tools/libs/ctrl/xc_dt_overlay.c diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 05967ecc92..b932589c8d 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2637,6 +2637,11 @@ int xc_livepatch_replace(xc_interface *xch, char *na= me, uint32_t timeout, uint32 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid, xen_pfn_t start_pfn, xen_pfn_t nr_pfns); =20 +#if defined(__arm__) || defined(__aarch64__) +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op); +#endif + /* Compat shims */ #include "xenctrl_compat.h" =20 diff --git a/tools/libs/ctrl/Makefile.common b/tools/libs/ctrl/Makefile.com= mon index 0a09c28fd3..247afbe5f9 100644 --- a/tools/libs/ctrl/Makefile.common +++ b/tools/libs/ctrl/Makefile.common @@ -24,6 +24,7 @@ OBJS-y +=3D xc_hcall_buf.o OBJS-y +=3D xc_foreign_memory.o OBJS-y +=3D xc_kexec.o OBJS-y +=3D xc_resource.o +OBJS-$(CONFIG_ARM) +=3D xc_dt_overlay.o OBJS-$(CONFIG_X86) +=3D xc_psr.o OBJS-$(CONFIG_X86) +=3D xc_pagetab.o OBJS-$(CONFIG_Linux) +=3D xc_linux.o diff --git a/tools/libs/ctrl/xc_dt_overlay.c b/tools/libs/ctrl/xc_dt_overla= y.c new file mode 100644 index 0000000000..202fc906f4 --- /dev/null +++ b/tools/libs/ctrl/xc_dt_overlay.c @@ -0,0 +1,48 @@ +/* + * + * Device Tree Overlay functions. + * Copyright (C) 2021 Xilinx Inc. + * Author Vikram Garhwal + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see . + */ + +#include "xc_private.h" + +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, + uint32_t overlay_fdt_size, uint8_t overlay_op) +{ + int err; + DECLARE_SYSCTL; + + DECLARE_HYPERCALL_BOUNCE(overlay_fdt, overlay_fdt_size, + XC_HYPERCALL_BUFFER_BOUNCE_IN); + + if ( (err =3D xc_hypercall_bounce_pre(xch, overlay_fdt)) ) + goto err; + + sysctl.cmd =3D XEN_SYSCTL_dt_overlay; + sysctl.u.dt_overlay.overlay_op =3D overlay_op; + sysctl.u.dt_overlay.overlay_fdt_size =3D overlay_fdt_size; + + set_xen_guest_handle(sysctl.u.dt_overlay.overlay_fdt, overlay_fdt); + + if ( (err =3D do_sysctl(xch, &sysctl)) !=3D 0 ) + PERROR("%s failed", __func__); + +err: + xc_hypercall_bounce_post(xch, overlay_fdt); + + return err; +} --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240815; cv=pass; d=zohomail.com; s=zohoarc; b=ZGq8ZWzuY1xnuvpTsdYEQceLEytK0v8d1/pSu1336V6bcVDPSM5WgcdCdN+nI1eJdpHGv3Zfow56Lnxbf9ZYW6NXc2bkvgW4LzD5AnWrUkjIF4AGDz9asfWrlT8A+3h9mmW8Lo46JQ08chVGo8cv9qAPWd7utqUhLyTl3AyKDbs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240815; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=KtKF0LHI/NoY/ECwAXJJYtPDohNMZ+9QagkF7lHl08hvtByTE/kKXXcmsXZMG87HnpWy/aMZ0pCc7D1bBXkvRH+PRZO9aBEXSis58INor/tOLsHD3iWVTI1U4x85VY6Dr4EgLv3GEn9rhKOP3V+dxobwJzQVM5QHJQCKuJyfULM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240815031578.4580024205205; Tue, 11 Apr 2023 12:20:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519861.806993 (Exim 4.92) (envelope-from ) id 1pmJX4-00019e-2w; Tue, 11 Apr 2023 19:19:58 +0000 Received: by outflank-mailman (output) from mailman id 519861.806993; Tue, 11 Apr 2023 19:19:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJX3-00017T-Q5; Tue, 11 Apr 2023 19:19:57 +0000 Received: by outflank-mailman (input) for mailman id 519861; Tue, 11 Apr 2023 19:19:56 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUR-0004Ta-Vq for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:15 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20615.outbound.protection.outlook.com [2a01:111:f400:7eaa::615]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 76edfa86-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:14 +0200 (CEST) Received: from BN9P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::32) by BY5PR12MB4322.namprd12.prod.outlook.com (2603:10b6:a03:20a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:11 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::eb) by BN9P221CA0020.outlook.office365.com (2603:10b6:408:10a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Tue, 11 Apr 2023 19:17:10 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:10 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:07 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 12:17:07 -0700 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:07 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 76edfa86-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E8b/gdsp9EhJpwqEqWnSuieF6eymTrNe7CZCQIhNlXPnI9rbzaQ9wvtKtsjf8kP5i3R8URY/xdnXA4z5xpo6gHBEMWaxZykiVSxkS5IX9GPzCVHxrsWjarIu4i2Gai1OZW1LhqjKfQ3613hbwJtVwcHRkvsqrjZQMhmB1zr+3fL7NYtkYjn/O/lE3EtnFmvqnRpqZjW2HhvCO8FLrJFTjXGgjdfpCxF+iPM1wo6kyd6vUyRKgOAiYIQGCBzoEf0Qa6jDfyC4ZMVRSiSGssuo3vgTR2fcrzTK+5aDDiUAsT2QnfwW7VVz06WpZOzG8MrZh1Rzisa1hHvAHTmyd6+Ukw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=nxIqwyEEBoGjZ2Kuiet6/zxQ1rXzFTD9+Tb8gozYJ/K69DjIujomDliSsWjN6KFcbMnN2aGkwTczNRgYS6wjhAw1GVWvCHbB877FDdlw/Z7ryiq0f0E0TkFr6zwbr6c+9/31vEwBGNPKAdGpMRl/1MRnkUrrkz2ExOW5z/Z0zUwocZDZe/bCYvRT+gZkSJQEFXS9Co2Di9Fi9PdJNEPQh4Q9FWsxvw/v6dOeJyMpOK92Qi76t4Up2UXXyPumbKQtuUsjFySgj4hkfiGchNgMjtqJzNIDEQ6BlcddYezacJLktwxN2ZYOhv3OVqVhnjwCzVsVvyy5irVapGD5gnheKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=Mlr/+9OeakKs1WY2xZ18xA0mf8IJHjFeJSeRCQ20Q0zD8LVeRq1TGn30xKGU8oa4JxImKkmgn4JGZaMnjvON9eZpaV/sVxo6PY/uIkYeMQfwhCSOKw8PW/xN+uEztqYsTT2xIFp0708WEh0TgXAcyESUMJ/qgIrlxY3WqsNsi6o= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD , Juergen Gross Subject: [XEN][PATCH v5 16/17] tools/libs/light: Implement new libxl functions for device tree overlay ops Date: Tue, 11 Apr 2023 12:16:17 -0700 Message-ID: <20230411191636.26926-17-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|BY5PR12MB4322:EE_ X-MS-Office365-Filtering-Correlation-Id: f399bca7-e537-444f-ca75-08db3ac15925 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K+t5V2+TAUOZSEpGSwWXK//7mVQ+/eyBcdLVEKdtEN4WY/OiGfcf1/gyhYIYcIO+xc2Z7SKl80+536Xeh5lp8rzwgmEG+EG1jTi+Dc0f7A5bykEp6HZNuGr4lWbKv/EtVCJdoFEo8wFwiEixU7By7P0fVXx77hwcPYNUCbnNTvhi4G3SB0PBW/wO19rtokte+XM11+gBEn3zZLSuFoIrdn97DHMFYsLdHHXCNCittTwO1WBOKmJPPZWZG6KA7wHnG8RYBi22flUwZQtwFON5Hv6xc2GS+LmOAlQsq3MSkv6Et51WAhgS6vECFMCqK+g7NSO5gvOm5emZJmtZTbipCt/XJ/VfOBh4Oa0djPeXy7z7gAgQqYxYVbz7N0Nuv3zzlGhZGDoQHxYkDAj4MNPHjlLD2z2CO2u/I8yj5k9ensKm4kjHEvBsvwLu2yiDG2oOYcvP7DfwpkT3fzXLKr1X6wKEXFe6tZv9rv5pz9WAzKXzusNAXLtYbtLK98MfTMptlzToh300Tn8FXSC3hHdECNcZfnPYVizzo/ogVgkdudl1bnIT1gI2jcjL7rKGZEXwY6i1IcLpLD37kdpYHv8szq26znZyba7r1Ca3/pdwXujCrw2C6froyU9xQXa4UdpI7Fh86Axdin70rTa6Hnd/Uv7KoVvjilC8Mzrj+v/lshuDw2ue+66wdjmcpghqxa2/+reQkMaVbByvXO+5tG6+1jiyC12STT/1S0UlEImC/76aPg8EpW7OH3jfEVSOg3NG X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199021)(36840700001)(46966006)(40470700004)(8936002)(5660300002)(44832011)(82310400005)(41300700001)(70206006)(70586007)(40460700003)(4326008)(8676002)(6916009)(316002)(2906002)(478600001)(54906003)(6666004)(36756003)(86362001)(40480700001)(1076003)(26005)(2616005)(336012)(426003)(186003)(356005)(81166007)(82740400003)(47076005)(36860700001)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:10.1336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f399bca7-e537-444f-ca75-08db3ac15925 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4322 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240815543100010 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/include/libxl.h | 11 +++++ tools/libs/light/Makefile | 3 ++ tools/libs/light/libxl_dt_overlay.c | 71 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 tools/libs/light/libxl_dt_overlay.c diff --git a/tools/include/libxl.h b/tools/include/libxl.h index cfa1a19131..1c5e8abaae 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -250,6 +250,12 @@ */ #define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1 =20 +#if defined(__arm__) || defined(__aarch64__) +/** + * This means Device Tree Overlay is supported. + */ +#define LIBXL_HAVE_DT_OVERLAY 1 +#endif /* * libxl_domain_build_info has device_model_user to specify the user to * run the device model with. See docs/misc/qemu-deprivilege.txt. @@ -2453,6 +2459,11 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *c= tx, uint32_t domid, int *num); void libxl_device_pci_list_free(libxl_device_pci* list, int num); =20 +#if defined(__arm__) || defined(__aarch64__) +int libxl_dt_overlay(libxl_ctx *ctx, void *overlay, + uint32_t overlay_size, uint8_t overlay_op); +#endif + /* * Turns the current process into a backend device service daemon * for a driver domain. diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index 96daeabc47..563a1e8d0a 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -112,6 +112,9 @@ OBJS-y +=3D _libxl_types.o OBJS-y +=3D libxl_flask.o OBJS-y +=3D _libxl_types_internal.o =20 +# Device tree overlay is enabled only for ARM architecture. +OBJS-$(CONFIG_ARM) +=3D libxl_dt_overlay.o + ifeq ($(CONFIG_LIBNL),y) CFLAGS_LIBXL +=3D $(LIBNL3_CFLAGS) endif diff --git a/tools/libs/light/libxl_dt_overlay.c b/tools/libs/light/libxl_d= t_overlay.c new file mode 100644 index 0000000000..a6c709a6dc --- /dev/null +++ b/tools/libs/light/libxl_dt_overlay.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021 Xilinx Inc. + * Author Vikram Garhwal + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "libxl_osdeps.h" /* must come before any other headers */ +#include "libxl_internal.h" +#include +#include + +static int check_overlay_fdt(libxl__gc *gc, void *fdt, size_t size) +{ + int r; + + if (fdt_magic(fdt) !=3D FDT_MAGIC) { + LOG(ERROR, "Overlay FDT is not a valid Flat Device Tree"); + return ERROR_FAIL; + } + + r =3D fdt_check_header(fdt); + if (r) { + LOG(ERROR, "Failed to check the overlay FDT (%d)", r); + return ERROR_FAIL; + } + + if (fdt_totalsize(fdt) > size) { + LOG(ERROR, "Overlay FDT totalsize is too big"); + return ERROR_FAIL; + } + + return 0; +} + +int libxl_dt_overlay(libxl_ctx *ctx, void *overlay_dt, uint32_t overlay_dt= _size, + uint8_t overlay_op) +{ + int rc; + int r; + GC_INIT(ctx); + + if (check_overlay_fdt(gc, overlay_dt, overlay_dt_size)) { + LOG(ERROR, "Overlay DTB check failed"); + rc =3D ERROR_FAIL; + goto out; + } else { + LOG(DEBUG, "Overlay DTB check passed"); + rc =3D 0; + } + + r =3D xc_dt_overlay(ctx->xch, overlay_dt, overlay_dt_size, overlay_op); + + if (r) { + LOG(ERROR, "%s: Adding/Removing overlay dtb failed.", __func__); + rc =3D ERROR_FAIL; + } + +out: + GC_FREE; + return rc; +} + --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240820; cv=pass; d=zohomail.com; s=zohoarc; b=b995q6IWSCKguR/xVMntO4p9RjgMR7x6IkvXKDfTMAw5odhuEDmQceVHLby28Dw6HeeCSRw4vJ5QZBNXO9RixRmamITEO7ZIn9NpVTNesNc3kLSGvk9VwpGvDZaVQKdRRK/noPP9zK5CgWMAuvfFkHVFwARXWe8jNUaXeLhOs4E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240820; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=b9w6VTAz5/aNQwc96wfv+680cN7aU5VXVWYk0nhtRgS8i/IPQxdzaBoJXO0C7SyFXWUip5YRp4ejW8wFXWUO3u6nPRBw7fmQfHuO9ptHN1LytmDOY6HKlj3vDCKUsPfFy8VL52zsVqe+Y/v9b1uIjTeRxwNaF4PMlihaQEQGEdw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240820003728.1855513124759; Tue, 11 Apr 2023 12:20:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519868.807010 (Exim 4.92) (envelope-from ) id 1pmJX7-0001tn-Pm; Tue, 11 Apr 2023 19:20:01 +0000 Received: by outflank-mailman (output) from mailman id 519868.807010; Tue, 11 Apr 2023 19:20:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJX7-0001tT-HI; Tue, 11 Apr 2023 19:20:01 +0000 Received: by outflank-mailman (input) for mailman id 519868; Tue, 11 Apr 2023 19:19:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUh-0004Ta-FG for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:31 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20631.outbound.protection.outlook.com [2a01:111:f400:7eab::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 80933d9d-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:30 +0200 (CEST) Received: from BN7PR02CA0032.namprd02.prod.outlook.com (2603:10b6:408:20::45) by MW4PR12MB5667.namprd12.prod.outlook.com (2603:10b6:303:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Tue, 11 Apr 2023 19:17:26 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::27) by BN7PR02CA0032.outlook.office365.com (2603:10b6:408:20::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36 via Frontend Transport; Tue, 11 Apr 2023 19:17:26 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:26 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:23 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:23 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 80933d9d-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJ0O6GHtiT21f4jamG/1nkPHCqa4FcTuvEoiZY7rnNzRVvZcMWqD+22gBPXrCKVZRbuhqzacuoSI40GoahdOs9YmS1GUW5+yVMr/ZuE/dTYJdv8Jv5NNTEJgukvDUr4a9yAD3cmLLDo21ymy8VNH2GtsPC5m4+aNyWl+PlH0v3MgXFDrZ4cxMi45wX2y05e/FdpGkGLOA573pcDtxRkZ/CJe9pYbdh5JC46HIJLI0Fij2qLWr5/Ti/FRgDc4OB5t9wCMzA9hykIEg+4d0EVWwvnHFKXAXAfcJdm56KTciJjx6ZOZE+MBDg2chC1GRaEzxa8wIwoc1fqOnOA6wDFltw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=Uxtz+1EHP7Es6fMd/EjL8S02P7I1hCuklZeceuPRvGkwc418ulHBVILrSdEbq2w4q59M5OA9jDTiy23+Ri6lwJtN4HRAKnhN7O8U1zaro/ZMdCNAw6ym0zTH20WiDj+RiI3/VD7eQ3MdaI8WZc2aHI0O12VpkNTrYocifrJHBWASnr73YLEAD4EioXEyhETX790iFZ41oRe7YM0SQQuEnT6JqP9Hz3FraOoVouW8t0qT/Z/phjJzjL7A7CxPhyeAZu2PiibxbekpY0qokVbEc8GbGzR8caiRTwIIr/npCXSPFMc9nNUV9L78rvMXRXVSoUhnmgRrXKZpmrMfOz3LkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=91E2KEtRfiC4xks88DcPT08G46pT034ykx3UwRRlezk=; b=jiBfdo0psJ+gincF4tYwny/wZE4YYqB+6weFDtEz4RDwWLvG1btBljprsLUqj7qRKvmdPI0tVipKGrL5HCSTJodkdK7Wum/AeI1WkuOse3Yuh+L8rqsvyudOZPx1cgMZ+NwJH9bS9/63FzMuLOe5hqM9bJkKmMMcC+uA+zTfq6c= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD , Juergen Gross Subject: [XEN][PATCH v5 16/17] tools/libs/light: Implement new libxl functions for device tree overlay ops Date: Tue, 11 Apr 2023 12:16:35 -0700 Message-ID: <20230411191636.26926-35-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT012:EE_|MW4PR12MB5667:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a392f45-94a7-4efa-ba31-08db3ac162ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0zobVB8q1qtHq3f8MXBx+n29ojXpLxjihYItaqooTtF8rfKBKAgmA5h2vRJvDxizfMIzSGZ3LBBi1Gb+MQGRui+yi3I327vpPoiHA6f8qRPbFOUhXncHvsUavOxX9l0rF815NWNH3APr3iVo1sRHaBdWhaJuul3bnVEZFvD2MjkSS5yjlYSU3HYX3I1otNAeam3xZ+VQHgQdniUUZ7ZHubJvg7zP3EU3cgzNGi3bJvz1Pv9FJRfVd+aas3ck15keQ8uZUdWwNCkT1H4pEHPGB2R0qlAq5pIzkI/k0EkHc7som6HxPQ32GAnSYTnJ/DTfDOCwvWqEZaofe51SkyeS2TUKVJMohIdXu1mMnZWX6iacg+USLyWny7QAat1VGwpWSV3apZubruWU4t1zDRqeJbBnopkKvUAvQfDUtD6f8XadAllpbvEVe5RzykvQvsAEY16aTGK1fdjpkA6RwQSPMdwLn4muAScMkEUvl93iubdM1r5awDcl3syKXHzdB5nFVpz4NXS7tdmH2uXP7hoXWQDhsdMr1mbV8qPafbv02S4k1nlOgSOlgBu1cBAsx+Lz036WMSxCSaJ9a/8BAqZgzynCiHx8Sxs07e9phhWHsmNXl+jbVvzSFMLr1XS7NTPugI+zeP1gvUBnN661TojN3pliFUBfvmcWhh7t1jnLmgc6gp1908WNuDkzEA2CsBI5nTZPJHa/9v0+Qh+bbdbuEn58S/Dawz7ZFuo1d4Ar3xI99rq912bMGpKJbziARJl6 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(36756003)(44832011)(82310400005)(40460700003)(2906002)(5660300002)(8936002)(86362001)(40480700001)(8676002)(26005)(6666004)(1076003)(36860700001)(54906003)(478600001)(2616005)(47076005)(336012)(426003)(186003)(70206006)(70586007)(81166007)(82740400003)(41300700001)(356005)(4326008)(6916009)(316002)(2004002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:26.1174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a392f45-94a7-4efa-ba31-08db3ac162ac X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5667 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240821558100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/include/libxl.h | 11 +++++ tools/libs/light/Makefile | 3 ++ tools/libs/light/libxl_dt_overlay.c | 71 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 tools/libs/light/libxl_dt_overlay.c diff --git a/tools/include/libxl.h b/tools/include/libxl.h index cfa1a19131..1c5e8abaae 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -250,6 +250,12 @@ */ #define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1 =20 +#if defined(__arm__) || defined(__aarch64__) +/** + * This means Device Tree Overlay is supported. + */ +#define LIBXL_HAVE_DT_OVERLAY 1 +#endif /* * libxl_domain_build_info has device_model_user to specify the user to * run the device model with. See docs/misc/qemu-deprivilege.txt. @@ -2453,6 +2459,11 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *c= tx, uint32_t domid, int *num); void libxl_device_pci_list_free(libxl_device_pci* list, int num); =20 +#if defined(__arm__) || defined(__aarch64__) +int libxl_dt_overlay(libxl_ctx *ctx, void *overlay, + uint32_t overlay_size, uint8_t overlay_op); +#endif + /* * Turns the current process into a backend device service daemon * for a driver domain. diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index 96daeabc47..563a1e8d0a 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -112,6 +112,9 @@ OBJS-y +=3D _libxl_types.o OBJS-y +=3D libxl_flask.o OBJS-y +=3D _libxl_types_internal.o =20 +# Device tree overlay is enabled only for ARM architecture. +OBJS-$(CONFIG_ARM) +=3D libxl_dt_overlay.o + ifeq ($(CONFIG_LIBNL),y) CFLAGS_LIBXL +=3D $(LIBNL3_CFLAGS) endif diff --git a/tools/libs/light/libxl_dt_overlay.c b/tools/libs/light/libxl_d= t_overlay.c new file mode 100644 index 0000000000..a6c709a6dc --- /dev/null +++ b/tools/libs/light/libxl_dt_overlay.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021 Xilinx Inc. + * Author Vikram Garhwal + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "libxl_osdeps.h" /* must come before any other headers */ +#include "libxl_internal.h" +#include +#include + +static int check_overlay_fdt(libxl__gc *gc, void *fdt, size_t size) +{ + int r; + + if (fdt_magic(fdt) !=3D FDT_MAGIC) { + LOG(ERROR, "Overlay FDT is not a valid Flat Device Tree"); + return ERROR_FAIL; + } + + r =3D fdt_check_header(fdt); + if (r) { + LOG(ERROR, "Failed to check the overlay FDT (%d)", r); + return ERROR_FAIL; + } + + if (fdt_totalsize(fdt) > size) { + LOG(ERROR, "Overlay FDT totalsize is too big"); + return ERROR_FAIL; + } + + return 0; +} + +int libxl_dt_overlay(libxl_ctx *ctx, void *overlay_dt, uint32_t overlay_dt= _size, + uint8_t overlay_op) +{ + int rc; + int r; + GC_INIT(ctx); + + if (check_overlay_fdt(gc, overlay_dt, overlay_dt_size)) { + LOG(ERROR, "Overlay DTB check failed"); + rc =3D ERROR_FAIL; + goto out; + } else { + LOG(DEBUG, "Overlay DTB check passed"); + rc =3D 0; + } + + r =3D xc_dt_overlay(ctx->xch, overlay_dt, overlay_dt_size, overlay_op); + + if (r) { + LOG(ERROR, "%s: Adding/Removing overlay dtb failed.", __func__); + rc =3D ERROR_FAIL; + } + +out: + GC_FREE; + return rc; +} + --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240657; cv=pass; d=zohomail.com; s=zohoarc; b=B7017Rb/OL1BTGqpChAVGxhE+dqEf28n64XF6THlKC3X/6J/XWFjeuuXACK54szo+ac+5VCCaksrRmm1hPRnKzHs2wd2VvJlnmxmPnH0ERa0RNU+p8wpBV7cpsvaNoMeu672wKecqzYX44o+dUgl80p0BiY+gfgPubISUD63Xtw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240657; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=FM/TeMzOXTEWyhJqNmtglOJVeIkIKXBMkKt+CD1HhRLUZ8HIGW9/Qhhq/W2CYkVCKtJiNK7Y8Dr5q4wlylJXraXbIR1Mc0xu6nQPkJAyuzTzPQW65J7uxjZ5/RfoS/dIJL3OH6lWA2U9aTZ+LEUlwVXM9d0h43wa5snS0A4ywuo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240657932242.36750825355477; Tue, 11 Apr 2023 12:17:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519782.806842 (Exim 4.92) (envelope-from ) id 1pmJUV-0007pa-9l; Tue, 11 Apr 2023 19:17:19 +0000 Received: by outflank-mailman (output) from mailman id 519782.806842; Tue, 11 Apr 2023 19:17:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUU-0007iE-Ba; Tue, 11 Apr 2023 19:17:18 +0000 Received: by outflank-mailman (input) for mailman id 519782; Tue, 11 Apr 2023 19:17:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUQ-0004Ta-Vc for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:14 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 75d4f138-d89d-11ed-b21e-6b7b168915f2; Tue, 11 Apr 2023 21:17:13 +0200 (CEST) Received: from MW4PR04CA0033.namprd04.prod.outlook.com (2603:10b6:303:6a::8) by SA0PR12MB4559.namprd12.prod.outlook.com (2603:10b6:806:9e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 19:17:09 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6a:cafe::c1) by MW4PR04CA0033.outlook.office365.com (2603:10b6:303:6a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:09 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 19:17:09 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:08 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:08 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:08 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75d4f138-d89d-11ed-b21e-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DTml8cnkj84ksqDvwmgLUZtR0xNNi8j8gmyZZ50NnJf6XmYk4HgUz7aoClfr4FK1jkfk4g7plQg+djTV75FFKMdPB0MHeFeu0W4d0eHgep/Ape8kzIMtibQyKSlQ2HcwCfkhZzQ61cG3MKquXcpIboKoRpvhINdRYEs+179ympYaKf2fbqF8cKSx9vE423zovjpRNHKf8rT7ooFcREz351MXGRmnGy6V3YM6zUOi5R2bLLuPmsJUV1ZOd6WLqzdMTidyptnQAZ1a+SAT06XcG4KIgsiHhXXdlILV4juyOxujiRVVO0R3sE+nX8flJHmSfRO67haMXeHYRNxVuNkp7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=HnPfgKNaLFifYRiXm89CjxS4F6TXWN/XgNhsUBNeY+VHE1YVDqBxhjNCQQL9rrOaT2XRtjgRmxCcikoVKx8LaB9Nq4VyTfo4SF/u9kg79qz3XWzXcmnK15+nx4p9iJf2zR5U/9VawbiiPi4Z5SGyGvtbLAqpw0w0GhF0M6caGbWoLlFL5cc9AGmrKvApx63v4pC5aQMtmIDvV66olDZ6NDoOZSfW/jgb4Xt+R4ldKtWAwvLbNW+VuVEhubTNm4sw1xwK+i4JH+RcZC1LwUr+euvvnhE8w4TQmOoN4wA6g1Bup0r8nhtRTHJ4UaCYiJ8oJsInS9QTJaAyt/2IDafrXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=rkrcfNVyCeJcZHMV3Mza5hd29yd4W4yc4A3VEwlix84TV47Qvdg/J/YD/UzPLoW9asNTunX/Xp1eeCtMc+rad/aRjHlgyONX5dtS7Tsk6n5H+vz4iSpN/C0apzzGMBWgTn55O00uFgxIx77ez6Pq5BTvsFNeOEPLg5z4cgq0ftM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD Subject: [XEN][PATCH v5 17/17] tools/xl: Add new xl command overlay for device tree overlay support Date: Tue, 11 Apr 2023 12:16:18 -0700 Message-ID: <20230411191636.26926-18-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT085:EE_|SA0PR12MB4559:EE_ X-MS-Office365-Filtering-Correlation-Id: e028d683-9b8b-4468-33f4-08db3ac158bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: acc5R9HxREvMwAXUxJDUDLP/yKj+S5WJ6zRQIH7J2xdWmf3Jqiu7x0lcP9LSJvCgCr61Qk9r2NXH5f2ToI2cyrpaUf67UPfRtH+cqDrbkgcuvmndpY8kp99iOxQzTV1MwgCXPdcXVFz8AqacI55kDNTUEpxempIAws7UXihOK5HmtDyLJfKyUMrlGm+W+kSv9q7RCCboOcVU2zwbraBLJ/0S+2kv0PIBQQZK8YFeNFVBOaJipQSAHQvdYRdtf5rXVjWEGhawFasc9dkrtYACET2+YgH6HTx3qyGDJU78m1Hu94wiaswrAQl1PdxBrodzHvqioimRUT8hz7VWmUOM9gA5iHF17CLEjxD9XDCeES0fvA4ZGBxWwI3uRoHYiCw0hniX07Rpwu7kM9Ce0cZyFL0a22B/DWq2394y70mdK5twYuNIKSb5TrZHA9bsEcOq6xrTzbrZPDSXEDTL33u6+yH5VG6Ut3qdKkOPbeNxkSY2S7bVPMPWJ0QsunegqlGFmg1GXz3QMTj+7WHEEJ4Ycwp96sfqQnX0a3b3xCSimkkQe3OwPzn5xpQtaFKyW8zg9UykK3EN/efvjcUGcsr6qxgLBnSjYk0k/XXVX8TqWHZAafajz+PAMfJc+aRFCDzRABFLsJdzfmHz+XhqKWdWA1DifLmYYxeIF5IRWUthWjHyOK6pCs9V561lQJMWq3rmDuoT29l5fO/6WKMwB/z54sksBswB4M1iehdjS67IFk8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(478600001)(40460700003)(40480700001)(47076005)(83380400001)(36756003)(82740400003)(356005)(81166007)(426003)(86362001)(2616005)(336012)(36860700001)(6666004)(44832011)(2906002)(316002)(1076003)(186003)(5660300002)(26005)(54906003)(41300700001)(8936002)(6916009)(82310400005)(8676002)(70206006)(70586007)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:09.3544 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e028d683-9b8b-4468-33f4-08db3ac158bd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4559 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240658419100025 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/xl/xl.h | 1 + tools/xl/xl_cmdtable.c | 6 +++++ tools/xl/xl_vmcontrol.c | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 72538d6a81..a923daccd3 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -138,6 +138,7 @@ int main_shutdown(int argc, char **argv); int main_reboot(int argc, char **argv); int main_list(int argc, char **argv); int main_vm_list(int argc, char **argv); +int main_dt_overlay(int argc, char **argv); int main_create(int argc, char **argv); int main_config_update(int argc, char **argv); int main_button_press(int argc, char **argv); diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index ccf4d83584..db0acff62a 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -630,6 +630,12 @@ const struct cmd_spec cmd_table[] =3D { "Issue a qemu monitor command to the device model of a domain", " ", }, + { "dt-overlay", + &main_dt_overlay, 0, 1, + "Add/Remove a device tree overlay", + "add/remove <.dtbo>" + "-h print this help\n" + }, }; =20 const int cmdtable_len =3D ARRAY_SIZE(cmd_table); diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 5518c78dc6..de56e00d8b 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1265,6 +1265,58 @@ int main_create(int argc, char **argv) return 0; } =20 +int main_dt_overlay(int argc, char **argv) +{ + const char *overlay_ops =3D NULL; + const char *overlay_config_file =3D NULL; + void *overlay_dtb =3D NULL; + int rc; + uint8_t op; + int overlay_dtb_size =3D 0; + const int overlay_add_op =3D 1; + const int overlay_remove_op =3D 2; + + if (argc < 2) { + help("dt_overlay"); + return EXIT_FAILURE; + } + + overlay_ops =3D argv[1]; + overlay_config_file =3D argv[2]; + + if (strcmp(overlay_ops, "add") =3D=3D 0) + op =3D overlay_add_op; + else if (strcmp(overlay_ops, "remove") =3D=3D 0) + op =3D overlay_remove_op; + else { + fprintf(stderr, "Invalid dt overlay operation\n"); + return EXIT_FAILURE; + } + + if (overlay_config_file) { + rc =3D libxl_read_file_contents(ctx, overlay_config_file, + &overlay_dtb, &overlay_dtb_size); + + if (rc) { + fprintf(stderr, "failed to read the overlay device tree file %= s\n", + overlay_config_file); + free(overlay_dtb); + return ERROR_FAIL; + } + } else { + fprintf(stderr, "overlay dtbo file not provided\n"); + return ERROR_FAIL; + } + + rc =3D libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + + free(overlay_dtb); + + if (rc) + return EXIT_FAILURE; + + return rc; +} /* * Local variables: * mode: C --=20 2.17.1 From nobody Mon Feb 9 08:47:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1681240831; cv=pass; d=zohomail.com; s=zohoarc; b=B+h3lnL588NNyA+27zbJtNRaqvbSQmodDpyD6SjAxH7Js11Hq41/pPZJYB+pm9vYy2UvXmdeA51fE4q0QNUzkvdLBjuMq7kf/oyw3N1NJyRjnAnqn069V1veskE7vqe7gK7KSWbNUPj1L5/VjyVJ1Vefl2AVFSfWrIboUzxsVho= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681240831; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=DZQlpA1Efim9lvQvbwNBp3RHvXE7olA3WJ5t4Y7P6IAblfpfIstQFWG1I48iDZAKuauJUZSnO09UwZfaSzpOycO67eczFq/GLSQGUOYDVlGrYX9bbp8P4+AsIz/gXMP7TCMpinACleD3l15v0hNpmB89M4wE+GABU/8MKquocSY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1681240831863655.1410720294823; Tue, 11 Apr 2023 12:20:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.519883.807039 (Exim 4.92) (envelope-from ) id 1pmJXD-0003M8-K3; Tue, 11 Apr 2023 19:20:07 +0000 Received: by outflank-mailman (output) from mailman id 519883.807039; Tue, 11 Apr 2023 19:20:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJXD-0003LY-Ev; Tue, 11 Apr 2023 19:20:07 +0000 Received: by outflank-mailman (input) for mailman id 519883; Tue, 11 Apr 2023 19:20:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pmJUk-0004DR-CY for xen-devel@lists.xenproject.org; Tue, 11 Apr 2023 19:17:34 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20620.outbound.protection.outlook.com [2a01:111:f400:fe59::620]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 80294892-d89d-11ed-8611-37d641c3527e; Tue, 11 Apr 2023 21:17:30 +0200 (CEST) Received: from BN7PR02CA0032.namprd02.prod.outlook.com (2603:10b6:408:20::45) by CH0PR12MB8505.namprd12.prod.outlook.com (2603:10b6:610:193::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Tue, 11 Apr 2023 19:17:27 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::fb) by BN7PR02CA0032.outlook.office365.com (2603:10b6:408:20::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36 via Frontend Transport; Tue, 11 Apr 2023 19:17:27 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Tue, 11 Apr 2023 19:17:26 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 11 Apr 2023 14:17:24 -0500 Received: from xsjfnuv50.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 11 Apr 2023 14:17:24 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 80294892-d89d-11ed-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bXcp6be5EOxaRQCLBYG53j+05Hu7TinVPhvIYfE9gJxAavjYLIKc6/7NioHLDCrcurhEiJ8Z2L+kT8x8gZErqZHQveFz/ruJQC4QkbuQqpM+92ljIOdfuP1I2u/pM4nz1sHzr2x8WdmSAXTeG2eg/BC+DDTNeWk8lZjUOdCyn5diec1fDD9yvuLTOeQ5YgC0gn68dAKFW97Q16ccg8J0j/r0k1YHoqXrxJVxZogmu9dMnkw80x5/LFGjdetpX2PvM8gZoSG8Fdn4fE+/BJeN2UF7mygE1eUVZUG4NOffEyu08L0s9wDgjSKyuYNR4a6rehID9pHzKBo806PvJx6twA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=UESNVU5X4U7Mb1sIUnUW6Y8bS06cx8WSLF1wrd4oXl7LaOBS0lr2K4Qe0+ehQ4ecstfVO8GS+uIHD58VyL/8yZaXE/DygxLfAybnwrm984eiL5SYI0oqjyWMNEyuQdrRqupBzXpjJIi19DjBXsAG0H0LpvXjM9vfuom1IOdVOVhKy9TyxbfNtu2BtzMXEUFOcZOUNiEBsqb/5jL951M0S0Qprc0Qm/rS23Ykn9k6VAfTYSm7Bei64FeQbd9n/gDX+HlnvFgBlEEZ7mgdlduem0kBgsuoRoMTv/hkzr2rYS+E1YtH83fyufPQzFdQCIK5LLUkEsBxy6Vf9O97nLxQQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8ANf04rvVBwwTVoSmk1wMh7BnV4jbgpw3PgliDnkIY=; b=1GiTmjkOyBemqL8wpiEBx/y65ZzIdEqTLmoD55ye5iseqtdm0w/3O0UOXVUz9BaJUICEmxgiIUKELqme1d8WUFiyqIehMkIZFtdJjfne7ZG3siohBJ3oBuULNFkBPUYiciJZmCtGOKSInpWejEyWQCnaqdfWD0LwyroHP+ufIqY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Vikram Garhwal To: CC: , Vikram Garhwal , Wei Liu , Anthony PERARD Subject: [XEN][PATCH v5 17/17] tools/xl: Add new xl command overlay for device tree overlay support Date: Tue, 11 Apr 2023 12:16:36 -0700 Message-ID: <20230411191636.26926-36-vikram.garhwal@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230411191636.26926-1-vikram.garhwal@amd.com> References: <20230411191636.26926-1-vikram.garhwal@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT012:EE_|CH0PR12MB8505:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d59fb95-371e-40ee-d911-08db3ac1632f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nW4r2U3H6TrJMWIKgWISxhpfKTRgrSgjfkPPjFEqwV+PV72ixWavNRL57lf2zNDQvBzpHxBd5fpfXOKDOoZuT0F9iXe5r2UGkLbHTo6FDWqwLxgsVqgBDxQYeUyVovX0KXicgBcTNmyPeNshlu+kRcDVyNvkn0Ryy5uBzfKG+LQctr271k1kF/ky7COwagWYTdwNcUctEsn+FhjKBK0+QXRmkZxEoZry2EUPvR3YK7IHS0SxTml6xucxAGGASNSmJpKQ0uiyfGDDjXnpZvfU2XL27qCF0OqLy9kXAtayBDdOisSra46hjYIDTtFTX39UaUk88yN1vPb0y6lYaDNMjkpp0U1qDpba40BDxhUgF7J0YL3bi31c5fX4jlBNiaLBxs3mElWEAgWdiXNCmVXwWFSfYwpjqq6L8CQgQZ/qUolUvE7N5+NJo1FJi0NXaiK4Oyv9lizIqEXHugZILPEbXo0NMfd1UTeSxPaMCK3iAi82zqUogxDD6kmvFO70tx/W32bf5hrPW08ShFLiMMB4cNea0g2f4SJ9AarBaBKiClsUNU+cnOX/XrGaWwzWVky1+pPgzMt0P0aZwIOHXWKQB682ONv95mLVneYfIc6DkQXBeXpGxsQtFtsGo62JFcw0lRgf7pUQwrPbHvo+63NR+VUp5MY9uhdzRvacRJq61i0hCX6nkI0QPvIdactc/McmqnLOvsBVAvi+O6tG0bbpOhvPh1fsTupE8G+oJmTh9RU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(6916009)(54906003)(8676002)(70206006)(70586007)(478600001)(4326008)(41300700001)(316002)(36756003)(86362001)(83380400001)(336012)(2616005)(426003)(26005)(1076003)(6666004)(47076005)(8936002)(2906002)(44832011)(82310400005)(5660300002)(40480700001)(36860700001)(81166007)(186003)(82740400003)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 19:17:26.9767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d59fb95-371e-40ee-d911-08db3ac1632f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8505 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1681240833566100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/xl/xl.h | 1 + tools/xl/xl_cmdtable.c | 6 +++++ tools/xl/xl_vmcontrol.c | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 72538d6a81..a923daccd3 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -138,6 +138,7 @@ int main_shutdown(int argc, char **argv); int main_reboot(int argc, char **argv); int main_list(int argc, char **argv); int main_vm_list(int argc, char **argv); +int main_dt_overlay(int argc, char **argv); int main_create(int argc, char **argv); int main_config_update(int argc, char **argv); int main_button_press(int argc, char **argv); diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index ccf4d83584..db0acff62a 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -630,6 +630,12 @@ const struct cmd_spec cmd_table[] =3D { "Issue a qemu monitor command to the device model of a domain", " ", }, + { "dt-overlay", + &main_dt_overlay, 0, 1, + "Add/Remove a device tree overlay", + "add/remove <.dtbo>" + "-h print this help\n" + }, }; =20 const int cmdtable_len =3D ARRAY_SIZE(cmd_table); diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 5518c78dc6..de56e00d8b 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1265,6 +1265,58 @@ int main_create(int argc, char **argv) return 0; } =20 +int main_dt_overlay(int argc, char **argv) +{ + const char *overlay_ops =3D NULL; + const char *overlay_config_file =3D NULL; + void *overlay_dtb =3D NULL; + int rc; + uint8_t op; + int overlay_dtb_size =3D 0; + const int overlay_add_op =3D 1; + const int overlay_remove_op =3D 2; + + if (argc < 2) { + help("dt_overlay"); + return EXIT_FAILURE; + } + + overlay_ops =3D argv[1]; + overlay_config_file =3D argv[2]; + + if (strcmp(overlay_ops, "add") =3D=3D 0) + op =3D overlay_add_op; + else if (strcmp(overlay_ops, "remove") =3D=3D 0) + op =3D overlay_remove_op; + else { + fprintf(stderr, "Invalid dt overlay operation\n"); + return EXIT_FAILURE; + } + + if (overlay_config_file) { + rc =3D libxl_read_file_contents(ctx, overlay_config_file, + &overlay_dtb, &overlay_dtb_size); + + if (rc) { + fprintf(stderr, "failed to read the overlay device tree file %= s\n", + overlay_config_file); + free(overlay_dtb); + return ERROR_FAIL; + } + } else { + fprintf(stderr, "overlay dtbo file not provided\n"); + return ERROR_FAIL; + } + + rc =3D libxl_dt_overlay(ctx, overlay_dtb, overlay_dtb_size, op); + + free(overlay_dtb); + + if (rc) + return EXIT_FAILURE; + + return rc; +} /* * Local variables: * mode: C --=20 2.17.1