From nobody Sun May 12 20:34:58 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; dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=1; a=rsa-sha256; t=1689064220; cv=none; d=zohomail.com; s=zohoarc; b=m2s/pthe1jjYhLljqMVRu8+RbQFtKoNkEoYRvA9R+xONbB5ojb9NxFtvMWC0LLhEFctJIyWDOF6SiT39PksN/39vLp8KqM7vSn8q34ZZHyF2X0niMu5PgTvsfT7Rsg0uXmbF8+YWmGMchKWjX1e/J6q1F2T774AnZhnPHBTMAW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689064220; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dk3lg1kmifrQv5WMidBKQfd64VXe9Ntgkfwp5vhYxrY=; b=Oa4L/h91eyRhHRwHek2LQEhIasL1b2QrwhNy0B4fvyqb1IecO0Fz5YoUzAUyOs0waZ8z2LAj/nzJyLYFQQJFCMcLmWx2UEQSryf5M+X9QAVHgiSV9o3qsoYybo1jGaDUoeqPHP4uqJRpmtkyvZROukQv3ctyVgtf1fU1ydkOdxM= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168906422056024.67084583341841; Tue, 11 Jul 2023 01:30:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.561603.878044 (Exim 4.92) (envelope-from ) id 1qJ8kk-0001gQ-P9; Tue, 11 Jul 2023 08:29:46 +0000 Received: by outflank-mailman (output) from mailman id 561603.878044; Tue, 11 Jul 2023 08:29:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qJ8kk-0001ff-Kz; Tue, 11 Jul 2023 08:29:46 +0000 Received: by outflank-mailman (input) for mailman id 561603; Tue, 11 Jul 2023 08:29:45 +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 1qJ8kj-0001cj-8H for xen-devel@lists.xenproject.org; Tue, 11 Jul 2023 08:29:45 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 159936a3-1fc5-11ee-8611-37d641c3527e; Tue, 11 Jul 2023 10:29:42 +0200 (CEST) Received: from BN9PR03CA0349.namprd03.prod.outlook.com (2603:10b6:408:f6::24) by MW3PR12MB4459.namprd12.prod.outlook.com (2603:10b6:303:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Tue, 11 Jul 2023 08:29:39 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::61) by BN9PR03CA0349.outlook.office365.com (2603:10b6:408:f6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32 via Frontend Transport; Tue, 11 Jul 2023 08:29:38 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Tue, 11 Jul 2023 08:29:38 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 11 Jul 2023 03:29:37 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Tue, 11 Jul 2023 01:29:37 -0700 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.23 via Frontend Transport; Tue, 11 Jul 2023 03:29:36 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 159936a3-1fc5-11ee-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JhNCSmuNj52GxjfeSx4MF9ZlobOGcqD+ZANrfmmnsStJjICkdhx46OFSnQ+f1Y+xhJmRbwmi8kon/ejOsp/Ws4Nt117+kzC72inXFDavjUaXuBTxS2DeF5nHqI06W5F/5pVbn63waNK+acZVEkR0iA/4xPfHn3vkbZTRjxkSMkQmwbP6ujgBjmz+AmKtM6OXJfgJlL0ccOhNmabwYcT6H3t5R5vlABbBmJZ3M+lycep3oGOPFQpYwKoLtPtYY21yB7G4blO7ANVZwXP9YtAPdEjZWXAf8iSRJ1Cyc0VazPpJg7ZlmrS6rs5c1cciUgfNWFG0wVBTjh6RGjlnILNf+w== 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=Dk3lg1kmifrQv5WMidBKQfd64VXe9Ntgkfwp5vhYxrY=; b=l8xePGT4laCgPZk5GHjg4HGin0pnz0wpx30VMUMPfShLvqLr6bXBay9951p3PiK/oaaSxPQMTDeCx9K+bFGDX723t35O5v8YsEjqQm5giw2HWdKIYAHhJHKP+3fgWGxPLBbYie/Jd5yxroWcD8sO8/a2R1aN+ngPqGO6Vr9O4tz081RYnlcvAyOStEhlX39ZZRMyW5+0zZAMrr1tcpeFr8iRusSGxqP8B9le/JdALeq4C3/OdiKY/Ly++nLKuH1nd9B6sI8Ba7SJu04sJMkQiLKgxp0bnLvSzlGae/zix0xbBzPaWVSEvuhEuKX+hNJ7KFlyaH1NGUJKdmLRxifAOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dk3lg1kmifrQv5WMidBKQfd64VXe9Ntgkfwp5vhYxrY=; b=QdrvXWhjednhsfhd2GVUjZYlpPNCY+Y3Xm7DBmk4yjbsjWtwx/eZGI/eW2E7yr8ikw4BsfqEpnpPeFyjJf77wttdhaCWN3dvfBsC/Jkcdqb0ERPR7/0OvAg5k5HlsiRpwlHe6mGs3QWvUA8QkLEmE+LyVJeb8i9/w4KlyHCN0pI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 1/2] xen/arm: Fix domain_handle_dtb_bootmodule() error path Date: Tue, 11 Jul 2023 10:29:30 +0200 Message-ID: <20230711082931.5402-2-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230711082931.5402-1-michal.orzel@amd.com> References: <20230711082931.5402-1-michal.orzel@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT058:EE_|MW3PR12MB4459:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e52833c-9f40-459f-fc3f-08db81e8f71e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RfwkPY8KkBo/zyKRfFJJDTXT7PQUwAiwRgHIIyTFecYcmUWyBGTtvbm4OMglbfyojSD4h0AZLEdi+lBjx+U6FytmLbXvIHFBpVYSmQ1DkZK8b2IOgp8kRJNpkzCiz85TS4zft68d5PN6X7dyJU3O3Vys4nZsJGLNJl2GQ+5Aq9YFl8m3Oe6JtLQVlKsA/ypkUM575+V2+izep9836Xsh4gkB3rhAKA/URkKldoIv3O0KOCC10o/UnFLhoNccRnqWEMdQwOnsY6U+VtkInyFr26GJShOX4+tj+bNAR3MQChs2PQDevJwM89urhONw6scMJjODumV3ZAksV2hGgM0V9t9RnJXK9UQLgE6MIrdkybY/0i0BYL7WeUugWA1dJm7anTBd9aq2gObAbWSVTYJErhvw4FaWAvWF0VIRURfxZBfCtoGrPneCZc8SRRLfviQinWjvaOV6X5AdBcLTut7BjpgMT9KVFlMahjWk6DaBn/xeO41BadJXkvyGQRH8A5tAk0XRBs/rVjrG3kmWTd6CJdv9EgWpAZKYpWpmjLUCBbBkqGpom8xBME5mXgkCR0vFsw5rmk2RvD2nkw6lYX9535V9OJEr+To0Z3gqj1USvrzCptCMpmO1eVU91oG1aTVp4z2FY03duuvMROTHmV2jMhuotmGLeup+BoGXg9uZ1iudJUXsM7SNcfnNBRvgQah5jlGQpRQWSN97bEhcYiFy1wEl7MxA48lTywQlB+VIfg1Mm2MiDsJLinL11GGyR7Jd4YbwezhzuPfPOBYL470+8g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(186003)(336012)(1076003)(44832011)(8936002)(8676002)(26005)(5660300002)(40460700003)(41300700001)(86362001)(54906003)(2616005)(40480700001)(81166007)(316002)(426003)(2906002)(82740400003)(6916009)(356005)(4326008)(83380400001)(6666004)(47076005)(70586007)(70206006)(36756003)(36860700001)(478600001)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 08:29:38.0987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e52833c-9f40-459f-fc3f-08db81e8f71e 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: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4459 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1689064221347100002 Content-Type: text/plain; charset="utf-8" Fix the error path in domain_handle_dtb_bootmodule(), so that the memory previously mapped is unmapped before returning the error code. This is because the function shall not make assumptions on the way of handling its error code in the callers. Today we call panic in case of domU creation failure, so having memory not unmapped is not a bug, but it can change. Similarly, fix prepare_dtb_domU() so that the memory allocated is freed before returning the error code from domain_handle_dtb_bootmodule(). Signed-off-by: Michal Orzel Acked-by: Julien Grall Reviewed-by: Luca Fancellu --- xen/arch/arm/domain_build.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d0d6be922db1..f2134f24b971 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3204,7 +3204,7 @@ static int __init domain_handle_dtb_bootmodule(struct= domain *d, =20 res =3D check_partial_fdt(pfdt, kinfo->dtb_bootmodule->size); if ( res < 0 ) - return res; + goto out; =20 for ( node_next =3D fdt_first_subnode(pfdt, 0);=20 node_next > 0; @@ -3235,7 +3235,7 @@ static int __init domain_handle_dtb_bootmodule(struct= domain *d, DT_ROOT_NODE_SIZE_CELLS_DEFAULT, false); if ( res ) - return res; + goto out; continue; } if ( dt_node_cmp(name, "passthrough") =3D=3D 0 ) @@ -3245,11 +3245,12 @@ static int __init domain_handle_dtb_bootmodule(stru= ct domain *d, DT_ROOT_NODE_SIZE_CELLS_DEFAULT, true); if ( res ) - return res; + goto out; continue; } } =20 + out: iounmap(pfdt); =20 return res; @@ -3326,7 +3327,7 @@ static int __init prepare_dtb_domU(struct domain *d, = struct kernel_info *kinfo) { ret =3D domain_handle_dtb_bootmodule(d, kinfo); if ( ret ) - return ret; + goto err; } =20 ret =3D make_gic_domU_node(kinfo); --=20 2.25.1 From nobody Sun May 12 20:34:58 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; dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=1; a=rsa-sha256; t=1689064223; cv=none; d=zohomail.com; s=zohoarc; b=M589j60pIQMSId19GrpYnh9v1m30e7WBn0iu6YbXjEEZxm6GTamharZcUHP7GfN1r9ylsZ6tQubu8LCrOrFMo5CWEvkj428PazqSOnxCxiJDxt8LYdvF+IXtYqMIOi5zofvjzYAGyHE58aMcNKUFHiJgnqlnowRP9VEdZKggUwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689064223; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RFJtVBokWQOgsGyRuqtzu1MVYHpDtHoyB0Kjiu13Ozg=; b=JAQM1ryA6mqWpGZqFKnacL6E91Pd8rwaQhBNmMdHK4IkyGuiMiyPb0nviaAabB/ULaC3G+MSvVYHCPrSzBL8SEgWE04J662wYaD6zudOwDIlbF0ObzEmbJCRUslb10qfnauhJT5A5KobWWqkQNWhhPBYMRE/9jYaJDGDMjVC78k= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689064223080206.4017328267645; Tue, 11 Jul 2023 01:30:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.561604.878060 (Exim 4.92) (envelope-from ) id 1qJ8kx-0002DJ-1r; Tue, 11 Jul 2023 08:29:59 +0000 Received: by outflank-mailman (output) from mailman id 561604.878060; Tue, 11 Jul 2023 08:29: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 1qJ8kw-0002D6-T7; Tue, 11 Jul 2023 08:29:58 +0000 Received: by outflank-mailman (input) for mailman id 561604; Tue, 11 Jul 2023 08:29:56 +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 1qJ8ku-0001cj-Rh for xen-devel@lists.xenproject.org; Tue, 11 Jul 2023 08:29:56 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060a.outbound.protection.outlook.com [2a01:111:f400:fe5b::60a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1c64cfa5-1fc5-11ee-8611-37d641c3527e; Tue, 11 Jul 2023 10:29:55 +0200 (CEST) Received: from MW4PR03CA0125.namprd03.prod.outlook.com (2603:10b6:303:8c::10) by PH7PR12MB7870.namprd12.prod.outlook.com (2603:10b6:510:27b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Tue, 11 Jul 2023 08:29:50 +0000 Received: from CO1NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::89) by MW4PR03CA0125.outlook.office365.com (2603:10b6:303:8c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 08:29:50 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT063.mail.protection.outlook.com (10.13.175.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.18 via Frontend Transport; Tue, 11 Jul 2023 08:29:49 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 11 Jul 2023 03:29:46 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Tue, 11 Jul 2023 01:29:39 -0700 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.23 via Frontend Transport; Tue, 11 Jul 2023 03:29:37 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1c64cfa5-1fc5-11ee-8611-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m7ZQwkn5k2R8LG32eKvVujZx/LGb923XsnbaztCxw8t7AwbkprxLwx6YfGtJXTBv4dcflHq/iVmYHD82EdExKZp6QFqgYRlPBElfnuzmKHldRWFWtXhrjUo4u+U7s066Ai3v8c0eyRD0Dmhat+uBBD2EWDkloChOV9y7GX4TQBsft/vOOkCqjYvhno2aMQTRtlSk1sYXDi3KIaFFs5KRNIHQFizfRI5xu9R17nOqw5H48IhE+S0uFqtVzsf+GjWGjdUVzCnmrjj9lp1Pm25dUXD/mJoH2r8WFbrIqMMVrQdRYRvFcBfBhdM93G/lW0Ja34aEcHWYDNvScAvfKVx4Fw== 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=RFJtVBokWQOgsGyRuqtzu1MVYHpDtHoyB0Kjiu13Ozg=; b=H2aC1leHpsENWD3DMzmY2gldE0D8fCymfO/jnrpDaCGfszgUpwwzzgmuzEHQO0o7dRYuRjA9zti09zrJHLHe4EJSZkXaba4PTRwyBu9iFY8912BnRWJbhTnRpSVtBi95GXKgNMgtYLmDseeUpyBceCVeeE8p7F7xADyDr/yz+eK/zy3EbBisbm1IBQysemkCobWL9xNFBIhC0pmB8HnwjpSnP9kibM9ZpPnxKf1IUgh13HCPFokEw+X3kB4fKIDgsYVHL3YJ8yslQT6G/dBimdgcxrMQ9vZPzRI/fCJHLSJ/Vlx1dY7hRS0B0UX+Hv6bxeqtVztXYcWPP6Crj1JfOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RFJtVBokWQOgsGyRuqtzu1MVYHpDtHoyB0Kjiu13Ozg=; b=gaGBgKgq7IteaQFjm56EFQu9aDxWLyU96zL56+hbdkXj/Es6XifOlxvGKbhqpU1Y59fXUxrO/QqCPI12xWUFdqTjM62w4oUpo9lsXjjKjkHwwELes9uVXl8X1Bhon1sgkmKkncbTPue/AvGTPuluuJc1+0CAjWmlP0Ru+db6o4g= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 2/2] xen/arm: Account for domU dtb bootmodule size separately Date: Tue, 11 Jul 2023 10:29:31 +0200 Message-ID: <20230711082931.5402-3-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230711082931.5402-1-michal.orzel@amd.com> References: <20230711082931.5402-1-michal.orzel@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT063:EE_|PH7PR12MB7870:EE_ X-MS-Office365-Filtering-Correlation-Id: b4d2e356-099a-468b-e17f-08db81e8fde3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 32N8AXTmIXJCkHIn7MtqV/g/Pn+cFwEFd8wL01It2PleCqijOx2jAwGUXN9fDWPO6lrJP513NRlk+pWYoNEPsP3aHhFWDiGNWs75QC3CqR0Vgy77fLJYasu/wwspVWw9Wa7Mxi9lZfGVZgpbJkqEgPmBmfoNcMJOkE9+63Sk4APULuiZw9r2dvbbdOHatXtHp0Pj1oglsn+Lt6e+5c67hQ8/cNSBXi5JdyAgtjXbyrEa7pDIcIILLvMFnrJZV4Kpg8VGesm+dA/j2lVLZX+YHXyMnUcEQiDMLsDcN7ZfG9SgPvHh7lFescsqXYJwcXex3HjCWbqhiAeTIwxwPblWrCxDeDurUIT/4tUrd6ahXhl2ymVwlttUCOUcIFmKLXpoXU3cPcCH0HNK5Xvqg1QRNG/j8Q1OS7HfFvY7yQdCw24WdRZCA0IcQfFxAWTfVdW+npzQ+SFku70pZ1HmVHtkBSBT+hXc/Sn9GUdbmpZ01Ep0UepiR7aC+008G8tqSUj+Xsg1D3aXrGhJcoO+rqyNQtvk86dNlZmqZXFS3WktXrSLTlJPnsC6ctlo56kM7rqUHjDHRiKjZ4SNliosFjYVplNWuel08qOXO11T5x9qXRaTmBQht8UtGgvVU9S6ClqevPL3gdNvPyl+TDecgA97C36zwJeXjqNlgIz+CzFfvAqOH1IWiuQzfSvHzSR9+6i1mIc1TqPIhZGB297+xj1acRLO2Ja287AxuQ3EzJ02MBSLzHHErkMvHjJhnWeaHDGZbFs2eC+3v0vungBn3ar8yA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199021)(46966006)(40470700004)(36840700001)(70206006)(6916009)(70586007)(2616005)(356005)(81166007)(86362001)(316002)(26005)(54906003)(1076003)(40480700001)(186003)(36756003)(40460700003)(82310400005)(4326008)(82740400003)(15650500001)(47076005)(8676002)(2906002)(8936002)(6666004)(44832011)(5660300002)(36860700001)(83380400001)(426003)(336012)(478600001)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 08:29:49.3616 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d2e356-099a-468b-e17f-08db81e8fde3 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: CO1NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7870 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1689064224112100001 Content-Type: text/plain; charset="utf-8" At the moment, we limit the allocation size when creating a domU dtb to 4KB, which is not enough when using a passthrough dtb with several nodes. Improve the handling by accounting for a dtb bootmodule (if present) size separately, while keeping 4KB for the Xen generated nodes (still plenty of space for new nodes). Also, cap the allocation size to 2MB, which is the max dtb size allowed. Signed-off-by: Michal Orzel Acked-by: Julien Grall Reviewed-by: Luca Fancellu --- Note for the future: As discussed with Julien, really the best way would be to generate dtb dire= ctly in the guest memory, where no allocation would be necessary. This of course requires some rework. The solution in this patch is good enough for now and can be treated as an intermediated step to support dtb creation of various sizes. --- xen/arch/arm/domain_build.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index f2134f24b971..1dc0eca37bd6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3257,14 +3257,15 @@ static int __init domain_handle_dtb_bootmodule(stru= ct domain *d, } =20 /* - * The max size for DT is 2MB. However, the generated DT is small, 4KB - * are enough for now, but we might have to increase it in the future. + * The max size for DT is 2MB. However, the generated DT is small (not inc= luding + * domU passthrough DT nodes whose size we account separately), 4KB are en= ough + * for now, but we might have to increase it in the future. */ #define DOMU_DTB_SIZE 4096 static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *k= info) { int addrcells, sizecells; - int ret; + int ret, fdt_size =3D DOMU_DTB_SIZE; =20 kinfo->phandle_gic =3D GUEST_PHANDLE_GIC; kinfo->gnttab_start =3D GUEST_GNTTAB_BASE; @@ -3273,11 +3274,18 @@ static int __init prepare_dtb_domU(struct domain *d= , struct kernel_info *kinfo) addrcells =3D GUEST_ROOT_ADDRESS_CELLS; sizecells =3D GUEST_ROOT_SIZE_CELLS; =20 - kinfo->fdt =3D xmalloc_bytes(DOMU_DTB_SIZE); + /* Account for domU passthrough DT size */ + if ( kinfo->dtb_bootmodule ) + fdt_size +=3D kinfo->dtb_bootmodule->size; + + /* Cap to max DT size if needed */ + fdt_size =3D min(fdt_size, SZ_2M); + + kinfo->fdt =3D xmalloc_bytes(fdt_size); if ( kinfo->fdt =3D=3D NULL ) return -ENOMEM; =20 - ret =3D fdt_create(kinfo->fdt, DOMU_DTB_SIZE); + ret =3D fdt_create(kinfo->fdt, fdt_size); if ( ret < 0 ) goto err; =20 --=20 2.25.1