From patchwork Thu Sep 19 10:42:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13807629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04A4FCE8D78 for ; Thu, 19 Sep 2024 10:45:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.800598.1210535 (Exim 4.92) (envelope-from ) id 1srEfC-0003qG-9d; Thu, 19 Sep 2024 10:45:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 800598.1210535; Thu, 19 Sep 2024 10:45:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1srEfC-0003q6-3f; Thu, 19 Sep 2024 10:45:30 +0000 Received: by outflank-mailman (input) for mailman id 800598; Thu, 19 Sep 2024 10:45:29 +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 1srEfB-0003mj-72 for xen-devel@lists.xenproject.org; Thu, 19 Sep 2024 10:45:29 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060a.outbound.protection.outlook.com [2a01:111:f403:2417::60a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 47174829-7674-11ef-a0b8-8be0dac302b0; Thu, 19 Sep 2024 12:45:27 +0200 (CEST) Received: from MW4PR03CA0340.namprd03.prod.outlook.com (2603:10b6:303:dc::15) by PH7PR12MB7353.namprd12.prod.outlook.com (2603:10b6:510:20c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.21; Thu, 19 Sep 2024 10:45:22 +0000 Received: from SJ5PEPF000001EE.namprd05.prod.outlook.com (2603:10b6:303:dc:cafe::1e) by MW4PR03CA0340.outlook.office365.com (2603:10b6:303:dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Thu, 19 Sep 2024 10:45:22 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001EE.mail.protection.outlook.com (10.167.242.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 10:45:22 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:20 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 19 Sep 2024 05:45:19 -0500 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: 47174829-7674-11ef-a0b8-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mA/8UfRpvJfEq9R7JuJDSanIX8RPEfSButTdJdmnfnwDRUd+yageOSM8fvfrX4pu+4Va6d5tsEUCHtTUioqywogJfl4hxxlSIXJDdo3mCCXb5wW++vm13S+vX7dMCnwP7olhqx65EWn20QCc/NHx0JmZM50sKJW9+8oplIs5bzP0D48isxuE0WJLUlju6H7p5MMtxFDw9QQLKNEGr4IhRjemoJ1mUeD4ag4wc77Na2StUo0zPtvJ/58x5mWOo5iFWDYIIfPnm6mTdalFiz9vN3UnTMdGIjjdB7RLwlfB29KHly84hEjXJOe88xOBdn5kSJioZO+KqBvA8jb42dnv8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gG9/qkw06hz698vVlrpLqB28KmGhGXJBzIpoErUxTEs=; b=rvNvMq5GNERdeyUjLcl5k0ATVX8vnoT7J/ubBpIVlNdjKzO55RP+IrteTTdPyAmc6CrlRMs+LH+myDR5LXPFYcedz2484UnZL9YK89M5rpBVAdX/7Og3ccv7NIBkz2VGRFpw1Zf4J/uCMC5nK8ZuoovIh+4oVbr9PA0sG66MF2Vcr2ydww97Tat9PjmnbsxDM9ndIdQ578tJToyZYeR2+eHXGP6p1pCKqm+afw4y3wBA87zwDaqdZFNglrDSJyyHZSat2sTMrceshJOWRa7CgoGaRJQ8604+5GdO3rJjKmJATv8uR93qq1wj6oUd/vyCtBxQwwatGYRnb1Ad0FZDzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gG9/qkw06hz698vVlrpLqB28KmGhGXJBzIpoErUxTEs=; b=2Jrp15IZY01T5u7O1sYBsKWaKvvu94AHNw+JGNMZcxn7Eu2VYDYv9CDt9UUHnOCGsWfLlVagOo7Drk94lx26gM9ECiOoyMfeyjCLyBCzttvCSiq/poYuTvuqtUPm3f7ExBnXFtLmTlkejaquMEZkMJ0ey70Rk0MEQnq1GRTjbGw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis Subject: [PATCH 1/4] dt-overlay: Fix NULL pointer dereference Date: Thu, 19 Sep 2024 12:42:35 +0200 Message-ID: <20240919104238.232704-2-michal.orzel@amd.com> X-Mailer: git-send-email 2.37.6 In-Reply-To: <20240919104238.232704-1-michal.orzel@amd.com> References: <20240919104238.232704-1-michal.orzel@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: michal.orzel@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EE:EE_|PH7PR12MB7353:EE_ X-MS-Office365-Filtering-Correlation-Id: f4bf68ea-8048-46c0-fd96-08dcd89829c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: Df9YzRg1mcLliC7ppPEdo1Fm233dNCqyeF8qAf9evuJhVVsC89tAmb7akcF8Fszo/zXSBmKQ/OiGAhtarnB7CA+meySgD60p2+S8PzioBMgF5p5w7sfZOGhy/2WzwNRxqLqxuseDTHmdK6rDxr1as6CL8K6/YVrj8+W+RAsyfZv2BvLiQB+o7DOBm/RK7IpuhsNB/OOlMjq+z7xyL8kpWwMrHMTD088fokW/bhlLh77AntC0pU7WU819nMP6NPfOGy6fpCqHNov8mLtWkC9V8YJPGm1ypAxwd5kavfv+UxYli+qvuAUQrO9epqBeQYjKVqKhf5I33e5L93UD5XSDNuoHbzdg7xZZTDWEir5b4eUTvszMAFTLcnJf/qqF1mgNyuF0i2OqlaEzJht+rppGTnXmZkU6cLEBRl1LCMxAA5+BFamMEtaWEoKGvdSezfg7E6ZDtmzYQh7teN4dHFIeBjXOFgKnTkU+Muds9DcxoR30zHyy14oBLjnFScWW5tCxjFCpYyXHWAVry5/GLGVmpaSJ5lsuXlkWvIyFZZaVa3JopPxIpOjfw78xt33qH8eVY6WwJZyXqgrWoeYAvoyFRLgF5TOqMuRtWgoms6rEMgQ7Yr7TWbjAHLSy0Ov4JjXNWpUI9JcBztlNKBXzcFkF45IwFDF9GUqUX0ROk+plhP/rqEjws3p7PE/2NQTD1QgroJ1S/CcdUltN1U1/kQKCMUxgBTjb8NTNknETQ62wH8r/YZe7tLWGDot+ksmYplYXwCOQw5lOorAlL26akQPvz2LKcjrAfPvqnhSYjwb7vbeiGbk+b20BWpooWf+5oEWas1v922rjecfgSPlpiNB4XQiO7S98jNq2TliHKVhsXvZ6Nv+yQXruV/0P/Q3j3UQbmChQPygS95uxydRDqkgPdQlZhWgoHvUlks7d4kQgzxfWGPe02x3IvpgDLK7DoZv/qDbFnoPwplRHpRtig/b/zkxj5qD5k/T/oC0tV9JrUuYs9DNB6qgtFAxpZa0wthYsK+8cQfyPKlurWm9UOzWlkEJMpg3ig7qDPaZVPVPt2wk+9KAspf5BgRfbztzjFDJQiL3y2oLDeYOVR1UuFimCrjeAD03wT4muUMabAwl/ExzA9Mx3kudZuULlYLskj0hDzpmtzhG2rymdj2kXHyf2WkGhLVyaesDPaU1LvRFq2jpVdW2LB+jkv+/BSauBdWMGUW4HQpuTb3BOnqQ6MHfHvdnhx1Q9aYRt1o/0crCfNNR+9NAhHjaBCtoRbokfR+ejWCLRGKtK1x2XNvAALeUEENXpyG6NEGT2VQu423oYFxUT5n6bkID6h+hhJ5rDyj15x2Fgrm5Pt4Moh0IkJSRI89FAkxkNOtBv2w34bUFIcpc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 10:45:22.4697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f4bf68ea-8048-46c0-fd96-08dcd89829c2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7353 Attempt to attach an overlay (xl dt-overlay attach) to a domain without first adding this overlay to Xen (xl dt-overlay add) results in an overlay track entry being NULL in handle_attach_overlay_nodes(). This leads to NULL pointer dereference and the following data abort crash: (XEN) Cannot find any matching tracker with input dtbo. Operation is supported only for prior added dtbo. (XEN) Data Abort Trap. Syndrome=0x5 (XEN) Walking Hypervisor VA 0x40 on CPU0 via TTBR 0x0000000046948000 (XEN) 0TH[0x000] = 0x46940f7f (XEN) 1ST[0x000] = 0x0 (XEN) CPU0: Unexpected Trap: Data Abort (XEN) ----[ Xen-4.20-unstable arm64 debug=y Not tainted ]---- ... (XEN) Xen call trace: (XEN) [<00000a0000208b30>] dt_overlay_domctl+0x304/0x370 (PC) (XEN) [<00000a0000208b30>] dt_overlay_domctl+0x304/0x370 (LR) (XEN) [<00000a0000274b7c>] arch_do_domctl+0x48/0x328 Fixes: 4c733873b5c2 ("xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains") Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini --- xen/common/dt-overlay.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index d53b4706cd2f..8606b14d1e8e 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -908,8 +908,11 @@ static long handle_attach_overlay_nodes(struct domain *d, out: spin_unlock(&overlay_lock); - rangeset_destroy(entry->irq_ranges); - rangeset_destroy(entry->iomem_ranges); + if ( entry ) + { + rangeset_destroy(entry->irq_ranges); + rangeset_destroy(entry->iomem_ranges); + } return rc; } From patchwork Thu Sep 19 10:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13807631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 132A1CE8D79 for ; Thu, 19 Sep 2024 10:45:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.800599.1210549 (Exim 4.92) (envelope-from ) id 1srEfE-0004HV-GN; Thu, 19 Sep 2024 10:45:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 800599.1210549; Thu, 19 Sep 2024 10:45:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1srEfE-0004HM-CP; Thu, 19 Sep 2024 10:45:32 +0000 Received: by outflank-mailman (input) for mailman id 800599; Thu, 19 Sep 2024 10:45:30 +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 1srEfC-00043V-Sf for xen-devel@lists.xenproject.org; Thu, 19 Sep 2024 10:45:30 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061d.outbound.protection.outlook.com [2a01:111:f403:200a::61d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 48ee939a-7674-11ef-99a2-01e77a169b0f; Thu, 19 Sep 2024 12:45:28 +0200 (CEST) Received: from MW4PR03CA0345.namprd03.prod.outlook.com (2603:10b6:303:dc::20) by CH3PR12MB8877.namprd12.prod.outlook.com (2603:10b6:610:170::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.21; Thu, 19 Sep 2024 10:45:23 +0000 Received: from SJ5PEPF000001EE.namprd05.prod.outlook.com (2603:10b6:303:dc:cafe::ea) by MW4PR03CA0345.outlook.office365.com (2603:10b6:303:dc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Thu, 19 Sep 2024 10:45:23 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001EE.mail.protection.outlook.com (10.167.242.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 10:45:23 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:22 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 19 Sep 2024 05:45:21 -0500 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: 48ee939a-7674-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UVKZMbu0d4kxDPoLiPDirlr79T+vjcV8r8GWaHR0S0WczbBejICVB8TT4VGXBG3svNM9wcfUNpTitp2Kn9yo3tH+WMoDrP8VtAfu/RuWS8I4CmdfjWBInF98bBAM7Nl6ypHzzB17fuIWzjcoN1yWNn5+01c3Zt2Dj6G4hwHqFHtiipz/jyxNbl4Is23bGOCOKnfCzKjYDuhzd0BjOE2n3o3xPhmxBUEKWH0e3VqDgBdo1GneV5fhOf7QmUPwx9/A29pzps0b494v2OXi3BwaHP2/Y5YCMrmPQREiLGiyyo1PPnQ/jloWe8Kd6rd8N/K2xLxjfyq0H0jLRJ+7BPQyTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5a8d8Dmwmijg24rkMyGYaLxqRaF0Hxcf7ag2CMKmCKk=; b=Uer9SpeXdmutUf2Wo9TwEx0opDpxSOJoKWL/nSoWQP4pZu/oHYLwQ5bfdMx0OFKBVst5Zj5yt7DpfJMDji2k6H74seZSZK5YlPAo9bANDwxHZ8qNXMSFXf0770pESYzo6tUuOrgE7vplXbaZ1tHCGr0Fz/6A/cb29u9Rhs9GOqmZQA3/7Yj5cXxHYsDIU9wClGep+J+Wpj3SCYVukpLfKwWlka4WZwO7bk/3U4IebdCtvbRsCPLNpD0pSwYWpR8TgH9PbJnlWUH3mJ9HBGjIep0+fIGeApAPAAWTQO+W3L0H+wKzTQLhbruqFCmSdLz01So6EKSOVCSTG2JB14WMfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5a8d8Dmwmijg24rkMyGYaLxqRaF0Hxcf7ag2CMKmCKk=; b=mCLRoTMOXs7b/8TvNgJ9UP4BdB6GXSCBlCn7OL+1nAf+maq0SSYo0/962661oWMCXp89PZRw4adtQ/0J6A2WNAIYEVwTqlog4LWx9PZGWr/MTP76vU+iHdE6JOn7nOFmxnLZkpjBNFVsVbi8DKxdX0i36DH+mhmg9S3ZTTFjVXg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis Subject: [PATCH 2/4] device-tree: Remove __init from unflatten_dt_alloc() Date: Thu, 19 Sep 2024 12:42:36 +0200 Message-ID: <20240919104238.232704-3-michal.orzel@amd.com> X-Mailer: git-send-email 2.37.6 In-Reply-To: <20240919104238.232704-1-michal.orzel@amd.com> References: <20240919104238.232704-1-michal.orzel@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: michal.orzel@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EE:EE_|CH3PR12MB8877:EE_ X-MS-Office365-Filtering-Correlation-Id: 75d06a8f-ba17-4984-4760-08dcd8982a2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: aDgpht7bjY6vIERjxIgsV5GedP5BOMFbMM4eKxqm1LoSbMNi4faVG4ya08BnZtF8cUsTbuIM0mnTne2hRoXDkDV1sXYJqA8+LhFNQvv4nDFN7AJGdV6y/t+ZXr/VXFeoBL13ce0EUSkIfS2zoq/b/ZFk/2DRGllaWROqtO7kLDrLPQY56750gE9cDty2Cyzf8bk3mHKpKLYvzpDiHFqzj5SRAOO2nLSZS8AUoBIXgUYf0+d9033m6Yk3Q11cqj0SVivPhM+uSakzMHcfDH129iKhQKxbwLgcCWVeDv0WhM4pvldSIfCeh9Er0812FXDhdMyNLIu1vO8//EPMAv28jsiMpgLzl3Q5bC2gDd9f9SGYrpWO4UPPtrAWUjOmjrG02WmxlVnmewcPmcU6FAFHQnjL7OOIxhIAGPQbURoUbLgB466ijyJMoOC06H7xnxIn07pskiHjAFdsMJMPbrdU/z6hUADPBxpJFk6OuS7eq1Cy5Xt8l7GRhqrshaXrF9zN2XB3tvHGrOvfvu/KabekaysSv9tWXC4QKVQ9T+TrsIYOPx2mThuEUBV23EHEvSt+vVjlKyI91sb1ZYImzUcVecHfa2W4PDcyZlPLf6vcx152umFqe7XIPBCXGLR6Oged1XjzQd1Ncxj3J+rwogJrmT2q9GQLaeCj837OQBRky2GwlG3XWNNSuWRxjlJ/XSa8dw4qoiVa4yJMaAipUozwDUw0KvUuuUInLTNT1E4kET//8ufzhi4FBlWBsuJXkjxxSMCBQH8ht/q+W8KVW4S2NXWwFNewFuhnNwAaB0DL9fTlS0CxmKc4Z2Zeq3Mwb33bUrPKVrX4Hl2YQDds4HtweEy8TnurwtnZkxMc95Wv7Ir7RSJ/hbQfM7DR6bBXfLRom1qxo2evVgMm8i0+oiVEsdTdVQvcOf6wsXvEBgydWtaYVr1cebJ+RowY/+nBrEmFb5or95tEBltGMwXz4fso7Q9h3WJ6XxSIEXesK0Gwqba49dJ6K8bLO0JnFFz5kvI4Mgha0RMQ80R9M8Mftg91su8bEquDi15RzHsT58c1ut4M0zF/jh2L0SgyZol7BC0krdGsrt7RpIjCbhCv84JviLvO8y5ATB7NpZjcGCqID9xu2o4oG7i3tmCEZeWEm0A0ayJPO/4ycf1SI3UojRNwXgfFi1eHy61Z9l5UQFz9C4kQ9CQKrmzEt9dyZaWoy/b1Bj4wabZGCIbLdwtY+StbDaMPqP49/7OtjB04RIqTfDE/b7CrSPIWEE7Slsg2mTm/lMZSyCdDkkeqsLqRbKFRwRyzkCJ4fJhTPgm0r1wOcyyXdAwYpFwSrw6nG78CeBJcDWJapqqTE/MT54K4xkkxoWQjI8modh5m7FvT1vjxWUBAswTu6Luk4DTeMRHR6leyL2BvJ5utwWLG28CH2bGzVE1b3k9vAXGf6aByYN07K9TPKkXAVdCGnlLlPPCl7V85 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 10:45:23.2509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75d06a8f-ba17-4984-4760-08dcd8982a2e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8877 With CONFIG_OVERLAY_DTB=y, unflatten_dt_alloc() is used as part of unflatten_dt_node() used during runtime. In case of a binary compiled such as unflatten_dt_alloc() does not get inlined (e.g. using -Og), attempt to add an overlay to Xen (xl dt-overlay add) results in a crash. (XEN) Instruction Abort Trap. Syndrome=0x7 (XEN) Walking Hypervisor VA 0xa00002c8cc0 on CPU2 via TTBR 0x0000000040340000 (XEN) 0TH[0x014] = 0x4033ff7f (XEN) 1ST[0x000] = 0x4033ef7f (XEN) 2ND[0x001] = 0x4000004033af7f (XEN) 3RD[0x0c8] = 0x0 (XEN) CPU2: Unexpected Trap: Instruction Abort (XEN) ----[ Xen-4.20-unstable arm64 debug=y Not tainted ]---- ... (XEN) Xen call trace: (XEN) [<00000a00002c8cc0>] 00000a00002c8cc0 (PC) (XEN) [<00000a0000202410>] device-tree.c#unflatten_dt_node+0xd0/0x504 (LR) (XEN) [<00000a0000204484>] unflatten_device_tree+0x54/0x1a0 (XEN) [<00000a000020800c>] dt-overlay.c#handle_add_overlay_nodes+0x290/0x3d4 (XEN) [<00000a0000208360>] dt_overlay_sysctl+0x8c/0x110 (XEN) [<00000a000027714c>] arch_do_sysctl+0x1c/0x2c Fixes: 9e9d2c079dc4 ("xen/arm/device: Remove __init from function type") Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini --- xen/common/device-tree/device-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c index 8d1017a49d80..d0528c582565 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -120,8 +120,8 @@ void dt_child_set_range(__be32 **cellp, int addrcells, int sizecells, dt_set_cell(cellp, sizecells, size); } -static void __init *unflatten_dt_alloc(unsigned long *mem, unsigned long size, - unsigned long align) +static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, + unsigned long align) { void *res; From patchwork Thu Sep 19 10:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13807630 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8F85CE8D77 for ; Thu, 19 Sep 2024 10:45:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.800600.1210559 (Exim 4.92) (envelope-from ) id 1srEfF-0004XU-PQ; Thu, 19 Sep 2024 10:45:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 800600.1210559; Thu, 19 Sep 2024 10:45:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1srEfF-0004XA-M7; Thu, 19 Sep 2024 10:45:33 +0000 Received: by outflank-mailman (input) for mailman id 800600; Thu, 19 Sep 2024 10:45:32 +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 1srEfE-0003mj-ER for xen-devel@lists.xenproject.org; Thu, 19 Sep 2024 10:45:32 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2413::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4a461542-7674-11ef-a0b8-8be0dac302b0; Thu, 19 Sep 2024 12:45:31 +0200 (CEST) Received: from SN6PR16CA0066.namprd16.prod.outlook.com (2603:10b6:805:ca::43) by LV2PR12MB5871.namprd12.prod.outlook.com (2603:10b6:408:174::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.17; Thu, 19 Sep 2024 10:45:25 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:805:ca:cafe::f2) by SN6PR16CA0066.outlook.office365.com (2603:10b6:805:ca::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.28 via Frontend Transport; Thu, 19 Sep 2024 10:45:25 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 10:45:24 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:24 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:24 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 19 Sep 2024 05:45:22 -0500 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: 4a461542-7674-11ef-a0b8-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RyKAfJat7D7YOTM5FsNmWSPdM5e8Q1zZkdhg/MA1QTfkH5Xa+GNJKQhhhDOx5cpK2juISO1cR4s5hWwoTt8KaIVFAdfdoVpNckiHoDsHhqOtDtPhVg9suJqYWMzPK0URBRWrSsuTqxiuoq6thELBwYGzXUiWOVjysiJ6zT9PJYFFEfkvO1gGwcQbsrfR/n59+Iq9wgMFJR4rxW3GGaZJCWHydfi3C2T7yDterLAnpbPP0ttUyImzFsLZqDFYgaX3Rqly15sgCnCUZDrhS9bB4qDZRJH+EeRaZDsArZdHsQA832Z+n5lmP9uxM4gR//NwgvCb+gOFTMZ+ydK6srgbmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=bu105dDIpB4eZMz42pqaBoX0Nyrbf+DW33CIprSzLCw=; b=WT9bp+3u1P9EbQuSHeZMFMSx5c4s3lPpiKprBfTevdMtXCUcGtYMsDkFAasSC3s3cMmpOMJIsHMXJWA+ViSVkHGg/pSPviSmulZODnT6ioqxPp98ZMz6RpkQuxKv/WZ8io8HqZM1/C7pAMmkRF3gLaYN3xL+vzIpOLe1aB5BaphhD39OoEGzneAVfQdXwYLzZjMSihaGBhQimJyJSAqOFgI9BMjAw6ayiY78TxFid/Inb3MNqC17sdNSz/L5+1UzL49+Pm11QiJ0zcOCGvRnFaCn9DVBqrwKoaqfva5ATPGpM+BnjInlAMMnWmE6V/bkG6UFxp3IVo5cALLo/Q9qmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bu105dDIpB4eZMz42pqaBoX0Nyrbf+DW33CIprSzLCw=; b=GLuN+ZWCgSPs0v7BgiJlEEPz2nnJKUTNtgfMxQqEdGBkrCd+KYHCZcq7JNBeY5xQDBoDzLFvCZhruKaeq0GwAOgvayZxDCBCgZoHAvPkt03jvZFnmn1VCkDZeUb8lKKT0UFgWn1EURKWTY98laCNTnEur+JVmpx/svsVilhgggE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis Subject: [PATCH 3/4] dt-overlay: Remove ASSERT_UNREACHABLE from add_nodes() Date: Thu, 19 Sep 2024 12:42:37 +0200 Message-ID: <20240919104238.232704-4-michal.orzel@amd.com> X-Mailer: git-send-email 2.37.6 In-Reply-To: <20240919104238.232704-1-michal.orzel@amd.com> References: <20240919104238.232704-1-michal.orzel@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|LV2PR12MB5871:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e76b153-6704-40b0-9347-08dcd8982b2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: lrcdtqYtoIxi7aZ9tV4ompS9lkZqcuMZStTO+i5x0Lccxv8D1pkvL8Yt9DK6YYdXViTO9FitywnRlu7/znlPTsrVr55EvL7fSNegxvINMKj68xJRakQW1XF31DOltuV1WxaqN2ZqUaLYCynnVs26xZ1n79ON/Tof4xIoY1AstJ2+o+GUXz1T5D6U/KMw5b0FDs1vixkysNywJ/+En8IlQY1oKI+pq2qaiJPMvu7ter1LLCqGLRdlQ5KOhS0jZHSl6wnA7uJB6QjygJvWNzYR619EnohbxY2FNHXmO61neZKvIRWW9OfjCSf2EmQgceBi/FIBiOADyPkWSKMMXmerX5hUrTeUPQ43a/1v+gt0ZpFoAorLf2tP1KleIYRFcekUuqKwzurc0snXppErQd5Kce/9tO9yga9y1OPsClJOY0UTAyVoc7W+3Lw9RPn/M9IV3HBR7t6FNfB18OQMWSQJC/urebsBkJM76nAPMzxNlhBw60R6MKviCnM0fPYaCohoVKFehHAGXYcO1mgBzjm9FhIVzDxLwNIqHnaAzPjGVPl3K4fOKn3/WEzHx8QGOflTP60jdH1VHPh6N+IVTr9CWV3yBI+V+D378WraiJ4g1pu9GzpbWaHTs7yP1QQN68hRPZK3IO1/arGjm9EvH9FTMjzZ6Kz4ObVZuhk2DQLiFbBor9qAT7dkugxKId0gl447G51+BmIdShIacnEvFFWEUaaPhh3YGuLVS53hNZqVBTnwGSun2uM895FX2398BzUgWyfgbUMJdIcK9iSM7JWlKDrwdyZky7lVtUsZcw6LWEVKLUpcftBQQeP1zs5KUrVHHlef7xIMockYGH9iaJkqBEkgi6QJJ/sLrMGUCX9IptnNW6kVSstz0xDoxqR4kwf5LWJF5AnC4OcRqIzBEqSiq4MNWKpP9QbeLempveW9i4WDMQy3Wfhg9JCj0Yq/FndMZ5FAR6k74y09iR9LMKTRsmjZFmpnc03026uMN/63uAU2MVoF+jovXL4E8tk4SS4hSi/FNCVbhp2lnI5rzN+rWCBuED6qFl8i6+AOYFBtQxhbEVnT11WweZaxS4NDUm6ToMSsuLbhLnei5ODia9RabaIfofnIwHCBaElKX2vrkjTOikXGsEzKckJ9ZwUhOeKA/70xPthwCXdMbknVj2ASvRRNyOhBT0+y2vw7bALnDBPJzfClmWqH1BGXaukMOsubno9tgX6E75N4aYhMPQwAUNLrOGG5iKKFN2Dwbb9ngubNlcctvc5Jh8JP+EDtQ147VWh8oYz4wxfE1aP1B7rZ3NQjJRI6s6Bh0fZ3x+5aah51X0iXowG7UZgMN0Uf92LKP8pq/prvsbnUflfXfq4MxaBMHRRRKtPaIpNaX5YEYGHCXi6LlGzlitbrxP19pn3rQzWFz/UUpKWOyw04p/XkOUPTIUodRUd+wi0cxgPCTbScqHAYUPw5FfOwpZ7ut3Tr X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 10:45:24.9956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e76b153-6704-40b0-9347-08dcd8982b2c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5871 The assumption stated in the comment that the code will never get there is incorrect. It's enough for the target-path to be incorrect (i.e. user error), which will lead to an incorrect overall node path and we will end up in this "unreachable" place causing a failure in debug builds. Fixes: 0c0facdab6f5 ("xen/arm: Implement device tree node addition functionalities") Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- xen/common/dt-overlay.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index 8606b14d1e8e..d18bd12bd38d 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -596,11 +596,7 @@ static long add_nodes(struct overlay_track *tr, char **nodes_full_path) overlay_node = dt_find_node_by_path_from(tr->dt_host_new, nodes_full_path[j]); if ( overlay_node == NULL ) - { - /* Sanity check. But code will never come here. */ - ASSERT_UNREACHABLE(); return -EFAULT; - } /* * Find previous and next node to overlay_node in dt_host_new. We will From patchwork Thu Sep 19 10:42:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13807632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45D4ACE8D7B for ; Thu, 19 Sep 2024 10:45:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.800601.1210569 (Exim 4.92) (envelope-from ) id 1srEfI-0004pb-5Q; Thu, 19 Sep 2024 10:45:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 800601.1210569; Thu, 19 Sep 2024 10:45:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1srEfI-0004pO-1b; Thu, 19 Sep 2024 10:45:36 +0000 Received: by outflank-mailman (input) for mailman id 800601; Thu, 19 Sep 2024 10:45:34 +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 1srEfG-00043V-DB for xen-devel@lists.xenproject.org; Thu, 19 Sep 2024 10:45:34 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061f.outbound.protection.outlook.com [2a01:111:f403:2416::61f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4ab526a4-7674-11ef-99a2-01e77a169b0f; Thu, 19 Sep 2024 12:45:32 +0200 (CEST) Received: from MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) by PH7PR12MB9074.namprd12.prod.outlook.com (2603:10b6:510:2f4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Thu, 19 Sep 2024 10:45:28 +0000 Received: from SJ5PEPF000001EB.namprd05.prod.outlook.com (2603:10b6:303:88:cafe::9d) by MW4PR04CA0246.outlook.office365.com (2603:10b6:303:88::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.26 via Frontend Transport; Thu, 19 Sep 2024 10:45:27 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001EB.mail.protection.outlook.com (10.167.242.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 10:45:27 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:26 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 19 Sep 2024 05:45:25 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 19 Sep 2024 05:45:24 -0500 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: 4ab526a4-7674-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BV2TD623yCKhf50tyHuXh+Ue52zd95akzrxfhDBrd2MPvbNlTsSMxo9zvu9Sr4fIF61jhjk7Cx+Ha+EVztRrtvTMgGbaL7Ye6umyutJTLfBCDliXTNkgHMZ6R1t1hfd59cYMYpi2TpZsrWBbnx8EnQve4ib0YHxh8VIdGA11Aq1lEjR6kRouaiJq57u2QIt1O0IWdxAVOIIhrirHhRfxmD/LKb4FmbaIsNnx1FbQlaj2zet1FsHGiX3jZmIr5FEJl+jhMIRVNXwElCtXiqO2HTd4ET6K8WytLpo93FwZaZttpjzwfy2ZYxy/mVsPoSgtFv3llcZGCRiw4czYpWAWZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DQjI7cMFWl7vGE3FBptt0AMsIehS9gCRp7pEUcchVYw=; b=KKQear7I3QTcnyiSfDvOvF8XK3ZuymRap2kKeOQWfeE2X/SCmBP3u6v3/KvyAreaFwXNMKUxaHo/GVr3ytmmSRZxry8fCp12IavLXp8coLVl5MSw1fi7nyufhf9yPmyFZ+xLZvQm16JaycZvofSApVmJ0CardFOGFlBrklggOh0FIuHlRSsl599epqRqlKSOzufOE7wM3LJuUBFc+Z7co6xlnFPUb2M3a5TvIzYxPxxvooEIF5Q3amQd128H1Le5hf42haZsTBtrpVr1O/dR57mPEr53Y9/e/Rx85ZSHuf9kMgkwy4B6YIoOnspy9SEMnnwdts2UjKhQG2gUnWMi3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DQjI7cMFWl7vGE3FBptt0AMsIehS9gCRp7pEUcchVYw=; b=p2ZB0zD+sn9RfEekLS3CJksmPRRWmeJwl/+e9q61tapzTQsHq2lG1aHt2SyqH1s+L6zzHqvHBN1c+TUI0Il+ezH2ogz+SElGGInmGVzWkgfDMfftaaUaP+8k80/sMTwzv81HWWIEUuXFNtUidR9Y/93vDRzHTgj1mz2Iwj2GeAQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis Subject: [PATCH 4/4] dt-overlay: Support target-path being root node Date: Thu, 19 Sep 2024 12:42:38 +0200 Message-ID: <20240919104238.232704-5-michal.orzel@amd.com> X-Mailer: git-send-email 2.37.6 In-Reply-To: <20240919104238.232704-1-michal.orzel@amd.com> References: <20240919104238.232704-1-michal.orzel@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001EB:EE_|PH7PR12MB9074:EE_ X-MS-Office365-Filtering-Correlation-Id: 5da4be19-0aeb-4e4c-dfc9-08dcd8982c85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: Nxb9Sdg/7MFMrb8lNA7D+MyNwLrjnJFBERfKRlANtrBNU5p+aTQjKSjpTz9bzq/HBaZoCZdGTdC8KkJ/S1wKAwoM4H5Bc0rkwLcCa5uc9Lx8onTZNMD1QYCSNJtP0bGmvB92IwIugM9zlj/TuAYrJHC2fAyLSMc1m8ITe3L/iseAIMRZFzd1Wajhq1Y5bb1NKB/G7O+gbWt5un1Moztc2mn/dA2TfgGA94426Wsgc2YbBDeQrLzEHUhKF8vy9Pc3mdayCmQlruz5IT5bJzART1hDEPjTQSQwpteq/w9KHC1RvCRGlgd8jJiB5pvZ0M0JgyacXqHC/3BM1LbTReVIXujErxOI0KZCIJ2d3sgMmTySgKMawbeXZZ2DyZ1AMP1Pi3v49SfLRILQkO6yh/XVBvO+EGUPQ1jN0M/naw3665F2V+7RQmBQAH4wtRsmfjBco8awa7MXF9PS979zJn+FAvPQwb/U/AJ8nkENKJ8gU1dZV1do9WzcgoqX0L6y6n3h/aWgxo38QgTStYMG9oBfMc8s5y8QxDb4iwOA0okpykQfdZGeZegHyz7pMizpD3wIZmKXYMHtb+vP4odyBGJJddZZmUHbg1i2lZDz6yoazU+vrEcAP8z4M/mxAnLrYXkF9mkGrifEHU4YcL0U9yvHAyxf1CUCNyCf6u0Dx49aIV85B1eQDR3n0z4cfynKqj0ORcykqrktEoo3pz9eUqTDSMYogzBu+qboPVIqjkcKTKzxgvpjYJboOdFS8JfAzZZs01nBGjvY0eGgEfacgeSw+qK4ImVl/DZFkkGn0JYtm/hqnHQJf8ncsvIaSHUlbMv5L/mmkVj9FBaL5l+orW0n5sEqxF4it+mM67gc7WAVdHBe5uIO7wZBx4lL/i/LXtbF+IC1ZdHZz33aHK/ZO47CjdKcBML7yoplBME1Ytm7+5dLIGuoitfnjqR5qJIC3J8zdwi3/ST++M+XHiGCicUIM3tP59fJi+YpVyqmu9giIFUeNmzsvSyM6zwPwmllwaL/2a32tSgVw+sTMWTRlVsMcmR6Kt1wVz7GAL1C6WB9rTpxff8Y6VzqbutgO0KbQiEk46Zp2YLjmY7LStQ5Qiq6tPsqP2N0dpQNfZbc5Eep9lfJlBb4Do2eH1prPegTlkeCuBp9HNk+/iiCz5GMgHRgMa/Iu1MzTHLxaOXajT9lQaxVKbmiBsVz+HWJd8d820n0ttju3vIdzJPgXxp/Qp/h2tX+a9XuSppg85h9m4u7GeKU69iFUcTiWhm8HXKM6g/ab9HnYx4BGe4h0mH86u8HZCZ1BTxIgO5zGlwEATsZiG0488m73V9RORuQoy6dKv5D8pttYqnqUZfGUDPLovT7mykHW/qI31ONQEXjllB93WL6/uhx9qeGuXGEzJEEmsN32lWkrFt4exH87oBkAcqOmK8bYZCw3Aebdd9KR5J1AoGuGwTTnL0fAsIAAdzJxzuD X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 10:45:27.1804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5da4be19-0aeb-4e4c-dfc9-08dcd8982c85 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001EB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9074 Even though in most cases device nodes are not present directly under the root node, it's a perfectly valid configuration (e.g. Qemu virt machine dtb). At the moment, we don't handle this scenario which leads to unconditional addition of extra leading '/' in the node full path. This makes the attempt to add such device overlay to fail. Signed-off-by: Michal Orzel --- xen/common/dt-overlay.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c index d18bd12bd38d..63b28889de90 100644 --- a/xen/common/dt-overlay.c +++ b/xen/common/dt-overlay.c @@ -325,6 +325,7 @@ static int overlay_get_nodes_info(const void *fdto, char **nodes_full_path) int node_name_len; unsigned int target_path_len = strlen(target_path); unsigned int node_full_name_len; + unsigned int extra_len; node_name = fdt_get_name(fdto, subnode, &node_name_len); @@ -332,10 +333,13 @@ static int overlay_get_nodes_info(const void *fdto, char **nodes_full_path) return node_name_len; /* - * Magic number 2 is for adding '/' and '\0'. This is done to keep - * the node_full_path in the correct full node name format. + * Extra length is for adding '/' and '\0' unless the target path is + * root in which case we don't add the '/' at the beginning. This is + * done to keep the node_full_path in the correct full node name + * format. */ - node_full_name_len = target_path_len + node_name_len + 2; + extra_len = (target_path_len > 1) + 1; + node_full_name_len = target_path_len + node_name_len + extra_len; nodes_full_path[node_num] = xmalloc_bytes(node_full_name_len); @@ -344,9 +348,11 @@ static int overlay_get_nodes_info(const void *fdto, char **nodes_full_path) memcpy(nodes_full_path[node_num], target_path, target_path_len); - nodes_full_path[node_num][target_path_len] = '/'; + /* Target is not root - add separator */ + if ( target_path_len > 1 ) + nodes_full_path[node_num][target_path_len++] = '/'; - memcpy(nodes_full_path[node_num] + target_path_len + 1, + memcpy(nodes_full_path[node_num] + target_path_len, node_name, node_name_len); nodes_full_path[node_num][node_full_name_len - 1] = '\0';