From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441407; cv=pass; d=zohomail.com; s=zohoarc; b=Ph61l9ahE0jGDkcnKlfGUrNXhWmy6DeV00eZdfVDb+9nl5q7glMguFdXZf3FV9ZTyViQyuhOceOzO33EOwXkRJfcv4dObT30MTdnlyGdyFRuprhqae/wRYSjXERLKt+Nsr9nwGqsfYM9loUjqSXtl/NnbZmDrOEOXEiybMHOxS4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441407; 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=ucS9bxaKbvaVkKdEqBhV0clkSHJP3512JULTceCiTlY=; b=cbtj3rhejHw1mAR7fJUAFywYyFoOaUx8Mt25CoG+/mxwaopBBtKbQ7I+oq1tLuXWareOffCYhCGqsMVRcD3rrj/WOq0ot4inGBMRrwBBYmI2CyW3HNP8UKIstwcx2lPWC4k+cnv+Iez06DAfLC9z/YKjMQLcUBCalSRV5+t1vm0= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163644140756825.257592558940814; Mon, 8 Nov 2021 23:03:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223702.386552 (Exim 4.92) (envelope-from ) id 1mkL9o-0000ye-AI; Tue, 09 Nov 2021 07:03:00 +0000 Received: by outflank-mailman (output) from mailman id 223702.386552; Tue, 09 Nov 2021 07:03:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkL9n-0000v6-Ss; Tue, 09 Nov 2021 07:02:59 +0000 Received: by outflank-mailman (input) for mailman id 223702; Tue, 09 Nov 2021 07:02:58 +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 1mkL9m-00004s-GX for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:02:58 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20617.outbound.protection.outlook.com [2a01:111:f400:7eab::617]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1057e480-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:02:57 +0100 (CET) Received: from DS7PR03CA0312.namprd03.prod.outlook.com (2603:10b6:8:2b::21) by PH0PR02MB8764.namprd02.prod.outlook.com (2603:10b6:510:f1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Tue, 9 Nov 2021 07:02:53 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::6d) by DS7PR03CA0312.outlook.office365.com (2603:10b6:8:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:02:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:50 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:45 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9Z-000Ga6-B8; Mon, 08 Nov 2021 23:02:45 -0800 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: 1057e480-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hvhb/GtflsSdlsrap72a9LIKqeI+HQaPHZQE6u7fqQVPFcbVp/OeswCDREjCpK0j2R03wdszzOHUkEawJKA9vlMH+6/u43YglGd4496Eed4rsElW433R2a4dFK5NuDBRA1IPrp8qOA42meNsWLKJxesG4uHNqu9z0ck6VR9pVQxa11uUmy4Yv9IqNoQiD+bSybBR+Z2nDxfRMW4Ekczf4UCiq8yETBCh9YeL0+S0GOoarNNM6KDbRh7t2LvJ2ygGEl+X20h8dGezN4qFLHyKKhXJxPYcb8Xhx2rme5fBrZb/qNaz8GoXLRvI75b5YdRqZ1OAG/CwEFx6/wukriRVtg== 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=ucS9bxaKbvaVkKdEqBhV0clkSHJP3512JULTceCiTlY=; b=WdigXF73JSyVQotKNifoDNsKB742B7i/wntqMxIkl2y8HYxJ5D/1nCpxYTIgfwZH5FibPHdmmaTYhPIEunBUYn4weC17tcsBDT8uPvpmAGPgQz10LjF8hIm8FjYITOPXP3jZHJQoeDRWLSLVmRwPdoPy/g6Xc3G95TIVQXinQg1yR7a4zmcYO0ZA4sNqfflwhQ6CdE88iDHjuYY/3Nr7+NeMUOIgsa79btfzggpApMPoWt7ab/eXFQkFZ1SOUapOYU1e5LNyl/qak7sVDsjtKB9jSq4CGHdggyMT/X+ag/oaB/5s2VBzpKoUCg4japg52CiV+6Dk3OIFKkb/J84OPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ucS9bxaKbvaVkKdEqBhV0clkSHJP3512JULTceCiTlY=; b=ffaJvF8Ge7QTHN8Jqk3nWzUTec/X9ybR8TO4BbBMiSNTcCZdPBuIHoBk7v96wt2nQkUX4JfPPCwdjlcV9+1osb99Nk8cUCc5Fs4200EXSNG+gvyCWiB0IHdkPHkqhfB1txPIOI/3KOFyPbNS4NBCmDcCBhtD9+cjEcxzQa9mfYs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Volodymyr Babchuk Subject: [XEN][RFC PATCH v2 01/12] device tree: Remove __init from function type Date: Mon, 8 Nov 2021 23:02:16 -0800 Message-ID: <1636441347-133850-2-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dcf0a359-5a55-466c-0314-08d9a34ef323 X-MS-TrafficTypeDiagnostic: PH0PR02MB8764: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:478; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hvv82Q3NNI84GInLTU04XdX9QUqq063oCXClE9vDHyA7ZzOjTqr7YSIRInytYWiKAzDaN2WmRgISQih7XNEsVCEzYORNOspQtqLnj9LOnSJcr53/TaMBN+yHX15zOmTQY97Jqe4IlZqhAHdlEI77/gFscQyEO5BN83MPiAjwfksEdWzoIwiubpfQW6eo2Wzf1xJ3mvha3wlvSqYMjQeYqLUyIXjoyT9AFqF8015Z0N2WSRp4+fWMme2wr1nSxY3PTHShukbLgWTMgjdIRtGPfIbfHocf1xTrSAqfsgf2ydRla4rIOIUEzj7EVdmBSWmmtkKIaeq1VGh9ajTciBKZj/rRQ9zdaVvP9ssviwAbeqrosvz/15QR5AWKFYMkCObbgqXQByS/2tU+cu5bq7PwlkZ9TBRNCCZJ0w+rhuL/QUEa7aJy0agnr1DnNmVggSHS14j61O37L9e7jRkHyx628QV7Noza9NOarfBSX3GvWP8KK1LHxJ0eUT/OcvxmrA9kZIv0RzMN4vpK4aE0PL/YRD8J0Os5RL/hj04PfQ+mAXJIzPA8v6cjCsaa47piIxiooyfezaspi/5mJhHpk1kFh3SC95/5Yk94Mfo1vH2pcwIqWgxe1ji/2d63UfwT/H/HPZUDZd84u0Lx4yrhWpE66o8KtGFkTP00Ppnj+USedVeR4USPr9tobi2vsLiiBWsIsR4E7terP5cW7Hf+IAkTHFnpL4W2MYWdw/PcUHoeSQ4= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(356005)(8936002)(186003)(47076005)(508600001)(82310400003)(7696005)(2616005)(30864003)(7636003)(26005)(70586007)(83380400001)(36860700001)(426003)(70206006)(8676002)(54906003)(4326008)(6916009)(2906002)(9786002)(36756003)(36906005)(336012)(316002)(5660300002)(6666004)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:02:53.0401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dcf0a359-5a55-466c-0314-08d9a34ef323 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT010.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8764 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441409356100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Change function type of 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(), handle_device_interrupt() and map_range_to_domain= () to device.c. Move map_range_data declaration to domain_build.h. These changes are done to support the dynamic programming of a nodes where = an overlay node will be added to fdt and unflattened node will be added 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 | 146 +++++++++++++++++++++++++++++++++= +++ xen/arch/arm/domain_build.c | 150 ---------------------------------= ---- xen/common/device_tree.c | 18 ++--- xen/include/asm-arm/domain_build.h | 10 +++ xen/include/xen/device_tree.h | 5 ++ 5 files changed, 170 insertions(+), 159 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 70cd6c1..c7cf2b9 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include =20 extern const struct device_desc _sdevice[], _edevice[]; extern const struct acpi_device_desc _asdevice[], _aedevice[]; @@ -84,6 +86,150 @@ 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; + bool need_mapping =3D !dt_device_for_passthrough(dev); + 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 ( need_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 0167731..3e8f6da 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -51,12 +51,6 @@ static int __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); =20 -struct map_range_data -{ - struct domain *d; - p2m_type_t p2mt; -}; - /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn #define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) @@ -1624,41 +1618,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) @@ -1690,59 +1649,6 @@ static int __init map_dt_irq_to_domain(const struct = dt_device_node *dev, return 0; } =20 -static 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; - bool need_mapping =3D !dt_device_for_passthrough(dev); - 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 ( need_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 @@ -1773,62 +1679,6 @@ static int __init map_device_children(struct domain = *d, } =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 * - Retrieve the IRQ configuration (i.e edge/level) from device tree diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 92ce59e..88f3f7e 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1821,12 +1821,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; @@ -2057,7 +2057,7 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, } =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" @@ -2066,7 +2066,7 @@ 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, +void unflatten_device_tree(const void *fdt, struct dt_device_node **mynodes) { unsigned long start, mem, size; @@ -2189,7 +2189,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/asm-arm/domain_build.h b/xen/include/asm-arm/domai= n_build.h index 34ceddc..17449b1 100644 --- a/xen/include/asm-arm/domain_build.h +++ b/xen/include/asm-arm/domain_build.h @@ -4,10 +4,20 @@ #include #include =20 +struct map_range_data +{ + struct domain *d; + p2m_type_t p2mt; +}; + 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); +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 le= n, + void *data); =20 #ifndef CONFIG_ACPI static inline int prepare_acpi(struct domain *d, struct kernel_info *kinfo) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 573e4a0..9fc63ab 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -177,6 +177,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.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441416; cv=pass; d=zohomail.com; s=zohoarc; b=mKHWBGxFOOwSFPLmGQ5PPZmWRjlvd5kcrrWUNLJDkv/5eeEaUgzQAVosododSZzrkEzEPm2MqEXzC8+1YKbP97NVb13BU12fpv2u2kvr5/h34grxtW6V1b1gghp0PPUM0A+yTqAy6yyM5oAuoQ08Y+MKSNqV9pJICbeVhhxFTNY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441416; 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=8VaOJ+8GZMWgZHrNqEq58Dkcy6TjJZGMbhhxpS2T/S8=; b=M4LPOSnhvXeesOFds9GNn92mZ9l2nH75N1nWGw+I9U1qUyJn18WiIOvSxlf0mKR9RFcN+Jezgb3OGO7MRMXSQgX78EUQnl9wzzx+zLZwrwLfz6adZZY+i3x31C5Eh10lieb7wL1OmMzLOjpZiviRAFWjuuC6sNKTpfRPhP1qaUo= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441416960697.4108099033704; Mon, 8 Nov 2021 23:03:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223711.386614 (Exim 4.92) (envelope-from ) id 1mkLA3-0003NT-3D; Tue, 09 Nov 2021 07:03:15 +0000 Received: by outflank-mailman (output) from mailman id 223711.386614; Tue, 09 Nov 2021 07:03:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkLA2-0003Lp-P3; Tue, 09 Nov 2021 07:03:14 +0000 Received: by outflank-mailman (input) for mailman id 223711; Tue, 09 Nov 2021 07:03: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 1mkLA0-00004s-PF for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:12 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060e.outbound.protection.outlook.com [2a01:111:f400:7eaa::60e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 190b3351-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:03:11 +0100 (CET) Received: from SN7PR04CA0171.namprd04.prod.outlook.com (2603:10b6:806:125::26) by CY4PR0201MB3619.namprd02.prod.outlook.com (2603:10b6:910:8c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Tue, 9 Nov 2021 07:03:06 +0000 Received: from SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com (2603:10b6:806:125:cafe::6) by SN7PR04CA0171.outlook.office365.com (2603:10b6:806:125::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:03:05 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0011.mail.protection.outlook.com (10.97.5.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:05 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:51 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:46 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9a-000Ga6-5E; Mon, 08 Nov 2021 23:02:46 -0800 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: 190b3351-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uw2mqBsT/podGjo0e4HbCsdiW99Hcw1Rt7XMZeEqG8hiSpWp2PK8IWmbj3DFma3PwGORhy5E4fgRITB/e1XvHwzFH/uzxJd7i0ENemAXq20Oblr7gDYPjLpMW4EN3A1m0W6eKlkrf7a0XN2/pxlxN6gXitXdW2j/l+w1xVAYnCWZ9e6ibM8+xIx7cDJq3uEio8EuMKRWThKWTOG7weO6xWLgzPKlwYkL74hnzLdltRIJ4wlC+Tiuykx62S6qhB5FXP1r5wdo8sT9f+XYAEuJlFP0AQnvhQw57Ib4Oe0nYsj4/+5yiHIM8WTe74HsFES9y8yoIhvp5UeLLEZIkxA0LQ== 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=8VaOJ+8GZMWgZHrNqEq58Dkcy6TjJZGMbhhxpS2T/S8=; b=S/JTK4k0UjCFIQrN5hMZyZDlKfODoOXA828h/j6lDJhQ9+MIkPb5VXNzECkNRB3apLOohJKO0vGfoSVbRkoXVRd/NVGOowDsw9BoAV1GeaCaVEtqQKVRM7DSmWWEQMDUDo9nPNSvoGuNqcbpi/OquGha/NtTcd7T20uCgBwgPT7FUd65lWsol3rZ2lpw+P8YGEFAvp2T/LccMC03zWE8acI4wgyAD1wJ1Agt79wgLXx/WzIyKgOyLvIwVehXAx7ZtWHoSAt4pfWETXXDymSFlx4OfrxzxWhPVcPhlalSOI0fwx8FMY3XAGgVLDv1Ijfo38/NriSGXDLoWMfb4MUvfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VaOJ+8GZMWgZHrNqEq58Dkcy6TjJZGMbhhxpS2T/S8=; b=se8QdvxRM1TifQvWktH8CQlke+U+gReTn/oD3IJ3h8sEEv+7TNqMWDXLLUtbQTroSxhMcyp3v+74zs+gs9oVmq9ajpimEr6LSGLE2PNchcMxT86w6ICOBaHfMVcixURIXEBE19YtC9vyAx+KdSNhWO8mnLWtfgHSlzfCJTodyJU= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Volodymyr Babchuk Subject: [XEN][RFC PATCH v2 02/12] xen: arm: Add CONFIG_OVERLAY_DTB Date: Mon, 8 Nov 2021 23:02:17 -0800 Message-ID: <1636441347-133850-3-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d47c434a-1be6-4998-83d0-08d9a34efaae X-MS-TrafficTypeDiagnostic: CY4PR0201MB3619: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:419; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aXnyCKOHAw8E+QF0/lfWdljerbM5thMYCcyCqHzO33D19myJNrXe/Djn+pleYNT9wJ5Qh6OluB96HA8rIeslJMucqRws6koL9t66uE8HQv7ib10v0UEcealb6+jEfg8pxUqWrPZOjjRuVubSuSO2+TSxlWxtebpMB6kY9xw/Kd1akLhbTyqXw3Y1u5weDdyBuduGQE3NUJKk/kj7aB/QrEVB2WgSq9cWgch9YVujn7/agPYmgPObx37oYbX62mO1DYgfsZMd+kCt25567JXJtSQuYue0uARjzVone9qGiAIPx9h0VexyKGdVnJKysWB18NUhvir3Iwa6tte/7AUEahZQ+83IGK1Ke1+nsA2RHobJibgvlo8+C3b7b2oUS8+ShKjCfbZCzjqIaYOgkrB8v9KNggZ7NmUHBJlHsYNPePbBvOY8dTblfDnfj48mLrfmcfzCfdgXLRIOoLMXEXnfSKmgDsgER0GlZhv+23zilFwsikfVCNsu92ddNnavVEVCRto8iY24ZwZJ6o14Cd9bQRj/AVHHCbEsQlabD9Pme19dVFsallXHBo2qwOpknS70s3NtNKmUXvYPx6rzSLDVAJkJWnWx+G7lZMYe25Rs4tGzrWJklwd46n1CEGJY7OeCc9HseWY+NmdFoF/1tAyhC7DQZVE7DCp8UPG/CVdiC9PqhIHmfUyG0GANu2WIM3AYoU9ZBowQT0zia6QCyHJYxdSaViRFtr/+ieiNr04S6x0= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(8676002)(6916009)(186003)(47076005)(26005)(6666004)(356005)(426003)(2906002)(2616005)(70206006)(70586007)(7636003)(336012)(9786002)(4744005)(5660300002)(7696005)(4326008)(8936002)(82310400003)(508600001)(316002)(36860700001)(36906005)(36756003)(54906003)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:05.7303 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d47c434a-1be6-4998-83d0-08d9a34efaae X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0201MB3619 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441418380100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- xen/arch/arm/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ecfa682..895f0ee 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -46,6 +46,14 @@ config HAS_ITS bool "GICv3 ITS MSI controller support (UNSUPPORTED)" if UNSUPPORT= ED depends on GICV3 && !NEW_VGIC =20 +config OVERLAY_DTB + depends on MPSOC_PLATFORM + bool "Enable DTB overlay" + default y + ---help--- + + Allows dynamic addition/removal of Xen device tree nodes using a dtbo. + config HVM def_bool y =20 --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441410; cv=pass; d=zohomail.com; s=zohoarc; b=Smvj3njUgn+WLJRZQQlr5k+ZBABRfZehDiJTqFFwXDvDlWuN3UojIVyZAkdrXjqA5iLSm+PumCMy0S6+21IOeoMCclp20oPLtryMKCtzQWPwu97lDAOielOdnxedp0xVsMs5aWR2kOQx5le2nlP65eeMad8A6zPqps+gVKjfRs0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441410; 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=WG0xFb3mDkPyPuUeQfLweYulR61V/m6A7KyclRYvaO0=; b=VmSsH92RSeePlWK9X9qTV9qTltLxagBR2mBpaTxwHX6DCeFEaYp0BZCpREtlrZ+YYJP6RcqNu1Vc+N/dGzFhCWaZh0ju2tCTBZkePwpL7a7KfSXno5KuL/osylmxhqVHf5TTpjoxacCxIrDl92yw+grxLo92j1x7LJCclUQRsC8= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441410889501.73940521674797; Mon, 8 Nov 2021 23:03:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223703.386574 (Exim 4.92) (envelope-from ) id 1mkL9w-0001zE-Ow; Tue, 09 Nov 2021 07:03:08 +0000 Received: by outflank-mailman (output) from mailman id 223703.386574; Tue, 09 Nov 2021 07:03: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 1mkL9w-0001z4-KB; Tue, 09 Nov 2021 07:03:08 +0000 Received: by outflank-mailman (input) for mailman id 223703; Tue, 09 Nov 2021 07:03: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 1mkL9v-00004s-Og for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:07 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2061b.outbound.protection.outlook.com [2a01:111:f400:7e8d::61b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 169d6844-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:03:07 +0100 (CET) Received: from SN7PR04CA0011.namprd04.prod.outlook.com (2603:10b6:806:f2::16) by CH0PR02MB8060.namprd02.prod.outlook.com (2603:10b6:610:109::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 07:03:04 +0000 Received: from SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com (2603:10b6:806:f2:cafe::1) by SN7PR04CA0011.outlook.office365.com (2603:10b6:806:f2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0031.mail.protection.outlook.com (10.97.4.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:03 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:46 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:46 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9a-000Ga6-Ni; Mon, 08 Nov 2021 23:02:46 -0800 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: 169d6844-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=POXcJey1kxEMAbWxtS/aapdEdNhPZcyjTr5ykNDvMVSqvRCqf0vZNcb4itgO0NJ0b9ETJRqJxPCruKAFzwQjkYCoNCZxe81+LNOxNrpQ6EsspQ+GAAkJl0Odl9Y+pTdq/szi1fIuzRsEWcjblD4gsvlCsUNmqDA1DzO2yMPrExk0PXWdtdA2s/nsnDzxRCSCTnpfrWMMvzR8N9tTOVV+reGyKBbqMQGV8PyuWFgatyKw2IHmUHgsP71MY+Nwd14AiathVPxvdm5ANYwaTQbtiJ6jSpwxa/MYnCXlFyJbzzn5XgKv9o/LGy79tU/1v56PFfJsqTORxZ6rekC1KTFYPg== 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=WG0xFb3mDkPyPuUeQfLweYulR61V/m6A7KyclRYvaO0=; b=GDvwZfrGW0ixdzChhguqMZuzM3qfYbUtQmNKFH3q1g0yMmdiMrMR4Sx240Maap3KnzHlvIkFvgui353A3GzYb8UwDU/+tdG4om9HFROkscopknB9ZEfmBwnfD0OxPv4ZjXI4kDBAjonsHninQSw5JEJpe/QNyFhe4PiXzEO3XLZC/di9n9pRPsfDJTrGwXzxWUYP3tgqDkAUNYfMe/rQGyxYav7cOCMSUyekWg+O2jmE9z2OB5FlWuRNwVTas10DrmWJsgHXbOo8k3XZOHqR+IYKE/dcnS7fQ7iRHgcei6c11Le3/DkLY+SKF91sbWzOnmke+3yfzwKAOvXZbhiQ1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WG0xFb3mDkPyPuUeQfLweYulR61V/m6A7KyclRYvaO0=; b=KlJQBWNVUpzjDgZktFjw2cSUCjd7vhx39FY2gm+cW9K+NKY5V29s32Re0YfUjeMkLx8bXGORb4cepWCquIxudmRqhw+POSP4swFbe0UTD/2eZWTkDEgYVe0lTCVIQyblHDPD83C2Ta4eV8fbh9gZhB0Q0wLF9bXmAp/03xY8B50= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal Subject: [XEN][RFC PATCH v2 03/12] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB. Date: Mon, 8 Nov 2021 23:02:18 -0800 Message-ID: <1636441347-133850-4-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0beb327a-5bda-49d4-d7fd-08d9a34ef968 X-MS-TrafficTypeDiagnostic: CH0PR02MB8060: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:162; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9eCpB3MIylPPtaKZHwPYtoz1ceK+JyUzja2YtSrFdkEGXmvb/rmNVgSh4w3XlL1K0bHmMV3OiIxNBPODMmrRnquU/BntXltufsZicRP5nSkwJOhtLPMCxz4VJG75UPa1IJpodxt5vHj6KcHsyaQt7kgrBqFTPyDX8A8JEzs3c2/+Hw0MG1jpwsfoqG9QJ16/M0XZqpNXGrqMDyXd8h7BCGtmcv06YLob4rPHmno2SJf0Us+rMPob2J7go/jfZZXptuD0cW4bjyYwatgBtNyEsWn1doTKB06BN75vPNOhEcJZmqbcQGDXXQxKqInX/9qpUe1EvPgqz2iJn9X77GakZPvZ3bf1CsXmZnBfKJxQdajl0GqQtYFcv5YmVSD6k/Cvu1xz+UzCo8G01JPDGU7o20zopFB3/rFC9Nnu1KYlmWibcYE1ocFZjfKc1BNu3DcSj+uOIF/EtZDDu3BYqvjGKFAzMUavBpGnNf9ZT6nOre4oKe/RfA/flW7XRoBC33Oh3j8KBr7rWEyJBIM2M+Si2MuDR0hgKl499kbujoke+taxakNMwCB+qvKOpelOfeezh5Ou6MwWISVGHFH5+a3Jf1JJgh9UXCAa613KrGDjPZhuKmRtYzclqbu1jZJEvMH2ecHMIp57DgDpoixuFmLDzjiE+bbLjZBfsUjCS6iw/qVx4CAQWSgE8ONW7MFdWQx566AFyqlilzeSQvfIzebfYp5lUu2vrvahvmeXnsF02xE= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(46966006)(36840700001)(36756003)(508600001)(54906003)(2616005)(4326008)(83380400001)(6666004)(2906002)(7696005)(6916009)(5660300002)(7636003)(107886003)(9786002)(356005)(316002)(36906005)(47076005)(8676002)(336012)(36860700001)(8936002)(426003)(4744005)(70206006)(70586007)(186003)(26005)(82310400003)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:03.5960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0beb327a-5bda-49d4-d7fd-08d9a34ef968 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB8060 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441411602100001 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index 6bd207c..f838f5f 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -1,7 +1,10 @@ include Makefile.libfdt =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) + +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.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441414; cv=pass; d=zohomail.com; s=zohoarc; b=j4/cj6Z2XLUxHGcK4WfP06KxxNL9nnwpi2LbypzzyROyx9aVZv9zwupsJdMnqkb3eIy8op7l7T8t+sBuICTQkW+f/4/1TOauN/0Pj8yx1Pvde97MGBor0UwX1us0tTVAsyYCpYAMzq+oQcAKQjIDRbR8wLAdsxGTyMhmMz06WfI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441414; 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=0Fql05hs8YXgjepE7Xhz/cxP9a1+eoyB0oUmynBhbxw=; b=SikPadS7J6MzSPPm8wdYxjl3LOpZYhb8OUmcvBgHS8pJpNJC7k1BI3K99eWnjfolkSWyOFE34Nv1lPQRiNRvz/HiIlXrX09be4AnFgIZxuEMZQd15gJbDFFB0ePKkgZxghsl3VNf9JFtBV+qps2CgwX7oEE+ynCVKNbjPlEMvIA= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441414846326.4760725623679; Mon, 8 Nov 2021 23:03:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223704.386584 (Exim 4.92) (envelope-from ) id 1mkL9y-0002Gs-4z; Tue, 09 Nov 2021 07:03:10 +0000 Received: by outflank-mailman (output) from mailman id 223704.386584; Tue, 09 Nov 2021 07:03: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 1mkL9x-0002G7-W9; Tue, 09 Nov 2021 07:03:09 +0000 Received: by outflank-mailman (input) for mailman id 223704; Tue, 09 Nov 2021 07:03:09 +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 1mkL9w-00004s-P2 for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:08 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20627.outbound.protection.outlook.com [2a01:111:f400:7eaa::627]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 16a729db-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:03:07 +0100 (CET) Received: from SN7PR04CA0151.namprd04.prod.outlook.com (2603:10b6:806:125::6) by BYAPR02MB4215.namprd02.prod.outlook.com (2603:10b6:a02:f4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 07:03:04 +0000 Received: from SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com (2603:10b6:806:125:cafe::d1) by SN7PR04CA0151.outlook.office365.com (2603:10b6:806:125::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0011.mail.protection.outlook.com (10.97.5.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:03 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:47 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:47 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9b-000Ga6-7N; Mon, 08 Nov 2021 23:02:47 -0800 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: 16a729db-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCweG3OeKbLm9pcVQWFFHmJcUZ0nghsurtf4L/I02bztruGwX8hqQ8abDpBXSQF9D7Ajt4mkwg0zQHM34/+ItWl8kdl6KX0K3exeUNk5kO/OCA6OpZkYv83EhgHHihtzEsEVmpjKhXJ0GksU0VMB5+X1TFewWeuAjWjyrAga7qW/ZKFeJHkHAycaHFxPaokqgOaJsrdr/slRF0AOz2f3SAIPP8StiKWU4efaBmSTlAC5/n3dxA35nOGYd2gmuC0pZkWxlaLGj3vJ4VKncsX26soXrjBoyD+QsaCiC+2DKUVslw3i1exLgadMfy6aXuLr5sdbYotW1f5JkHewj9zM2g== 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=0Fql05hs8YXgjepE7Xhz/cxP9a1+eoyB0oUmynBhbxw=; b=YPBnihvDhnOIbwb5E9kVJtYoe6m0Iw2q8bFCVn1c0fJb+ZB+Zjn1cno9wZPun1CBTPB0IrJ3gSpBlEN0Jtm/LtWS/ADqBQAm+hgZXudFqMZlKBFPcnzZsN45mSCKcxReqkQW/gqfOBPlW4EjyKrQF+f7unjcnnYU3hjnROCFDvFIoRc8tgGkLUzobKsHd1C/7Mcswb2FIoQGfG5Z7BLIXfHKjsGJcEtRKC42nxV1N7YgfTC9dFNm2yazxq08Mf6TOX1ndSl0hEVKeYkLSZKHrGuoQm2hxzlg3ncy+J2f2VPaA3dIoPkZBgEJZOrM4cWHl6OeTshyFhQmF550JzgoMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0Fql05hs8YXgjepE7Xhz/cxP9a1+eoyB0oUmynBhbxw=; b=JvjNCc7VuZtbQfnJMoD07KzES5qIdZp8+xqzDsHfRog5t/gsIRQ080FXK2Yz8damjCYWJ/gRngmCWJEo+iMLnJInrZeAQauh8S2osN0yyfRMoI08Q2AxbHrA3l8iNLJgXZt3eZDyXHD9lUYFt0BepBBUWzXq6oYjq0ufZvm7NO0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal Subject: [XEN][RFC PATCH v2 04/12] libfdt: Add fdt_ prefix to overlay_get_target() Date: Mon, 8 Nov 2021 23:02:19 -0800 Message-ID: <1636441347-133850-5-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c742b77-b06e-4ddd-5241-08d9a34ef96b X-MS-TrafficTypeDiagnostic: BYAPR02MB4215: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HJ6phTSI/Gijv0Ww1XTUIN83/EGjiM0a19/68+rSWLFmWq58diQPM9taCgYW588TY1aKPvBBUyAd105VfF+In8sngwJmBvFR72yIp95FRW9HEdLyKlre35G8W4pxWc7GxbolqC88bmtTqSUJtSgs0HNuKOtxZrlQNiyP6pyRgO8P2iHjo+jMKkqAdoHZc5j3cWVzA/j0c7AmfH7Tfu+/0XJr3b+gib048unvygYR26qSaropagRovYBBno/7J0BqGKvhYFdiQpxAv4eOSK6m98L/DEz1P+gZll/N7llsE+k7JtTvfPGB7eL0pO7ADEzmuSTNExdg9eJMLv8tVvd8kVXt2JOXtXPPhsUbqUDyLCKYNSTLEQv+jTQ9NkkmcGsrOrbWazWzC9TL3H+UI8Kx7aRCjDgl/B0RM8lbaTgFl+pnP+/5jMi4iLfQ5jifEVVHHhkAr35iBU+VMFewAfiQeIF3Pruqd1XKyiS6dM+oJ+IHDyBpJlc1+wdPxAouCYaPEt7oXw5fyYYihUnftPENPpuMKWfJ9K+vmsWcs16CAREaAO1tloB1gPF6Vz02PR61WN9v3ehEtrm5v4eC816lPMTVUwphVEvicVQ74XkAfWb2ddaKAw59HwJkatJGCehTDEEPiBV6iR8TuLaYp94ipr8DyZenRT1IZuyLwT2hRcVIMSAsA/Kbmd5KZJi3p/B8HSHYEOeFYyFye8zwrbngevBz1B2Py3uTHqEVj7Oxl3A= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(7696005)(4326008)(2616005)(186003)(356005)(5660300002)(8936002)(36906005)(508600001)(107886003)(8676002)(82310400003)(47076005)(70206006)(316002)(54906003)(70586007)(426003)(9786002)(6916009)(83380400001)(36756003)(7636003)(336012)(6666004)(36860700001)(26005)(2906002)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:03.6132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c742b77-b06e-4ddd-5241-08d9a34ef96b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4215 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441416347100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add fdt_ prefix to overlay_get_target() and remove static type. This is don= e to get the target path for all the overlay nodes. This is useful to find which nodes are to be added/removed in dt_host. Also, sending this patch to dtc mailing list to avoid the divergence. Signed-off-by: Vikram Garhwal --- xen/common/libfdt/fdt_overlay.c | 12 ++++++------ xen/include/xen/libfdt/libfdt.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/common/libfdt/fdt_overlay.c b/xen/common/libfdt/fdt_overla= y.c index 7b95e2b..194f51b 100644 --- a/xen/common/libfdt/fdt_overlay.c +++ b/xen/common/libfdt/fdt_overlay.c @@ -42,13 +42,13 @@ static uint32_t overlay_get_target_phandle(const void *= fdto, int fragment) } =20 /** - * overlay_get_target - retrieves the offset of a fragment's target + * fdt_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 + * fdt_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) * @@ -56,7 +56,7 @@ static uint32_t overlay_get_target_phandle(const void *fd= to, int fragment) * 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 fdt_overlay_get_target(const void *fdt, const void *fdto, int fragment, char const **pathp) { uint32_t phandle; @@ -638,7 +638,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_get_target(fdt, fdto, fragment, NULL); if (target < 0) return target; =20 @@ -781,7 +781,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_get_target(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; @@ -803,7 +803,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_get_target(fdt, fdto, fragment, &target_path); if (ret < 0) return ret; target =3D ret; diff --git a/xen/include/xen/libfdt/libfdt.h b/xen/include/xen/libfdt/libfd= t.h index c71689e..1f549d0 100644 --- a/xen/include/xen/libfdt/libfdt.h +++ b/xen/include/xen/libfdt/libfdt.h @@ -2115,6 +2115,9 @@ int fdt_overlay_apply(void *fdt, void *fdto); =20 const char *fdt_strerror(int errval); =20 +int fdt_overlay_get_target(const void *fdt, const void *fdto, int fragment, + char const **pathp); + #ifdef __cplusplus } #endif --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441406; cv=pass; d=zohomail.com; s=zohoarc; b=PjF89KbMydTiMgAA0aK3JHoNU76MpUYtdLB0fiA6aCCewU9dT7DhV8kcxfjTGq3r0/XiqvGpfb6oAZMawxsgeV8eZjtej4pPqRF570LiIh6c7zqK1t+Oj0WUaQ5ir/6GWaIHiFbQkdFQ2jEy0Ds5erzt8o0FSxqgQObsFQJe2Jc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441406; 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=kIewzG8LywGWbHesUbd3OwI+EI+4G2+90rM3TjxjMto=; b=LGGqiFrt+nyrWjshbQwVoAjkB8REXKZUeaMJZyQzyaiPsRYiF7mST8icSbB+XjhwkgqKAgS0L1eJqJN/ZXFZkP2DnDpkj1n44Xii7yOOEUqmUxOCGhGSBMnbOb67U+XzoQD9dhcfy02PVw7raHa6GAj1NEF/8oDe9Q2Q1/Dny/8= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441406453952.4025639706399; Mon, 8 Nov 2021 23:03:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223697.386508 (Exim 4.92) (envelope-from ) id 1mkL9j-000052-64; Tue, 09 Nov 2021 07:02:55 +0000 Received: by outflank-mailman (output) from mailman id 223697.386508; Tue, 09 Nov 2021 07:02: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 1mkL9j-00004t-1P; Tue, 09 Nov 2021 07:02:55 +0000 Received: by outflank-mailman (input) for mailman id 223697; Tue, 09 Nov 2021 07:02:53 +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 1mkL9h-0008WR-L0 for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:02:53 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20620.outbound.protection.outlook.com [2a01:111:f400:fe5a::620]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0ce2e50c-412b-11ec-a9d2-d9f7a1cc8784; Tue, 09 Nov 2021 08:02:51 +0100 (CET) Received: from DS7PR03CA0324.namprd03.prod.outlook.com (2603:10b6:8:2b::24) by PH0PR02MB7319.namprd02.prod.outlook.com (2603:10b6:510:1e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 07:02:48 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::60) by DS7PR03CA0324.outlook.office365.com (2603:10b6:8:2b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:48 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:47 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:47 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:47 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9b-000Ga6-Ly; Mon, 08 Nov 2021 23:02:47 -0800 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: 0ce2e50c-412b-11ec-a9d2-d9f7a1cc8784 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eAP3qgvzQ3dPMe3SrwEtSEu1Dr3ppafUBsjhSG+PA+Gd5vxY/0c/CRdPMMWVzNnmYuZyL7PzCzf/kbmM+knLC27hRTknAbxg97mhcWbcHK1XH2UwXi3hJanceOOjcwYRerenn/ORieMONQQms2A2EFXU0dt38x/l8W/bEBkX//zltAB/DdjQEre5jLw0omyLyp/4xxXDEojBzaS38wdtgdDPTjcEwZWrFi6hzPSO1oDR9sOWCPeBgAuEwIrR2+/FCTTsb31/mdoQT26YnwQ5Svoc7FCc7yuA1u6r8izLoUJWoj0PC4Kqd9od94EPYlK/T9/mrifj7IMKo5LAdMGH9g== 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=kIewzG8LywGWbHesUbd3OwI+EI+4G2+90rM3TjxjMto=; b=AC+zclWUX4ssIdyn93a9IQn6m6QDevnHOpDEA9DcDCC5Q1U5zkjQHjomzZ74t019M8o7u3TpPg9dM9jXl+0e7Putf8JHToEi/J6K6ij0hIY9BLLSL/JZ+owJohdsrY63CqvGue4hDPMm9w8GAlvKUkDHRU8EZJsLkt30dSux81pj2r8IV5PNbmHzAs8zeNWU1LAg1gQgmrCuWmF3BlKaWKFVeNcAaOo5qVgklJcYkvF/sZ0FpCOw98+JkazGJyKW8Op2Ux+8AzkigC6NIKChNCjAEU7iBG7sUAUUQWAGioJBG/fZT7PhN7F8oiQNkwaOsmVWt4HhP1pltaSDRYEBXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kIewzG8LywGWbHesUbd3OwI+EI+4G2+90rM3TjxjMto=; b=RxwU6jSjsdsz0tComLWtsmkxc7BuI1XJtTd1Bxms/rbKzjwRWdKazW0IilVeMiZj/rCd1wI8WM7iBvO2lO2Cj70EHVrxtJdmJ25lmUJ4/2O8/sBPhwaAF5u8PRtCNkPIk3L/EKh61s34clGjuPlWAxXRrZMb+DOJe1GF1K7v+AQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal Subject: [XEN][RFC PATCH v2 05/12] device tree: Add _dt_find_node_by_path() to find nodes in device tree Date: Mon, 8 Nov 2021 23:02:20 -0800 Message-ID: <1636441347-133850-6-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16419d0b-8a6a-4c6d-519f-08d9a34ef01b X-MS-TrafficTypeDiagnostic: PH0PR02MB7319: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CxrKvQBgjaFpqcDX9shXu8wa92CnssaHYwKGafmN6YKDRGt6L4gNl595IsjZJ4BvF8Uw+OY2Y1GCneV2XjdMkuxHfHIzIAvXlG5jxcKgJg0edp8LHMJArYw0NTW1zngjBMV0c2ABNrHxEvA/d99RJ1+vMxU4VqTNbIS3kCU1urUDiNfNqpbHbklGEhAFQgxyaPTN0N+vSFqUuPKAsOUasY9t2dSOjpN64f72Fw3EZ476FzPQycLxO07/hcqXovaZtRK8v2HuT1AaKsS0iYb/vALngN/hLwOptK+Y8y7Q5ptOdnNGlIuZiJXm9DeLjfF00k5psJhgwswRAfIbvhIZS9jnDmJ5ReZ6yPiJ/mevQabMvuAFEHIYI9faQq6fUN2pCnSiHQ4azgar4W2z52H8F/24RQU7p8ccg5qFrf+PRSjfUphq83xGtYZX9Vcdu/gUdotttxVsrYD+tPbZwK6dtVz7FxCTWLzbuZXeeusqAfAQHREehjiBwoSdk0+WizXybFI9duUXrum4zpO24FUMa1Rza+SXopaQEs0nFoDA7uk2r/PtCXsbCE6QWE/VVwnoiNAGiPpCLEA0aQpD6CgvzPRDhIG+aC6yaJn5vsRQmgNTuxCzXrv0y0Dn9ETHiAU4ucJaf4v09AzMK1nIAvw0eY6ScNSciOqhM5tcitd5LdYFZF2oBtkF6U/u7KI/ZrIusFzX01tgkvavrRuPXmu6uYRL/8oODc2FkS0nZITnhadDrrIS8LAc0y7QZy1P8RAf X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(46966006)(36840700001)(336012)(5660300002)(426003)(36906005)(7636003)(82310400003)(36860700001)(70586007)(2906002)(316002)(4326008)(2616005)(36756003)(107886003)(9786002)(47076005)(356005)(7696005)(83380400001)(54906003)(26005)(6916009)(186003)(8936002)(8676002)(6666004)(70206006)(508600001)(102446001)(37363002);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:02:47.9785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16419d0b-8a6a-4c6d-519f-08d9a34ef01b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT010.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB7319 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441407742100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add _dt_find_by_path() to find a matching node with path for a dt_device_no= de. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 10 ++++++++-- xen/include/xen/device_tree.h | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 88f3f7e..26d2e28 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -358,17 +358,23 @@ 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 *_dt_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 return np; } =20 +struct dt_device_node *dt_find_node_by_path(const char *path) +{ + return _dt_find_node_by_path(dt_host, path); +} + void dt_print_node_names(struct dt_device_node *dt) { struct dt_device_node *np; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 9fc63ab..5ba26a0 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -525,6 +525,15 @@ struct dt_device_node *dt_find_node_by_alias(const cha= r *alias); */ struct dt_device_node *dt_find_node_by_path(const char *path); =20 +/** + * _dt_find_node_by_path - Find a node matching a full DT path + * @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(struct dt_device_node *dt, + const char *path); =20 /** * dt_find_node_by_gpath - Same as dt_find_node_by_path but retrieve the --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441418; cv=pass; d=zohomail.com; s=zohoarc; b=QiYHUQyjpRYVISaz/w2HfXyLjQC5vrLPWPBmxlbeCtIXJv9D+S7oJ/liGhJ7lMPb8jUygTuvadFAZwORXbL4j4JvQJAxPw4FZwAC1Q5b4YUEG07P1mg5NfhZ83Z/lXPxRZnkbARVLsLPmvLzuDQWdgGm1AU/c0Yd8n41TjVpDy8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441418; 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=aqdp/GvnsU179UtkDRtrXW3Ma3HQaHxw15Jk4pDNfYo=; b=W0PPmvgYDJ0z907dupPGZ24oooPif5qJkd3yATUNqKOlw8Fw+HkFq+NF3etxOdbLj1mVVxFgy7uWwbc4UeiAwd0O8QcomvUJ2Jztveou9MxTHal7yR0V28Yd8RWQ2bIeuaeXn16hGM6Rx0tAfYP9d/cRf5IWQUg+Lrhluy9o9eQ= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441418982842.0475772361104; Mon, 8 Nov 2021 23:03:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223713.386625 (Exim 4.92) (envelope-from ) id 1mkLA4-0003gQ-Vl; Tue, 09 Nov 2021 07:03:16 +0000 Received: by outflank-mailman (output) from mailman id 223713.386625; Tue, 09 Nov 2021 07:03: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 1mkLA4-0003eY-9T; Tue, 09 Nov 2021 07:03:16 +0000 Received: by outflank-mailman (input) for mailman id 223713; Tue, 09 Nov 2021 07:03: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 1mkLA1-00004s-PT for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:13 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060e.outbound.protection.outlook.com [2a01:111:f400:7eaa::60e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1a3634d2-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:03:12 +0100 (CET) Received: from SN7PR04CA0171.namprd04.prod.outlook.com (2603:10b6:806:125::26) by CY4PR0201MB3619.namprd02.prod.outlook.com (2603:10b6:910:8c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Tue, 9 Nov 2021 07:03:06 +0000 Received: from SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com (2603:10b6:806:125:cafe::b7) by SN7PR04CA0171.outlook.office365.com (2603:10b6:806:125::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:03:06 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0011.mail.protection.outlook.com (10.97.5.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:06 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:53 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:48 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9c-000Ga6-5x; Mon, 08 Nov 2021 23:02:48 -0800 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: 1a3634d2-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3GKJ4r3y3CWlFyoB/zQMb0f7UQM5KSJLKCARc6DzgoW23d3RZcbavHp4fjoO2VtJ68Dycw8PUF6Vqiwota5tSVqvOMl4jmlmRk+mO3B8DsX6DmEMaU+lqp1vwiu4/Ar+fZLcS8t4EtNYqNEOV1v8952VnLhJSfnb091rb26IzM9snQvVW/bSZsR2EzT++2fxY9ZxI30f9HPA2W2L/+P0yD/XppTEPvqy3hZ4v0FsZG8/6uEZGrJPHJCFcj97MbPGHLQ9XKcJ1kQ6eH7alISNqoNS/3N7C2qVxrPlwtZ6Se/F0lEZklUmiNlZV50SJfoUaiqFCvHiEknYugCpT3Rkw== 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=aqdp/GvnsU179UtkDRtrXW3Ma3HQaHxw15Jk4pDNfYo=; b=ZD5xW270DnlVUPcovsyyDgb4hl8G4fLv2/wg5w9VwlH5Xe4JifH8z7+8hYWYeA3lFWA/PazEASRVCKmktZ9/6jokjynHgYZEM9dVnJ8GRh8exk6NQ4MFLAeJJntZ0mPgt8A7lb+7cY4aQaJCH570Ne7XxebeRw89nN4s7M/uOuI37R9RAYKfYrC5N1DuQxXXjPIiI6gTZNcMhTC5ot7D28rQH06TIsfG4rgEA9hfppSr4s3l8NpoGiUCO/EJ50S/pNKfXGIkKoOpEMpK/N4qjHhbZmmx1Qqc9DhJ7y9GxLGAHZ7YVy3stUDReq98TrOmAnHx0IkAX/sGreUifl4ACw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aqdp/GvnsU179UtkDRtrXW3Ma3HQaHxw15Jk4pDNfYo=; b=XBYUbDxAxubZQ38sWbNo/V4IM2MaLyBbB17nDFhX8vHg/T/GQNkmvHoGg+N4rqmQMzLb8snQ3Z+Vwz2a+Grm6jHWZ52nOOFW7EKR3TrPH35+PdZuvJymmFnbameTHOFBNYzOt1VP5XWfPrbfaArhsohoMnwiCh3EEQENyQFcG2Q= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Volodymyr Babchuk Subject: [XEN][RFC PATCH v2 06/12] xen/smmu: Add remove_device callback for smmu_iommu ops Date: Mon, 8 Nov 2021 23:02:21 -0800 Message-ID: <1636441347-133850-7-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d74691a-c175-4967-4fe6-08d9a34efb27 X-MS-TrafficTypeDiagnostic: CY4PR0201MB3619: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VEOLW/UI1lpFtm/Lr4yeO2cQz5ryPivi0xHg5pebB55DFvQJs2gUUiXkhQOiDySkl1DDy07hiQJo+KzSgs5rvCyI3oYo2pCqSipboIPQHdiU9D6niTSeLfItzdI753H7F0psW1nJq1JWEsOrwDR1nNSPhf0UQnjjOH6IxsukDNN8rSRZhZ2igJjvdQBi7fUuG9csvt14outrrgGfVIFEIP48epZfpFUMk596R39LcBDUVfn6iS4QCfMQsHlr0Q2yqPgOARpbY3hUBwpSfOwhccybsQBEqL2XyHFyXoW7VRYNoy5+t1uAcI7e2sr735wg7wWA9j5ru32Uy3gIoKyp7DVdHsyhFqLLEVPW8SEkS/M+dEiVinx56JDNC6/EEjq0RTzb7ecSLLTX2vwbkWys7SC5XZIELPy/HLbth0VpPh1kathmHMKXA9xW749SyJwPHB7dhzkf+j1IDvoxzBJJOFL8P67sDnTHRGp5pvRYtKeKgQeEGX9cDCXth8Tcif9xk0Zg5qlU5FUV4SJRztsz/76H6mUJq2ZrGO+MEUzW1Sk9gne1rf4TeX++f2g6my9ejq2iJquhpw3lcMzYaPbOrrE9Z4wFProp/WlCczmtyiu74svUPIYYPNg4cawfESyEIcbjRPehJAqMXueDuuP0KpM45yhM/gAe95Ab5PoNHKocBYu2D+nTlYUBLNSBaxUYBFHa1tITPTd6yt/qeusydTZ1GqZ9fQs1MBUmiwY7FBk= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(8676002)(6916009)(186003)(47076005)(26005)(6666004)(356005)(426003)(2906002)(2616005)(70206006)(70586007)(7636003)(336012)(9786002)(5660300002)(7696005)(4326008)(8936002)(82310400003)(508600001)(316002)(36860700001)(36906005)(36756003)(54906003)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:06.5220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d74691a-c175-4967-4fe6-08d9a34efb27 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0201MB3619 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441420786100001 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 --- xen/drivers/passthrough/arm/smmu.c | 54 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 54 insertions(+) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index c9dfc4c..1a32e2c 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -816,6 +816,17 @@ 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)) + 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 +864,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 +913,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; @@ -2876,6 +2929,7 @@ static const struct iommu_ops arm_smmu_iommu_ops =3D { .init =3D arm_smmu_iommu_domain_init, .hwdom_init =3D arm_smmu_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, .iotlb_flush_all =3D arm_smmu_iotlb_flush_all, --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441414; cv=pass; d=zohomail.com; s=zohoarc; b=AOgkvqFovoT8wFHqKRT5ab4javb31g3P4V8M9uQ7AwBWg0klyf5lzoIPjBbYvoeBbmZzub+4lIUZM1wHHKrX3wFX5iIZWAQCJzCiYh9XMqXfArlKvUn25QC7bY7LLGdltF2p39Tpt2kEfClaD5yH7nOfYpF/noKAQZN/3NCYaFY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441414; 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=3epwOTRbTwCC6qELaH9f3CNhp6wdSrPjn5h5Ob5r4mE=; b=U9GvvYLY72dN6LCmXEpVyEN+wSfAIjC4McQI+BAcIZOf+hmYSOvzrfBYVpbVsIkAdy40Ab5uw4C8dbZG7+B4gsMFISuQd8+KK7rPqsSigXL/TkTkvJQGvA9uik6FMbeumj8WlLVqXwhP7Dx761XNHUSacxa+fOa6kga+2ha92Ec= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163644141413114.253919066678236; Mon, 8 Nov 2021 23:03:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223705.386595 (Exim 4.92) (envelope-from ) id 1mkL9z-0002cj-P3; Tue, 09 Nov 2021 07:03:11 +0000 Received: by outflank-mailman (output) from mailman id 223705.386595; Tue, 09 Nov 2021 07:03: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 1mkL9z-0002bV-Eq; Tue, 09 Nov 2021 07:03:11 +0000 Received: by outflank-mailman (input) for mailman id 223705; Tue, 09 Nov 2021 07:03: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 1mkL9x-00004s-P0 for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:09 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2062f.outbound.protection.outlook.com [2a01:111:f400:7e88::62f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17876806-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:03:07 +0100 (CET) Received: from SN7PR04CA0165.namprd04.prod.outlook.com (2603:10b6:806:125::20) by DM6PR02MB3963.namprd02.prod.outlook.com (2603:10b6:5:95::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Tue, 9 Nov 2021 07:03:04 +0000 Received: from SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com (2603:10b6:806:125:cafe::98) by SN7PR04CA0165.outlook.office365.com (2603:10b6:806:125::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0011.mail.protection.outlook.com (10.97.5.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:48 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:48 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9c-000Ga6-Kr; Mon, 08 Nov 2021 23:02:48 -0800 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: 17876806-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GjDJCREnjc/R3Tgtz+/Ide2ELBuw5EczeKdxmP8JaMqSj60ITmzEV4vZ2ke0ryS9fvMODllPwI+9mjGQtWNNzJM3R8bhUmHGQDJklWUVH7KxPGx2IvDq0S1ToF01lWvNlMkKFShFcGvyVUB/slMovKV0bwTisyBmDv86c6cdJw/hc5AdV2DT4ByLWT689lFzt08LpPUEU8wRDHtMjDtP2epFT3LFIYZyON3Gr+NqEkuUfMxWqKisAUnaWnWTFOCwAOQxgws7a1EcWXhV8Ggd7CE3uyQ5SLNftyJgw8EL+5Ts9Vgw9SN5qHNJs+C1NObzopeQR5b7FElXnTUPBE1mXA== 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=3epwOTRbTwCC6qELaH9f3CNhp6wdSrPjn5h5Ob5r4mE=; b=bDLg5XDWi4QE7QCucKw8Xjk6ueACZb1/dQW5Zbp6CVfStiX/araOeiznCQNCs4bwLfZkMhCACkU2bH9PQPR7QneYJakvo+yvszNNQidbnDd0u/fDNv1uBZaY1GqK2GgoURL8eC9UZZAFvNDaYtKbxCc7qfdkuvIpbeGqlKxNLRPr7l8V03ELvg9g2iz3krdIpk6OqAvMKKC89gBLV+dPvQehEfGRqtZviL7Pm+6Km5RVEy/1ZhCo8DieECGMlw88sY9KjNLW/KLi0fPQqCAIru8kraehB40W/f93a3IQKoLd88lJx+Jmhnnjrpiec7iUGAjzmruYnf4QM2Q/EOTmKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3epwOTRbTwCC6qELaH9f3CNhp6wdSrPjn5h5Ob5r4mE=; b=TxrDKZAIME9NJR0cWlLT4ctjAE74CiYkWv0cLU7PuV8BmqnobU9beEmuEASgIZoUdEpuc/soH4uZVd+76LC38TpmvyLCyezjWwuxqsx1fKr2NOiTgFXr8J6n3gvZLY41KRl3QjwRt6QOoFxVwob+z6cmet46f11Dv36KKin07po= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Jan Beulich , Paul Durrant Subject: [XEN][RFC PATCH v2 07/12] xen/smmu: Add remove_device callback for smmu_iommu ops Date: Mon, 8 Nov 2021 23:02:22 -0800 Message-ID: <1636441347-133850-8-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b09a1caf-13d6-416d-378a-08d9a34ef9fc X-MS-TrafficTypeDiagnostic: DM6PR02MB3963: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IfA09W3pIEgPQT6Hcxe9ccp+O+2bbYG1KKLGfosynnytPwctXLEZtKRFR4lZM7G+Ug3GZWJlTZt4AYX+pFLDxbyQABhIHriBPR/SF+rGS8xJGZeJ68NtgDETCNZ0EYEhTHmrvf5jXgBvhIdtyatPdGpVroJID1UjqibLRJmQtowkapowhAbKGECukusIIkqvyuwiadJFoxv/wNf4SRq4FQbFVCh9eY8RcgbG8WIC2Jf5AKT+92sB2iNTwxNiC3JWDLJdfsG6WH6XuUEGTT8ynSyLOWTwl4RUbQTqaZJ6YSzsFfPwx9hijT0Ec3u643XkP8bwsIdtBWxSyubTwLBzBiY25BAF5TXcL4jTkBAdKby2f3IgSn8+2ijRi8UEc3NYdiqaY8EuAjpTky/IlAgwtAY/1hLtgHaFH5I9hDe9opCdcqrNKKrO/VpWYB/qkt0W8n9vwm0Gf8W65C5k40nv+O6XB2Qy0D41dY0eym6yeBqQXPlGOWtqdOUq5lXjHXV/x2iwBdsYRt2Eoso6aN67aQCuJU4HSUO+/QAiq3mCflNpj2XHxphxhx246nL/cYbWJU6wJgSGmT7teeq70zdsg45UBxbdL5d5TE7JCTq8RuR6wCrzkrwz9kcAeUVGGbL/jn3FyP43p2srP1mCJQN4y8NWqHNTN1Bi/YvTqX/iqwgIZOCmBIeWLzgUfOSq5P7b0137OKmqJBFcAIwtcR9scdEdiNFyPe/B4bqsuE6c+oc= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(46966006)(36840700001)(36906005)(7636003)(36860700001)(8936002)(47076005)(54906003)(316002)(82310400003)(2616005)(70586007)(2906002)(426003)(508600001)(70206006)(6916009)(9786002)(36756003)(5660300002)(186003)(7696005)(4326008)(8676002)(26005)(356005)(336012)(6666004)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:04.5628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b09a1caf-13d6-416d-378a-08d9a34ef9fc X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0011.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB3963 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441416339100001 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 --- xen/drivers/passthrough/device_tree.c | 30 ++++++++++++++++++++++++++++++ xen/include/xen/iommu.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthroug= h/device_tree.c index 98f2aa0..9d9eed8 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -127,6 +127,36 @@ 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; + + if ( iommu_dt_device_is_assigned(np) ) + return -EPERM; + + /* + * The driver which supports generic IOMMU DT bindings must have + * these callback implemented. + */ + if ( !ops->remove_device ) + return -EOPNOTSUPP; + + /* + * Remove master device from the IOMMU if latter is present and availa= ble. + */ + rc =3D ops->remove_device(0, dev); + + if ( rc =3D=3D 0 ) + iommu_fwspec_free(dev); + + 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 6b2cdff..c4d5d12 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -215,6 +215,8 @@ int iommu_release_dt_devices(struct domain *d); */ int iommu_add_dt_device(struct dt_device_node *np); =20 +int iommu_remove_dt_device(struct dt_device_node *np); + int iommu_do_dt_domctl(struct xen_domctl *, struct domain *, XEN_GUEST_HANDLE_PARAM(xen_domctl_t)); =20 --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441418; cv=pass; d=zohomail.com; s=zohoarc; b=GpKl1XPX3nZGDrddq11IXhga1HCMmE8Jx2DFKuy9cq31VLkt/1y04lzMEHNvX6sT0+GP8r3NtV2QmXzimjQsSwwxFqIFXUhdwW53TlUQymOYtEfrnZpl3RqEmzLUM9r//NakiuwmVm90NeJn62nw86VaBAmEo4gg1MBZDg3t2ag= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441418; 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=hD5keOeFhUtsoqEKF+D/RnMWmS5ZQuiG1eIV46VPO5I=; b=QrjHup+sYhJoizg/0+lZ2Braz6E7y6LDOzEY+g3tItL8x24I/L0Jj89DF6poCE92sRIQtT49x13upPpxPPhxLhV6TZ8hJczqaLhm1ETFIXUDiaT4lwGk0MTGG722NXhhHWTmSNvfV/G877ZCP4Jp61aqpojPOB0RXiQPcjDfA2w= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441418468685.7298735177876; Mon, 8 Nov 2021 23:03:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223706.386601 (Exim 4.92) (envelope-from ) id 1mkLA0-0002js-Rq; Tue, 09 Nov 2021 07:03:12 +0000 Received: by outflank-mailman (output) from mailman id 223706.386601; Tue, 09 Nov 2021 07:03: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 1mkLA0-0002iU-6s; Tue, 09 Nov 2021 07:03:12 +0000 Received: by outflank-mailman (input) for mailman id 223706; Tue, 09 Nov 2021 07:03: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 1mkL9y-0008WR-9o for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:10 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20622.outbound.protection.outlook.com [2a01:111:f400:7e89::622]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16e6771a-412b-11ec-a9d2-d9f7a1cc8784; Tue, 09 Nov 2021 08:03:08 +0100 (CET) Received: from SN7PR04CA0027.namprd04.prod.outlook.com (2603:10b6:806:f2::32) by CH0PR02MB8044.namprd02.prod.outlook.com (2603:10b6:610:109::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Tue, 9 Nov 2021 07:03:04 +0000 Received: from SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com (2603:10b6:806:f2:cafe::d4) by SN7PR04CA0027.outlook.office365.com (2603:10b6:806:f2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0031.mail.protection.outlook.com (10.97.4.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:04 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:49 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:49 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9d-000Ga6-3A; Mon, 08 Nov 2021 23:02:49 -0800 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: 16e6771a-412b-11ec-a9d2-d9f7a1cc8784 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NLKTknKUGdV3u1bhtKqciqvKEMP7s69m4HNBPHGQIROUB89SHBEshxFBqTKLTA2HP+nZicVrArr/XSDaRuZCurC5/SDd/W+iTwwala50FPMI9imZ0dnAIweVCoZDeq1emrWYup3BTczFX+oZKVtKKthsx/wzXC+sVojOQOcYMZf+R09spsAfA5bIWn5PwVZZq15Bc8SW3XzRO93Tc6D756oN0qvHzswe/7kAy/MJUPylit2eIBk6ZSaO69TBlSYyz4rexx9y8aAxhHY9zwDA6OTv8IN8HnsiZ+QXQZFxYyECLTC3S/kwjH0EQRkQd3nmTgjcfIRnU5jFeRnuIR4QjQ== 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=hD5keOeFhUtsoqEKF+D/RnMWmS5ZQuiG1eIV46VPO5I=; b=S28iiMACvtbTsTKg84ZaiXVgLuBW0b/jQIoiqt9EASW0pdTKcbhnFnmh43VnJzl2wEZILRVZbtT7OcADKtvFzTg3xlfRQxVSp9/yFTKdAi8P++d1a7f0KSYHpoC3G0413NVy1RsXdpWML37SfyWCk3KKDw0L0toLnzE9io89itJ7eg2OBo4xGBTH3/YBsaTcEOgTq5pNUqekyo8bciwcW+xN4QtZE1ClNVf4JNVPAoncHG/Y0Z4oPVr7aVZKkur1dubR5mC+krEXEcisblhxqzeAy3n84KB/DgFsu1MgHSOM90kP5ZVVYoxQPn9VOOJdyT0T/GAOifyAnWZKaFOfVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hD5keOeFhUtsoqEKF+D/RnMWmS5ZQuiG1eIV46VPO5I=; b=rjOr//JTwrR/ccLrVM4ixIUPr5qT0KkkgfLiHCt3pjLi5iTmSrmfHCgapV50I747Z4U9WZsL1453ELki3pBjSiL1Xg92iUylHc6uATkA7O4xwaYPfYv3UivjAG2GTJkET9fG1OmdaNUy6HYUfdgJ+W84EeUe5aVrmfvJWDtF0HY= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu Subject: [XEN][RFC PATCH v2 08/12] xen/arm: Implement device tree node removal functionalities Date: Mon, 8 Nov 2021 23:02:23 -0800 Message-ID: <1636441347-133850-9-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd9ba6e1-7297-4d8f-c5b9-08d9a34ef9fe X-MS-TrafficTypeDiagnostic: CH0PR02MB8044: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:298; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SFYEBkJYZozvnwaXiSQsFzc4T+7fchNCtRzwKidmRDLXLBby8EuklegjHhsj9wNLTzdVqnY7rcoF85whMoUAQST8F9wp89yjBKKaCz46F8Zze3QGROux4XddC3z+NGAfuQJB6bWrGipCrYgGZ4r59CuTI8tnBiKkzK3dwk9GSKglX0wafWwLLVmFirli46/8vK2o8527qslovEoSNkN7qRM7J6hA+5q6NK3lCkBrFY5iizh4PSVHJwlQNxIcXE5+955LSOTVttUBiBBGZUq65VDVMJixnJwMkkNtJn91BR8GKxUvkFYRRq7FshfnlCuJJL2B+9DXYcYTXyGs23Yi3yz11KIGzL8KZ2gF0biPNf6hWQ+EY3qBCFOFuljDLxs1onzlu7B9yEqAo5Ec9YMs8hUVl3qbhjvqSfpcWe5Fij4rI81XZdncgj5t4ggk4QeXgmeWAfwiCwmhSy5E7mRGYfl0T9mWFXQcL3Th+rihpJkPfbkD3lZ1zr6M3MRTJyyOzKfTKgWz2jtXVg+GnYnPXmtj7TxR9XiB2fu2fyeo0LlVSbfIJcGZ0xnFsUm9p3ZM0Jb5F3qSyw1VbJL5q2OiLy1oVR3F3uYGmCRMxizYcql+o2wWEiPuvx25uJmq2Q0yVj2pWviiLh7Stn5fyfoZvQHwp75DgQeLiB1NQXUZfF1TNp9uGV1wuEGzYsDnC4J/kKgQmktRJgU59z12DqWJKk6qOdrsHVQhBCyUbkdiFcoS29QvbX9Prgtb+b9Ls/Tx X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(36906005)(36860700001)(82310400003)(5660300002)(54906003)(356005)(316002)(30864003)(186003)(26005)(8676002)(47076005)(6916009)(83380400001)(70206006)(70586007)(7416002)(7696005)(8936002)(336012)(6666004)(4326008)(2616005)(508600001)(426003)(36756003)(2906002)(7636003)(9786002)(102446001)(403724002);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:04.5806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd9ba6e1-7297-4d8f-c5b9-08d9a34ef9fe X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB8044 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441420846100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce sysctl XEN_SYSCTL_overlay to remove device-tree nodes added using device tree overlay. xl 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 domus. If even one of the node in dtbo is not available for removal i.e. either n= ot there in dt_host or currently used by any domain, in that case we don't remove any node in the given dtbo. 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 node. When a node is removed, we also free the memo= ry used by overlay_track for the particular overlay node. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 53 ++++++ xen/common/sysctl.c | 372 ++++++++++++++++++++++++++++++++++++++= ++++ xen/include/public/sysctl.h | 23 +++ xen/include/xen/device_tree.h | 4 + 4 files changed, 452 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 26d2e28..19320e1 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -385,6 +385,59 @@ void dt_print_node_names(struct dt_device_node *dt) return; } =20 +#if defined (CONFIG_OVERLAY_DTB) +int overlay_remove_node(struct dt_device_node *device_node) +{ + struct dt_device_node *np; + struct dt_device_node *parent_node; + struct dt_device_node *current_node; + + parent_node =3D device_node->parent; + + current_node =3D parent_node; + + 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 ( np->name =3D=3D device_node->name ) + { + current_node->allnext =3D np->next; + return 0; + } + + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np->sib= ling ) + { + current_node =3D np; + if ( np->sibling->name =3D=3D device_node->name ) + { + /* Found the node. Now we remove it. */ + current_node->allnext =3D np->allnext->allnext; + + if ( np->sibling->sibling ) + current_node->sibling =3D np->sibling->sibling; + else + current_node->sibling =3D NULL; + + break; + } + } + + return 0; +} +#endif + int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path, uint32_t u_plen, struct dt_device_node **node) { diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index f2dab72..fca47f5 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -28,6 +28,311 @@ #include #include =20 +#if defined (CONFIG_OVERLAY_DTB) +#include +#include +#include +#include +#include +#endif + +#if defined (CONFIG_OVERLAY_DTB) +static LIST_HEAD(overlay_tracker); +static DEFINE_SPINLOCK(overlay_lock); + +/* + * overlay_node_track describes information about added nodes through dtbo. + * @dt_host_new: Pointer to the updated dt_host_new unflattened 'updated f= dt'. + * @node_fullname: Store the name of nodes. + * @entry: List pointer. + */ +struct overlay_track { + struct list_head entry; + struct dt_device_node *dt_host_new; + char **node_fullname; + uint8_t num_nodes; +}; + +/* Basic sanity check for the dtbo tool stack provided to Xen. */ +static int check_overlay_fdt(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; +} + +static int overlay_node_count(void *fdto) +{ + 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__"); + + fdt_for_each_subnode(subnode, fdto, overlay) + { + num_overlay_nodes++; + } + } + + return num_overlay_nodes; +} + +/* + * overlay_get_node_info will get the all node's full name with path. This= is + * useful when checking node for duplication i.e. dtbo tries to add nodes = which + * already exists in device tree. + */ +static void overlay_get_node_info(void *fdto, char ***node_full_path, + int num_overlay_nodes) +{ + int fragment; + int node_num =3D 0; + + *node_full_path =3D xmalloc_bytes(num_overlay_nodes * sizeof(char *)); + + fdt_for_each_subnode(fragment, fdto, 0) + { + int target; + int overlay; + int subnode; + const char *target_path; + + target =3D fdt_overlay_get_target(device_tree_flattened, fdto, fra= gment, + &target_path); + overlay =3D fdt_subnode_offset(fdto, fragment, "__overlay__"); + + fdt_for_each_subnode(subnode, fdto, overlay) + { + const char *node_name =3D fdt_get_name(fdto, subnode, NULL); + int node_name_len =3D strlen(node_name); + int target_path_len =3D strlen(target_path); + int node_full_name_len =3D target_path_len + node_name_len + 2; + + (*node_full_path)[node_num] =3D xmalloc_bytes(node_full_name_l= en); + + memcpy((*node_full_path)[node_num], target_path, target_path_l= en); + + (*node_full_path)[node_num][target_path_len] =3D '/'; + + memcpy((*node_full_path)[node_num] + target_path_len + 1, node= _name, + node_name_len); + + (*node_full_path)[node_num][node_full_name_len - 1] =3D '\0'; + + node_num++; + } + } +} + +/* + * Checks if all the devices node listed are present in dt_host and used b= y any + * domain. + */ +static int check_nodes(char **full_dt_node_path, uint32_t num_nodes) +{ + int rc =3D 0; + unsigned int i; + struct dt_device_node *overlay_node; + uint32_t ret =3D 0; + + for ( i =3D 0; i < num_nodes; i++ ) { + dt_dprintk("Finding node %s in the dt_host\n", full_dt_node_path[i= ]); + + overlay_node =3D dt_find_node_by_path(full_dt_node_path[i]); + + if ( overlay_node =3D=3D NULL ) + { + rc =3D -EINVAL; + + printk(XENLOG_G_ERR "Device %s is not present in the tree." + " Removing nodes failed\n", full_dt_node_path[i]); + return rc; + } + + ret =3D dt_device_used_by(overlay_node); + + dt_dprintk("Checking if node %s is used by any domain\n", + full_dt_node_path[i]); + + if ( ret !=3D 0 && ret !=3D DOMID_IO ) + { + rc =3D -EINVAL; + + printk(XENLOG_G_ERR "Device %s as it is being used by domain %= d." + " Removing nodes failed\n", full_dt_node_path[i], ret); + return rc; + } + } + + return rc; +} + +/* Remove nodes from dt_host. */ +static int remove_nodes(char **full_dt_node_path, uint32_t num_nodes) +{ + struct domain *d =3D hardware_domain; + int rc =3D 0; + struct dt_device_node *overlay_node; + unsigned int naddr; + unsigned int i, j, nirq; + struct dt_raw_irq rirq; + u64 addr, size; + + for ( j =3D 0; j < num_nodes; j++ ) { + dt_dprintk("Removing node: %s\n", full_dt_node_path[j]); + + overlay_node =3D dt_find_node_by_path(full_dt_node_path[j]); + + nirq =3D dt_number_of_irq(overlay_node); + + /* Remove IRQ permission */ + for ( i =3D 0; i < nirq; i++ ) + { + rc =3D dt_device_get_raw_irq(overlay_node, i, &rirq); + if ( rc ) + { + printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", + i, dt_node_full_name(overlay_node)); + return rc; + } + + rc =3D platform_get_irq(overlay_node, i); + if ( rc < 0 ) + { + printk(XENLOG_ERR "Unable to get irq %u for %s\n", + i, dt_node_full_name(overlay_node)); + return rc; + } + + rc =3D irq_deny_access(d, rc); + if ( rc ) + { + printk(XENLOG_ERR "unable to revoke access for irq %u for = %s\n", + i, dt_node_full_name(overlay_node)); + return rc; + } + } + + rc =3D iommu_remove_dt_device(overlay_node); + if ( rc !=3D 0 && rc !=3D -ENXIO ) + return rc; + + naddr =3D dt_number_of_address(overlay_node); + + /* Remove mmio access. */ + for ( i =3D 0; i < naddr; i++ ) + { + 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 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; + } + } + + rc =3D overlay_remove_node(overlay_node); + if ( rc ) + return rc; + } + + 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(char **full_dt_node_path, + uint32_t num_nodes) +{ + int rc =3D 0; + struct overlay_track *entry, *temp, *track; + bool found_entry =3D false; + unsigned int i; + + 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. + */ + list_for_each_entry_safe( entry, temp, &overlay_tracker, entry ) + { + /* Checking the num of nodes first. If not same skip to next entry= . */ + if ( num_nodes =3D=3D entry->num_nodes ) + { + for( i =3D 0; i < num_nodes; i++ ) { + if( strcmp(full_dt_node_path[i], entry->node_fullname[i]) ) + { + /* Node name didn't match. Skip to next entry. */ + break; + } + } + + /* Found one tracker with all node name matching. */ + track =3D entry; + found_entry =3D true; + break; + } + } + + if ( found_entry =3D=3D false ) { + rc =3D -EINVAL; + + printk(XENLOG_G_ERR "Cannot find any matching tracker with input d= tbo." + " 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 check_nodes(full_dt_node_path, num_nodes); + + if ( rc ) + goto out; + + rc =3D remove_nodes(full_dt_node_path, num_nodes); + + if ( rc ) { + printk(XENLOG_G_ERR "Removing node failed\n"); + goto out; + } + + list_del(&entry->entry); + xfree(entry->node_fullname); + xfree(entry->dt_host_new); + xfree(entry); + +out: + spin_unlock(&overlay_lock); + return rc; +} +#endif + long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { long ret =3D 0; @@ -476,6 +781,73 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_= sysctl) copyback =3D 1; break; =20 +#if defined (CONFIG_OVERLAY_DTB) + case XEN_SYSCTL_overlay: + { + void *overlay_fdt; + char **node_full_path =3D NULL; + int num_overlay_nodes; + + if ( op->u.overlay_dt.overlay_fdt_size > 0 ) + overlay_fdt =3D xmalloc_bytes(op->u.overlay_dt.overlay_fdt_siz= e); + else + { + ret =3D -EINVAL; + break; + } + + if ( overlay_fdt =3D=3D NULL ) + { + ret =3D -ENOMEM; + break; + } + + ret =3D copy_from_guest(overlay_fdt, op->u.overlay_dt.overlay_fdt, + op->u.overlay_dt.overlay_fdt_size); + if ( ret ) + { + gprintk(XENLOG_ERR, "copy from guest failed\n"); + xfree(overlay_fdt); + + ret =3D -EFAULT; + break; + } + + if ( op->u.overlay_dt.overlay_op =3D=3D XEN_SYSCTL_DT_OVERLAY_ADD ) + { + ret =3D handle_add_overlay_nodes(overlay_fdt, + op->u.overlay_dt.overlay_fdt_si= ze); + } else if ( op->u.overlay_dt.overlay_op =3D=3D + XEN_SYSCTL_DT_OVERLAY_REMOVE ) + { + ret =3D check_overlay_fdt(overlay_fdt, + op->u.overlay_dt.overlay_fdt_size); + if ( ret ) + { + ret =3D -EFAULT; + break; + } + + num_overlay_nodes =3D overlay_node_count(overlay_fdt); + if ( num_overlay_nodes =3D=3D 0 ) + { + ret =3D -ENOMEM; + break; + } + + overlay_get_node_info(overlay_fdt, &node_full_path, + num_overlay_nodes); + + ret =3D handle_remove_overlay_nodes(node_full_path, + num_overlay_nodes); + } + + xfree(node_full_path); + + break; + } +#endif + default: ret =3D arch_do_sysctl(op, u_sysctl); copyback =3D 0; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 3e53681..6624724 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1065,6 +1065,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 (CONFIG_OVERLAY_DTB) +#define XEN_SYSCTL_DT_OVERLAY_ADD 1 +#define XEN_SYSCTL_DT_OVERLAY_REMOVE 2 + +/* + * XEN_SYSCTL_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_overlay_dt { + XEN_GUEST_HANDLE_64(void) overlay_fdt; + uint32_t overlay_fdt_size; /* Overlay dtb size. */ + uint8_t overlay_op; /* Add or remove. */ +}; +#endif + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -1095,6 +1114,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_overlay 30 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -1125,6 +1145,9 @@ struct xen_sysctl { #if defined(__i386__) || defined(__x86_64__) struct xen_sysctl_cpu_policy cpu_policy; #endif +#if defined (CONFIG_OVERLAY_DTB) + struct xen_sysctl_overlay_dt overlay_dt; +#endif uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 5ba26a0..cf29cf5 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -553,6 +553,10 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_pat= h, uint32_t u_plen, */ void dt_print_node_names(struct dt_device_node *dt); =20 +#if defined (CONFIG_OVERLAY_DTB) +int overlay_remove_node(struct dt_device_node *device_node); +#endif + /** * dt_get_parent - Get a node's parent if any * @node: Node to get parent --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441407; cv=pass; d=zohomail.com; s=zohoarc; b=Q+46d2ymMQPBcUPRjwSXxXSHprwIMiajD5UjnOwyzqBLbpUCoBLK4Rw7q/V/FAEXjoh4OnMWVoXrNvyheFi29cIl7AOqjmEY7ANJZV8xv3NGTsRUDrRy3z01oR4CjH4MNqE/+Sc7ieEOsa3aoCe98KkHLtiMGFff3HMTlGFOacg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441407; 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=wyrbSWuVg8mh72pt0EIeRsiFgh0ZFhFqclg9XrgPE/4=; b=n8tGGdDcPtA8CJ0VRocpI0HG7Bfow6Hd5wHjQvTRZwSvgIljctZrP2gj9cr9C6WFZy9dvZfI74EOZdqmDJX7yhNUFE2y+gzuYU5sKQRyHOXPeavIp3o8eUORatEWCle+Li1ndH6gphGXavaDB+uE0rVDYtLos+3B5qUWaAdCfS0= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441407116168.02579878139932; Mon, 8 Nov 2021 23:03:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223701.386542 (Exim 4.92) (envelope-from ) id 1mkL9n-0000pV-Ng; Tue, 09 Nov 2021 07:02:59 +0000 Received: by outflank-mailman (output) from mailman id 223701.386542; Tue, 09 Nov 2021 07:02:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkL9n-0000o8-FD; Tue, 09 Nov 2021 07:02:59 +0000 Received: by outflank-mailman (input) for mailman id 223701; Tue, 09 Nov 2021 07:02:58 +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 1mkL9m-0008WR-9s for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:02:58 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20600.outbound.protection.outlook.com [2a01:111:f400:7e88::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 106aea44-412b-11ec-a9d2-d9f7a1cc8784; Tue, 09 Nov 2021 08:02:55 +0100 (CET) Received: from DS7PR03CA0322.namprd03.prod.outlook.com (2603:10b6:8:2b::29) by CH2PR02MB7096.namprd02.prod.outlook.com (2603:10b6:610:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Tue, 9 Nov 2021 07:02:52 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::e0) by DS7PR03CA0322.outlook.office365.com (2603:10b6:8:2b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:52 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:52 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:49 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:49 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9d-000Ga6-Hm; Mon, 08 Nov 2021 23:02:49 -0800 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: 106aea44-412b-11ec-a9d2-d9f7a1cc8784 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DQ/HRZVZRKHbJJj6B8yux5m0AaGx7aRxB7EwDCXGMprYHw6gZ8Gto5T1L9oH4hMw1SrihvlmBDCw3Rn6H3txqj+9JSMA+mrCgmgFg6Y44lHfqaVNsTtmAFMRyI5USGAEIeX8aHiaK/Kk/Yf5Sf+FwbZM6HxFz1o+q1rXzWsMHTPDymgORzgWg0pXfriOIbZFeW/K3uraZDYvLXwr32Dge0gjjImb1ycMeMzaxCCsqqKtsLDZtFq7iSoTjFRRwxtlWrxQz/NEK2BE8AXKK94Si3VZH4Myw+yDW7lEMpyOJLtSsLFU50GuzEXJ2IJMdnNEwJZEVFfCjyzKFpzjLt4WJw== 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=wyrbSWuVg8mh72pt0EIeRsiFgh0ZFhFqclg9XrgPE/4=; b=g7FPXH2jJqWpJ4IuzNVeiwZqrGTUKKhm+6QCsJcMz4CQ9ItAuInxDStA/8jQfNDpfVd6LB7+1/cOQhoK33YlfDCAHwkWZfvL69DgpnKKRufxIgKW5WIhSxeM672Ni+g6yAg2AtQ9XGg+8kYmzcIYknyOuGZMrnagP0QvZvu5iXldPZl7Rj9xw6YT09wAKT84bQ6vnJbb3KreQT/Ou0lhvOKRE7B6k9fFCE2U+h4oQXr5vrLSX9eDFw6gObciJXDDwlgOcI3sOEa7kxN3egXykCfHmpUMP7yr3HRzkllCdkcTmIKgO6SRpFAqGMEeSAMijxVVpMLyPrQpieJItcDIVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wyrbSWuVg8mh72pt0EIeRsiFgh0ZFhFqclg9XrgPE/4=; b=Sk/OyTFjBzZsK/KhA9UqQFg5EB1xkdSXExumgM3a1lNRg+P2hLjEJrS5eNy1bG2wAeuNZuHAwEjL1Fjx2liPuVbgjFrDLwld1JSPN3ElY+IONXlWXX6UnPHXvJSJDIxlh9JY6GygAlxV97w1zcNG+DGYR0W3VQTB+CQvUXNZ7BE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu Subject: [XEN][RFC PATCH v2 09/12] xen/arm: Implement device tree node addition functionalities Date: Mon, 8 Nov 2021 23:02:24 -0800 Message-ID: <1636441347-133850-10-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53fc7495-d8b0-423b-8eec-08d9a34ef2af X-MS-TrafficTypeDiagnostic: CH2PR02MB7096: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:287; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D9sM5O9mquk0D9fEps5z/Mk8ZS3cinM6zl00gYYL53VuyB4YUnD/EUDwHs1mWUpRcRiIo4Rets5kdfrOJ+ZUPQZNbe+PBE/pGSfKd2W8TWM+HzJ/I01VxQeDwBTyhUcm1Wmq59jxpKjQVK1ggY6BWmAA7JpCunFn006fEvIWaM3Hw4s5o5KEV1CN+f1VbbOV58pEtxfWCIENijGUBtNCWT25Oy4P2OZrqlGJqU8s7Sr+ZTHYXGmRHWyburxglH/IBfp0CoFFlfoGbjS0VwE0GgqqzooULEV/UdS4Z2vrW+pj0grSy/FJ7wlkI5MJt0a61VjXYgBxHwsegedVk5tyfDh3J74qz0zTYrWTcxkyf4T9Bx8bk6hysFKl5XwSlAMH4nroEQLiFTNZzuEiWCFkpic8T9sIPAddAShPT6PluUWNZCdJhn3jYD0miA5L6Na5NX2SJYRhdYNvxlYv4o+I4sCRvg6k/HNYxwHubOCeWKF/1FkcjnSBvIQY4xtsiGJnBkUGFxfN0YTMP//jh3uj3Rugadkxy0IvmnQ5AonJJKHCTSf9uhRCcNKLpACLEawBZk25WDg0v/SOuB0HIoDcLw6eR4m75mTI4xb8Ny3r4C1h2lpTKPLpVXAxBmwRcnwpZvUF+BsjM5HTAQ58Z0jDxAddbyc5FmsJkmntQuL8623QZa3X14dGvrHaqiGr/Q0sT+nfPWj93HUVa5Ucv5FJfst2rsPjUN9DwnhEnMBdfvXEPsHhcCnQP+5qFxLmXqLowAMtpYaXvGTqo3MrhUUBOw== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(7416002)(82310400003)(9786002)(4326008)(36860700001)(186003)(2616005)(356005)(7636003)(2906002)(426003)(336012)(83380400001)(36906005)(316002)(70586007)(70206006)(6916009)(26005)(54906003)(508600001)(8936002)(8676002)(47076005)(6666004)(5660300002)(7696005)(36756003)(102446001)(403724002);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:02:52.3044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53fc7495-d8b0-423b-8eec-08d9a34ef2af X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT010.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB7096 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441409359100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update sysctl XEN_SYSCTL_overlay to enable support for dtbo nodes addition = using device tree overlay. xl 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. Signed-off-by: Vikram Garhwal --- xen/common/device_tree.c | 41 +++++++++ xen/common/sysctl.c | 199 ++++++++++++++++++++++++++++++++++++++= ++++ xen/include/xen/device_tree.h | 2 + 3 files changed, 242 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 19320e1..5dff64c 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -386,6 +386,47 @@ void dt_print_node_names(struct dt_device_node *dt) } =20 #if defined (CONFIG_OVERLAY_DTB) +int 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; + struct dt_device_node *next_node; + struct dt_device_node *new_node; + + parent_node =3D dt_find_node_by_path(parent_node_path); + + new_node =3D device_node; + + if ( new_node =3D=3D NULL ) + return -EINVAL; + + if ( parent_node =3D=3D NULL ) + { + dt_dprintk("Node not found. Partial dtb will not be added"); + return -EINVAL; + } + + /* + * If node is found. We can attach the device_node as a child of the + * parent node. Iterate to the last child node of parent. + */ + + for ( np =3D parent_node->child; np->sibling !=3D NULL; np =3D np->sib= ling ) + { + } + + next_node =3D np->allnext; + new_node->parent =3D parent_node; + np->sibling =3D new_node; + np->allnext =3D new_node; + /* Now plug next_node at the end of device_node. */ + new_node->sibling =3D next_node; + new_node->allnext =3D next_node; + np->sibling->sibling =3D NULL; + return 0; +} + int overlay_remove_node(struct dt_device_node *device_node) { struct dt_device_node *np; diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index fca47f5..38824b2 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -331,6 +331,205 @@ out: spin_unlock(&overlay_lock); return rc; } + +/* + * Adds device tree nodes under target node. + * We use dt_host_new to unflatten the updated device_tree_flattened. This= is + * done to avoid the removal of device_tree generation, iomem regions mapp= ing to + * hardware domain done by handle_node(). + */ +static long handle_add_overlay_nodes(void *overlay_fdt, + uint32_t overlay_fdt_size) +{ + int rc =3D 0; + struct dt_device_node *overlay_node; + char **node_full_path =3D NULL; + void *fdt =3D NULL; + struct dt_device_node *dt_host_new; + struct domain *d =3D hardware_domain; + struct overlay_track *tr =3D NULL; + unsigned int naddr; + unsigned int i, j; + int num_overlay_nodes; + u64 addr, size; + + fdt =3D xmalloc_bytes(fdt_totalsize(device_tree_flattened)); + if ( fdt =3D=3D NULL ) + return -ENOMEM; + + num_overlay_nodes =3D overlay_node_count(overlay_fdt); + if ( num_overlay_nodes =3D=3D 0 ) + return -ENOMEM; + + spin_lock(&overlay_lock); + + memcpy(fdt, device_tree_flattened, fdt_totalsize(device_tree_flattened= )); + + rc =3D check_overlay_fdt(overlay_fdt, overlay_fdt_size); + if ( rc ) + goto err; + + /* + * overlay_get_node_info is called to get the node information from dt= bo. + * This is done before fdt_overlay_apply() because the overlay apply w= ill + * erase the magic of overlay_fdt. + */ + overlay_get_node_info(overlay_fdt, &node_full_path, num_overlay_nodes); + + rc =3D fdt_overlay_apply(fdt, overlay_fdt); + if ( rc ) + { + printk(XENLOG_ERR "Adding overlay node failed with error %d\n", rc= ); + goto err; + } + + for ( j =3D 0; j < num_overlay_nodes; j++ ) { + /* Check if any of the node already exists in dt_host. */ + overlay_node =3D dt_find_node_by_path(node_full_path[j]); + if ( overlay_node !=3D NULL ) + { + printk(XENLOG_ERR "node %s exists in device tree\n", + node_full_path[j]); + rc =3D -EINVAL; + xfree(node_full_path); + goto err; + } + } + + /* Unflatten the fdt into a new dt_host. */ + unflatten_device_tree(fdt, &dt_host_new); + + for ( j =3D 0; j < num_overlay_nodes; j++ ) { + dt_dprintk("Adding node: %s\n", node_full_path[j]); + + /* Find the newly added node in dt_host_new by it's full path. */ + overlay_node =3D _dt_find_node_by_path(dt_host_new, node_full_path= [j]); + if ( overlay_node =3D=3D NULL ) + { + dt_dprintk("%s node not found\n", node_full_path[j]); + rc =3D -EFAULT; + goto remove_node; + } + + /* Add the node to dt_host. */ + rc =3D overlay_add_node(overlay_node, overlay_node->parent->full_n= ame); + if ( rc ) + { + /* Node not added in dt_host. */ + goto remove_node; + } + + /* Get the node from dt_host and add interrupt and IOMMUs. */ + 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. */ + printk(XENLOG_ERR "Cannot find %s node under updated dt_host\n= ", + overlay_node->name); + goto remove_node; + } + + /* First let's handle the interrupts. */ + rc =3D handle_device_interrupts(d, overlay_node, false); + if ( rc ) + { + printk(XENLOG_G_ERR "Interrupt failed\n"); + goto remove_node; + } + + /* Add device to IOMMUs */ + rc =3D iommu_add_dt_device(overlay_node); + if ( rc < 0 ) + { + printk(XENLOG_G_ERR "Failed to add %s to the IOMMU\n", + dt_node_full_name(overlay_node)); + goto remove_node; + } + + /* 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 and map MMIOs */ + for ( i =3D 0; i < naddr; i++ ) + { + struct map_range_data mr_data =3D { .d =3D d, + .p2mt =3D p2m_mmio_direct_c = }; + 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)); + goto remove_node; + } + + rc =3D map_range_to_domain(overlay_node, addr, size, &mr_data); + if ( rc ) + goto remove_node; + } + } + + /* This will happen if everything above goes right. */ + tr =3D xzalloc(struct overlay_track); + if ( tr =3D=3D NULL ) + { + rc =3D -ENOMEM; + goto remove_node; + } + + tr->dt_host_new =3D dt_host_new; + tr->node_fullname =3D node_full_path; + tr->num_nodes =3D num_overlay_nodes; + + if ( tr->node_fullname =3D=3D NULL ) + { + rc =3D -ENOMEM; + goto remove_node; + } + + INIT_LIST_HEAD(&tr->entry); + list_add_tail(&tr->entry, &overlay_tracker); + +err: + spin_unlock(&overlay_lock); + xfree(fdt); + return rc; + +/* + * Failure case. We need to remove the nodes, free tracker(if tr exists) a= nd + * dt_host_new. + */ +remove_node: + xfree(fdt); + rc =3D check_nodes(node_full_path, j); + + if ( rc ) { + spin_unlock(&overlay_lock); + return rc; + } + + rc =3D remove_nodes(node_full_path, j); + + if ( rc ) { + printk(XENLOG_G_ERR "Removing node failed\n"); + spin_unlock(&overlay_lock); + return rc; + } + + spin_unlock(&overlay_lock); + + xfree(dt_host_new); + + if ( tr ) + xfree(tr); + + if ( node_full_path ) + xfree(node_full_path); + + return rc; +} #endif =20 long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index cf29cf5..eafb269 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -554,6 +554,8 @@ int dt_find_node_by_gpath(XEN_GUEST_HANDLE(char) u_path= , uint32_t u_plen, void dt_print_node_names(struct dt_device_node *dt); =20 #if defined (CONFIG_OVERLAY_DTB) +int overlay_add_node(struct dt_device_node *device_node, + const char *parent_node_path); int overlay_remove_node(struct dt_device_node *device_node); #endif =20 --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441421; cv=pass; d=zohomail.com; s=zohoarc; b=HiOUjslb6KMwC2qai0KlXSjuAT1TCnorx1pdNa58HXrI6CRCV2Udk2QR8fhuVvhKxamm5qn66+/aPIg1lWpNvigg1QeY5TlSVSs7JHqOAAnmyhRY4TSWySvtTR58f9RXIqiL9/Sgu6ipFOnIvFgVxMaAiP+N8qp84pcbzJETqwI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441421; 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=ujbtJPA/WbrVfjNedBqDlhpazGXXQ7bSk/0Y/imNNWc=; b=Xlm7RK1b8j36c6st5Ofw0FTcnQrqvxUoPKi76kRGScBc/K2ZrbBqUU9Btvuz75lsvSEHnYM0LnqNED+TL0qCXhhUWAKqs+1xGd5T+NLdcD6+a+M1zv77ZRfsmOWHs0zzbAa8/YdVXAoK7yf9bbV8wzmwN1gCGDRD2b9acvs1KTw= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163644142108387.9604474980946; Mon, 8 Nov 2021 23:03:41 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223712.386622 (Exim 4.92) (envelope-from ) id 1mkLA4-0003YR-AM; Tue, 09 Nov 2021 07:03:16 +0000 Received: by outflank-mailman (output) from mailman id 223712.386622; Tue, 09 Nov 2021 07:03: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 1mkLA3-0003Ug-He; Tue, 09 Nov 2021 07:03:15 +0000 Received: by outflank-mailman (input) for mailman id 223712; Tue, 09 Nov 2021 07:03:13 +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 1mkLA1-0008WR-9S for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:03:13 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20620.outbound.protection.outlook.com [2a01:111:f400:fe5b::620]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1925f301-412b-11ec-a9d2-d9f7a1cc8784; Tue, 09 Nov 2021 08:03:10 +0100 (CET) Received: from SN7PR04CA0015.namprd04.prod.outlook.com (2603:10b6:806:f2::20) by DM6PR02MB4745.namprd02.prod.outlook.com (2603:10b6:5:fd::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 07:03:05 +0000 Received: from SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com (2603:10b6:806:f2:cafe::3e) by SN7PR04CA0015.outlook.office365.com (2603:10b6:806:f2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:05 +0000 Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0031.mail.protection.outlook.com (10.97.4.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:03:05 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:50 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:50 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9e-000Ga6-0h; Mon, 08 Nov 2021 23:02:50 -0800 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: 1925f301-412b-11ec-a9d2-d9f7a1cc8784 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VzW/NvmKvxmoNPyLTIGLQP//Vgg0VZ9k9PQx2XDXegxBcyUrSX/ppez/Jzcaxaj/1FGjmz/shZv9o46DNs0r2ppsPyT28M/Ip3AdGU18DHoais+/fS7eq/mQ/Uj7pMal4QbymqKH6fZXuwpYDnMmhqditHGPHDewMv/0OSXD9KX16bWM1TVFvBd7R6Qs1eLPlHF/LwBIbu9Xqw2OYn4y7CKdEQI6V5WCdEGM1hmVzdd/BAVaiWYyN/i5YUwFm3jIL5bXM4mpqxPSVj7/kkZkieLT3ldtFkGX/zVvzpFI0KmX3er6MOz0Q5yDtxEGfJ595luABKQpJyls0VRZxMfSyg== 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=ujbtJPA/WbrVfjNedBqDlhpazGXXQ7bSk/0Y/imNNWc=; b=dSb3QIHFXr4lVL7bZrkCzIJ8X8vQuKyKwbbNf222PAnK6zAljM4Ypg62axnnYdkxFCtDC6JvpZgNTCzLfpADKHpPgLvAo/510dJ5e9Q6vLV6HBdKkfqhsbLSpPE5od0dFL9Oj3rukP/LtvQVG/ZEgxUYgHp+C2tOW/Crig4FDmH5GKBUgdHg6Q6yog5jv745CPoyy77Y9ySQ0WSHFqDIM3K+NN53WUJMYFxcNetI0VcdWe0hFrAoImnDfHcjl4qRm4T04EiZrXrubBxMSuxN+n2Sr1SoHXjDzp3Wv2JWmKuik9seT9eR47l9teRR1Z0EPH9rp5RCC9Tc9IDRtGz5Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ujbtJPA/WbrVfjNedBqDlhpazGXXQ7bSk/0Y/imNNWc=; b=EaXIpKaw8LiRQAXNY/d3rksmbHF/nVKJ1/5IJ2keLcDa8934QTeqCUoNaD/5SIMPBSM/7E+3o4zj0A0Njr/RihgEeVyXrt9mfSMjuA4u3V6U7+G5PLoN1jGsCqdE5IWpiAchc60rOA2w1fYrarETHgroTJdkeUI0a6APCrhavqM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Ian Jackson , Wei Liu , Juergen Gross Subject: [XEN][RFC PATCH v2 10/12] tools/libs/ctrl: Implement new xc interfaces for dt overlay Date: Mon, 8 Nov 2021 23:02:25 -0800 Message-ID: <1636441347-133850-11-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c29dba09-5c53-4513-132c-08d9a34efa8d X-MS-TrafficTypeDiagnostic: DM6PR02MB4745: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pqNyJ9iOnux0HjCv7wMjg0hBvit40EHolFNkI6T037OwjxVYFDy9mVLFEKCYINMph+BFT9zAIrJfWdbpj4ALP1aEKs1yiPA3y8pVsLGDfmXHr1UIKuFa97910Q9fhcAHA5NssSFC6RJd0G2MtloN7kr7gN+X6lKdWRtsQnpHUnR97hY2+b6YdLPM3ZZ1GMaHelxC3HJ607P1Lr/bthrAXP1U1G5rYhBIY0FNVuIYk6Hyv4jFVjAP2VFATipC0b4sGxdtnyT1s9pZEvcTn9R0w5DrT7EcZ79bUorBipr+wQe8ny9qRCDZjdrq+a91fw407prO/qTUaPBNBupQ7KrP3Gsg3aSltC2CFlhyJj8v6z/BtVh4F7cxPMPgq5DmR0SG6t/P0C2g+/PuD6LypGPfCvmvzQfrvUMvCOzB9CXTeKE/sPGj+u4rb2zoer0WFbLOnelnRkl53SamCVEMLHrBGUROQAca99EhuYrgV796FLu8616zBcuGUgnzIPBLmhXGJHkm9CtDN2B6MXYADr923iiCFKwJi5v0YAoCYj62Az1pk7F8izu0YE23XLJWhMm0eqVkPVb/Dk+6IW70eh8JE2XOfeephoJQlkA/CskZvZ/Kh6uHY4l7cmwiGywpCBcaLx0eddVa6EXCGpK2Xsmck5l+UFMe4c1urTEytDJkEvp+qeWcPI/6p/6zymlDQ43bSYYbf1koZOZ6IwaMQ6GLBYM7+5RKtGKtzqkerhkRoB+rVcePOfFpkHoHdxHlRkyoVm74Xa5wt/wT6Gg/wf7EOF/9sx4b+qv4m1FDVFcBP9LLpMQ8JQqcnNqN9NIGoOxmzIcSRPGmdo24+kQ57PAAMg== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(46966006)(36840700001)(426003)(2616005)(36906005)(26005)(8676002)(70206006)(186003)(356005)(4326008)(5660300002)(336012)(7696005)(6916009)(6666004)(8936002)(70586007)(82310400003)(36860700001)(9786002)(2906002)(508600001)(54906003)(316002)(36756003)(47076005)(7636003)(102446001)(2004002);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:03:05.5102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c29dba09-5c53-4513-132c-08d9a34efa8d X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0031.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB4745 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441422826100005 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 | 1 + tools/libs/ctrl/xc_overlay.c | 51 ++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 57 insertions(+) create mode 100644 tools/libs/ctrl/xc_overlay.c diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 07b96e6..cfd7c5c 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2684,6 +2684,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 (CONFIG_OVERLAY_DTB) +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_si= ze, + uint8_t overlayop); +#endif + /* Compat shims */ #include "xenctrl_compat.h" =20 diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile index 519246b..a21a949 100644 --- a/tools/libs/ctrl/Makefile +++ b/tools/libs/ctrl/Makefile @@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk =20 SRCS-y +=3D xc_altp2m.c SRCS-y +=3D xc_cpupool.c +SRCS-$(CONFIG_OVERLAY_DTB) +=3D xc_overlay.c SRCS-y +=3D xc_domain.c SRCS-y +=3D xc_evtchn.c SRCS-y +=3D xc_gnttab.c diff --git a/tools/libs/ctrl/xc_overlay.c b/tools/libs/ctrl/xc_overlay.c new file mode 100644 index 0000000..77f9edc --- /dev/null +++ b/tools/libs/ctrl/xc_overlay.c @@ -0,0 +1,51 @@ +/* + * + * Overlay control 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_bitops.h" +#include "xc_private.h" +#include +#include + +int xc_dt_overlay(xc_interface *xch, void *overlay_fdt, int overlay_fdt_si= ze, + uint8_t 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_overlay; + sysctl.u.overlay_dt.overlay_op=3D op; + sysctl.u.overlay_dt.overlay_fdt_size =3D overlay_fdt_size; + + set_xen_guest_handle(sysctl.u.overlay_dt.overlay_fdt, overlay_fdt); + + if ( (err =3D do_sysctl(xch, &sysctl)) !=3D 0 ) + PERROR("%s failed\n", __func__); + +err: + xc_hypercall_bounce_post(xch, overlay_fdt); + + return err; +} --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441407; cv=pass; d=zohomail.com; s=zohoarc; b=HEHnHy8j1rIthPYLI30+3KgeO2vD4INSuUPQ/nD15FdG3sya3yILjO4iHdk5LNkWkC04YSmzyr5lDykKDf/cJrRzmrmM5rMwUg/oePziZJDltKhohqOhXMHbZ2/EZ3rbXbOj1RTeD76GQbRxXYpubzLkw1SnyID1d0UBYOLZMAQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441407; 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=f5zhM1yaBAdXw5ec2yVU1t3POrwQaiIRB5jEhPe+n2w=; b=htGxHByAaNYDwgRtMoYjartXfItIO1TV4kDb9m3V1SAipjm8IESPCm5/j2sZX+vtH0JL9mmGkmseTYK+EP+ykfCz/Iqb2HMTHaUBICLQLu0QPWGVoAq0AKIh23BSIZHlfvbBWzH2H2hM9rKanQNEbAsGxVnzp9At7Zufud26T64= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441407371806.6441430983424; Mon, 8 Nov 2021 23:03:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223699.386530 (Exim 4.92) (envelope-from ) id 1mkL9m-0000cv-O7; Tue, 09 Nov 2021 07:02:58 +0000 Received: by outflank-mailman (output) from mailman id 223699.386530; Tue, 09 Nov 2021 07:02: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 1mkL9m-0000ci-Hh; Tue, 09 Nov 2021 07:02:58 +0000 Received: by outflank-mailman (input) for mailman id 223699; Tue, 09 Nov 2021 07:02:57 +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 1mkL9l-0008WR-9g for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:02:57 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060d.outbound.protection.outlook.com [2a01:111:f400:7eab::60d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0f77f2f4-412b-11ec-a9d2-d9f7a1cc8784; Tue, 09 Nov 2021 08:02:55 +0100 (CET) Received: from DS7PR03CA0311.namprd03.prod.outlook.com (2603:10b6:8:2b::23) by CH0PR02MB8010.namprd02.prod.outlook.com (2603:10b6:610:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Tue, 9 Nov 2021 07:02:52 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::bd) by DS7PR03CA0311.outlook.office365.com (2603:10b6:8:2b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Tue, 9 Nov 2021 07:02:52 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:52 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:50 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:50 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9e-000Ga6-IY; Mon, 08 Nov 2021 23:02:50 -0800 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: 0f77f2f4-412b-11ec-a9d2-d9f7a1cc8784 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/5951yxrc2G9GErmcRSoyIb3W2UIxzv/4klY4KIlIBXWLMh+aMhJ7elFB1m4eeR9ZbwfOiGEh1/hlgD5/m82d57ZP53Ni/JXOUSxEhHf/WKs2zYV4mEeuQTomEIajQd7g/8i79EU8WgjiuS2IDBHH64FqEgj1zNOWJU9GJCRmWfkEUFSikVmeqbzoR7+QfgGMChRQ6O1S5scW4EaxBivwy7n/KDEhaKgXwseVO2qmN365dMYBnMZy6f1JUilQMgDq5SOPqr4glpkuxeUqraMWBnzVih/EFADQgX1Tj1Bpd0u55JN6eeXLEbZu+geicveEGMSRo+8kGa8nUESdN5+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=f5zhM1yaBAdXw5ec2yVU1t3POrwQaiIRB5jEhPe+n2w=; b=NMehr3lFLvJr1Uocc5AeVibjwCOXVpKx2VTFdmjbxy3h1nPpfSnseMuGvVnD4WLs4kYtix7rCGaNV4R5kIsMGon2Vj20ibE7FSdQDRmf4zzk6m7zCLzTvkO6btK7NdxT/lJ6AoQFkwh2Y6etiU/jwjjXpC1mj0xPn3IB4EabCIzEFVO9zQaYTaV9K/7JnpUX10sRwWCtzS/FGKSA23exGcWWRqFAs+1WW5p6ztO5XKN3hrvRQqgs/hcxU9x03SiRoUdvNzbanoJi937ETgIdm+qzSipPP2/8WHfLJky8jC5l37lD1Kg6bkeaxU+YkM1It3acw3LYCwDyU4LmvR+wag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f5zhM1yaBAdXw5ec2yVU1t3POrwQaiIRB5jEhPe+n2w=; b=Cyvb4k4giMGG9wy3hW21e5Q7Tl4i70A4dlqGW617FSi7loKSqywcANKrkEj7suYPRvFh0WPHvvMlmVgddKzpup7mD7P67TwqW0g538gcaln7xg0J8TVqaNm2XrPu10jleH565I61p1VpJICSLKKhXLDZzx0MGihkyDlV8ehcdRA= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Ian Jackson , Wei Liu , Anthony PERARD , Juergen Gross Subject: [XEN][RFC PATCH v2 11/12] tools/libs/light: Implement new libxl functions for device tree overlay ops Date: Mon, 8 Nov 2021 23:02:26 -0800 Message-ID: <1636441347-133850-12-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64343fd2-fc7a-44ec-a629-08d9a34ef2eb X-MS-TrafficTypeDiagnostic: CH0PR02MB8010: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gYfXO1AdMcMIcgMFoXbr0iAxdityKK5JvQJ6xFA9s28qBXZKeIvaDfd3AhkGRa0mo+N0AvYXsYx+Aq4rLU1R9OdRG/lGI/1Btp9NMEJzYxrH9eqR+JT2j1CwksihAhb/I/lE7d27FmA606EbhhdTahWjnSL7mq99wMyRNr3DCCb5VoDwCf9Dm6hdVBf9xb11V0VDWVO0B8CGYyWV6d0pHsuiFCqm8nqG2DEfAE7k+wFAqyvDiJ++5jEAHFYCD51IrUbuGypITLvss265cpUiGIVUJmpZypsFZSoH9Xi4jEgeuoiORWMU+WciLlJ4KKJPjtoj9HUCi6WxDzmnBuNpAlvG1Z5Ay1LWAdTtfkavjgsYfLvgRezzsYLHF2g4YTY7ft9OYJKS4Zve2R5c7JTJ6i0N/CWxP6SHLBViw04tO9hbTIvbJ8mbAAZfMsER5gBI05Zxj38FwOlslRmk1dpQAL8J9EwOSvP7EO9Jh2r60LYI30vB0L+1vcTOEAN+RFJ4qwHmakRzWSl6Y/IIxWQsEsZXOdFd0UsPBAmUmcqudHtDhkassbABiwueKrCK4ACDIKohz7EgNfvvHQ7f1GidDxxKmlG8C1A1KjND4Cpp7T88rT0oSxn3Fle9egsaB+zctPxEubVMPErKnXl1I6kEX5X5qgA4aQuThLnkRn5Wd0bDbpPE85uDtg/pzzSc0Evdu/kPqYSfkyP+yUY+bL3AYWIQFqD8P5bRTJJTlAVbfbqhm+BS5Cv5K18GPKLMrYRi X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(36840700001)(46966006)(54906003)(7696005)(36860700001)(336012)(8936002)(6916009)(2616005)(426003)(82310400003)(26005)(186003)(508600001)(70586007)(70206006)(47076005)(316002)(8676002)(6666004)(36906005)(7636003)(2906002)(356005)(9786002)(5660300002)(36756003)(4326008)(102446001)(2004002);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:02:52.6982 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64343fd2-fc7a-44ec-a629-08d9a34ef2eb X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT010.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB8010 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441409352100004 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/include/libxl.h | 5 ++++ tools/libs/light/Makefile | 3 ++ tools/libs/light/libxl_overlay.c | 65 ++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 73 insertions(+) create mode 100644 tools/libs/light/libxl_overlay.c diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 2e8679d..3dcb3e7 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2406,6 +2406,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 (CONFIG_OVERLAY_DTB) +int libxl_dt_overlay(libxl_ctx *ctx, void *overlay, + int overlay_size, uint8_t 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 194bc5f..0fffa93 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -117,6 +117,9 @@ SRCS-y +=3D libxl_genid.c SRCS-y +=3D _libxl_types.c SRCS-y +=3D libxl_flask.c SRCS-y +=3D _libxl_types_internal.c +ifeq ($(CONFIG_OVERLAY_DTB),y) +SRCS-y +=3D libxl_overlay.o +endif =20 ifeq ($(CONFIG_LIBNL),y) CFLAGS_LIBXL +=3D $(LIBNL3_CFLAGS) diff --git a/tools/libs/light/libxl_overlay.c b/tools/libs/light/libxl_over= lay.c new file mode 100644 index 0000000..d965aee --- /dev/null +++ b/tools/libs/light/libxl_overlay.c @@ -0,0 +1,65 @@ +/* + * 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 +#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, int overlay_dt_size, + uint8_t op) +{ + int rc =3D 0; + GC_INIT(ctx); + + if (check_overlay_fdt(gc, overlay_dt, overlay_dt_size)) { + LOG(ERROR, "Overlay DTB check failed\n"); + return ERROR_FAIL; + } else + LOG(DEBUG, "Overlay DTB check passed\n"); + + /* We don't need to do xc_interface_open here. */ + rc =3D xc_dt_overlay(ctx->xch, overlay_dt, overlay_dt_size, op); + + if (rc) + LOG(ERROR, "%s: Adding/Removing overlay dtb failed.\n", __func__); + + return rc; +} + --=20 2.7.4 From nobody Sat Apr 27 09:23:06 2024 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=xilinx.com); dmarc=fail(p=none dis=none) header.from=xilinx.com ARC-Seal: i=2; a=rsa-sha256; t=1636441407; cv=pass; d=zohomail.com; s=zohoarc; b=bBnC/XyoMaQSKURhlyzNdgy7x8n5sNU1OQ+CNQU3Kro4omrzH/6nwi65P0T686ld5T/sTYo/30xSsEfxB6X2hRB2pK9HYYIy5GJTVS8rUtjNgLZi0qFN1RDRIRFbdoLGW5LytJbGqF+kzUP+Jkhg2TJugo9XRMQE87Ym+CkK52U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636441407; 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=eVTdL2JkAaFCrQBMdzufBf1qaaoyDchjyzTR3R/6sMQ=; b=lelZAme/kE0cuax0HTvk7kLROkBjZWRCH8byCpCmZT+cwWgaf8SJ1Yo8IPGFrjlBKPLlQKiTM+zcLJ+9HYhy0OdjKcc2V/EPZy847GTJ0LA9AVLYUL+ZXDUjMV7p2H5//XarRReEJkZR+0CWiRDhvOH7CHfmVrUlbFD3zabkc7M= 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=xilinx.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1636441407259107.46754228553823; Mon, 8 Nov 2021 23:03:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.223700.386537 (Exim 4.92) (envelope-from ) id 1mkL9n-0000k1-9y; Tue, 09 Nov 2021 07:02:59 +0000 Received: by outflank-mailman (output) from mailman id 223700.386537; Tue, 09 Nov 2021 07:02:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mkL9n-0000iA-3I; Tue, 09 Nov 2021 07:02:59 +0000 Received: by outflank-mailman (input) for mailman id 223700; Tue, 09 Nov 2021 07:02:58 +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 1mkL9l-00004s-Uf for xen-devel@lists.xenproject.org; Tue, 09 Nov 2021 07:02:58 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on20624.outbound.protection.outlook.com [2a01:111:f400:7eb2::624]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 10c1cc54-412b-11ec-9787-a32c541c8605; Tue, 09 Nov 2021 08:02:57 +0100 (CET) Received: from DS7PR03CA0326.namprd03.prod.outlook.com (2603:10b6:8:2b::28) by MN2PR02MB6894.namprd02.prod.outlook.com (2603:10b6:208:202::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 07:02:53 +0000 Received: from DM3NAM02FT010.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2b:cafe::d9) by DS7PR03CA0326.outlook.office365.com (2603:10b6:8:2b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Tue, 9 Nov 2021 07:02:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT010.mail.protection.outlook.com (10.13.5.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 07:02:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 8 Nov 2021 23:02:51 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 8 Nov 2021 23:02:51 -0800 Received: from [172.19.2.115] (port=44056 helo=xsjfnuv50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mkL9f-000Ga6-3f; Mon, 08 Nov 2021 23:02:51 -0800 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: 10c1cc54-412b-11ec-9787-a32c541c8605 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SjUmxrbS9Z48N1bB0x+nE/xu3+s2n7pbUxPKHP1625KlF327Li7N5Kds3JksfRKXBk8qeTeylI145cGR7pEX2dC5tJ5nxG2c7tLX0lEqdUqSYDayZx13fCvkcXvcNj051POGK9tb+sQ/GvQfD22bg8BR+iJaQzLskktIl36sZkCBHBAAsZAfMCeJJQV5zmvCrHKQtcFIQV/ztfS4qaIq0qaI5bJJ1ro660Q9dRoAIp0GMarpWgWqiLpCEcd0FOymTcSUm3FamYE71zj2LC7TYFW3lu/XzMIKBPS08B0NihvVcj/K/7XR2gbAKZYL0+AcIdUIH2z1qwxoX+3mqbzmFA== 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=eVTdL2JkAaFCrQBMdzufBf1qaaoyDchjyzTR3R/6sMQ=; b=Rxy5+F86No0TIR1bdFe9VXQW3azprKEbUS7aMS67PSudjCYsFYYIVnl6hkulqwqo6zRJ82UWmzO/InZhoaWzBnS24FcPFf1gJRzfKqeVuZHfxecl/jr1ijyzRyt2sKTGjFfiTChU/AudJXHW93MOMXpTz7sFz8qVeWaQYEH+zGrq2+6YcJIMg9o9AG9ra1vhBzVogGHw/BYx/AHzvcWbEmaSGWSQzdKdme6p2YhEV9A62atOVXd+l9YIbWi8dS1PA8vVf4wPVScJlexsXWnmpNuf4UXDb1J5Jhawg/OStugkO/Fn0xpsNPJt75+dSyXcbRyjN+H8+QyvCCIo7slWnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eVTdL2JkAaFCrQBMdzufBf1qaaoyDchjyzTR3R/6sMQ=; b=ja6xZHGxpWL5BZNipXkWRCQSD0ax2aNePpFfIZG7iuJM+XaiY2DAM0ZhPdl0SQXwmlpsq/w0/u9VlP7z96kxU+IM1VUX4ktk6Ymx9mkRtwg9JIoHhBN43ybYL5FMq4zuB6CL92ESATp2Ems/xaj0w/20e6kov8q9FVL4RnE/6ZQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=pass action=none header.from=xilinx.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 xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; From: Vikram Garhwal To: CC: , , , , Vikram Garhwal , Ian Jackson , Wei Liu , Anthony PERARD Subject: [XEN][RFC PATCH v2 12/12] tools/xl: Add new xl command overlay Date: Mon, 8 Nov 2021 23:02:27 -0800 Message-ID: <1636441347-133850-13-git-send-email-fnu.vikram@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> References: <1636441347-133850-1-git-send-email-fnu.vikram@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec176ae9-4f43-44fc-9f81-08d9a34ef37b X-MS-TrafficTypeDiagnostic: MN2PR02MB6894: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PmBHn+r2mrAQuobPjEC5u+B9C+zkhFQnlM38LS6wn0N3NGQX4a8LyKunx4YQubG0hiuypa+pitqKfNLN7esvj3ZHV+vgVgUgYDhhpjiRQHNd7EwqqYoWDcL7+ut9iqa3b0fdVnQaME5ys5RNd8ieBsaq/lf94C6TB55J2qab63XHH3z4ILhVT6FiLfE49nBOaeSaaDzuVhbvjtLdBaSQI22bokqu35lL16OAN3UfAjZ5G3J0oC6z08MiPdCtbLBNgskaTp+PSpwvANowwWk9uUb8w03QiStvmr58ennoX0sfDDHUeIe8IMMYFrKdRqMRJfmq1esUgoZsLAnOzgs4k5dM3Bwnw8W6qKq4jOpttxTisuuEMD8q2Pr7oRzq7fGmpx3yfUonJZh6NJys/kQ7TMPUtcrJ8OBk7P0QOGpB7Ivvn0s7VAdC+lYnZOpBCkFyC5E5NPrVRMgw7UFuCMRyk+HGQZA63UwRvQ94FwbZeoJov4m7AWzn9kJWOCIwI0Q9JEkAyGM/YHDL5HbJ4OsQDHLuKmyw4jSKQLd3AkO78XxjNBjKRwz/rRRgKl8Qu75bvG0IzydLvzIpJFwRUFEyg7zcR/gLHXS1IAF0278c4hmUatOJAKAsDP2TiXJnbYdTGCRkjLNIAAU1yolpoZGaX/Gz3npws52xZF5d5SjlJr6SEW4CvMhK61DwDJO6mMP1LmQYYQou1Nv0k7ETsM59FCDvtHDctEBW5IV/PYxzApo= X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(46966006)(36840700001)(7696005)(26005)(8936002)(8676002)(6916009)(6666004)(4326008)(186003)(7636003)(9786002)(426003)(2616005)(336012)(47076005)(82310400003)(316002)(70586007)(5660300002)(508600001)(36756003)(36906005)(54906003)(83380400001)(70206006)(36860700001)(356005)(2906002)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 07:02:53.6438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec176ae9-4f43-44fc-9f81-08d9a34ef37b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT010.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR02MB6894 X-ZohoMail-DKIM: pass (identity @xilinx.onmicrosoft.com) X-ZM-MESSAGEID: 1636441409352100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Vikram Garhwal --- tools/xl/xl.h | 8 ++++++++ tools/xl/xl_cmdtable.c | 8 ++++++++ tools/xl/xl_vmcontrol.c | 47 +++++++++++++++++++++++++++++++++++++++++++++= ++ 3 files changed, 63 insertions(+) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 7e23f30..2ee75a0 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -98,6 +98,11 @@ struct save_file_header { =20 #define SAVEFILE_BYTEORDER_VALUE ((uint32_t)0x01020304UL) =20 +#if defined (CONFIG_OVERLAY_DTB) +#define XL_DT_OVERLAY_ADD 1 +#define XL_DT_OVERLAY_REMOVE 2 +#endif + void save_domain_core_begin(uint32_t domid, int preserve_domid, const char *override_config_file, @@ -140,6 +145,9 @@ 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); +#if defined (CONFIG_OVERLAY_DTB) +int main_dt_overlay(int argc, char **argv); +#endif 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 661323d..dd43920 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -20,6 +20,14 @@ #include "xl.h" =20 const struct cmd_spec cmd_table[] =3D { +#if defined (CONFIG_OVERLAY_DTB) + { "overlay", + &main_dt_overlay, 1, 1, + "Add/Remove a device tree overlay", + "add/remove <.dtbo>" + "-h print this help\n" + }, +#endif { "create", &main_create, 1, 1, "Create a domain from config file ", diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 435155a..88c8e66 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -1262,6 +1262,53 @@ int main_create(int argc, char **argv) return 0; } =20 +#if defined (CONFIG_OVERLAY_DTB) +int main_dt_overlay(int argc, char **argv) +{ + const char *overlay_ops =3D argv[1]; + const char *overlay_config_file =3D argv[2]; + void *overlay_dtb =3D NULL; + int rc; + uint8_t op; + int overlay_dtb_size =3D 0; + + if (overlay_ops =3D=3D NULL) { + fprintf(stderr, "No overlay operation mode provided\n"); + return ERROR_FAIL; + } + + if (strcmp(overlay_ops, "add") =3D=3D 0) + op =3D XL_DT_OVERLAY_ADD; + else if (strcmp(overlay_ops, "remove") =3D=3D 0) + op =3D XL_DT_OVERLAY_REMOVE; + else { + fprintf(stderr, "Invalid dt overlay operation\n"); + return ERROR_FAIL; + } + + 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); + if (rc) + fprintf(stderr, "Overlay operation failed\n"); + + free(overlay_dtb); + return rc; +} +#endif /* * Local variables: * mode: C --=20 2.7.4