From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367476; cv=pass; d=zohomail.com; s=zohoarc; b=W1gX+ebFTK37PvffZs7Jvlc2W1Qcq5H/rn2kl3Gur+L97HVn2XQ0Iio2vITlo/FFgZ9pKOv+JX2LlFhIOkEfEigJUfuHyFRxtBjxCDJ1oFBXSa9XKuiNBq8lLvAjLv6ojSUXkm/K9ooQ0/6tFSOOh1YXR42GyPUOTpycMVlXhjQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367476; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XEw/BQc9OhWtZdx4wzaPbYZYqlYnRfTqRtQ1Jr6B9Zs=; b=eKt18dYyWMmoi0IXToSyt9Vc9MJE7yNL+tb0kYQAmH7lkqHvSpqdKsdnQr2MSr70kguqcw/NfY1i+zIO5Nv841ygjIT4kEC8048jOS7lVzxsbLuR3Qy96MVbYo5WmSQXmcBWEDWqQrMmhjmaKFgHl8sX6/Jb6ksdOheIvER/zzA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367476168358.03546543740106; Tue, 1 Jul 2025 03:57:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029520.1403296 (Exim 4.92) (envelope-from ) id 1uWYgG-0003Dv-1Q; Tue, 01 Jul 2025 10:57:40 +0000 Received: by outflank-mailman (output) from mailman id 1029520.1403296; Tue, 01 Jul 2025 10:57:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgF-0003Do-ST; Tue, 01 Jul 2025 10:57:39 +0000 Received: by outflank-mailman (input) for mailman id 1029520; Tue, 01 Jul 2025 10:57:38 +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 1uWYgE-0002hE-Q4 for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:38 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20615.outbound.protection.outlook.com [2a01:111:f403:200a::615]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2dc17935-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:29 +0200 (CEST) Received: from BN0PR04CA0004.namprd04.prod.outlook.com (2603:10b6:408:ee::9) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.17; Tue, 1 Jul 2025 10:57:25 +0000 Received: from BN2PEPF00004FC1.namprd04.prod.outlook.com (2603:10b6:408:ee:cafe::28) by BN0PR04CA0004.outlook.office365.com (2603:10b6:408:ee::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.31 via Frontend Transport; Tue, 1 Jul 2025 10:57:25 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FC1.mail.protection.outlook.com (10.167.243.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:24 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:20 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2dc17935-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nguq9h1Za+oFs4DRodl77nP0iKneLXfluCAcNOrg5R+hLy3p/q30PVF1LYd57GywStcb14Zb3nEwyv0OUUCzAeNajYliR/a+1LXjaEseqgE89D8i67ukB6JqTx3yC36PGCFFx16tICRUiGAd/cN+H0MIQPIAvxKACM8kcXjWOQrguwSBmjg0f8OkBtJ7s/XZ+KpCxxfWQn0qBXSfLmdY/wymIEwDgyei5EHuZyZ43HghbnLJ0vc4B7sucZtL7Vp9sRCskG7Qjsd0sFksz4tjx733pKqgJVYCkicPmLJdDoIkkhUlsiO0SUFERoQK+liZFpaFfyBHYABQd5hi4ITYuA== 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=XEw/BQc9OhWtZdx4wzaPbYZYqlYnRfTqRtQ1Jr6B9Zs=; b=J6xegk1HEwU5Q+hsjNsSxEaWWaElDPrZrvPRBzk5hJhe7LBRJVa5BmzmXapN9R42ZInvowSpOh0DtpPc85SshiAnQTF/Wem1buEYPIcbuT7GRgcUmUceu27jNBe6axq3XMC5+bUSHyPYDsjWSBWZJhnLO9AnJuC8C0ml5id6t44sGZq6QhA8hdC8MZ9bIsqcnj22h9Y260D0hL3GXQFDgdBywSb6T5rNnYqd8QS+eQRfiKB5Mh/kHL12o9ouUIVE2nIJYA8X/ej8aO+Hr2ueBJhnE8lypBRT66i0MDwl2nDQNAFo8OwuS1NYU5ZBp2Y/k92zOUG6lf3Wda1CwprCjw== 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=XEw/BQc9OhWtZdx4wzaPbYZYqlYnRfTqRtQ1Jr6B9Zs=; b=yBPKhMV1qGrDFkQU33wh9xbc4fj2ahqJaTOCydCkU3JqtI/cSgSFa3aXW30Aax2R+V8aKsg4Q+i50BiIb1kFMhpxSxVOJHLU4e8ZYmB9Ty+9SU2jb3VdLbB5Ewmjd7KLBVNmEh4YVmmrU15jo0X1H1AsW8lZNtDYXnobRTZBTwA= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Stefano Stabellini" , Julien Grall , "Bertrand Marquis" , Michal Orzel , "Daniel P. Smith" Subject: [PATCH v5 01/10] x86: Replace arch-specific boot_module with common one Date: Tue, 1 Jul 2025 12:56:55 +0200 Message-ID: <20250701105706.86133-2-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FC1:EE_|BY5PR12MB4145:EE_ X-MS-Office365-Filtering-Correlation-Id: 29e50b65-85e7-4ce0-cf56-08ddb88e0fcd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7Cewx6J3TsSuet0tF97xTE8/fIXxgA6slNveFtpIYo5ABhaYmmpycgx76fhh?= =?us-ascii?Q?acYQ5D3bM90sjG5QVWO80h72qZ4TrV+ayhtZ9NkEsDjZ/Gg9JBzyW0ENT9QZ?= =?us-ascii?Q?DNURKrlVWNbHChvL6XOZeKK2Wgxqooyd6FWjrCYFvxspSeQuiy8DR6yATkQQ?= =?us-ascii?Q?9mAf9s4AWhweOQL8dD2V/kroL7mj9+I9/g/ERFcSqNrqmky7T3O51CozdzR8?= =?us-ascii?Q?bN7X0rA5wWLZvz6CyaFs1bKj4RjeBNYzwnoxNM9OSkwNHP+/kZMR23/ofU9h?= =?us-ascii?Q?n6ZCCMzFkekvERPOQLTFI0Hp9J2mjeeQM3QarV5XUILw9TmSU5Tlx3Y3Ine6?= =?us-ascii?Q?2v9AIthP4Lt7kcCB54j+7PajQd+4zgU/PDduDVS+nK1xTjkxFtE/75QKX+Jy?= =?us-ascii?Q?r4crparMJbA3aOAgy0b5J4YNev4m8VgpajyZBITF6r/DBn63TbEq9EON0IeF?= =?us-ascii?Q?id+8Ac45YMYh/uQ+pTC634eQcJXdMoWPwyUUuxzHB2coet0xMNS3QKkVXaZS?= =?us-ascii?Q?aTLcEdWAH1t3hLefLGNpEtEX04vKM2HBN9y/1Ukx+wSXAL5SatDzGOI//0Xx?= =?us-ascii?Q?WJQiinGSIbM+ygkZWvIAmK7PgW8mAGLMu8uORfN6DgtqDqOdN/vGsg5yPZfb?= =?us-ascii?Q?dQSY2MjHku2aoF4fDeEqUXgxas9Wx1neyFaJULV5fd3Ut5fjDWHpeC178C57?= =?us-ascii?Q?ta1bj9VwWPcd0k0vXeRLbkMYeZNCL8FctBE0OrOV1o8RbmjC4cBu1mrfgKGn?= =?us-ascii?Q?R7wtrO75eu+ZIYyRxd2nkl/1wr5KVuV12CfXcEe9UhmPpDHE3/IVizEdu9mI?= =?us-ascii?Q?nKfjHiwb3taqPxMDUnv1bIJisFBb82tqU6v2egxQjP2cz0EpdfVDuJFRwVGZ?= =?us-ascii?Q?jRm6ku9KNL+ITbeOBP9lkwUAYKj3zBbZG8PZ5Fq+gwcmC+mHL0bVrV+7Z0Up?= =?us-ascii?Q?WqsfKuPXvhmbsmwvup+tklutc2uri9qj2CK87KsvP1EGKnWNPfWr7tnXcK0V?= =?us-ascii?Q?4NNdpK+eFzcy3jIKe/IAHotr3G2jzvwkWVCr1XH64MdUgAoeZ+U7MO4+CPC6?= =?us-ascii?Q?uBJhJrgbkAN6dq5aO/5oH6Grlq2FclAR3Ft6Y4lIavxypd50Ak63hJCSE/LO?= =?us-ascii?Q?c6KQzjnRaLVmRt2eVwL7jF4PWajzmZM/YSCP2XG3K/MNCHLHLPEl3kSFL1Op?= =?us-ascii?Q?od7rQjixnYQjKRVCjYFDDHAAjwHe4qcq2lo7wXrcUsYf51yDw2l+YskLQEP1?= =?us-ascii?Q?ZI0gFP8CgqX1bd6TZeOQ7hHj5SmM9WiyrQxFgULV18ahuAjsWu+oKaNXuY++?= =?us-ascii?Q?0GZUV8cr1edBcfXdIaqUkvVOXxrq/PRu1RBPHrJSkqvavn7VM6PRmlqmNQns?= =?us-ascii?Q?oBkUUmQlO5EogNkhzNbeea3xYLAvfUjax7LDRGIpttfvyN/AOZa7y6yx2Tnu?= =?us-ascii?Q?9ZVeKRx6fF1qgO4o9yWbj13e92iVkUy092XvnFBMjNMQRpSq50qSgi09zWGj?= =?us-ascii?Q?Nsmm/OzboLC79aOWjHSF5d/fEBve3FqHf0H2?= 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)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:24.6067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29e50b65-85e7-4ce0-cf56-08ddb88e0fcd 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: BN2PEPF00004FC1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367477631116600 Content-Type: text/plain; charset="utf-8" These types resemble each other very closely in layout and intent, and with "struct boot_module" already in common code it makes perfect sense to merge them. In order to do so, add an arch-specific area for x86-specific tidbits, and rename identical fields with conflicting names. No functional change intended. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/arch/x86/cpu/microcode/core.c | 7 ++-- xen/arch/x86/hvm/dom0_build.c | 6 ++-- xen/arch/x86/include/asm/bootfdt.h | 50 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 56 +++-------------------------- xen/arch/x86/pv/dom0_build.c | 4 +-- xen/arch/x86/setup.c | 43 +++++++++++----------- xen/include/xen/bootfdt.h | 8 +++++ xen/xsm/xsm_policy.c | 2 +- 8 files changed, 93 insertions(+), 83 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootfdt.h diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 34a94cd25b..816e9bfe40 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -764,8 +764,7 @@ static int __init early_microcode_load(struct boot_info= *bi) struct cpio_data cd; =20 /* Search anything unclaimed or likely to be a CPIO archive. */ - if ( bm->type !=3D BOOTMOD_UNKNOWN && - bm->type !=3D BOOTMOD_RAMDISK ) + if ( bm->kind !=3D BOOTMOD_UNKNOWN && bm->kind !=3D BOOTMOD_RA= MDISK ) continue; =20 size =3D bm->size; @@ -815,12 +814,12 @@ static int __init early_microcode_load(struct boot_in= fo *bi) return -ENODEV; } =20 - if ( bi->mods[idx].type !=3D BOOTMOD_UNKNOWN ) + if ( bi->mods[idx].kind !=3D BOOTMOD_UNKNOWN ) { printk(XENLOG_WARNING "Microcode: Chosen module %d already use= d\n", idx); return -ENODEV; } - bi->mods[idx].type =3D BOOTMOD_MICROCODE; + bi->mods[idx].kind =3D BOOTMOD_MICROCODE; =20 size =3D bi->mods[idx].size; data =3D bootstrap_map_bm(&bi->mods[idx]); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index a038e58c11..2bb8ef355c 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -650,7 +650,7 @@ static int __init pvh_load_kernel( struct boot_module *image =3D bd->kernel; struct boot_module *initrd =3D bd->module; void *image_base =3D bootstrap_map_bm(image); - void *image_start =3D image_base + image->headroom; + void *image_start =3D image_base + image->arch.headroom; unsigned long image_len =3D image->size; unsigned long initrd_len =3D initrd ? initrd->size : 0; size_t cmdline_len =3D bd->cmdline ? strlen(bd->cmdline) + 1 : 0; @@ -721,9 +721,9 @@ static int __init pvh_load_kernel( { size_t initrd_space =3D elf_round_up(&elf, initrd_len); =20 - if ( initrd->cmdline_pa ) + if ( initrd->arch.cmdline_pa ) { - initrd_cmdline =3D __va(initrd->cmdline_pa); + initrd_cmdline =3D __va(initrd->arch.cmdline_pa); if ( !*initrd_cmdline ) initrd_cmdline =3D NULL; } diff --git a/xen/arch/x86/include/asm/bootfdt.h b/xen/arch/x86/include/asm/= bootfdt.h new file mode 100644 index 0000000000..a4c4bf30b9 --- /dev/null +++ b/xen/arch/x86/include/asm/bootfdt.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef X86_BOOTFDT_H +#define X86_BOOTFDT_H + +#include + +struct arch_boot_module +{ + /* + * Module State Flags: + * relocated: indicates module has been relocated in memory. + * released: indicates module's pages have been freed. + */ + bool relocated:1; + bool released:1; + + /* + * A boot module may need decompressing by Xen. Headroom is an estima= te of + * the additional space required to decompress the module. + * + * Headroom is accounted for at the start of the module. Decompressin= g is + * done in-place with input=3Dstart, output=3Dstart-headroom, expectin= g the + * pointers to become equal (give or take some rounding) when decompre= ssion + * is complete. + * + * Memory layout at boot: + * + * start ----+ + * v + * |<-----headroom------>|<------size------->| + * +-------------------+ + * | Compressed Module | + * +---------------------+-------------------+ + * | Decompressed Module | + * +-----------------------------------------+ + */ + unsigned long headroom; + paddr_t cmdline_pa; +}; + +#endif /* X86_BOOTFDT_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 3afc214c17..d33b100e04 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,6 +8,7 @@ #ifndef X86_BOOTINFO_H #define X86_BOOTINFO_H =20 +#include #include #include #include @@ -19,55 +20,6 @@ /* Max number of boot domains that Xen can construct */ #define MAX_NR_BOOTDOMS 1 =20 -/* Boot module binary type / purpose */ -enum bootmod_type { - BOOTMOD_UNKNOWN, - BOOTMOD_XEN, - BOOTMOD_KERNEL, - BOOTMOD_RAMDISK, - BOOTMOD_MICROCODE, - BOOTMOD_XSM_POLICY, -}; - -struct boot_module { - enum bootmod_type type; - - /* - * Module State Flags: - * relocated: indicates module has been relocated in memory. - * released: indicates module's pages have been freed. - */ - bool relocated:1; - bool released:1; - - /* - * A boot module may need decompressing by Xen. Headroom is an estima= te of - * the additional space required to decompress the module. - * - * Headroom is accounted for at the start of the module. Decompressin= g is - * done in-place with input=3Dstart, output=3Dstart-headroom, expectin= g the - * pointers to become equal (give or take some rounding) when decompre= ssion - * is complete. - * - * Memory layout at boot: - * - * start ----+ - * v - * |<-----headroom------>|<------size------->| - * +-------------------+ - * | Compressed Module | - * +---------------------+-------------------+ - * | Decompressed Module | - * +-----------------------------------------+ - */ - unsigned long headroom; - - paddr_t cmdline_pa; - - paddr_t start; - size_t size; -}; - /* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. @@ -94,16 +46,16 @@ struct boot_info { * Failure - a value greater than MAX_NR_BOOTMODS */ static inline unsigned int __init next_boot_module_index( - const struct boot_info *bi, enum bootmod_type t, unsigned int start) + const struct boot_info *bi, boot_module_kind k, unsigned int start) { unsigned int i; =20 - if ( t =3D=3D BOOTMOD_XEN ) + if ( k =3D=3D BOOTMOD_XEN ) return bi->nr_modules; =20 for ( i =3D start; i < bi->nr_modules; i++ ) { - if ( bi->mods[i].type =3D=3D t ) + if ( bi->mods[i].kind =3D=3D k ) return i; } =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index e1b78d47c2..a4b5362357 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -422,7 +422,7 @@ static int __init dom0_construct(const struct boot_doma= in *bd) =20 image_base =3D bootstrap_map_bm(image); image_len =3D image->size; - image_start =3D image_base + image->headroom; + image_start =3D image_base + image->arch.headroom; =20 d->max_pages =3D ~0U; =20 @@ -659,7 +659,7 @@ static int __init dom0_construct(const struct boot_doma= in *bd) * pages. Tell the boot_module handling that we've freed it, s= o the * memory is left alone. */ - initrd->released =3D true; + initrd->arch.released =3D true; } =20 iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 24e4f5ac7f..7e70b46332 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -303,7 +303,7 @@ struct boot_info __initdata xen_boot_info =3D { * * The extra entry exists to be able to add the Xen image as a module. */ - .mods =3D { [0 ... MAX_NR_BOOTMODS] =3D { .type =3D BOOTMOD_UNKNOWN } = }, + .mods =3D { [0 ... MAX_NR_BOOTMODS] =3D { .kind =3D BOOTMOD_UNKNOWN } = }, }; =20 static struct boot_info *__init multiboot_fill_boot_info( @@ -338,7 +338,7 @@ static struct boot_info *__init multiboot_fill_boot_inf= o( */ for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) { - bi->mods[i].cmdline_pa =3D mods[i].string; + bi->mods[i].arch.cmdline_pa =3D mods[i].string; =20 if ( efi_enabled(EFI_LOADER) ) { @@ -361,7 +361,7 @@ static struct boot_info *__init multiboot_fill_boot_inf= o( } =20 /* Variable 'i' should be one entry past the last module. */ - bi->mods[i].type =3D BOOTMOD_XEN; + bi->mods[i].kind =3D BOOTMOD_XEN; =20 return bi; } @@ -388,11 +388,11 @@ unsigned long __init initial_images_nrpages(nodeid_t = node) =20 void __init release_boot_module(struct boot_module *bm) { - ASSERT(!bm->released); + ASSERT(!bm->arch.released); =20 init_domheap_pages(bm->start, bm->start + PAGE_ALIGN(bm->size)); =20 - bm->released =3D true; + bm->arch.released =3D true; } =20 void __init free_boot_modules(void) @@ -402,7 +402,7 @@ void __init free_boot_modules(void) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - if ( bi->mods[i].released ) + if ( bi->mods[i].arch.released ) continue; =20 release_boot_module(&bi->mods[i]); @@ -997,8 +997,8 @@ static size_t __init domain_cmdline_size(const struct b= oot_info *bi, { size_t s =3D 0; =20 - if ( bd->kernel->cmdline_pa ) - s +=3D strlen(__va(bd->kernel->cmdline_pa)); + if ( bd->kernel->arch.cmdline_pa ) + s +=3D strlen(__va(bd->kernel->arch.cmdline_pa)); =20 if ( bi->kextra ) s +=3D strlen(bi->kextra); @@ -1065,9 +1065,10 @@ static struct domain *__init create_dom0(struct boot= _info *bi) if ( !(cmdline =3D xzalloc_array(char, cmdline_size)) ) panic("Error allocating cmdline buffer for %pd\n", d); =20 - if ( bd->kernel->cmdline_pa ) + if ( bd->kernel->arch.cmdline_pa ) strlcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader), + cmdline_cook(__va(bd->kernel->arch.cmdline_pa), + bi->loader), cmdline_size); =20 if ( bi->kextra ) @@ -1089,7 +1090,7 @@ static struct domain *__init create_dom0(struct boot_= info *bi) strlcat(cmdline, " acpi=3D", cmdline_size); strlcat(cmdline, acpi_param, cmdline_size); } - bd->kernel->cmdline_pa =3D 0; + bd->kernel->arch.cmdline_pa =3D 0; bd->cmdline =3D cmdline; } =20 @@ -1302,7 +1303,7 @@ void asmlinkage __init noreturn __start_xen(void) } =20 /* Dom0 kernel is always first */ - bi->mods[0].type =3D BOOTMOD_KERNEL; + bi->mods[0].kind =3D BOOTMOD_KERNEL; bi->domains[0].kernel =3D &bi->mods[0]; =20 if ( pvh_boot ) @@ -1486,7 +1487,7 @@ void asmlinkage __init noreturn __start_xen(void) xen->size =3D __2M_rwdata_end - _stext; } =20 - bi->mods[0].headroom =3D + bi->mods[0].arch.headroom =3D bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); bootstrap_unmap(); =20 @@ -1568,9 +1569,9 @@ void asmlinkage __init noreturn __start_xen(void) for ( j =3D bi->nr_modules - 1; j >=3D 0; j-- ) { struct boot_module *bm =3D &bi->mods[j]; - unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->size); + unsigned long size =3D PAGE_ALIGN(bm->arch.headroom + bm->size= ); =20 - if ( bm->relocated ) + if ( bm->arch.relocated ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ @@ -1580,12 +1581,12 @@ void asmlinkage __init noreturn __start_xen(void) if ( highmem_start && end > highmem_start ) continue; =20 - if ( s < end && (bm->headroom || (end - size) > bm->start) ) + if ( s < end && (bm->arch.headroom || (end - size) > bm->start= ) ) { - move_memory(end - size + bm->headroom, bm->start, bm->size= ); + move_memory(end - size + bm->arch.headroom, bm->start, bm-= >size); bm->start =3D (end - size); - bm->size +=3D bm->headroom; - bm->relocated =3D true; + bm->size +=3D bm->arch.headroom; + bm->arch.relocated =3D true; } } =20 @@ -1611,7 +1612,7 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - if ( bi->mods[0].headroom && !bi->mods[0].relocated ) + if ( bi->mods[0].arch.headroom && !bi->mods[0].arch.relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { @@ -2169,7 +2170,7 @@ void asmlinkage __init noreturn __start_xen(void) initrdidx =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); if ( initrdidx < MAX_NR_BOOTMODS ) { - bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; + bi->mods[initrdidx].kind =3D BOOTMOD_RAMDISK; bi->domains[0].module =3D &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) printk(XENLOG_WARNING diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index 236b456dd2..854e7f1ed9 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -7,6 +7,10 @@ #include #include =20 +#if __has_include() +#include +#endif + #define MIN_FDT_ALIGN 8 =20 #define NR_MEM_BANKS 256 @@ -108,6 +112,10 @@ struct boot_module { bool domU; paddr_t start; paddr_t size; + +#if __has_include() + struct arch_boot_module arch; +#endif }; =20 /* DT_MAX_NAME is the node name max length according the DT spec */ diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 1f88b4fc5a..1b4030edb4 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -53,7 +53,7 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - bm->type =3D BOOTMOD_XSM_POLICY; + bm->kind =3D BOOTMOD_XSM; break; =20 } --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367473; cv=pass; d=zohomail.com; s=zohoarc; b=XT2gOr63TUU/KrcHK8RUM4ve3aDkcJ9+bkF9gdnsNEllikSNRNIuxCWk8TstxBd1WgRVa261weNB/LKiVBONpapM6XQszQPt9Js7bPoUBCL2Xo72D6qMcaLIG5+cZS8Zf7il39aSx+w4YU4mOowRQU6agvg1f4tSQSPCMCPIdHg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367473; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ud/TQIZp2ue4dBTHWbX6XL/bQtyUjvSVs/0Ir1+e1is=; b=CKd0t8GW/J3xqWXGxtnvEmy4vx38VCP0KidgrhH1eYJ1BeW8nPEV7ypoPunLXkK5mprQQwAuLXRWbe3zYitJeVcEaMqIOIXHHd7I6BUK7siB/HaNKU++O0CDT0o+zfIG1o1YjyliN4r/4Rdk9nzyXFGGide6TMoADvp20OwhHKk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367473158325.12536527764314; Tue, 1 Jul 2025 03:57:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029519.1403281 (Exim 4.92) (envelope-from ) id 1uWYgC-0002ld-Iz; Tue, 01 Jul 2025 10:57:36 +0000 Received: by outflank-mailman (output) from mailman id 1029519.1403281; Tue, 01 Jul 2025 10:57: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 1uWYgC-0002kS-C6; Tue, 01 Jul 2025 10:57:36 +0000 Received: by outflank-mailman (input) for mailman id 1029519; Tue, 01 Jul 2025 10:57: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 1uWYgA-0002T2-D8 for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:34 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20613.outbound.protection.outlook.com [2a01:111:f403:2415::613]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2f82f69c-566a-11f0-b894-0df219b8e170; Tue, 01 Jul 2025 12:57:32 +0200 (CEST) Received: from BN9PR03CA0374.namprd03.prod.outlook.com (2603:10b6:408:f7::19) by LV3PR12MB9215.namprd12.prod.outlook.com (2603:10b6:408:1a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.19; Tue, 1 Jul 2025 10:57:26 +0000 Received: from BN2PEPF00004FBD.namprd04.prod.outlook.com (2603:10b6:408:f7:cafe::c6) by BN9PR03CA0374.outlook.office365.com (2603:10b6:408:f7::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.31 via Frontend Transport; Tue, 1 Jul 2025 10:57:26 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBD.mail.protection.outlook.com (10.167.243.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:26 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:23 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2f82f69c-566a-11f0-b894-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yo527uizXYVrY9ACXAt4/iazPsH8Jj0iErfHKSYtvhTaBAV3Y+ba8OQm6lViEVB/jpK3ivjLf7+OTdNCQQ0vWLaMxYWBVmpq7oqhxbcjpctEwihnVg0JutvKVyJ/ZDdbyQgMGFAh/QJzDTsrlcMTQ5FoEvpIDlCIWeNiI7TtLZltFuWZtkojx21BZov5D97dCaTibSFFQSBT9W15HpkCByWZjkuMbhIhMCXAUYJ7is1WYJ0x4SE46yZUTr13EIUo+1Sk3T76/o2vuXjZ90C+NKtCLOkNbQ3xY4xd6iEm/eofbXINN8XDeFqfLh6Vrxg7FZQjcdc2wQhx29CLjvhiiw== 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=ud/TQIZp2ue4dBTHWbX6XL/bQtyUjvSVs/0Ir1+e1is=; b=BK9+pCTpX/c7TXY02fIrULs+XtoF34huAP4GUbKXyTlp1Ni7uY3jzYepypKvM2MnnHHHqN5dcCvoAFlsY1b6l0e1DIcHwA0vlHyhMynQrswaj/vdUJ3qLoTmRXMdE8K7vmStRxWa1B5F09yIsMYSwtzQ6QFfEPPiyaYq/vGZ3hj3GOGDm8NfetWi9FaWwlXHhl9BkHyarTnzO6D0Z1nHklbC1DquWJSwcpGbOntxtcSnOZn1FhRSp7ijwQ0fzdfkVDRWEDiNKS2QTm40sk/p2up46dsX4W/RVQ4E4FZVcRXQ/T1HLreNiPkQ9tNOvId9pYFm/T7Q3r2IVdxTAoD1IQ== 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=ud/TQIZp2ue4dBTHWbX6XL/bQtyUjvSVs/0Ir1+e1is=; b=35J6dani8vXacvBWlYkJte4qMUZoeKSYfTv8/IlgJuPWA64eUzr/uk+331qh+k+v+i8x49Xz6uRbMyvP345yJRqg3q9pGu48vrWGfEBgxoDFnwaCi5NM+7SNIC9gT75Z2gwf45+jjg5mexZfuKBGtZrFedvhu6gaL3V9hhFhDb4= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , Anthony PERARD , "Jan Beulich" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 02/10] xen: Refactor kernel_info to have a header like boot_domain Date: Tue, 1 Jul 2025 12:56:56 +0200 Message-ID: <20250701105706.86133-3-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBD:EE_|LV3PR12MB9215:EE_ X-MS-Office365-Filtering-Correlation-Id: 006fc6dc-0ad7-4443-4049-08ddb88e10d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s/KS3nxBDL368VBFp2mhU7pppEC0O6JwXyj/GzWiwjth9XdBSYlDzzN129xA?= =?us-ascii?Q?a3QKs09UxX651xeyySeP2qv6ocpW7mbyT7Pj67B4IlkqHPGgEVYC8IUQaQFl?= =?us-ascii?Q?t+kFIAoQRyDeVMJ/1q7iGA7WzyRLc6KNYP/TMgjdJd3ffaV+MuuTT6Cs+MPk?= =?us-ascii?Q?XwfJw5Oks3q9bdEEtDYXZenge9v8LTMknMEqpgoLw+c4oafcX1qo/eqhowpI?= =?us-ascii?Q?RrTJz+vSoIc+rJwPXFqMwXf0/fb7BrS2I7mG8sp4B5Vx+WB+owAdwo28QGqG?= =?us-ascii?Q?8E5MLQAZxWyiX55c9cZhjmT+/drdfTRNizTdGvmu5JfMznRCvUPRcM5TgwaO?= =?us-ascii?Q?VzicnZagf4upHx4JQZRhk/PFGKes1M7oYpYWveFGNaJkr9ntc9q1he2pN+Nx?= =?us-ascii?Q?FvMa1z84PpcTW5e1CQvAAt1ggt9WCiYB5lhkhDlut31RPrFitAuH25LJDdhY?= =?us-ascii?Q?VyrdFwLcwhirKVai0RIUFgViFV1Ggtcq9Sx4+/ljZGlCN2NJGh1qoF9fMGgK?= =?us-ascii?Q?d0N0LopiLW72xuJB3QzgRPmB8R6kymR49AnFawHIfpecJkjEr6JjGgaFkAX/?= =?us-ascii?Q?QwE+3A4W5N8d1gBxT2j0+2aEQeDJaglG9rWSwYSKLo87LvKRTvADL2CXc6fe?= =?us-ascii?Q?nrBCCYMHpAtcf30ROa4h9lLK6tmdQ8epG/uWPpNb+MpDwZ2miS2M3fvXjiDu?= =?us-ascii?Q?v7fEmRxM7r5gqeM+P94sHQiROYo729TSQTDjs60nUx6Mv+6xBon9gKHOph/4?= =?us-ascii?Q?GrrIXjzUL3hROyZSVqAQR9RBFFZFE/v70TTrActl2Gi1cXUDG68BklX9K4Q0?= =?us-ascii?Q?596CSmOZ1psWUebPsr13M1KHEozI36CfgiNTeH/Tu2WrYDEaOtsFImLijtTo?= =?us-ascii?Q?X3l8iGxpT869roFVXHwtLg2ZOIym/8k4xyZeo2IDiT8HrH/T0bfXVHH2/jei?= =?us-ascii?Q?yoShHVOBEJtkNPeNspiths6PP6ksYp+6X2fQWkKyZcRQe0THT3RA4kBL6EJ+?= =?us-ascii?Q?V7zpFMFfgDaeAi7HI00y0AP8aPAD2HnWnx1e4TyJQIUWzFDWMlto3uWHCe95?= =?us-ascii?Q?Mh/fnv2Vj4FOcqgnGDfpSksWOkDj/3XirrU61eJj3xdb4e9jpL/YQC1mUpUu?= =?us-ascii?Q?gqkPOYflPkDDgze+gazYpJmVanoho0yuJTtpILJ0iYG7SqS2C3wmHV/cnX+T?= =?us-ascii?Q?/xc7PXTjVTph4TLtpJVaxns1eCs9+WwwffoE3kOR2wXJq+/omK1b4cRGCf36?= =?us-ascii?Q?57cHfIXzmMPUJbi/DkbTjwHM4cOm84u72FBz7r4C06b4GvolANcn9n66z13x?= =?us-ascii?Q?/t450jvLq1agVx8Tx0WuGiZaVZKtBZvzfS1V7VzqdDd2SDh+Q+7YkWFumgu5?= =?us-ascii?Q?DP+Qflzss2kVieewNagAiFKXpYmL/cUosk8DGEs0wiNAhmTPOFQMCGRK/ogW?= =?us-ascii?Q?5YMN6woabGYlE0NvGqh6cBG0nWCC9Rsgsbp8d0wS//bEtwqD3OfLLmQn9VqQ?= =?us-ascii?Q?/3YVuwODac6jfyr39DzoUrahgfIA32OAkXl+?= 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)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:26.3200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 006fc6dc-0ad7-4443-4049-08ddb88e10d3 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: BN2PEPF00004FBD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9215 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367475684116600 Content-Type: text/plain; charset="utf-8" Create a struct header within kernel_info with the contents common to kernel_info and boot_domain, and define that header in common code. This en= ables x86 to use that header as-is and drop x86's boot_domain. Not a functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/arch/arm/dom0less-build.c | 8 ++++---- xen/arch/arm/domain_build.c | 20 ++++++++++---------- xen/arch/arm/kernel.c | 8 ++++---- xen/common/device-tree/dom0less-build.c | 18 +++++++++--------- xen/common/device-tree/domain-build.c | 20 ++++++++++---------- xen/common/device-tree/kernel.c | 20 ++++++++++---------- xen/include/xen/bootfdt.h | 10 ++++++++++ xen/include/xen/fdt-kernel.h | 5 ++--- 8 files changed, 59 insertions(+), 50 deletions(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 4b285cff5e..08e8424030 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -32,7 +32,7 @@ static int __init make_gicv2_domU_node(struct kernel_info= *kinfo) int res =3D 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; - const struct domain *d =3D kinfo->d; + const struct domain *d =3D kinfo->hdr.d; =20 res =3D domain_fdt_begin_node(fdt, "interrupt-controller", vgic_dist_base(&d->arch.vgic)); @@ -85,7 +85,7 @@ static int __init make_gicv3_domU_node(struct kernel_info= *kinfo) void *fdt =3D kinfo->fdt; int res =3D 0; __be32 *reg, *cells; - const struct domain *d =3D kinfo->d; + const struct domain *d =3D kinfo->hdr.d; unsigned int i, len =3D 0; =20 res =3D domain_fdt_begin_node(fdt, "interrupt-controller", @@ -152,7 +152,7 @@ static int __init make_gicv3_domU_node(struct kernel_in= fo *kinfo) =20 int __init make_intc_domU_node(struct kernel_info *kinfo) { - switch ( kinfo->d->arch.vgic.version ) + switch ( kinfo->hdr.d->arch.vgic.version ) { #ifdef CONFIG_GICV3 case GIC_V3: @@ -175,7 +175,7 @@ static int __init make_vpl011_uart_node(struct kernel_i= nfo *kinfo) gic_interrupt_t intr; __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; __be32 *cells; - struct domain *d =3D kinfo->d; + struct domain *d =3D kinfo->hdr.d; =20 res =3D domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_ad= dr); if ( res ) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3f5c7c2e5a..fb577f816f 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -464,8 +464,8 @@ static int __init write_properties(struct domain *d, st= ruct kernel_info *kinfo, int had_dom0_bootargs =3D 0; struct dt_device_node *iommu_node; =20 - if ( kinfo->cmdline && kinfo->cmdline[0] ) - bootargs =3D &kinfo->cmdline[0]; + if ( kinfo->hdr.cmdline && kinfo->hdr.cmdline[0] ) + bootargs =3D &kinfo->hdr.cmdline[0]; =20 /* * We always skip the IOMMU device when creating DT for hwdom if there= is @@ -579,7 +579,7 @@ static int __init write_properties(struct domain *d, st= ruct kernel_info *kinfo, =20 if ( dt_node_path_is_equal(node, "/chosen") ) { - const struct boot_module *initrd =3D kinfo->initrd; + const struct boot_module *initrd =3D kinfo->hdr.initrd; =20 if ( bootargs ) { @@ -1456,7 +1456,7 @@ int __init make_timer_node(const struct kernel_info *= kinfo) if ( res ) return res; =20 - if ( !is_64bit_domain(kinfo->d) ) + if ( !is_64bit_domain(kinfo->hdr.d) ) res =3D fdt_property_string(fdt, "compatible", "arm,armv7-timer"); else res =3D fdt_property_string(fdt, "compatible", "arm,armv8-timer"); @@ -1468,7 +1468,7 @@ int __init make_timer_node(const struct kernel_info *= kinfo) * It always exposes an active-low level-sensitive interrupt. */ =20 - if ( is_hardware_domain(kinfo->d) ) + if ( is_hardware_domain(kinfo->hdr.d) ) { irq[TIMER_PHYS_SECURE_PPI] =3D timer_get_irq(TIMER_PHYS_SECURE_PPI= ); irq[TIMER_PHYS_NONSECURE_PPI] =3D @@ -1517,7 +1517,7 @@ int __init make_chosen_node(const struct kernel_info = *kinfo) { int res; const char *bootargs =3D NULL; - const struct boot_module *initrd =3D kinfo->initrd; + const struct boot_module *initrd =3D kinfo->hdr.initrd; void *fdt =3D kinfo->fdt; =20 dt_dprintk("Create chosen node\n"); @@ -1525,9 +1525,9 @@ int __init make_chosen_node(const struct kernel_info = *kinfo) if ( res ) return res; =20 - if ( kinfo->cmdline && kinfo->cmdline[0] ) + if ( kinfo->hdr.cmdline && kinfo->hdr.cmdline[0] ) { - bootargs =3D &kinfo->cmdline[0]; + bootargs =3D &kinfo->hdr.cmdline[0]; res =3D fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) += 1); if ( res ) return res; @@ -1976,7 +1976,7 @@ static int __init construct_dom0(struct domain *d) d->max_pages =3D dom0_mem >> PAGE_SHIFT; =20 kinfo.unassigned_mem =3D dom0_mem; - kinfo.d =3D d; + kinfo.hdr.d =3D d; =20 rc =3D kernel_probe(&kinfo, NULL); if ( rc < 0 ) @@ -1988,7 +1988,7 @@ static int __init construct_dom0(struct domain *d) int __init construct_hwdom(struct kernel_info *kinfo, const struct dt_device_node *node) { - struct domain *d =3D kinfo->d; + struct domain *d =3D kinfo->hdr.d; int rc; =20 iommu_hwdom_init(d); diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index e734ec5c1e..10e5dcad5e 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -46,7 +46,7 @@ static void __init place_modules(struct kernel_info *info, paddr_t kernbase, paddr_t kernend) { /* Align DTB and initrd size to 2Mb. Linux only requires 4 byte alignm= ent */ - const struct boot_module *mod =3D info->initrd; + const struct boot_module *mod =3D info->hdr.initrd; const struct membanks *mem =3D kernel_info_get_mem(info); const paddr_t initrd_len =3D ROUNDUP(mod ? mod->size : 0, MB(2)); const paddr_t dtb_len =3D ROUNDUP(fdt_totalsize(info->fdt), MB(2)); @@ -152,12 +152,12 @@ static void __init kernel_zimage_load(struct kernel_i= nfo *info) =20 kernel =3D ioremap_wc(paddr, len); if ( !kernel ) - panic("Unable to map the %pd kernel\n", info->d); + panic("Unable to map the %pd kernel\n", info->hdr.d); =20 - rc =3D copy_to_guest_phys_flush_dcache(info->d, load_addr, + rc =3D copy_to_guest_phys_flush_dcache(info->hdr.d, load_addr, kernel, len); if ( rc !=3D 0 ) - panic("Unable to copy the kernel in the %pd memory\n", info->d); + panic("Unable to copy the kernel in the %pd memory\n", info->hdr.d= ); =20 iounmap(kernel); } diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 221b875a2f..e321747175 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -167,18 +167,18 @@ static int __init handle_passthrough_prop(struct kern= el_info *kinfo, return -EINVAL; } =20 - res =3D iomem_permit_access(kinfo->d, paddr_to_pfn(mstart), + res =3D iomem_permit_access(kinfo->hdr.d, paddr_to_pfn(mstart), paddr_to_pfn(PAGE_ALIGN(mstart + size - = 1))); if ( res ) { printk(XENLOG_ERR "Unable to permit to dom%d access to" " 0x%"PRIpaddr" - 0x%"PRIpaddr"\n", - kinfo->d->domain_id, + kinfo->hdr.d->domain_id, mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1); return res; } =20 - res =3D map_regions_p2mt(kinfo->d, + res =3D map_regions_p2mt(kinfo->hdr.d, gaddr_to_gfn(gstart), PFN_DOWN(size), maddr_to_mfn(mstart), @@ -217,7 +217,7 @@ static int __init handle_passthrough_prop(struct kernel= _info *kinfo, return -EINVAL; } =20 - res =3D map_device_irqs_to_domain(kinfo->d, node, true, NULL); + res =3D map_device_irqs_to_domain(kinfo->hdr.d, node, true, NULL); if ( res < 0 ) return res; =20 @@ -229,7 +229,7 @@ static int __init handle_passthrough_prop(struct kernel= _info *kinfo, if ( xen_force && !dt_device_is_protected(node) ) return 0; =20 - return iommu_assign_dt_device(kinfo->d, node); + return iommu_assign_dt_device(kinfo->hdr.d, node); } =20 static int __init handle_prop_pfdt(struct kernel_info *kinfo, @@ -296,14 +296,14 @@ static int __init handle_prop_pfdt(struct kernel_info= *kinfo, address_cells, size_cells); if ( res < 0 ) { - printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->d= ); + printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->h= dr.d); return res; } } else if ( (xen_path && !xen_reg) || (xen_reg && !xen_path && !xen_forc= e) ) { printk(XENLOG_ERR "xen,reg or xen,path missing for %pd\n", - kinfo->d); + kinfo->hdr.d); return -EINVAL; } =20 @@ -605,7 +605,7 @@ static int __init alloc_xenstore_page(struct domain *d) =20 static int __init alloc_xenstore_params(struct kernel_info *kinfo) { - struct domain *d =3D kinfo->d; + struct domain *d =3D kinfo->hdr.d; int rc =3D 0; =20 #ifdef CONFIG_HVM @@ -773,7 +773,7 @@ static int __init construct_domU(struct domain *d, =20 d->max_pages =3D ((paddr_t)mem * SZ_1K) >> PAGE_SHIFT; =20 - kinfo.d =3D d; + kinfo.hdr.d =3D d; =20 rc =3D kernel_probe(&kinfo, node); if ( rc < 0 ) diff --git a/xen/common/device-tree/domain-build.c b/xen/common/device-tree= /domain-build.c index cd01a8b4bc..51182d10ef 100644 --- a/xen/common/device-tree/domain-build.c +++ b/xen/common/device-tree/domain-build.c @@ -76,7 +76,7 @@ bool __init allocate_bank_memory(struct kernel_info *kinf= o, gfn_t sgfn, paddr_t tot_size) { struct membanks *mem =3D kernel_info_get_mem(kinfo); - struct domain *d =3D kinfo->d; + struct domain *d =3D kinfo->hdr.d; struct membank *bank; =20 /* @@ -170,7 +170,7 @@ int __init find_unallocated_memory(const struct kernel_= info *kinfo, unsigned int i, j; int res; =20 - ASSERT(domain_use_host_layout(kinfo->d)); + ASSERT(domain_use_host_layout(kinfo->hdr.d)); =20 unalloc_mem =3D rangeset_new(NULL, NULL, 0); if ( !unalloc_mem ) @@ -336,23 +336,23 @@ void __init dtb_load(struct kernel_info *kinfo, unsigned long left; =20 printk("Loading %pd DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n", - kinfo->d, kinfo->dtb_paddr, + kinfo->hdr.d, kinfo->dtb_paddr, kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt)); =20 - left =3D copy_to_guest(kinfo->d, kinfo->dtb_paddr, + left =3D copy_to_guest(kinfo->hdr.d, kinfo->dtb_paddr, kinfo->fdt, fdt_totalsize(kinfo->fdt)); =20 if ( left !=3D 0 ) panic("Unable to copy the DTB to %pd memory (left =3D %lu bytes)\n= ", - kinfo->d, left); + kinfo->hdr.d, left); xfree(kinfo->fdt); } =20 void __init initrd_load(struct kernel_info *kinfo, copy_to_guest_phys_cb copy_to_guest) { - const struct boot_module *mod =3D kinfo->initrd; + const struct boot_module *mod =3D kinfo->hdr.initrd; paddr_t load_addr =3D kinfo->initrd_paddr; paddr_t paddr, len; int node; @@ -368,7 +368,7 @@ void __init initrd_load(struct kernel_info *kinfo, len =3D mod->size; =20 printk("Loading %pd initrd from %"PRIpaddr" to 0x%"PRIpaddr"-0x%"PRIpa= ddr"\n", - kinfo->d, paddr, load_addr, load_addr + len); + kinfo->hdr.d, paddr, load_addr, load_addr + len); =20 /* Fix up linux,initrd-start and linux,initrd-end in /chosen */ node =3D fdt_path_offset(kinfo->fdt, "/chosen"); @@ -391,12 +391,12 @@ void __init initrd_load(struct kernel_info *kinfo, =20 initrd =3D ioremap_wc(paddr, len); if ( !initrd ) - panic("Unable to map the %pd initrd\n", kinfo->d); + panic("Unable to map the %pd initrd\n", kinfo->hdr.d); =20 - res =3D copy_to_guest(kinfo->d, load_addr, + res =3D copy_to_guest(kinfo->hdr.d, load_addr, initrd, len); if ( res !=3D 0 ) - panic("Unable to copy the initrd in the %pd memory\n", kinfo->d); + panic("Unable to copy the initrd in the %pd memory\n", kinfo->hdr.= d); =20 iounmap(initrd); } diff --git a/xen/common/device-tree/kernel.c b/xen/common/device-tree/kerne= l.c index e1b22dc1c7..7a00768e6b 100644 --- a/xen/common/device-tree/kernel.c +++ b/xen/common/device-tree/kernel.c @@ -136,16 +136,16 @@ int __init kernel_probe(struct kernel_info *info, /* domain is NULL only for the hardware domain */ if ( domain =3D=3D NULL ) { - ASSERT(is_hardware_domain(info->d)); + ASSERT(is_hardware_domain(info->hdr.d)); =20 mod =3D boot_module_find_by_kind(BOOTMOD_KERNEL); =20 - info->kernel =3D mod; - info->initrd =3D boot_module_find_by_kind(BOOTMOD_RAMDISK); + info->hdr.kernel =3D mod; + info->hdr.initrd =3D boot_module_find_by_kind(BOOTMOD_RAMDISK); =20 cmd =3D boot_cmdline_find_by_kind(BOOTMOD_KERNEL); if ( cmd ) - info->cmdline =3D &cmd->cmdline[0]; + info->hdr.cmdline =3D &cmd->cmdline[0]; } else { @@ -162,7 +162,7 @@ int __init kernel_probe(struct kernel_info *info, dt_get_range(&val, node, &kernel_addr, &size); mod =3D boot_module_find_by_addr_and_kind( BOOTMOD_KERNEL, kernel_addr); - info->kernel =3D mod; + info->hdr.kernel =3D mod; } else if ( dt_device_is_compatible(node, "multiboot,ramdisk") ) { @@ -171,7 +171,7 @@ int __init kernel_probe(struct kernel_info *info, =20 val =3D dt_get_property(node, "reg", &len); dt_get_range(&val, node, &initrd_addr, &size); - info->initrd =3D boot_module_find_by_addr_and_kind( + info->hdr.initrd =3D boot_module_find_by_addr_and_kind( BOOTMOD_RAMDISK, initrd_addr); } else if ( dt_device_is_compatible(node, "multiboot,device-tree= ") ) @@ -192,7 +192,7 @@ int __init kernel_probe(struct kernel_info *info, name =3D dt_node_name(domain); cmd =3D boot_cmdline_find_by_name(name); if ( cmd ) - info->cmdline =3D &cmd->cmdline[0]; + info->hdr.cmdline =3D &cmd->cmdline[0]; } if ( !mod || !mod->size ) { @@ -201,10 +201,10 @@ int __init kernel_probe(struct kernel_info *info, } =20 printk("Loading %pd kernel from boot module @ %"PRIpaddr"\n", - info->d, info->kernel->start); - if ( info->initrd ) + info->hdr.d, info->hdr.kernel->start); + if ( info->hdr.initrd ) printk("Loading ramdisk from boot module @ %"PRIpaddr"\n", - info->initrd->start); + info->hdr.initrd->start); =20 /* * uImage isn't really used nowadays thereby leave kernel_uimage_probe= () diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index 854e7f1ed9..be0abe30ef 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -100,6 +100,16 @@ struct shared_meminfo { struct shmem_membank_extra extra[NR_SHMEM_BANKS]; }; =20 + +struct boot_domain { + struct domain *d; + + struct boot_module *kernel; + struct boot_module *initrd; + + const char* cmdline; +}; + /* * The domU flag is set for kernels and ramdisks of "xen,domain" nodes. * The purpose of the domU flag is to avoid getting confused in diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index 12a0b42d17..fee8eac1db 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -16,7 +16,7 @@ #endif =20 struct kernel_info { - struct domain *d; + struct boot_domain hdr; =20 void *fdt; /* flat device tree */ paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */ @@ -34,8 +34,7 @@ struct kernel_info { paddr_t gnttab_size; =20 /* boot blob load addresses */ - const struct boot_module *kernel, *initrd, *dtb; - const char* cmdline; + const struct boot_module *dtb; paddr_t dtb_paddr; paddr_t initrd_paddr; =20 --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367468; cv=pass; d=zohomail.com; s=zohoarc; b=Tmxe4XgcX+8PKfn/P0Xps/TYFQ9bWzAD8AXhNo5Y1IHzq0ATzK0qjef9mYOGoTXwBWSQFemn6OMdfhj1v5GcUmvBEy9ZMVKcJdRgsGaGxiAP+AcG2B84QDA0iIb/Xryv5eXilyWpApWureGXG8Cb6MPQlHzWRVorXhq1RnFsRNw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367468; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zhjfLrwIQPJ+iVWbDjZy0i0N31K4BCB4hKss8LyD06s=; b=FhfoC8+jlX8QNoQuYbDukuZRPXFtVm89/TMs0e98kONn/3diJz0FiQzM8SKBI/n1ox5tKE/3cvrzMw1iDbt3nyY48fO41RrQcvxeZUxXOs3aCbtNarY7VSTYN/kwms4Dj2tl2tdyaF59bBy9/druKQFAodCdua0I9rhpBqCMKLM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175136746872873.30508422391335; Tue, 1 Jul 2025 03:57:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029518.1403275 (Exim 4.92) (envelope-from ) id 1uWYgC-0002iL-8E; Tue, 01 Jul 2025 10:57:36 +0000 Received: by outflank-mailman (output) from mailman id 1029518.1403275; Tue, 01 Jul 2025 10:57: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 1uWYgC-0002iC-3n; Tue, 01 Jul 2025 10:57:36 +0000 Received: by outflank-mailman (input) for mailman id 1029518; Tue, 01 Jul 2025 10:57:34 +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 1uWYgA-0002hE-CG for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:34 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20625.outbound.protection.outlook.com [2a01:111:f403:2009::625]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 30362da4-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:33 +0200 (CEST) Received: from BN0PR04CA0010.namprd04.prod.outlook.com (2603:10b6:408:ee::15) by PH8PR12MB7229.namprd12.prod.outlook.com (2603:10b6:510:227::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.16; Tue, 1 Jul 2025 10:57:28 +0000 Received: from BN2PEPF00004FC1.namprd04.prod.outlook.com (2603:10b6:408:ee:cafe::e) by BN0PR04CA0010.outlook.office365.com (2603:10b6:408:ee::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.32 via Frontend Transport; Tue, 1 Jul 2025 10:57:28 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FC1.mail.protection.outlook.com (10.167.243.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:28 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:26 -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: 30362da4-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WHTFlUe3avZBkREl80wLyu3Ta2UuZ+R+N3WjOV3yRcEdSzh1wQAJuz+xwPCH7PGBb0zo38mtwf5uD6QL8wqwzC0PHgjckTUUn7YoJ3lXtNvwDlPMEzx7SlGjJOd011dc0eC7wK+lBUoilQMjka5qeCAHje+qA/LgcHhF8Lulp/ZYxwZUJfHGT7KhGPFarYbMeW4h/viI3eLZT8zytnjF9nT8vvDvzKCrB82sgWUt8zl9wxOEm/HadR1fL2dPt2xWsTTcZDS1dvkosKI4pRlY0TB+9ZZofvfZ6GJQekJCktJELgxIss6fV5IPyClm/9kGIzABlI5wDkaYAYOvGeoAUQ== 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=zhjfLrwIQPJ+iVWbDjZy0i0N31K4BCB4hKss8LyD06s=; b=KivAWMjbqFVgtGoS20x/uasPXb2zmVoBDZErtR9w+qL+KRtkLs2z93SaLolT26GkxvyU0bREAJCThpiAhspUUh3xeO0KvmL/t8mx1J63Tp24ugAua8UB2WKJNA3kozL8XGpWySbVqeOdGpQqubR4HXpRg1qODUxIgCjfedMjkI5XB7tWLgiWyM5Z1uT5FcA6kuDJPtO7tSTIoZQKVn8nNHeCjuOafy4LKRbdW6LZnmTZzGNovb9ZmXv0o+FgdpfmU4SGhAzMa9ajw9P4PiTwlrMJt4l83kGFDIHNqtWXl36bNFWtAvJ6Nf495Vk9ZJ3gYt9wPBiFhSgCPZEXjCn9Lg== 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=zhjfLrwIQPJ+iVWbDjZy0i0N31K4BCB4hKss8LyD06s=; b=EqpPaMz0uTwKz1Pxd2aKmCKwCtdQ6P8JC1jitx6SEgbr9mPgDjReTJVRxNIb3fRC/9dLkCteq8TTGaHKHh6q+DjcrttWKggehLnyfTGbrjTLIjjgnI4YpnhxAkLNFejLUYzSZDReCQE7CwmFZO+BBTrLWzMF29t9r23ekhxO60c= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , "Stefano Stabellini" , Julien Grall , "Bertrand Marquis" , Michal Orzel Subject: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one Date: Tue, 1 Jul 2025 12:56:57 +0200 Message-ID: <20250701105706.86133-4-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FC1:EE_|PH8PR12MB7229:EE_ X-MS-Office365-Filtering-Correlation-Id: 29eba615-4dbc-4451-c829-08ddb88e123a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CIO+l1RkJyxzAb4SbybULhSAAZKM9NCc1qruB2CZz0nfh8wq/G9rkxM28ACB?= =?us-ascii?Q?iMwd9g7q6c3k0Ai3R9gt2eSOyCxStDfkPBFRE+DVrpWE1TbxNKBxbq61T6ES?= =?us-ascii?Q?ML4PUMNO2owUclhFxg2wdYrGN0G0g6oq9U59ZYIRTJBNqb89YaelVha5oV3a?= =?us-ascii?Q?YMZzKq/JXPboJZK4zD/qh2l4Hyp7rJup7bfIhjjqKhKg3R42EXXyQREfbjQ/?= =?us-ascii?Q?0wCVJP3Ymp35u+dV/iluxC1mCqUsV+Q9i0jkQQYi20cWJl3u4I6u8xqYPPdH?= =?us-ascii?Q?59QKZx7yAQggAQXycAI/qPtUx2wUl2oTvoDClza3suRDIBcZ+AtnHb/806K4?= =?us-ascii?Q?0bHPdyCtXFSzn6T8o1g6n0Ogib9jNEiBuJpQAp8/u3fVAPwefRzof5i0G45o?= =?us-ascii?Q?asJHk9sp3wm15MtzKOYPzIEvV8Pp8HFVP477AyHtvMUcn0mGWLGNfRZS1QI5?= =?us-ascii?Q?xQ48d8wCvNaJcmKgZrPzvi2lffx9hJ0AFgHYRTiLgxdgZ5un6ok3E9CZ6jJ/?= =?us-ascii?Q?gMb6Vpwq4VfkkTzdteSLuWy0uo96lNbP7zyVPo45kFXkJ9875bzSnCZRZKwc?= =?us-ascii?Q?JfVTe/mWyd7rD686axAZyuIK1P4dQE0XNGWgo7b0D8w/Gyv+Wj7kkDOkrrXu?= =?us-ascii?Q?vKAKhU5OSblxN8vb67jsD5MrTOStBzHAC4yDIgjMAaIloQ+tWW/08Bml2sJR?= =?us-ascii?Q?h3Wl0538CGyf9+sxZzlOkHZBVxhBv8dyf8P1ey3efLAZq7XS0lPASWLny8Vy?= =?us-ascii?Q?COtNNSuzwKKNkF09G3qHCuvhrQKZY27ARQNKsAi6Ue0kRAQpEIx5Kk5KrGWR?= =?us-ascii?Q?JLUynZGCO4k3w6lZ2SchUSrVYXL0vzfjAtrnClOwin90fPisPAasK3AzloAZ?= =?us-ascii?Q?3hY2j31/0gnEURJ1Bpz5gVRmms1M0bz+flMZq+1Niu1vy5VxGbn7NTPTjfe0?= =?us-ascii?Q?35BiD/otO1WgvXKUOm/rfOLdjzeJDwN6ojllHtYhE4d0wZ6ASfFy0ZUxBxdd?= =?us-ascii?Q?wE/uBPdvXlgtIhuR6wdif1Oi6b8R2MTnA+UuVbJ/HpdeSUBXRFOTzjTgpyXD?= =?us-ascii?Q?V0FRpH9rogQ8xi5vBaO/DGQXj4L76GiZFNLI7rNC0ay3SgfK7ocLGY/4tPZg?= =?us-ascii?Q?oubYLPSl0ylmuSCzH3/dzdiDTntRQvIU3oFSlQ1fMKWxfSvVmD8pjFxPhate?= =?us-ascii?Q?+/q3Hhi8BgPWyovYNr34sXpKauR4uiZGoAKHWCTIbjGLa3fy1yWXPSXNgk0V?= =?us-ascii?Q?5E1JQw3OYB3VxhgK3itWYbQ4ozskJzXyXh6+iGOKA23bDTtdkbP3jBe5c6SN?= =?us-ascii?Q?dXxvu6f79YdwIe1f2dtAGg6Lqd04yk1lZo3A6jpfZW4ycYHPuh0az63mukAv?= =?us-ascii?Q?CAHz3F5MTqKxro7wDg17LOKx9M2dwTQF9+2mwkV8JsMEWlELGvXv0ze6j5WA?= =?us-ascii?Q?wYiBr1HeoZ7/aCmJYOEqFGvqIxT3cNxq4jkwJVFLqFK12PqNKHWivksdTNU2?= =?us-ascii?Q?LsBh2kCsd4SGSBGQc2m7Jbm+VD2LyTuMbp2A?= 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)(1800799024)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:28.6761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29eba615-4dbc-4451-c829-08ddb88e123a 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: BN2PEPF00004FC1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7229 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367469636116600 Content-Type: text/plain; charset="utf-8" Add the single arch-specific field in an "arch" subfield defined in asm/bootfdt.h. No functional change intended. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/dom0_build.c | 2 +- xen/arch/x86/include/asm/boot-domain.h | 33 -------------------------- xen/arch/x86/include/asm/bootfdt.h | 6 +++++ xen/arch/x86/include/asm/bootinfo.h | 1 - xen/arch/x86/pv/dom0_build.c | 2 +- xen/arch/x86/setup.c | 12 ++++++---- xen/include/xen/bootfdt.h | 4 ++++ 7 files changed, 19 insertions(+), 41 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.h diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 2bb8ef355c..8d2734f2b5 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -648,7 +648,7 @@ static int __init pvh_load_kernel( { struct domain *d =3D bd->d; struct boot_module *image =3D bd->kernel; - struct boot_module *initrd =3D bd->module; + struct boot_module *initrd =3D bd->initrd; void *image_base =3D bootstrap_map_bm(image); void *image_start =3D image_base + image->arch.headroom; unsigned long image_len =3D image->size; diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/= asm/boot-domain.h deleted file mode 100644 index d7c6042e25..0000000000 --- a/xen/arch/x86/include/asm/boot-domain.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (c) 2024 Apertus Solutions, LLC - * Author: Daniel P. Smith - * Copyright (c) 2024 Christopher Clark - */ - -#ifndef __XEN_X86_BOOTDOMAIN_H__ -#define __XEN_X86_BOOTDOMAIN_H__ - -#include - -struct boot_domain { - domid_t domid; - - struct boot_module *kernel; - struct boot_module *module; - const char *cmdline; - - struct domain *d; -}; - -#endif - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/arch/x86/include/asm/bootfdt.h b/xen/arch/x86/include/asm/= bootfdt.h index a4c4bf30b9..c21dbe961b 100644 --- a/xen/arch/x86/include/asm/bootfdt.h +++ b/xen/arch/x86/include/asm/bootfdt.h @@ -3,6 +3,12 @@ #define X86_BOOTFDT_H =20 #include +#include + +struct arch_boot_domain +{ + domid_t domid; +}; =20 struct arch_boot_module { diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index d33b100e04..4f2cc5906e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -12,7 +12,6 @@ #include #include #include -#include =20 /* Max number of boot modules a bootloader can provide in addition to Xen = */ #define MAX_NR_BOOTMODS 63 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index a4b5362357..c37bea9454 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -375,7 +375,7 @@ static int __init dom0_construct(const struct boot_doma= in *bd) struct vcpu *v =3D d->vcpu[0]; =20 struct boot_module *image =3D bd->kernel; - struct boot_module *initrd =3D bd->module; + struct boot_module *initrd =3D bd->initrd; void *image_base; unsigned long image_len; void *image_start; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 7e70b46332..5adb7af930 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -297,7 +297,9 @@ static const char *cmdline_cook(const char *p, const ch= ar *loader_name); struct boot_info __initdata xen_boot_info =3D { .loader =3D "unknown", .cmdline =3D "", - .domains =3D { [0 ... MAX_NR_BOOTDOMS - 1] =3D { .domid =3D DOMID_INVA= LID } }, + .domains =3D { [0 ... MAX_NR_BOOTDOMS - 1] =3D { + .arch.domid =3D DOMID_INVALID + }}, /* * There's a MAX_NR_BOOTMODS-th entry in the array. It's not off by on= e. * @@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain. Not d0 for pvshim. */ - bd->domid =3D get_initial_domain_id(); - d =3D domain_create(bd->domid, &dom0_cfg, + bd->arch.domid =3D get_initial_domain_id(); + d =3D domain_create(bd->arch.domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged | CDF_hardware); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->arch.domid, PTR_ERR(d)); =20 init_dom0_cpuid_policy(d); =20 @@ -2171,7 +2173,7 @@ void asmlinkage __init noreturn __start_xen(void) if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].kind =3D BOOTMOD_RAMDISK; - bi->domains[0].module =3D &bi->mods[initrdidx]; + bi->domains[0].initrd =3D &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index be0abe30ef..8ea52290b7 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -108,6 +108,10 @@ struct boot_domain { struct boot_module *initrd; =20 const char* cmdline; + +#if __has_include() + struct arch_boot_domain arch; +#endif }; =20 /* --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367482; cv=pass; d=zohomail.com; s=zohoarc; b=hArGfP9ABpnZF07P+WjiW3hGfqAVG0fWwchF1pq0inAHeIAOLXktcLLqsx7rdgWn8mcplnZOR1JxnGMgT6gxP/JcQwpgAtfGITB1yMZ/3ngxXRSMpbL1q8onFLAaXJY+qI+muiLmeIRvJ9/4aX6vkfx6Luytqbg9eApwF0kQbbI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367482; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ndMUqJ5v26UYy2Vo7yrxtc0yO6wxlNoKeS3pngBUHxs=; b=VgV+GlMgxu8TakTsHWzTTBrCa+e2M/LcpykXYo8J+0SVDTkIrBcPceG2IYWZPOU85UnZaaTB0vBph1Ttaqf02+jySZm4fFPJkhtzs7oKOxp0JttWH8mDU4NAsZSZT0J0uR2oYJR6e5W6JXJSQ8HpRBx5UBbbjxWKZ6vFDib02XU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367482307795.9890213658051; Tue, 1 Jul 2025 03:58:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029521.1403305 (Exim 4.92) (envelope-from ) id 1uWYgH-0003Tv-91; Tue, 01 Jul 2025 10:57:41 +0000 Received: by outflank-mailman (output) from mailman id 1029521.1403305; Tue, 01 Jul 2025 10:57:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgH-0003Ta-54; Tue, 01 Jul 2025 10:57:41 +0000 Received: by outflank-mailman (input) for mailman id 1029521; Tue, 01 Jul 2025 10:57:40 +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 1uWYgF-0002hE-QG for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:39 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20626.outbound.protection.outlook.com [2a01:111:f403:2407::626]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3326318d-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:38 +0200 (CEST) Received: from BLAPR05CA0027.namprd05.prod.outlook.com (2603:10b6:208:335::7) by MN2PR12MB4288.namprd12.prod.outlook.com (2603:10b6:208:1d2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.21; Tue, 1 Jul 2025 10:57:33 +0000 Received: from BN2PEPF00004FBE.namprd04.prod.outlook.com (2603:10b6:208:335:cafe::7a) by BLAPR05CA0027.outlook.office365.com (2603:10b6:208:335::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 10:57:33 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBE.mail.protection.outlook.com (10.167.243.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:32 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:28 -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: 3326318d-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sjkb3jcLfPVgz1bK1EZf2KDiKqUfkACMNhPPUdr8NR5K5PKAF3ia328iNAxhhzi6YtQRJ+GCSyh90NFfVSsHKaoAMJ4AMdn2pS3jQ5B+i+6f/cHp/WtRyUQmGE0pnpZkOy+dvmKqBJZXMib3lY+/9HdOduXNN5DD3lDVpxEBiwo2BZ1rVfdMiVNFO1Daz50AVuYFIrry1ty/sXV9ik90NQHmmLgfWVUah4H7WR5Cq5XxV0ppmr3Q+w7y6Hp9KA5WuB+KQN7nJ5ky/M/TlDhOFokZqqr79jXZA4WcdZPy/Fjcwl5mRAzf97irs8eC4ett2wYJ/605c9Nq3jXlvM5urw== 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=ndMUqJ5v26UYy2Vo7yrxtc0yO6wxlNoKeS3pngBUHxs=; b=Yr1+8KSlfFHCP3svtfm5TYEw83GZI5+YLd3dDry0VJvF4FBsnCOk6fWFl9ikSv204vYj/cdJglt1mmiD9JThYSSI3vsZ+AaxwZGWO/aARqCqNEZ7lQPjTWkYj97CDE515TBx6VRkTXgRqXCoIC3qGZaptcN3/pFuNycpvJedQNmtDHNaL5WlpTgKROn6/KcHuLinU7kn89uNvcROX+ehQnfz+0Hq07agoAKSczHwf8Vw2v7yVaNJ/nY1H2LvR9niH3Vxje8TpgqJFgpTtNg7bqKfpbK2oEif/dQw4nafj1IhppOG6j4+E0jmYpvjU1J/sH5xcJqFbvQpK/1cvf19ug== 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=ndMUqJ5v26UYy2Vo7yrxtc0yO6wxlNoKeS3pngBUHxs=; b=j37jwRqWTdqHrNjkfQBCg6G95dgGzsmBhugzoWIBiR3oAgG1++1ZZ2yLCEl9OisETFDQP1BrB6Bdt2Itp2jst+jOIiltDX9vYva5z7VvIgy6abuRlLABo3M0Zl754KARfiaeW2AjmR5CZdKnqrSIMTB2ITDvPk6i+j3ouWaRmb0= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Alistair Francis , Bob Eshleman , "Connor Davis" , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v5 04/10] xen/dt: Move bootfdt functions to xen/bootfdt.h Date: Tue, 1 Jul 2025 12:56:58 +0200 Message-ID: <20250701105706.86133-5-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBE:EE_|MN2PR12MB4288:EE_ X-MS-Office365-Filtering-Correlation-Id: 850acc4b-fd55-4b23-1e56-08ddb88e14b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5CPE7q3Na9YCT1zWE27G0OnHrnNqNE1rCQs2OQ1S8OwkqCfy85/JO9sbF1im?= =?us-ascii?Q?jxSIb+9zIlmmlbLJNByx62AXSXu2wi6Bum7CBmsUj4DK9OobmmxNudbhC3go?= =?us-ascii?Q?aFVVuARJXoyEpCys/IObdrAQET6ChAyUbSX48vHE753qoemiA73HIyzQxGWL?= =?us-ascii?Q?ehDloB5ppZabivQomPF8MBCoTMvH6lMPUXEE/sQA7ItjmsVfVQ5VyZOehdAZ?= =?us-ascii?Q?k7zNBX4u4kooqfMfl5+cN4WQyBMpjWoXl/dmLVBMsHjB/KcO5/2rEeRY2W3N?= =?us-ascii?Q?nK3y+9Fjre+Zbg4lAyhhBCpbADUCos7wQIU69SEU48ywHuFS2oDb84g2eZMe?= =?us-ascii?Q?RerQHK5u3P+4IJ+HxtekmqH/kjTAShFnEe9P421AP7dyh4dOAEJSrOmGG8zj?= =?us-ascii?Q?MHuhTX6zscPj1tYEfFihxSSL+K/DMZEzt90ParCAqV/rfM6h9Qp6gYvDT6Oy?= =?us-ascii?Q?X+MAFeyAhp9K+ZSCphU1x8fhxAHi7x70RRv4Kp+JnPK2mO6xkWzfaOIvsR8o?= =?us-ascii?Q?xVJpjteQoSl0sKaThZ+vWO74aDFxxhE6CPovNB6l1wt36F5VieodEM70hRcb?= =?us-ascii?Q?fwqXaeMxGgfIOVEoRNqGRdsJ6An67v/ydxkZaM2eW/L+VEuRdI/e1Q6g0ByS?= =?us-ascii?Q?v0DVuD4ENw46Pbz0SGMe09VOCUtMzxu3HC8+d5jUnHS2FMSp4mNdYFXcn951?= =?us-ascii?Q?XyG5ta4GW7kexPgOZr/eIIj+vEKGkMvRpU7MDnz/ZcSp6lLtM+S2D533I6xa?= =?us-ascii?Q?tuFw/+54qXGbyPVZiEPgqoIJpvFTlxVaDgPXmTJfVtjgiODODYtTf1i1l1CJ?= =?us-ascii?Q?ZphB+DHB5+hNYRZgxRArJui7F8F6s/c4yLvE1taU0askm3PO7+aRHOiVKQom?= =?us-ascii?Q?Nh2WHvcE4LPxoYsu3drLsNGA0LUENXHbQO7BzMWQlUKgfWneP2XXfZB2yqvp?= =?us-ascii?Q?wVCtGVeoDZsYqArnWV4zQXkYYw1XzR9sROKQ1JteyJMvpbF+HCJtJYgt5svv?= =?us-ascii?Q?+2q3jc0MrXRbhbHYbwJtwXenLYGqy2Y3ITgBQo6o/Fd8FQrhuB1LKBMXNl74?= =?us-ascii?Q?zaO3b6nFvVutzbcLic6irpY18MBl2IGpGxet7FqgWgTAwQIgYMwsqf930MU8?= =?us-ascii?Q?b7zroR7BtDpXcfXmDg8tK8ickL6n9zxWgc3aMLeCDN6HxQYzWQ9tT3q6DgTa?= =?us-ascii?Q?cibn1kk5iPY8C/wicfahiV71fBHm9jRc63dKRY1Pcn8ROpZQ4rj2TMwz62zY?= =?us-ascii?Q?tsO/riDMDxMn6k5/JcEiZLmHVApJPCGl3pKITIjpUx8JauA2hZu7Q3gNegqI?= =?us-ascii?Q?m2WaeGVwQpfQviJGSuDX1JAuRwATXvFkNiu/UILMvJlnkeTYH766r076REuj?= =?us-ascii?Q?mRUuzvGwaGsNvSmeBuKncGGuAkAltdp+sRWJRlCQK5lelX4ibNfh/nKkA9wM?= =?us-ascii?Q?+Avc46SdVNFnoilegWW3O6a1CSVQ7IBDtiiUVdJmqN1cXLRVT3A5Qp+xInxY?= =?us-ascii?Q?4gpVbP8/XRU8hx3DutMZaDjsZfWMk6CKdawr?= 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)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:32.8337 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 850acc4b-fd55-4b23-1e56-08ddb88e14b5 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: BN2PEPF00004FBE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4288 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367483734116600 Content-Type: text/plain; charset="utf-8" Part of an unpicking process to extract bootfdt contents independent of boo= tinfo to a separate file for x86 to take. Move functions required for early FDT parsing from device_tree.h and arm's setup.h onto bootfdt.h Declaration motion only. Not a functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/arch/riscv/cpufeature.c | 1 + xen/arch/riscv/smpboot.c | 1 + xen/common/device-tree/device-tree.c | 1 + xen/common/device-tree/static-evtchn.c | 1 + xen/common/sched/boot-cpupool.c | 1 + xen/include/xen/bootfdt.h | 91 ++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 78 ---------------------- 7 files changed, 96 insertions(+), 78 deletions(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index b7d5ec6580..b846a106a3 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -8,6 +8,7 @@ */ =20 #include +#include #include #include #include diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c index 470f6d1311..3b8bf98e20 100644 --- a/xen/arch/riscv/smpboot.c +++ b/xen/arch/riscv/smpboot.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/= device-tree.c index 886e6c7712..725ff71646 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -7,6 +7,7 @@ * benh@kernel.crashing.org */ =20 +#include #include #include #include diff --git a/xen/common/device-tree/static-evtchn.c b/xen/common/device-tre= e/static-evtchn.c index 8b82e6b3d8..88342b44a1 100644 --- a/xen/common/device-tree/static-evtchn.c +++ b/xen/common/device-tree/static-evtchn.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 +#include #include #include =20 diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupoo= l.c index 641f3495cb..03be73efdd 100644 --- a/xen/common/sched/boot-cpupool.c +++ b/xen/common/sched/boot-cpupool.c @@ -7,6 +7,7 @@ * Copyright (C) 2022 Arm Ltd. */ =20 +#include #include #include =20 diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index 8ea52290b7..0846317f30 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -2,8 +2,11 @@ #ifndef XEN_BOOTFDT_H #define XEN_BOOTFDT_H =20 +#include +#include #include #include +#include #include #include =20 @@ -16,8 +19,80 @@ #define NR_MEM_BANKS 256 #define NR_SHMEM_BANKS 32 =20 +/* Default #address and #size cells */ +#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 + #define MAX_MODULES 32 /* Current maximum useful modules */ =20 +#define DEVICE_TREE_MAX_DEPTH 16 + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 dt_read_number(const __be32 *cell, int size) +{ + u64 r =3D 0; + + while ( size-- ) + r =3D (r << 32) | be32_to_cpu(*(cell++)); + return r; +} + +/* Wrapper for dt_read_number() to return paddr_t (instead of uint64_t) */ +static inline paddr_t dt_read_paddr(const __be32 *cell, int size) +{ + uint64_t dt_r; + paddr_t r; + + /* + * dt_read_number will return uint64_t whereas paddr_t may not be 64-b= it. + * Thus, there is an implicit cast from uint64_t to paddr_t. + */ + dt_r =3D dt_read_number(cell, size); + + if ( dt_r !=3D (paddr_t)dt_r ) + { + printk("Physical address greater than max width supported\n"); + WARN(); + } + + /* + * Xen will truncate the address/size if it is greater than the maximum + * supported width and it will give an appropriate warning. + */ + r =3D dt_r; + + return r; +} + +static inline u64 dt_next_cell(int s, const __be32 **cellp) +{ + const __be32 *p =3D *cellp; + + *cellp =3D p + s; + return dt_read_number(p, s); +} + +typedef int (*device_tree_node_func)(const void *fdt, + int node, const char *name, int depth, + u32 address_cells, u32 size_cells, + void *data); + +/** + * device_tree_for_each_node - iterate over all device tree sub-nodes + * @fdt: flat device tree. + * @node: parent node to start the search from + * @func: function to call for each sub-node. + * @data: data to pass to @func. + * + * Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. + * + * Returns 0 if all nodes were iterated over successfully. If @func + * returns a value different from 0, that value is returned immediately. + */ +int device_tree_for_each_node(const void *fdt, int node, + device_tree_node_func func, + void *data); + typedef enum { BOOTMOD_XEN, BOOTMOD_FDT, @@ -260,4 +335,20 @@ static inline struct membanks *membanks_xzalloc(unsign= ed int nr, return banks; } =20 +/* + * Interpret the property `prop_name` of `node` as a u32. + * + * Returns the property value on success; otherwise returns `dflt`. + */ +u32 device_tree_get_u32(const void *fdt, int node, + const char *prop_name, u32 dflt); + +/* + * Interpret the property `prop_name` of `node` as a "reg". + * + * Returns outputs in `start` and `size`. + */ +void device_tree_get_reg(const __be32 **cell, uint32_t address_cells, + uint32_t size_cells, paddr_t *start, paddr_t *siz= e); + #endif /* XEN_BOOTFDT_H */ diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index d2de7c3a13..b6d16756fc 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -22,8 +22,6 @@ #include #include =20 -#define DEVICE_TREE_MAX_DEPTH 16 - /* * Struct used for matching a device */ @@ -164,17 +162,8 @@ struct dt_raw_irq { u32 specifier[DT_MAX_IRQ_SPEC]; }; =20 -typedef int (*device_tree_node_func)(const void *fdt, - int node, const char *name, int depth, - u32 address_cells, u32 size_cells, - void *data); - extern const void *device_tree_flattened; =20 -int device_tree_for_each_node(const void *fdt, int node, - device_tree_node_func func, - void *data); - /** * dt_unflatten_host_device_tree - Unflatten the host device tree * @@ -245,10 +234,6 @@ void intc_dt_preinit(void); #define dt_node_cmp(s1, s2) strcasecmp((s1), (s2)) #define dt_compat_cmp(s1, s2) strcasecmp((s1), (s2)) =20 -/* Default #address and #size cells */ -#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 -#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 - #define dt_for_each_property_node(dn, pp) \ for ( pp =3D (dn)->properties; (pp) !=3D NULL; pp =3D (pp)->next ) =20 @@ -258,55 +243,6 @@ void intc_dt_preinit(void); #define dt_for_each_child_node(dt, dn) \ for ( dn =3D (dt)->child; (dn) !=3D NULL; dn =3D (dn)->sibling ) =20 -/* Helper to read a big number; size is in cells (not bytes) */ -static inline u64 dt_read_number(const __be32 *cell, int size) -{ - u64 r =3D be32_to_cpu(*cell); - - switch ( size ) - { - case 1: - break; - case 2: - r =3D (r << 32) | be32_to_cpu(cell[1]); - break; - default: - /* Nonsensical size. default to 1 */ - printk(XENLOG_ERR "dt_read_number(,%d) bad size\n", size); - ASSERT_UNREACHABLE(); - break; - }; - - return r; -} - -/* Wrapper for dt_read_number() to return paddr_t (instead of uint64_t) */ -static inline paddr_t dt_read_paddr(const __be32 *cell, int size) -{ - uint64_t dt_r; - paddr_t r; - - /* - * dt_read_number will return uint64_t whereas paddr_t may not be 64-b= it. - * Thus, there is an implicit cast from uint64_t to paddr_t. - */ - dt_r =3D dt_read_number(cell, size); - - if ( dt_r !=3D (paddr_t)dt_r ) - { - printk("Physical address greater than max width supported\n"); - WARN(); - } - - /* - * Xen will truncate the address/size if it is greater than the maximum - * supported width and it will give an appropriate warning. - */ - r =3D dt_r; - - return r; -} - /* Helper to convert a number of cells to bytes */ static inline int dt_cells_to_size(int size) { @@ -319,14 +255,6 @@ static inline int dt_size_to_cells(int bytes) return (bytes / sizeof(u32)); } =20 -static inline u64 dt_next_cell(int s, const __be32 **cellp) -{ - const __be32 *p =3D *cellp; - - *cellp =3D p + s; - return dt_read_number(p, s); -} - static inline const char *dt_node_full_name(const struct dt_device_node *n= p) { return (np && np->full_name) ? np->full_name : ""; @@ -961,12 +889,6 @@ int dt_get_pci_domain_nr(struct dt_device_node *node); =20 struct dt_device_node *dt_find_node_by_phandle(dt_phandle handle); =20 -void device_tree_get_reg(const __be32 **cell, uint32_t address_cells, - uint32_t size_cells, paddr_t *start, paddr_t *siz= e); - -u32 device_tree_get_u32(const void *fdt, int node, - const char *prop_name, u32 dflt); - #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args) --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367480; cv=pass; d=zohomail.com; s=zohoarc; b=YgF8isfrqAqzLdwTbPYIhDpLsDBl2oJpm2NkPHt0LiAvT13jSiU9LFeio950UMDIuH9ETKnQMCNE9WxWbkJ6o949iPaXdv/Jgw1DAjUh+4f7DEBEQMpZRU2NtQU+fZ9ubsry82sugq6fB1OE9tHFeMWYBnkMRjEJiBkLeuFZ5Cw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367480; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BbVNr8wahsI5DaFX/g57h2I+6mdJW2lNt8ZCBnBHPBE=; b=CKhXCBbExCBxfUTag9HBjGT/c4x8z8fESY2dTqH3D19aQfNBPrRnlj94q9s+JBZSFTfehkeAe/eOiPC6P0tIlgZxiQkLMkbFgZrLE7WeBFW8UnZZVEevjGu59jZE1kKfCEtGK6R6WtF+NlYZuj7Zi4FRpdIxoRmw9oz0kXFBPY0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367479617788.9906019305204; Tue, 1 Jul 2025 03:57:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029524.1403315 (Exim 4.92) (envelope-from ) id 1uWYgJ-0003n1-Pv; Tue, 01 Jul 2025 10:57:43 +0000 Received: by outflank-mailman (output) from mailman id 1029524.1403315; Tue, 01 Jul 2025 10:57:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgJ-0003mn-LB; Tue, 01 Jul 2025 10:57:43 +0000 Received: by outflank-mailman (input) for mailman id 1029524; Tue, 01 Jul 2025 10:57:42 +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 1uWYgI-0002hE-DV for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:42 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20616.outbound.protection.outlook.com [2a01:111:f403:2413::616]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 34eb0576-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:41 +0200 (CEST) Received: from BN9PR03CA0375.namprd03.prod.outlook.com (2603:10b6:408:f7::20) by CH1PPF0B4A257F6.namprd12.prod.outlook.com (2603:10b6:61f:fc00::605) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.26; Tue, 1 Jul 2025 10:57:35 +0000 Received: from BN2PEPF00004FBD.namprd04.prod.outlook.com (2603:10b6:408:f7:cafe::4) by BN9PR03CA0375.outlook.office365.com (2603:10b6:408:f7::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.30 via Frontend Transport; Tue, 1 Jul 2025 10:57:35 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBD.mail.protection.outlook.com (10.167.243.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:35 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:32 -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: 34eb0576-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b8S2u3V4c08uQGf4QFfEfV5pwiko9Otbjy1toHEPfrIPp0E/hQtuPZF+xm0PWSI9cTcJEXY6rQ4xSbmRI1gXztSfgU8Z2o+snnLNZUg21v/SlFSUqG1QsB8JD8E+Gu4a8PoEyc8vI91oCbDqVQpLUcqVmaLZ495kLFrlqVe2aXE5eh+EX3IhRPo9tbvcm4FPimWVsmdnnvRccyheOp8L/5qnMbP3XnLndHPsSLOYfxM85GRsDb20SEIPv+zx3p1M0R8tcR97SJ0QyFwO18U71E4+JFU7tp9PYqEMZR7FMY2F3CS4DdekDqj9eVXCvUzI2S/ft/e5yqGf0s3BMFP0Hw== 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=BbVNr8wahsI5DaFX/g57h2I+6mdJW2lNt8ZCBnBHPBE=; b=TO3CuIiSw0dALyUq0u5ofsWoXPUtXX35hXVJAGcZY6yIC1aMoIfDUMoxm/fQ2EOVwPvC7kyFjhLUhNZdxi0WRRusQ0ikjcj3mrSkXPkg20VsitZF4Lc9ejQ/NRlfT4iwSQ0npns/yqG9+y7ja5kORtbE8IomRJ4x+5WlwJ7UJFUW3unQapFQ1ixrgwD234cphtex4dl24/XNwWSLHD72nLrBD/r2Hx+Qwoub+lsKOZ53aDVxUJuMbDsgZwvD34xwVxZfIAS//h7CDlROpre2y2x7FCHJJ7Wes9tHq5fNN6MRn1HVZoMnmoosCZkCBz4jZ5zNQvX52zyI4FnkcOTvzw== 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=BbVNr8wahsI5DaFX/g57h2I+6mdJW2lNt8ZCBnBHPBE=; b=RO0pXIeY84UYzS4JfbKjp078BA7+8gsvkkuga82Sm1D6+x/C5N+x2QPJgb+TQ8/noCSg+ebbhWFqc5fsRJQ/m/OhL4CuuFOaR64jICfR0jG9+oMp/ZlS7i6fSsY/8ZcbQ/uj1tZndhS/sn8rfHUUbsZdmnlPaMqTZi8kH5Z7HTU= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , Anthony PERARD , "Jan Beulich" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Alistair Francis , "Bob Eshleman" , Connor Davis , Oleksii Kurochko Subject: [PATCH v5 05/10] xen/dt: Move bootinfo functions to a new bootinfo.h Date: Tue, 1 Jul 2025 12:56:59 +0200 Message-ID: <20250701105706.86133-6-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBD:EE_|CH1PPF0B4A257F6:EE_ X-MS-Office365-Filtering-Correlation-Id: 24a245bc-5cca-4b0c-9ba8-08ddb88e1628 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UuebJ3tn2ryMTeQeYYEsRmDL9GCT7nzJ4UAn88j5zvdprixapnl3/34WcZFG?= =?us-ascii?Q?cVDGV86FRwMidyewIdffPpHTjE/GeLwTIunNQZRy3jPizRhhyuDOBumiMaCE?= =?us-ascii?Q?N0v2K9PgrN9XMethzwS3IbleOzrm6Tf61dSd+44h5wucAFKtVilKt5gO8Vve?= =?us-ascii?Q?i0lFrI0S73UNbeYTFebNjRRlBJupb28rCox7Oo6sawJ9KjylO3b/F/Pg2dLq?= =?us-ascii?Q?K79ZpVxnG3/Q3mpFT/qFcaDjZbtJ2WGNWmrmc/n3rjjAT9X9nguYEHH5HxCW?= =?us-ascii?Q?t+0uV+Xyc+zsIKBQG5fqz+ao4WfB0Ab+99Gm/y5Xgy6T5ff3C1OOXloEUlZt?= =?us-ascii?Q?vwd88Zz0RTDR8dCHFkNn7XAi+QyzAZ2Mw0WmyoRfg9A28BUC89oIF94N9X/g?= =?us-ascii?Q?EzE4caYOs64tb2jHO+1yN/+G3zlFtROroof9fzpTv/UdedoOMvHwvQ5Pxfq8?= =?us-ascii?Q?1HEfxkdPVWV2Rw95jIjSENuFn8Vd/7zJM1qYOwoxVQpq1gtKKjovvY+M9y5N?= =?us-ascii?Q?uZR7XXgaTKs4y1/QRMXYOVDtLIlsXPAMa9KA+4MWlsQqWD/W6He1Z8HGFBTA?= =?us-ascii?Q?4ZusuITgA+F3z+gHBsOXRuohaqSCmBWqchkP7HDElMsbRK41KZQDgQeZIsJV?= =?us-ascii?Q?JObwQF8FTcrsalaIE17MxS8x2yhRaq5saYyKcAxROqQrFMue0h/65XGbtXUa?= =?us-ascii?Q?Bm1x997X5uWinFb67rIFg12kgC6ETM7YUZb54qi5j4qTxNP2PBVLHF16uSpq?= =?us-ascii?Q?UjfRFNzUbUlU8J3TNYaYIIkbla5LsTaAHEhP4MB7FGQRL1nQ0TCG3vwVBWV9?= =?us-ascii?Q?LAQDebe/99a8ZyW/u7tUYLi864G95IP/U1rXR/dedK+59O9Acrer6wqPZ+Ha?= =?us-ascii?Q?1Tipo0u2+hsdZck1WPHV/OlilzFl5OZ+O4wj+EtVWKiC4+XFpGP8yDmhkOhH?= =?us-ascii?Q?3q1Cv8bu8ozI4fYUIAiCVZxJ+WK5AnfiEi/jRV7ShnvUQDhxmy/4Ds2MKm5k?= =?us-ascii?Q?JtSGWuJjZJSl94OxVZ8xhAk5pQzI8NeU7/CsaeIzMetTazso2alB15Lcu6nw?= =?us-ascii?Q?SKIeEAqfWqLH1J4b3waTiQnbwzbBgFMFoE5D0z5frvGkTFDce6TnvCmNztGc?= =?us-ascii?Q?rhiLDA+Wco3oo/GLRDcdXzXKhUsxjC03aQECdHMq+aPdi0fZrc5U0XNJgtcb?= =?us-ascii?Q?IVjFAXufE1dCRbdYrxVtHVmTQWLoP8mZjbSgrbd89K9JDe9qjzE8XX5NQi1B?= =?us-ascii?Q?FZnLaX1gUbvUm20AyLPgpSlLM9ruIxRu1eXiSDLCT1FeRKPCzuZa+mZzWGGl?= =?us-ascii?Q?mHrvzraZMhip9ji91oKjZ1u/Ql6zuOHwCkwhR1uw+0tp78c/vaznwj5PcaWg?= =?us-ascii?Q?C5PQkZPEDMwri4T5+Lo6msIby/iQSyyaQM5XAQ6ltuZgoe90DHtDvoaHdwnu?= =?us-ascii?Q?Cjsn10wmLMmbWpFSblPWJUahGuhYU3xXKRrgj46+tumEkRV1T4BINDCFGFK3?= =?us-ascii?Q?iFpOu39swVAHvD6Xj3BoWKgCf89boCGB8snH?= 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)(7416014)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:35.2683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24a245bc-5cca-4b0c-9ba8-08ddb88e1628 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: BN2PEPF00004FBD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PPF0B4A257F6 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367481751116600 Content-Type: text/plain; charset="utf-8" Part of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take. With this, bootfdt.h can be cleanly included from x86. A later patch extracts the definitions so the functions may be called too. Not a functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/include/asm/setup.h | 2 +- xen/arch/arm/setup.c | 1 + xen/arch/riscv/mm.c | 2 +- xen/arch/riscv/setup.c | 2 +- xen/common/device-tree/bootfdt.c | 2 +- xen/common/device-tree/bootinfo.c | 2 +- xen/common/device-tree/dom0less-build.c | 2 +- xen/common/device-tree/domain-build.c | 2 +- xen/common/device-tree/kernel.c | 2 +- xen/include/xen/bootfdt.h | 208 ----------------------- xen/include/xen/bootinfo.h | 213 ++++++++++++++++++++++++ xen/include/xen/fdt-domain-build.h | 2 +- xen/include/xen/fdt-kernel.h | 2 +- 14 files changed, 225 insertions(+), 218 deletions(-) create mode 100644 xen/include/xen/bootinfo.h diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fb577f816f..822f7430bd 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index b199d92a42..1eaf13bd66 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -3,7 +3,7 @@ =20 #include #include -#include +#include #include =20 #if defined(CONFIG_MMU) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 58acc2d0d4..28fe1de3e2 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -8,6 +8,7 @@ * Copyright (c) 2011 Citrix Systems. */ =20 +#include #include #include #include diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c index 774ea42f2d..1ef015f179 100644 --- a/xen/arch/riscv/mm.c +++ b/xen/arch/riscv/mm.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 -#include +#include #include #include #include diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 8bcd19218d..3e99e2e194 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -2,7 +2,7 @@ =20 #include #include -#include +#include #include #include #include diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/boot= fdt.c index 39334d6205..1848478e82 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -5,7 +5,7 @@ * Copyright (C) 2012-2014 Citrix Systems, Inc. */ =20 -#include +#include #include #include #include diff --git a/xen/common/device-tree/bootinfo.c b/xen/common/device-tree/boo= tinfo.c index 2a27d1318b..00a43fb358 100644 --- a/xen/common/device-tree/bootinfo.c +++ b/xen/common/device-tree/bootinfo.c @@ -10,7 +10,7 @@ */ =20 #include -#include +#include #include #include #include diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index e321747175..4413b17aac 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 -#include +#include #include #include #include diff --git a/xen/common/device-tree/domain-build.c b/xen/common/device-tree= /domain-build.c index 51182d10ef..b97206c917 100644 --- a/xen/common/device-tree/domain-build.c +++ b/xen/common/device-tree/domain-build.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 -#include +#include #include #include #include diff --git a/xen/common/device-tree/kernel.c b/xen/common/device-tree/kerne= l.c index 7a00768e6b..7f73520388 100644 --- a/xen/common/device-tree/kernel.c +++ b/xen/common/device-tree/kernel.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 -#include +#include #include #include #include diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index 0846317f30..ad6b11cb6d 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -5,10 +5,7 @@ #include #include #include -#include #include -#include -#include =20 #if __has_include() #include @@ -16,15 +13,10 @@ =20 #define MIN_FDT_ALIGN 8 =20 -#define NR_MEM_BANKS 256 -#define NR_SHMEM_BANKS 32 - /* Default #address and #size cells */ #define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 =20 -#define MAX_MODULES 32 /* Current maximum useful modules */ - #define DEVICE_TREE_MAX_DEPTH 16 =20 /* Helper to read a big number; size is in cells (not bytes) */ @@ -104,78 +96,6 @@ typedef enum { BOOTMOD_UNKNOWN } boot_module_kind; =20 -enum membank_type { - /* - * The MEMBANK_DEFAULT type refers to either reserved memory for the - * device/firmware (when the bank is in 'reserved_mem') or any RAM (wh= en - * the bank is in 'mem'). - */ - MEMBANK_DEFAULT, - /* - * The MEMBANK_STATIC_DOMAIN type is used to indicate whether the memo= ry - * bank is bound to a static Xen domain. It is only valid when the bank - * is in reserved_mem. - */ - MEMBANK_STATIC_DOMAIN, - /* - * The MEMBANK_STATIC_HEAP type is used to indicate whether the memory - * bank is reserved as static heap. It is only valid when the bank is - * in reserved_mem. - */ - MEMBANK_STATIC_HEAP, - /* - * The MEMBANK_FDT_RESVMEM type is used to indicate whether the memory - * bank is from the FDT reserve map. - */ - MEMBANK_FDT_RESVMEM, -}; - -enum region_type { - MEMORY, - RESERVED_MEMORY, - STATIC_SHARED_MEMORY -}; - -/* Indicates the maximum number of characters(\0 included) for shm_id */ -#define MAX_SHM_ID_LENGTH 16 - -struct shmem_membank_extra { - char shm_id[MAX_SHM_ID_LENGTH]; - unsigned int nr_shm_borrowers; -}; - -struct membank { - paddr_t start; - paddr_t size; - union { - enum membank_type type; -#ifdef CONFIG_STATIC_SHM - struct shmem_membank_extra *shmem_extra; -#endif - }; -}; - -struct membanks { - __struct_group(membanks_hdr, common, , - unsigned int nr_banks; - unsigned int max_banks; - enum region_type type; - ); - struct membank bank[]; -}; - -struct meminfo { - struct membanks_hdr common; - struct membank bank[NR_MEM_BANKS]; -}; - -struct shared_meminfo { - struct membanks_hdr common; - struct membank bank[NR_SHMEM_BANKS]; - struct shmem_membank_extra extra[NR_SHMEM_BANKS]; -}; - - struct boot_domain { struct domain *d; =20 @@ -207,134 +127,6 @@ struct boot_module { #endif }; =20 -/* DT_MAX_NAME is the node name max length according the DT spec */ -#define DT_MAX_NAME 41 -struct bootcmdline { - boot_module_kind kind; - bool domU; - paddr_t start; - char dt_name[DT_MAX_NAME]; - char cmdline[BOOTMOD_MAX_CMDLINE]; -}; - -struct boot_modules { - int nr_mods; - struct boot_module module[MAX_MODULES]; -}; - -struct bootcmdlines { - unsigned int nr_mods; - struct bootcmdline cmdline[MAX_MODULES]; -}; - -struct bootinfo { - struct meminfo mem; - /* The reserved regions are only used when booting using Device-Tree */ - struct meminfo reserved_mem; - struct boot_modules modules; - struct bootcmdlines cmdlines; -#ifdef CONFIG_ACPI - struct meminfo acpi; -#endif -#ifdef CONFIG_STATIC_SHM - struct shared_meminfo shmem; -#endif -}; - -#ifdef CONFIG_ACPI -#define BOOTINFO_ACPI_INIT \ - .acpi.common.max_banks =3D NR_MEM_BANKS, \ - .acpi.common.type =3D MEMORY, -#else -#define BOOTINFO_ACPI_INIT -#endif - -#ifdef CONFIG_STATIC_SHM -#define BOOTINFO_SHMEM_INIT \ - .shmem.common.max_banks =3D NR_SHMEM_BANKS, \ - .shmem.common.type =3D STATIC_SHARED_MEMORY, -#else -#define BOOTINFO_SHMEM_INIT -#endif - -#define BOOTINFO_INIT \ -{ \ - .mem.common.max_banks =3D NR_MEM_BANKS, \ - .mem.common.type =3D MEMORY, \ - .reserved_mem.common.max_banks =3D NR_MEM_BANKS, \ - .reserved_mem.common.type =3D RESERVED_MEMORY, \ - BOOTINFO_ACPI_INIT \ - BOOTINFO_SHMEM_INIT \ -} - -extern struct bootinfo bootinfo; - -bool check_reserved_regions_overlap(paddr_t region_start, - paddr_t region_size, - bool allow_memreserve_overlap); - -struct boot_module *add_boot_module(boot_module_kind kind, - paddr_t start, paddr_t size, bool domU); -struct boot_module *boot_module_find_by_kind(boot_module_kind kind); -struct boot_module * boot_module_find_by_addr_and_kind(boot_module_kind ki= nd, - paddr_t start= ); -void add_boot_cmdline(const char *name, const char *cmdline, - boot_module_kind kind, paddr_t start, bool domU); -struct bootcmdline *boot_cmdline_find_by_kind(boot_module_kind kind); -struct bootcmdline * boot_cmdline_find_by_name(const char *name); -const char *boot_module_kind_as_string(boot_module_kind kind); - -void populate_boot_allocator(void); - -size_t boot_fdt_info(const void *fdt, paddr_t paddr); - -const char *boot_fdt_cmdline(const void *fdt); -int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); - -static inline struct membanks *bootinfo_get_reserved_mem(void) -{ - return container_of(&bootinfo.reserved_mem.common, struct membanks, co= mmon); -} - -static inline struct membanks *bootinfo_get_mem(void) -{ - return container_of(&bootinfo.mem.common, struct membanks, common); -} - -#ifdef CONFIG_ACPI -static inline struct membanks *bootinfo_get_acpi(void) -{ - return container_of(&bootinfo.acpi.common, struct membanks, common); -} -#endif - -#ifdef CONFIG_STATIC_SHM -static inline struct membanks *bootinfo_get_shmem(void) -{ - return container_of(&bootinfo.shmem.common, struct membanks, common); -} - -static inline struct shmem_membank_extra *bootinfo_get_shmem_extra(void) -{ - return bootinfo.shmem.extra; -} -#endif - -static inline struct membanks *membanks_xzalloc(unsigned int nr, - enum region_type type) -{ - struct membanks *banks =3D xzalloc_flex_struct(struct membanks, bank, = nr); - - if ( !banks ) - goto out; - - banks->max_banks =3D nr; - banks->type =3D type; - - out: - return banks; -} - /* * Interpret the property `prop_name` of `node` as a u32. * diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h new file mode 100644 index 0000000000..f834f19571 --- /dev/null +++ b/xen/include/xen/bootinfo.h @@ -0,0 +1,213 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef XEN_BOOTINFO_H +#define XEN_BOOTINFO_H + +#include +#include +#include +#include + +#define NR_MEM_BANKS 256 +#define NR_SHMEM_BANKS 32 + +#define MAX_MODULES 32 /* Current maximum useful modules */ + +enum membank_type { + /* + * The MEMBANK_DEFAULT type refers to either reserved memory for the + * device/firmware (when the bank is in 'reserved_mem') or any RAM (wh= en + * the bank is in 'mem'). + */ + MEMBANK_DEFAULT, + /* + * The MEMBANK_STATIC_DOMAIN type is used to indicate whether the memo= ry + * bank is bound to a static Xen domain. It is only valid when the bank + * is in reserved_mem. + */ + MEMBANK_STATIC_DOMAIN, + /* + * The MEMBANK_STATIC_HEAP type is used to indicate whether the memory + * bank is reserved as static heap. It is only valid when the bank is + * in reserved_mem. + */ + MEMBANK_STATIC_HEAP, + /* + * The MEMBANK_FDT_RESVMEM type is used to indicate whether the memory + * bank is from the FDT reserve map. + */ + MEMBANK_FDT_RESVMEM, +}; + +enum region_type { + MEMORY, + RESERVED_MEMORY, + STATIC_SHARED_MEMORY +}; + +/* Indicates the maximum number of characters(\0 included) for shm_id */ +#define MAX_SHM_ID_LENGTH 16 + +struct shmem_membank_extra { + char shm_id[MAX_SHM_ID_LENGTH]; + unsigned int nr_shm_borrowers; +}; + +struct membank { + paddr_t start; + paddr_t size; + union { + enum membank_type type; +#ifdef CONFIG_STATIC_SHM + struct shmem_membank_extra *shmem_extra; +#endif + }; +}; + +struct membanks { + __struct_group(membanks_hdr, common, , + unsigned int nr_banks; + unsigned int max_banks; + enum region_type type; + ); + struct membank bank[]; +}; + +struct meminfo { + struct membanks_hdr common; + struct membank bank[NR_MEM_BANKS]; +}; + +struct shared_meminfo { + struct membanks_hdr common; + struct membank bank[NR_SHMEM_BANKS]; + struct shmem_membank_extra extra[NR_SHMEM_BANKS]; +}; + +/* DT_MAX_NAME is the node name max length according the DT spec */ +#define DT_MAX_NAME 41 +struct bootcmdline { + boot_module_kind kind; + bool domU; + paddr_t start; + char dt_name[DT_MAX_NAME]; + char cmdline[BOOTMOD_MAX_CMDLINE]; +}; + +struct boot_modules { + int nr_mods; + struct boot_module module[MAX_MODULES]; +}; + +struct bootcmdlines { + unsigned int nr_mods; + struct bootcmdline cmdline[MAX_MODULES]; +}; + +struct bootinfo { + struct meminfo mem; + /* The reserved regions are only used when booting using Device-Tree */ + struct meminfo reserved_mem; + struct boot_modules modules; + struct bootcmdlines cmdlines; +#ifdef CONFIG_ACPI + struct meminfo acpi; +#endif +#ifdef CONFIG_STATIC_SHM + struct shared_meminfo shmem; +#endif +}; + +#ifdef CONFIG_ACPI +#define BOOTINFO_ACPI_INIT \ + .acpi.common.max_banks =3D NR_MEM_BANKS, \ + .acpi.common.type =3D MEMORY, +#else +#define BOOTINFO_ACPI_INIT +#endif + +#ifdef CONFIG_STATIC_SHM +#define BOOTINFO_SHMEM_INIT \ + .shmem.common.max_banks =3D NR_SHMEM_BANKS, \ + .shmem.common.type =3D STATIC_SHARED_MEMORY, +#else +#define BOOTINFO_SHMEM_INIT +#endif + +#define BOOTINFO_INIT \ +{ \ + .mem.common.max_banks =3D NR_MEM_BANKS, \ + .mem.common.type =3D MEMORY, \ + .reserved_mem.common.max_banks =3D NR_MEM_BANKS, \ + .reserved_mem.common.type =3D RESERVED_MEMORY, \ + BOOTINFO_ACPI_INIT \ + BOOTINFO_SHMEM_INIT \ +} + +extern struct bootinfo bootinfo; + +bool check_reserved_regions_overlap(paddr_t region_start, + paddr_t region_size, + bool allow_memreserve_overlap); + +struct boot_module *add_boot_module(boot_module_kind kind, + paddr_t start, paddr_t size, bool domU= ); +struct boot_module *boot_module_find_by_kind(boot_module_kind kind); +struct boot_module * boot_module_find_by_addr_and_kind(boot_module_kind ki= nd, + paddr_t start= ); +void add_boot_cmdline(const char *name, const char *cmdline, + boot_module_kind kind, paddr_t start, bool domU); +struct bootcmdline *boot_cmdline_find_by_kind(boot_module_kind kind); +struct bootcmdline * boot_cmdline_find_by_name(const char *name); +const char *boot_module_kind_as_string(boot_module_kind kind); + +void populate_boot_allocator(void); + +size_t boot_fdt_info(const void *fdt, paddr_t paddr); +const char *boot_fdt_cmdline(const void *fdt); +int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); + +static inline struct membanks *bootinfo_get_reserved_mem(void) +{ + return container_of(&bootinfo.reserved_mem.common, struct membanks, co= mmon); +} + +static inline struct membanks *bootinfo_get_mem(void) +{ + return container_of(&bootinfo.mem.common, struct membanks, common); +} + +#ifdef CONFIG_ACPI +static inline struct membanks *bootinfo_get_acpi(void) +{ + return container_of(&bootinfo.acpi.common, struct membanks, common); +} +#endif + +#ifdef CONFIG_STATIC_SHM +static inline struct membanks *bootinfo_get_shmem(void) +{ + return container_of(&bootinfo.shmem.common, struct membanks, common); +} + +static inline struct shmem_membank_extra *bootinfo_get_shmem_extra(void) +{ + return bootinfo.shmem.extra; +} +#endif + +static inline struct membanks *membanks_xzalloc(unsigned int nr, + enum region_type type) +{ + struct membanks *banks =3D xzalloc_flex_struct(struct membanks, bank, = nr); + + if ( !banks ) + goto out; + + banks->max_banks =3D nr; + banks->type =3D type; + + out: + return banks; +} + +#endif /* XEN_BOOTINFO_H */ diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domai= n-build.h index 45981dbec0..60565fdbf9 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -3,7 +3,7 @@ #ifndef __XEN_FDT_DOMAIN_BUILD_H__ #define __XEN_FDT_DOMAIN_BUILD_H__ =20 -#include +#include #include #include #include diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index fee8eac1db..ee29aad9fe 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -7,7 +7,7 @@ #ifndef __XEN_FDT_KERNEL_H__ #define __XEN_FDT_KERNEL_H__ =20 -#include +#include #include #include =20 --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367489; cv=pass; d=zohomail.com; s=zohoarc; b=USG56oSGrayFBDIbEh2o/pBCOANrJOWw1IjYdZkm6D8UbQbE8kvKsGfn0Hy5lquP36pMEFifPS2T19eaGHiQ4sXiX7vBI88aOHu5YavF/q9RUv+PM5+AHHuGLEUaY6c5p6qwKiXc+E3JE0Eb7pEQNj0up3zfhxNbBKX+Tdh2RCk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367489; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EZ8mPV20eg3UxX25KPokn65IJOL0jNvmLs3RF/kL5p8=; b=NRpv2rrOQQ+TrSZhd8Mu5YCYh4youZZuDCZwbW27e5SKM57awcxZVXRCrD6FVV8pnHb05OCHJzqIdtUpZqtC6xSZNRxfa3rfmQAceJhqzKh6mVI/PgydPUBH5NlWt14h3WudkPjiZyW8DXGRJUkpfCKOSdRX6gRb9RN+Gr72eDs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367489577178.42290171208924; Tue, 1 Jul 2025 03:58:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029525.1403325 (Exim 4.92) (envelope-from ) id 1uWYgN-00049N-5g; Tue, 01 Jul 2025 10:57:47 +0000 Received: by outflank-mailman (output) from mailman id 1029525.1403325; Tue, 01 Jul 2025 10:57:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgN-000496-10; Tue, 01 Jul 2025 10:57:47 +0000 Received: by outflank-mailman (input) for mailman id 1029525; Tue, 01 Jul 2025 10:57:45 +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 1uWYgL-0002hE-7j for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:45 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20631.outbound.protection.outlook.com [2a01:111:f403:2406::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36f41195-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:43 +0200 (CEST) Received: from BL0PR02CA0123.namprd02.prod.outlook.com (2603:10b6:208:35::28) by IA0PR12MB8303.namprd12.prod.outlook.com (2603:10b6:208:3de::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.29; Tue, 1 Jul 2025 10:57:38 +0000 Received: from BN2PEPF00004FC0.namprd04.prod.outlook.com (2603:10b6:208:35:cafe::7b) by BL0PR02CA0123.outlook.office365.com (2603:10b6:208:35::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.32 via Frontend Transport; Tue, 1 Jul 2025 10:57:38 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FC0.mail.protection.outlook.com (10.167.243.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:37 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:35 -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: 36f41195-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=svUge+K5J7vf7nXV1wmgHvKyXmVskYTUkStn415TqTHc4COxzQvNqPNZlIuZGP3/VPEGI+iDLxF4LJEqoP6X1MFpJM5R+S8xG4Tj98UuoOrlNCoc+zYU/58HrISGshm0rPaww0p0PVfZGF5rJWyAHm6SRPVgEQ/QAlt0Tud7ASHVUDWlqsy4+FJy5zBNhNI+Tcb7beIfHRJelNY5U1B6kaY3epEsM0F02wgW/4ZonPaSbiFV/Mlxhmn17sAjRbc+pobom8hiVDg7aPaqxK7lwypLqlgQdQcKZZ5DQsLCzkhIq4Zdki0n7GHe4tyvhWXAIfErrlp9OwpGjYPQ9DbPLw== 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=EZ8mPV20eg3UxX25KPokn65IJOL0jNvmLs3RF/kL5p8=; b=v/+8TMaQUXmiD2fZxu82nNwOj6Z0A9gd1QXeQbCSSRgxJR59dn4HLxINC/vBgydVjr2kTqx8HP5g+1ZiiObNOVsuzGutLuTGoXDx9chKv31N8g3onPtZAfDK8Q9HMa7CaH3Dcn6QJ/2cZLVt/L1u/VdPzmQLpW5or6oSQp9qErQwvL9icx8kfCN4B8+sN9XKimxMK92qMCensiJsdUJjzAp/xhU3IGs7Jx3l0BliPm66igNqSDTdxGsghPOgt664v0oOR93GpYZ7ErwPaYWlrfd1ize+RHHlKjWRQOKh7rR81PCWVepC2rRcrJ9CsF6lWJFYPWHfcMJVpZ5sgJP++Q== 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=EZ8mPV20eg3UxX25KPokn65IJOL0jNvmLs3RF/kL5p8=; b=M4FUehYkVMBfKPsBzjAyWkUCnAqkuJTEWU42YhJZ3ExuB702NEScizTV6RKxskz+gIvYSYJWEtVKdh/qZkV9BzUpoT10e5c+Rf9Gveu2HvlHJ7ucGLegkoBfizD7ece27gX6aZVWVvgIw7394+vElhHcERh5nNul4KvLhueF3CE= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Daniel P. Smith" Subject: [PATCH v5 06/10] xen/dt: Rename bootfdt.c -> bootinfo-fdt.c Date: Tue, 1 Jul 2025 12:57:00 +0200 Message-ID: <20250701105706.86133-7-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FC0:EE_|IA0PR12MB8303:EE_ X-MS-Office365-Filtering-Correlation-Id: aa24d299-49e1-4684-4eca-08ddb88e1786 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uOwHuA1YzYb1SNiIWhWAWmTeIvCRi0l2V4e80L3+28zHCgQoHpzrMjrCgoik?= =?us-ascii?Q?oLDGTH1OlZpmPh3I6xFu9xUg2m3kds+3woMr+eFlbivkyOxHAWbWQom6pG5N?= =?us-ascii?Q?sfbLhY+9N8mD/yrLk3mbYXRGdLnnPHdiMZtPdronwY8lSfI3X2Q/OIcRxM84?= =?us-ascii?Q?wnO+7OQmfTpXqrYdFIMmjYtv4JU+SxmGars1y5dLAHCZjtXv0WbCwPdXFrVE?= =?us-ascii?Q?BJGFnD8aySrqM3Jn0XHDBK8OmxFtRVkUPcRJmIEH+BJk7yo5wJev9wR15Rpj?= =?us-ascii?Q?cgolUBvsHjf3IjhpMhv8TbQJp1vN4TZSW8aRM+OhKdzo5DKx8IUaHkq69xjS?= =?us-ascii?Q?//R03tD/TlPm2b1FyuCtrCyK72353/HyxLT9tvPaRuCr96gnOO1jFcuc4dlT?= =?us-ascii?Q?rfspYDfNTJHgUBB9Jh/4x7HmsiVPmhTUV6A3OoPcKM6BD91oGDZcqL/yC/8B?= =?us-ascii?Q?t+TtDBAmh07cH0u6Doyld5wUPMf4K6ElHGm2WEfEpt2+BCmH8nQxiZSqW6fu?= =?us-ascii?Q?09jCHKG2223aadnu2cS9hzU2ow2AhxHYofh3DsvnwxAnUyXtnkqOqZAxaPzE?= =?us-ascii?Q?plaQGkbIlt0OZYYKt3w9wE9AVBhLQNQpJM5WJ16263uyPU158lv1SPehls/E?= =?us-ascii?Q?Xq8vjzTAyH6vt8z/IQnKYdGGeaQZ7v/Ld+O5C0+W4DJz/yFqGIr5anI2BRoa?= =?us-ascii?Q?PHGOQiPYHeQc4IbVFHYQEnMsyv86cmjGyXjY/1QRLM0odAgHvXIPSqGZBKVu?= =?us-ascii?Q?16KzoFmyoBXTQIFmZGuAVTFZhWWL/bZV7kG45oltnOulH8vQ3pp11X6RUZjs?= =?us-ascii?Q?WbZvY8cEEqkgeh2J8sfReQ1P9x4nyDyW8INyawhoxAdWvxZTRHAIHPv3zofq?= =?us-ascii?Q?6G3oCdhX4rZA4ICbg3RVaP0EhuTUtzu7XM5pLlhDUsB/c5KoX+p3PERD/Qxu?= =?us-ascii?Q?Zq8u3F5E7jXdjD9bFgUtoEBFKlRAeQvOItFqGasv0QL2KlvdAAUWIQJFIVPn?= =?us-ascii?Q?6h04zi2VyeRzsG1d61dTwm5ajwlRnG6ZqOjuxp9cKIR/VSFfyVMQdVrBfLBy?= =?us-ascii?Q?PVQSPevkkXFBYng0sKh9u+X/egEZG2OkVnL/u0DS6bwnIQkl/3GAaX6kg2uv?= =?us-ascii?Q?6mrJ3YXXFLmCFRCrd1vcCRaZ5kgjku15EgguneZLSjiSJDQzb8i2ZidPN3Yo?= =?us-ascii?Q?/1t0WDRxWgc2eq7yO742llnBaHuCIaegLF32KjuRvvybJ2h/Byl4/LwXIjSl?= =?us-ascii?Q?9AZx1Wz1AHWWjwr2HPWgj/iUwQnLMMJuYd5LKcdSq/B3a0ygih9ZrZe12AEE?= =?us-ascii?Q?ZMSOTVHGoFFQGdw+bLdcjdVrMzrVzev90KGtZDWEUas1Meobl2H3ysc2beI9?= =?us-ascii?Q?PmrTLZMtQWxAV7UXBngxgi5+i/VzWQs2jaOd+ZAKHYkgKDKMM5++Wcne6Rah?= =?us-ascii?Q?8tzWt1+BIT9GFoeG0wMgpoOyBdVBEO8dhIUhm3i44bIES5ZFHBC9KZgLPYP9?= =?us-ascii?Q?AX1Ud7zZ6xrufaz+ASqGBTgGYTdsg+V25rV2?= 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)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:37.5593 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa24d299-49e1-4684-4eca-08ddb88e1786 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: BN2PEPF00004FC0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8303 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367493878116600 Content-Type: text/plain; charset="utf-8" This file will eventually contain bootfdt helpers that make heavy use of bootinfo. To simplify git history do the rename here explicitly. A later patch extracts bootinfo-independent helpers into bootfdt.c. Doing so here would needlessly pollute the diffs. Not a functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/common/device-tree/Makefile | 1 + xen/common/device-tree/bootfdt.c | 646 +------------------------- xen/common/device-tree/bootinfo-fdt.c | 597 ++++++++++++++++++++++++ 3 files changed, 619 insertions(+), 625 deletions(-) create mode 100644 xen/common/device-tree/bootinfo-fdt.c diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile index 13127296cb..8abc069c4b 100644 --- a/xen/common/device-tree/Makefile +++ b/xen/common/device-tree/Makefile @@ -1,4 +1,5 @@ obj-y +=3D bootfdt.init.o +obj-y +=3D bootinfo-fdt.init.o obj-y +=3D bootinfo.init.o obj-y +=3D device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) +=3D domain-build.init.o diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/boot= fdt.c index 1848478e82..0d8d9ea357 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -1,206 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Early Device Tree - * - * Copyright (C) 2012-2014 Citrix Systems, Inc. - */ - -#include -#include -#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include - -static void __init __maybe_unused build_assertions(void) -{ - /* - * Check that no padding is between struct membanks "bank" flexible ar= ray - * member and struct meminfo "bank" member - */ - BUILD_BUG_ON((offsetof(struct membanks, bank) !=3D - offsetof(struct meminfo, bank))); - /* Ensure "struct membanks" and "struct membank" are equally aligned */ - BUILD_BUG_ON(alignof(struct membanks) !=3D alignof(struct membank)); -} - -static bool __init device_tree_node_is_available(const void *fdt, int node) -{ - const char *status; - int len; - - status =3D fdt_getprop(fdt, node, "status", &len); - if ( !status ) - return true; - - if ( len > 0 ) - { - if ( !strcmp(status, "ok") || !strcmp(status, "okay") ) - return true; - } - - return false; -} - -static bool __init device_tree_node_matches(const void *fdt, int node, - const char *match) -{ - const char *name; - size_t match_len; - - name =3D fdt_get_name(fdt, node, NULL); - match_len =3D strlen(match); - - /* Match both "match" and "match@..." patterns but not - "match-foo". */ - return strncmp(name, match, match_len) =3D=3D 0 - && (name[match_len] =3D=3D '@' || name[match_len] =3D=3D '\0'); -} - -static bool __init device_tree_node_compatible(const void *fdt, int node, - const char *match) -{ - int len, l; - const void *prop; - - prop =3D fdt_getprop(fdt, node, "compatible", &len); - if ( prop =3D=3D NULL ) - return false; - - while ( len > 0 ) { - if ( !dt_compat_cmp(prop, match) ) - return true; - l =3D strlen(prop) + 1; - prop +=3D l; - len -=3D l; - } - - return false; -} - -/* - * Check if a node is a proper /memory node according to Devicetree - * Specification v0.4, chapter 3.4. - */ -static bool __init device_tree_is_memory_node(const void *fdt, int node, - int depth) -{ - const char *type; - int len; - - if ( depth !=3D 1 ) - return false; - - if ( !device_tree_node_matches(fdt, node, "memory") ) - return false; - - type =3D fdt_getprop(fdt, node, "device_type", &len); - if ( !type ) - return false; - - if ( (len <=3D strlen("memory")) || strcmp(type, "memory") ) - return false; - - return true; -} - -void __init device_tree_get_reg(const __be32 **cell, uint32_t address_cell= s, - uint32_t size_cells, paddr_t *start, - paddr_t *size) -{ - uint64_t dt_start, dt_size; - - /* - * dt_next_cell will return uint64_t whereas paddr_t may not be 64-bit. - * Thus, there is an implicit cast from uint64_t to paddr_t. - */ - dt_start =3D dt_next_cell(address_cells, cell); - dt_size =3D dt_next_cell(size_cells, cell); - - if ( dt_start !=3D (paddr_t)dt_start ) - { - printk("Physical address greater than max width supported\n"); - WARN(); - } - - if ( dt_size !=3D (paddr_t)dt_size ) - { - printk("Physical size greater than max width supported\n"); - WARN(); - } - - /* - * Xen will truncate the address/size if it is greater than the maximum - * supported width and it will give an appropriate warning. - */ - *start =3D dt_start; - *size =3D dt_size; -} - -static int __init device_tree_get_meminfo(const void *fdt, int node, - const char *prop_name, - u32 address_cells, u32 size_cell= s, - struct membanks *mem, - enum membank_type type) -{ - const struct fdt_property *prop; - unsigned int i, banks; - const __be32 *cell; - u32 reg_cells =3D address_cells + size_cells; - paddr_t start, size; - - if ( !device_tree_node_is_available(fdt, node) ) - return 0; - - if ( address_cells < 1 || size_cells < 1 ) - { - printk("fdt: property `%s': invalid #address-cells or #size-cells", - prop_name); - return -EINVAL; - } - - prop =3D fdt_get_property(fdt, node, prop_name, NULL); - if ( !prop ) - return -ENOENT; - - cell =3D (const __be32 *)prop->data; - banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); - - for ( i =3D 0; i < banks && mem->nr_banks < mem->max_banks; i++ ) - { - device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); - /* - * Some valid device trees, such as those generated by OpenPOWER - * skiboot firmware, expose all reserved memory regions in the - * FDT memory reservation block AND in the reserved-memory node wh= ich - * has already been parsed. Thus, any matching overlaps in the - * reserved_mem banks should be ignored. - */ - if ( mem =3D=3D bootinfo_get_reserved_mem() && - check_reserved_regions_overlap(start, size, true) ) - return -EINVAL; - /* Some DT may describe empty bank, ignore them */ - if ( !size ) - continue; - mem->bank[mem->nr_banks].start =3D start; - mem->bank[mem->nr_banks].size =3D size; - mem->bank[mem->nr_banks].type =3D type; - mem->nr_banks++; - } - - if ( i < banks ) - { - printk("Warning: Max number of supported memory regions reached.\n= "); - return -ENOSPC; - } - - return 0; -} +#include =20 u32 __init device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt) @@ -214,18 +16,6 @@ u32 __init device_tree_get_u32(const void *fdt, int nod= e, return fdt32_to_cpu(*(uint32_t*)prop->data); } =20 -/** - * device_tree_for_each_node - iterate over all device tree sub-nodes - * @fdt: flat device tree. - * @node: parent node to start the search from - * @func: function to call for each sub-node. - * @data: data to pass to @func. - * - * Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. - * - * Returns 0 if all nodes were iterated over successfully. If @func - * returns a value different from 0, that value is returned immediately. - */ int __init device_tree_for_each_node(const void *fdt, int node, device_tree_node_func func, void *data) @@ -273,429 +63,35 @@ int __init device_tree_for_each_node(const void *fdt,= int node, return 0; } =20 -static int __init process_memory_node(const void *fdt, int node, - const char *name, int depth, - u32 address_cells, u32 size_cells, - struct membanks *mem) -{ - return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, - mem, MEMBANK_DEFAULT); -} - -static int __init process_reserved_memory_node(const void *fdt, int node, - const char *name, int depth, - u32 address_cells, - u32 size_cells, - void *data) -{ - int rc =3D process_memory_node(fdt, node, name, depth, address_cells, - size_cells, data); - - if ( rc =3D=3D -ENOSPC ) - panic("Max number of supported reserved-memory regions reached.\n"= ); - else if ( rc !=3D -ENOENT ) - return rc; - return 0; -} - -static int __init process_reserved_memory(const void *fdt, int node, - const char *name, int depth, - u32 address_cells, u32 size_cell= s) -{ - return device_tree_for_each_node(fdt, node, - process_reserved_memory_node, - bootinfo_get_reserved_mem()); -} - -static void __init process_multiboot_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cell= s) -{ - static int __initdata kind_guess =3D 0; - const struct fdt_property *prop; - const __be32 *cell; - boot_module_kind kind; - paddr_t start, size; - int len; - /* sizeof("/chosen/") + DT_MAX_NAME + '/' + DT_MAX_NAME + '/0' =3D> 92= */ - char path[92]; - int parent_node, ret; - bool domU; - - parent_node =3D fdt_parent_offset(fdt, node); - ASSERT(parent_node >=3D 0); - - /* Check that the node is under "/chosen" (first 7 chars of path) */ - ret =3D fdt_get_path(fdt, node, path, sizeof (path)); - if ( ret !=3D 0 || strncmp(path, "/chosen", 7) ) - return; - - prop =3D fdt_get_property(fdt, node, "reg", &len); - if ( !prop ) - panic("node %s missing `reg' property\n", name); - - if ( len < dt_cells_to_size(address_cells + size_cells) ) - panic("fdt: node `%s': `reg` property length is too short\n", - name); - - cell =3D (const __be32 *)prop->data; - device_tree_get_reg(&cell, address_cells, size_cells, &start, &size); - - if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") =3D=3D 0= || - fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D=3D 0= ) - kind =3D BOOTMOD_KERNEL; - else if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") =3D= =3D 0 || - fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") = =3D=3D 0 ) - kind =3D BOOTMOD_RAMDISK; - else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") =3D= =3D 0 ) - kind =3D BOOTMOD_XSM; - else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree"= ) =3D=3D 0 ) - kind =3D BOOTMOD_GUEST_DTB; - else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") = =3D=3D 0 ) - kind =3D BOOTMOD_MICROCODE; - else - kind =3D BOOTMOD_UNKNOWN; - - /** - * Guess the kind of these first two unknowns respectively: - * (1) The first unknown must be kernel. - * (2) Detect the XSM Magic from the 2nd unknown: - * a. If it's XSM, set the kind as XSM, and that also means we - * won't load ramdisk; - * b. if it's not XSM, set the kind as ramdisk. - * So if user want to load ramdisk, it must be the 2nd unknown. - * We also detect the XSM Magic for the following unknowns, - * then set its kind according to the return value of has_xsm_magic. - */ - if ( kind =3D=3D BOOTMOD_UNKNOWN ) - { - switch ( kind_guess++ ) - { - case 0: kind =3D BOOTMOD_KERNEL; break; - case 1: kind =3D BOOTMOD_RAMDISK; break; - default: break; - } - if ( kind_guess > 1 && has_xsm_magic(start) ) - kind =3D BOOTMOD_XSM; - } - - domU =3D fdt_node_check_compatible(fdt, parent_node, "xen,domain") =3D= =3D 0; - add_boot_module(kind, start, size, domU); - - prop =3D fdt_get_property(fdt, node, "bootargs", &len); - if ( !prop ) - return; - add_boot_cmdline(fdt_get_name(fdt, parent_node, &len), prop->data, - kind, start, domU); -} - -static int __init process_chosen_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cells) -{ - const struct fdt_property *prop; - paddr_t start, end; - int len; - - if ( fdt_get_property(fdt, node, "xen,static-heap", NULL) ) - { - int rc; - - printk("Checking for static heap in /chosen\n"); - - rc =3D device_tree_get_meminfo(fdt, node, "xen,static-heap", - address_cells, size_cells, - bootinfo_get_reserved_mem(), - MEMBANK_STATIC_HEAP); - if ( rc ) - return rc; - - using_static_heap =3D true; - } - - printk("Checking for initrd in /chosen\n"); - - prop =3D fdt_get_property(fdt, node, "linux,initrd-start", &len); - if ( !prop ) - /* No initrd present. */ - return 0; - if ( len !=3D sizeof(u32) && len !=3D sizeof(u64) ) - { - printk("linux,initrd-start property has invalid length %d\n", len); - return -EINVAL; - } - start =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(le= n)); - - prop =3D fdt_get_property(fdt, node, "linux,initrd-end", &len); - if ( !prop ) - { - printk("linux,initrd-end not present but -start was\n"); - return -EINVAL; - } - if ( len !=3D sizeof(u32) && len !=3D sizeof(u64) ) - { - printk("linux,initrd-end property has invalid length %d\n", len); - return -EINVAL; - } - end =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(len)= ); - - if ( start >=3D end ) - { - printk("linux,initrd limits invalid: %"PRIpaddr" >=3D %"PRIpaddr"\= n", - start, end); - return -EINVAL; - } - - printk("Initrd %"PRIpaddr"-%"PRIpaddr"\n", start, end - 1); - - add_boot_module(BOOTMOD_RAMDISK, start, end-start, false); - - return 0; -} - -static int __init process_domain_node(const void *fdt, int node, - const char *name, - u32 address_cells, u32 size_cells) -{ - const struct fdt_property *prop; - - printk("Checking for \"xen,static-mem\" in domain node\n"); - - prop =3D fdt_get_property(fdt, node, "xen,static-mem", NULL); - if ( !prop ) - /* No "xen,static-mem" present. */ - return 0; - - return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_ce= lls, - size_cells, bootinfo_get_reserved_mem(), - MEMBANK_STATIC_DOMAIN); -} - -#ifndef CONFIG_STATIC_SHM -static inline int process_shm_node(const void *fdt, int node, - uint32_t address_cells, uint32_t size_c= ells) -{ - printk("CONFIG_STATIC_SHM must be enabled for parsing static shared" - " memory nodes\n"); - return -EINVAL; -} -#endif - -static int __init early_scan_node(const void *fdt, - int node, const char *name, int depth, - u32 address_cells, u32 size_cells, - void *data) +void __init device_tree_get_reg(const __be32 **cell, uint32_t address_cell= s, + uint32_t size_cells, paddr_t *start, + paddr_t *size) { - int rc =3D 0; + uint64_t dt_start, dt_size; =20 /* - * If Xen has been booted via UEFI, the memory banks are - * populated. So we should skip the parsing. + * dt_next_cell will return uint64_t whereas paddr_t may not be 64-bit. + * Thus, there is an implicit cast from uint64_t to paddr_t. */ - if ( !efi_enabled(EFI_BOOT) && - device_tree_is_memory_node(fdt, node, depth) ) - rc =3D process_memory_node(fdt, node, name, depth, - address_cells, size_cells, bootinfo_get_m= em()); - else if ( depth =3D=3D 1 && !dt_node_cmp(name, "reserved-memory") ) - rc =3D process_reserved_memory(fdt, node, name, depth, - address_cells, size_cells); - else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || - device_tree_node_compatible(fdt, node, "multiboot,module" ))) - process_multiboot_node(fdt, node, name, address_cells, size_cells); - else if ( depth =3D=3D 1 && device_tree_node_matches(fdt, node, "chose= n") ) - rc =3D process_chosen_node(fdt, node, name, address_cells, size_ce= lls); - else if ( depth =3D=3D 2 && device_tree_node_compatible(fdt, node, "xe= n,domain") ) - rc =3D process_domain_node(fdt, node, name, address_cells, size_ce= lls); - else if ( depth <=3D 3 && device_tree_node_compatible(fdt, node, "xen,= domain-shared-memory-v1") ) - rc =3D process_shm_node(fdt, node, address_cells, size_cells); - - if ( rc < 0 ) - printk("fdt: node `%s': parsing failed\n", name); - return rc; -} - -static void __init early_print_info(void) -{ - const struct membanks *mi =3D bootinfo_get_mem(); - const struct membanks *mem_resv =3D bootinfo_get_reserved_mem(); - struct boot_modules *mods =3D &bootinfo.modules; - struct bootcmdlines *cmds =3D &bootinfo.cmdlines; - unsigned int i; - - for ( i =3D 0; i < mi->nr_banks; i++ ) - printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", - mi->bank[i].start, - mi->bank[i].start + mi->bank[i].size - 1); - printk("\n"); - for ( i =3D 0 ; i < mods->nr_mods; i++ ) - printk("MODULE[%d]: %"PRIpaddr" - %"PRIpaddr" %-12s\n", - i, - mods->module[i].start, - mods->module[i].start + mods->module[i].size - 1, - boot_module_kind_as_string(mods->module[i].kind)); - - for ( i =3D 0; i < mem_resv->nr_banks; i++ ) - { - printk(" RESVD[%u]: %"PRIpaddr" - %"PRIpaddr"\n", i, - mem_resv->bank[i].start, - mem_resv->bank[i].start + mem_resv->bank[i].size - 1); - } -#ifdef CONFIG_STATIC_SHM - early_print_info_shmem(); -#endif - printk("\n"); - for ( i =3D 0 ; i < cmds->nr_mods; i++ ) - printk("CMDLINE[%"PRIpaddr"]:%s %s\n", cmds->cmdline[i].start, - cmds->cmdline[i].dt_name, - &cmds->cmdline[i].cmdline[0]); - printk("\n"); -} - -/* This function assumes that memory regions are not overlapped */ -static int __init cmp_memory_node(const void *key, const void *elem) -{ - const struct membank *handler0 =3D key; - const struct membank *handler1 =3D elem; - - if ( handler0->start < handler1->start ) - return -1; - - if ( handler0->start >=3D (handler1->start + handler1->size) ) - return 1; - - return 0; -} - -static void __init swap_memory_node(void *_a, void *_b, size_t size) -{ - struct membank *a =3D _a, *b =3D _b; - - SWAP(*a, *b); -} - -/** - * boot_fdt_info - initialize bootinfo from a DTB - * @fdt: flattened device tree binary - * - * Returns the size of the DTB. - */ -size_t __init boot_fdt_info(const void *fdt, paddr_t paddr) -{ - struct membanks *reserved_mem =3D bootinfo_get_reserved_mem(); - struct membanks *mem =3D bootinfo_get_mem(); - unsigned int i; - int nr_rsvd; - int ret; - - ret =3D fdt_check_header(fdt); - if ( ret < 0 ) - panic("No valid device tree\n"); - - add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); - - nr_rsvd =3D fdt_num_mem_rsv(fdt); - if ( nr_rsvd < 0 ) - panic("Parsing FDT memory reserve map failed (%d)\n", nr_rsvd); + dt_start =3D dt_next_cell(address_cells, cell); + dt_size =3D dt_next_cell(size_cells, cell); =20 - for ( i =3D 0; i < nr_rsvd; i++ ) + if ( dt_start !=3D (paddr_t)dt_start ) { - struct membank *bank; - paddr_t s, sz; - - if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &s, &sz) < 0 ) - continue; - - if ( reserved_mem->nr_banks < reserved_mem->max_banks ) - { - bank =3D &reserved_mem->bank[reserved_mem->nr_banks]; - bank->start =3D s; - bank->size =3D sz; - bank->type =3D MEMBANK_FDT_RESVMEM; - reserved_mem->nr_banks++; - } - else - panic("Cannot allocate reserved memory bank\n"); + printk("Physical address greater than max width supported\n"); + WARN(); } =20 - ret =3D device_tree_for_each_node(fdt, 0, early_scan_node, NULL); - if ( ret ) - panic("Early FDT parsing failed (%d)\n", ret); - - /* - * On Arm64 setup_directmap_mappings() expects to be called with the l= owest - * bank in memory first. There is no requirement that the DT will prov= ide - * the banks sorted in ascending order. So sort them through. - */ - sort(mem->bank, mem->nr_banks, sizeof(struct membank), - cmp_memory_node, swap_memory_node); - - early_print_info(); - - return fdt_totalsize(fdt); -} - -const __init char *boot_fdt_cmdline(const void *fdt) -{ - int node; - const struct fdt_property *prop; - - node =3D fdt_path_offset(fdt, "/chosen"); - if ( node < 0 ) - return NULL; - - prop =3D fdt_get_property(fdt, node, "xen,xen-bootargs", NULL); - if ( prop =3D=3D NULL ) + if ( dt_size !=3D (paddr_t)dt_size ) { - struct bootcmdline *dom0_cmdline =3D - boot_cmdline_find_by_kind(BOOTMOD_KERNEL); - - if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL) || - ( dom0_cmdline && dom0_cmdline->cmdline[0] ) ) - prop =3D fdt_get_property(fdt, node, "bootargs", NULL); + printk("Physical size greater than max width supported\n"); + WARN(); } - if ( prop =3D=3D NULL ) - return NULL; - - return prop->data; -} =20 -/* - * Wrapper to convert physical address from paddr_t to uint64_t and - * invoke fdt_begin_node(). This is required as the physical address - * provided as part of node name should not contain any leading - * zeroes. Thus, one should use PRIx64 (instead of PRIpaddr) to append - * unit (which contains the physical address) with name to generate a - * node name. - */ -int __init domain_fdt_begin_node(void *fdt, const char *name, uint64_t uni= t) -{ /* - * The size of the buffer to hold the longest possible string (i.e. - * interrupt-controller@ + a 64-bit number + \0). + * Xen will truncate the address/size if it is greater than the maximum + * supported width and it will give an appropriate warning. */ - char buf[38]; - int ret; - - /* ePAPR 3.4 */ - ret =3D snprintf(buf, sizeof(buf), "%s@%"PRIx64, name, unit); - - if ( ret >=3D sizeof(buf) ) - { - printk(XENLOG_ERR - "Insufficient buffer. Minimum size required is %d\n", - (ret + 1)); - - return -FDT_ERR_TRUNCATED; - } - - return fdt_begin_node(fdt, buf); + *start =3D dt_start; + *size =3D dt_size; } - -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree= /bootinfo-fdt.c new file mode 100644 index 0000000000..16036472f3 --- /dev/null +++ b/xen/common/device-tree/bootinfo-fdt.c @@ -0,0 +1,597 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Early Device Tree with bootinfo hooks + * + * Copyright (C) 2012-2014 Citrix Systems, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void __init __maybe_unused build_assertions(void) +{ + /* + * Check that no padding is between struct membanks "bank" flexible ar= ray + * member and struct meminfo "bank" member + */ + BUILD_BUG_ON((offsetof(struct membanks, bank) !=3D + offsetof(struct meminfo, bank))); + /* Ensure "struct membanks" and "struct membank" are equally aligned */ + BUILD_BUG_ON(alignof(struct membanks) !=3D alignof(struct membank)); +} + +static bool __init device_tree_node_is_available(const void *fdt, int node) +{ + const char *status; + int len; + + status =3D fdt_getprop(fdt, node, "status", &len); + if ( !status ) + return true; + + if ( len > 0 ) + { + if ( !strcmp(status, "ok") || !strcmp(status, "okay") ) + return true; + } + + return false; +} + +static bool __init device_tree_node_matches(const void *fdt, int node, + const char *match) +{ + const char *name; + size_t match_len; + + name =3D fdt_get_name(fdt, node, NULL); + match_len =3D strlen(match); + + /* Match both "match" and "match@..." patterns but not + "match-foo". */ + return strncmp(name, match, match_len) =3D=3D 0 + && (name[match_len] =3D=3D '@' || name[match_len] =3D=3D '\0'); +} + +static bool __init device_tree_node_compatible(const void *fdt, int node, + const char *match) +{ + int len, l; + const void *prop; + + prop =3D fdt_getprop(fdt, node, "compatible", &len); + if ( prop =3D=3D NULL ) + return false; + + while ( len > 0 ) { + if ( !dt_compat_cmp(prop, match) ) + return true; + l =3D strlen(prop) + 1; + prop +=3D l; + len -=3D l; + } + + return false; +} + +/* + * Check if a node is a proper /memory node according to Devicetree + * Specification v0.4, chapter 3.4. + */ +static bool __init device_tree_is_memory_node(const void *fdt, int node, + int depth) +{ + const char *type; + int len; + + if ( depth !=3D 1 ) + return false; + + if ( !device_tree_node_matches(fdt, node, "memory") ) + return false; + + type =3D fdt_getprop(fdt, node, "device_type", &len); + if ( !type ) + return false; + + if ( (len <=3D strlen("memory")) || strcmp(type, "memory") ) + return false; + + return true; +} + +static int __init device_tree_get_meminfo(const void *fdt, int node, + const char *prop_name, + u32 address_cells, u32 size_cell= s, + struct membanks *mem, + enum membank_type type) +{ + const struct fdt_property *prop; + unsigned int i, banks; + const __be32 *cell; + u32 reg_cells =3D address_cells + size_cells; + paddr_t start, size; + + if ( !device_tree_node_is_available(fdt, node) ) + return 0; + + if ( address_cells < 1 || size_cells < 1 ) + { + printk("fdt: property `%s': invalid #address-cells or #size-cells", + prop_name); + return -EINVAL; + } + + prop =3D fdt_get_property(fdt, node, prop_name, NULL); + if ( !prop ) + return -ENOENT; + + cell =3D (const __be32 *)prop->data; + banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); + + for ( i =3D 0; i < banks && mem->nr_banks < mem->max_banks; i++ ) + { + device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); + /* + * Some valid device trees, such as those generated by OpenPOWER + * skiboot firmware, expose all reserved memory regions in the + * FDT memory reservation block AND in the reserved-memory node wh= ich + * has already been parsed. Thus, any matching overlaps in the + * reserved_mem banks should be ignored. + */ + if ( mem =3D=3D bootinfo_get_reserved_mem() && + check_reserved_regions_overlap(start, size, true) ) + return -EINVAL; + /* Some DT may describe empty bank, ignore them */ + if ( !size ) + continue; + mem->bank[mem->nr_banks].start =3D start; + mem->bank[mem->nr_banks].size =3D size; + mem->bank[mem->nr_banks].type =3D type; + mem->nr_banks++; + } + + if ( i < banks ) + { + printk("Warning: Max number of supported memory regions reached.\n= "); + return -ENOSPC; + } + + return 0; +} + +static int __init process_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cells, + struct membanks *mem) +{ + return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, + mem, MEMBANK_DEFAULT); +} + +static int __init process_reserved_memory_node(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, + u32 size_cells, + void *data) +{ + int rc =3D process_memory_node(fdt, node, name, depth, address_cells, + size_cells, data); + + if ( rc =3D=3D -ENOSPC ) + panic("Max number of supported reserved-memory regions reached.\n"= ); + else if ( rc !=3D -ENOENT ) + return rc; + return 0; +} + +static int __init process_reserved_memory(const void *fdt, int node, + const char *name, int depth, + u32 address_cells, u32 size_cell= s) +{ + return device_tree_for_each_node(fdt, node, + process_reserved_memory_node, + bootinfo_get_reserved_mem()); +} + +static void __init process_multiboot_node(const void *fdt, int node, + const char *name, + u32 address_cells, u32 size_cell= s) +{ + static int __initdata kind_guess =3D 0; + const struct fdt_property *prop; + const __be32 *cell; + boot_module_kind kind; + paddr_t start, size; + int len; + /* sizeof("/chosen/") + DT_MAX_NAME + '/' + DT_MAX_NAME + '/0' =3D> 92= */ + char path[92]; + int parent_node, ret; + bool domU; + + parent_node =3D fdt_parent_offset(fdt, node); + ASSERT(parent_node >=3D 0); + + /* Check that the node is under "/chosen" (first 7 chars of path) */ + ret =3D fdt_get_path(fdt, node, path, sizeof (path)); + if ( ret !=3D 0 || strncmp(path, "/chosen", 7) ) + return; + + prop =3D fdt_get_property(fdt, node, "reg", &len); + if ( !prop ) + panic("node %s missing `reg' property\n", name); + + if ( len < dt_cells_to_size(address_cells + size_cells) ) + panic("fdt: node `%s': `reg` property length is too short\n", + name); + + cell =3D (const __be32 *)prop->data; + device_tree_get_reg(&cell, address_cells, size_cells, &start, &size); + + if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") =3D=3D 0= || + fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D=3D 0= ) + kind =3D BOOTMOD_KERNEL; + else if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") =3D= =3D 0 || + fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") = =3D=3D 0 ) + kind =3D BOOTMOD_RAMDISK; + else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") =3D= =3D 0 ) + kind =3D BOOTMOD_XSM; + else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree"= ) =3D=3D 0 ) + kind =3D BOOTMOD_GUEST_DTB; + else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") = =3D=3D 0 ) + kind =3D BOOTMOD_MICROCODE; + else + kind =3D BOOTMOD_UNKNOWN; + + /** + * Guess the kind of these first two unknowns respectively: + * (1) The first unknown must be kernel. + * (2) Detect the XSM Magic from the 2nd unknown: + * a. If it's XSM, set the kind as XSM, and that also means we + * won't load ramdisk; + * b. if it's not XSM, set the kind as ramdisk. + * So if user want to load ramdisk, it must be the 2nd unknown. + * We also detect the XSM Magic for the following unknowns, + * then set its kind according to the return value of has_xsm_magic. + */ + if ( kind =3D=3D BOOTMOD_UNKNOWN ) + { + switch ( kind_guess++ ) + { + case 0: kind =3D BOOTMOD_KERNEL; break; + case 1: kind =3D BOOTMOD_RAMDISK; break; + default: break; + } + if ( kind_guess > 1 && has_xsm_magic(start) ) + kind =3D BOOTMOD_XSM; + } + + domU =3D fdt_node_check_compatible(fdt, parent_node, "xen,domain") =3D= =3D 0; + add_boot_module(kind, start, size, domU); + + prop =3D fdt_get_property(fdt, node, "bootargs", &len); + if ( !prop ) + return; + add_boot_cmdline(fdt_get_name(fdt, parent_node, &len), prop->data, + kind, start, domU); +} + +static int __init process_chosen_node(const void *fdt, int node, + const char *name, + u32 address_cells, u32 size_cells) +{ + const struct fdt_property *prop; + paddr_t start, end; + int len; + + if ( fdt_get_property(fdt, node, "xen,static-heap", NULL) ) + { + int rc; + + printk("Checking for static heap in /chosen\n"); + + rc =3D device_tree_get_meminfo(fdt, node, "xen,static-heap", + address_cells, size_cells, + bootinfo_get_reserved_mem(), + MEMBANK_STATIC_HEAP); + if ( rc ) + return rc; + + using_static_heap =3D true; + } + + printk("Checking for initrd in /chosen\n"); + + prop =3D fdt_get_property(fdt, node, "linux,initrd-start", &len); + if ( !prop ) + /* No initrd present. */ + return 0; + if ( len !=3D sizeof(u32) && len !=3D sizeof(u64) ) + { + printk("linux,initrd-start property has invalid length %d\n", len); + return -EINVAL; + } + start =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(le= n)); + + prop =3D fdt_get_property(fdt, node, "linux,initrd-end", &len); + if ( !prop ) + { + printk("linux,initrd-end not present but -start was\n"); + return -EINVAL; + } + if ( len !=3D sizeof(u32) && len !=3D sizeof(u64) ) + { + printk("linux,initrd-end property has invalid length %d\n", len); + return -EINVAL; + } + end =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(len)= ); + + if ( start >=3D end ) + { + printk("linux,initrd limits invalid: %"PRIpaddr" >=3D %"PRIpaddr"\= n", + start, end); + return -EINVAL; + } + + printk("Initrd %"PRIpaddr"-%"PRIpaddr"\n", start, end - 1); + + add_boot_module(BOOTMOD_RAMDISK, start, end-start, false); + + return 0; +} + +static int __init process_domain_node(const void *fdt, int node, + const char *name, + u32 address_cells, u32 size_cells) +{ + const struct fdt_property *prop; + + printk("Checking for \"xen,static-mem\" in domain node\n"); + + prop =3D fdt_get_property(fdt, node, "xen,static-mem", NULL); + if ( !prop ) + /* No "xen,static-mem" present. */ + return 0; + + return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_ce= lls, + size_cells, bootinfo_get_reserved_mem(), + MEMBANK_STATIC_DOMAIN); +} + +#ifndef CONFIG_STATIC_SHM +static inline int process_shm_node(const void *fdt, int node, + uint32_t address_cells, uint32_t size_c= ells) +{ + printk("CONFIG_STATIC_SHM must be enabled for parsing static shared" + " memory nodes\n"); + return -EINVAL; +} +#endif + +static int __init early_scan_node(const void *fdt, + int node, const char *name, int depth, + u32 address_cells, u32 size_cells, + void *data) +{ + int rc =3D 0; + + /* + * If Xen has been booted via UEFI, the memory banks are + * populated. So we should skip the parsing. + */ + if ( !efi_enabled(EFI_BOOT) && + device_tree_is_memory_node(fdt, node, depth) ) + rc =3D process_memory_node(fdt, node, name, depth, + address_cells, size_cells, bootinfo_get_m= em()); + else if ( depth =3D=3D 1 && !dt_node_cmp(name, "reserved-memory") ) + rc =3D process_reserved_memory(fdt, node, name, depth, + address_cells, size_cells); + else if ( depth <=3D 3 && (device_tree_node_compatible(fdt, node, "xen= ,multiboot-module" ) || + device_tree_node_compatible(fdt, node, "multiboot,module" ))) + process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( depth =3D=3D 1 && device_tree_node_matches(fdt, node, "chose= n") ) + rc =3D process_chosen_node(fdt, node, name, address_cells, size_ce= lls); + else if ( depth =3D=3D 2 && device_tree_node_compatible(fdt, node, "xe= n,domain") ) + rc =3D process_domain_node(fdt, node, name, address_cells, size_ce= lls); + else if ( depth <=3D 3 && device_tree_node_compatible(fdt, node, "xen,= domain-shared-memory-v1") ) + rc =3D process_shm_node(fdt, node, address_cells, size_cells); + + if ( rc < 0 ) + printk("fdt: node `%s': parsing failed\n", name); + return rc; +} + +static void __init early_print_info(void) +{ + const struct membanks *mi =3D bootinfo_get_mem(); + const struct membanks *mem_resv =3D bootinfo_get_reserved_mem(); + struct boot_modules *mods =3D &bootinfo.modules; + struct bootcmdlines *cmds =3D &bootinfo.cmdlines; + unsigned int i; + + for ( i =3D 0; i < mi->nr_banks; i++ ) + printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", + mi->bank[i].start, + mi->bank[i].start + mi->bank[i].size - 1); + printk("\n"); + for ( i =3D 0 ; i < mods->nr_mods; i++ ) + printk("MODULE[%d]: %"PRIpaddr" - %"PRIpaddr" %-12s\n", + i, + mods->module[i].start, + mods->module[i].start + mods->module[i].size - 1, + boot_module_kind_as_string(mods->module[i].kind)); + + for ( i =3D 0; i < mem_resv->nr_banks; i++ ) + { + printk(" RESVD[%u]: %"PRIpaddr" - %"PRIpaddr"\n", i, + mem_resv->bank[i].start, + mem_resv->bank[i].start + mem_resv->bank[i].size - 1); + } +#ifdef CONFIG_STATIC_SHM + early_print_info_shmem(); +#endif + printk("\n"); + for ( i =3D 0 ; i < cmds->nr_mods; i++ ) + printk("CMDLINE[%"PRIpaddr"]:%s %s\n", cmds->cmdline[i].start, + cmds->cmdline[i].dt_name, + &cmds->cmdline[i].cmdline[0]); + printk("\n"); +} + +/* This function assumes that memory regions are not overlapped */ +static int __init cmp_memory_node(const void *key, const void *elem) +{ + const struct membank *handler0 =3D key; + const struct membank *handler1 =3D elem; + + if ( handler0->start < handler1->start ) + return -1; + + if ( handler0->start >=3D (handler1->start + handler1->size) ) + return 1; + + return 0; +} + +static void __init swap_memory_node(void *_a, void *_b, size_t size) +{ + struct membank *a =3D _a, *b =3D _b; + + SWAP(*a, *b); +} + +/** + * boot_fdt_info - initialize bootinfo from a DTB + * @fdt: flattened device tree binary + * + * Returns the size of the DTB. + */ +size_t __init boot_fdt_info(const void *fdt, paddr_t paddr) +{ + struct membanks *reserved_mem =3D bootinfo_get_reserved_mem(); + struct membanks *mem =3D bootinfo_get_mem(); + unsigned int i; + int nr_rsvd; + int ret; + + ret =3D fdt_check_header(fdt); + if ( ret < 0 ) + panic("No valid device tree\n"); + + add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); + + nr_rsvd =3D fdt_num_mem_rsv(fdt); + if ( nr_rsvd < 0 ) + panic("Parsing FDT memory reserve map failed (%d)\n", nr_rsvd); + + for ( i =3D 0; i < nr_rsvd; i++ ) + { + struct membank *bank; + paddr_t s, sz; + + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &s, &sz) < 0 ) + continue; + + if ( reserved_mem->nr_banks < reserved_mem->max_banks ) + { + bank =3D &reserved_mem->bank[reserved_mem->nr_banks]; + bank->start =3D s; + bank->size =3D sz; + bank->type =3D MEMBANK_FDT_RESVMEM; + reserved_mem->nr_banks++; + } + else + panic("Cannot allocate reserved memory bank\n"); + } + + ret =3D device_tree_for_each_node(fdt, 0, early_scan_node, NULL); + if ( ret ) + panic("Early FDT parsing failed (%d)\n", ret); + + /* + * On Arm64 setup_directmap_mappings() expects to be called with the l= owest + * bank in memory first. There is no requirement that the DT will prov= ide + * the banks sorted in ascending order. So sort them through. + */ + sort(mem->bank, mem->nr_banks, sizeof(struct membank), + cmp_memory_node, swap_memory_node); + + early_print_info(); + + return fdt_totalsize(fdt); +} + +const __init char *boot_fdt_cmdline(const void *fdt) +{ + int node; + const struct fdt_property *prop; + + node =3D fdt_path_offset(fdt, "/chosen"); + if ( node < 0 ) + return NULL; + + prop =3D fdt_get_property(fdt, node, "xen,xen-bootargs", NULL); + if ( prop =3D=3D NULL ) + { + struct bootcmdline *dom0_cmdline =3D + boot_cmdline_find_by_kind(BOOTMOD_KERNEL); + + if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL) || + ( dom0_cmdline && dom0_cmdline->cmdline[0] ) ) + prop =3D fdt_get_property(fdt, node, "bootargs", NULL); + } + if ( prop =3D=3D NULL ) + return NULL; + + return prop->data; +} + +/* + * Wrapper to convert physical address from paddr_t to uint64_t and + * invoke fdt_begin_node(). This is required as the physical address + * provided as part of node name should not contain any leading + * zeroes. Thus, one should use PRIx64 (instead of PRIpaddr) to append + * unit (which contains the physical address) with name to generate a + * node name. + */ +int __init domain_fdt_begin_node(void *fdt, const char *name, uint64_t uni= t) +{ + /* + * The size of the buffer to hold the longest possible string (i.e. + * interrupt-controller@ + a 64-bit number + \0). + */ + char buf[38]; + int ret; + + /* ePAPR 3.4 */ + ret =3D snprintf(buf, sizeof(buf), "%s@%"PRIx64, name, unit); + + if ( ret >=3D sizeof(buf) ) + { + printk(XENLOG_ERR + "Insufficient buffer. Minimum size required is %d\n", + (ret + 1)); + + return -FDT_ERR_TRUNCATED; + } + + return fdt_begin_node(fdt, buf); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367484; cv=pass; d=zohomail.com; s=zohoarc; b=anQ4OSfWFFb+VIRBAXHztYJxbuvcXQPeJVbogaKvogc1yUhy1jdcCmB9nqmBAJvgnlmU66ddvH1mEILGQGwd1cCO1Z+9iHHYsNu55IYqoVuvOmzmBqVFqvqt1SiEr/n+JJcZSXj2F1qSa0emNHF4cPrpHf4v0TBrbf8QiN+ktl0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367484; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zd2eubkDW8FKsjdHvMt4efYEdWC1FtbTeDT9SBTH9xo=; b=nIaCoxF919AxIxn4NHnstlIu1yEa9R81XncLIA4wcBFl8uanEYzvv+sYxtTmrbsmhqWuA2DQWxAmEeSkO/PG1yhV0mVZ5LZyvmgXCX6zbsUyZU3wE3BcbxYvSOaJDQytS8O+XGHZlLji+DD4M/loHotaziVlF6xv3rd8//ZHB38= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367484251119.77776924342345; Tue, 1 Jul 2025 03:58:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029526.1403334 (Exim 4.92) (envelope-from ) id 1uWYgO-0004RL-L4; Tue, 01 Jul 2025 10:57:48 +0000 Received: by outflank-mailman (output) from mailman id 1029526.1403334; Tue, 01 Jul 2025 10:57:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgO-0004Qf-Gh; Tue, 01 Jul 2025 10:57:48 +0000 Received: by outflank-mailman (input) for mailman id 1029526; Tue, 01 Jul 2025 10:57:46 +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 1uWYgM-0002T2-F2 for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:46 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060c.outbound.protection.outlook.com [2a01:111:f403:2416::60c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 36a81716-566a-11f0-b894-0df219b8e170; Tue, 01 Jul 2025 12:57:44 +0200 (CEST) Received: from BL0PR02CA0132.namprd02.prod.outlook.com (2603:10b6:208:35::37) by IA1PR12MB8223.namprd12.prod.outlook.com (2603:10b6:208:3f3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.32; Tue, 1 Jul 2025 10:57:40 +0000 Received: from BN2PEPF00004FBF.namprd04.prod.outlook.com (2603:10b6:208:35:cafe::95) by BL0PR02CA0132.outlook.office365.com (2603:10b6:208:35::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.30 via Frontend Transport; Tue, 1 Jul 2025 10:57:40 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBF.mail.protection.outlook.com (10.167.243.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:39 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57: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: 36a81716-566a-11f0-b894-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qh9u1Jwc4C3bRBh1iF3TQjHfXijiDa1nMnlpWecYcfqlbgKMHeHFYqodO2KlURTMEjYqIJ72vt9APFNAclmIaEVAJYCSLJO37ONBZ09GlmoVOb8gWNJ1lZJz0QT6pzQiIQduNsF6VdhxRAJeltdpZOGWDx4DjdBLojbnw3CwshVUtHEGgrtC1RJp40DxfHOv1Je1RWHJprPsdWL/tH9BjUFdY4opD+jROdfeMAY6xF8dTSqWwZkJ949xyzkP3nmfPhqNaZ+rZnzc5XeW6JPvolOwItw6dQF8t50/GnbW5Sdlf3IvcZHCooTdOMgE/8DNyHndPg9y7mH7bBhmf5663g== 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=zd2eubkDW8FKsjdHvMt4efYEdWC1FtbTeDT9SBTH9xo=; b=PSOMX9r5FhOT7V5/b54TQ0REaycwbySda3urzVaS2ApHTwHy5DQXXZ3eu3zbbIoIKooI/Qtx7oaeKH5OVLQSzZUHLeBc9oQ5nV3n5oPC+H+R090znCRtcftOK7PmZuy7DhnL6RdPoxjah0CmW3zcn9N1IWcIqPkW64HnKAsd7egeZ2wUjClGry5kLhM2LsbZVFa6rFQjde1sXTPb4hXVt7fEWJ7RocJg3qxvaWwgxmxCB1WpS//66x7b3RyZ050VVueHC8SccBReA2GwDeNlvPPxNN0v0GxW2Es78Yi2uC/lUCn0D2fMOZTFYmVKxq0x33AFMBKEVskLrV06zfH0RA== 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=zd2eubkDW8FKsjdHvMt4efYEdWC1FtbTeDT9SBTH9xo=; b=yPzEKXaMrboGRl6SRFy13O6ioy7hUK8SkxWQycrsFsJAyiYKKCGd5fjCunEEzXFvYOfMam2HxAacgrpTgGcxD/VR/TM53kzCTqS09IgsV+901bCoq+TjPKFO3GNCs//1haG2BJpil+VfOE7JpW4xaOGOPKtGMgmHUJ2hlBdpHz8= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Daniel P. Smith" Subject: [PATCH v5 07/10] xen/dt: Extract helper to map nodes to module kinds Date: Tue, 1 Jul 2025 12:57:01 +0200 Message-ID: <20250701105706.86133-8-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBF:EE_|IA1PR12MB8223:EE_ X-MS-Office365-Filtering-Correlation-Id: a52b7ae1-fb37-4843-b829-08ddb88e18d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?i27pIkfvseXJHNxF5qByAGYJA5fuwQSUFkN7fwbuBdNqmji720BdYKhE0x8m?= =?us-ascii?Q?K9scY8+1YECBDcf05D06UjngWpQsNOziD1fhq7JAY5kAy3iexv+eXew4LsUr?= =?us-ascii?Q?N1cmLCB2qS++lmpH8HSexp6YhRYGoPKBdrJAcF3s5ePrIWIK1qyuf8w8F3AR?= =?us-ascii?Q?hvo2iQqyc7Gyps7jZ5sGzuI3USGd/JM+0dgts5QmwzJuzeaBSVaWMAy7Jquq?= =?us-ascii?Q?5j/0U1FQ2iQeX9VNs3xmdPhZsrAZ0NJ6kh9HxF/CBY4Lg0jVSVGOUvEOb2uD?= =?us-ascii?Q?qEsgBHhL4hPYCL1LMhSTskYOkAkHlRqS6MnrVYjrldUZftOxNIG6ARsZ9i5l?= =?us-ascii?Q?TLlWwXRcXh0S3iyNHQ7+CTSpyD9nOFWU89Xh2/wv/bsj2JBgAdaCb9u+Jwj5?= =?us-ascii?Q?l0fzopQNAfMB5hTEsb/0EShoj0qcdUk5PZl+jJjkigOxN/DXB06DjjTdaGaW?= =?us-ascii?Q?94BlGras+yVPHLnXUBr61swO1QADyveJfRjJpd0fNjUSw91ztECOYSdqQxwl?= =?us-ascii?Q?RI1Gcup0BwOp+th8JeVcvv7UeQ0c92jN0nXlBu41u4pkwupHmdqC2WJ+0qde?= =?us-ascii?Q?hOMBeIeQ5p1GSNVXcICr/fQ/s/y1bdGqxx9QcqC4kQPAD4JKNL/irS/0L34d?= =?us-ascii?Q?kMR4VICMDAV787JJnqM2j7AE7oXCPAiu2sYuusm8e5vMA8clIRWfIpO6ekiu?= =?us-ascii?Q?fnZIY2/CtSyVEK/acn9jx/DAWnISKy2MGtpgnKdLI103PYZq31tiufJm6J6h?= =?us-ascii?Q?vcxTiorjk2uO9X2fDvVhdNIkDDhUtvLa9s6mQ8/ciEcw/NXHpNuCdKvGp/g6?= =?us-ascii?Q?arHUZLC8KavXNHA2SRYKQRfqCUBRLoG+QTLAxTGV2199qkUJQ90dy4CD1Zqt?= =?us-ascii?Q?vnYDMvh/x8V85BUbtZs/zU/hREyJyTC59TZwparKQWeQJtghDEXgbzZQqe1J?= =?us-ascii?Q?hY0bpDUglDpBz27arqnaoC8szPFL01FA2i079qnLalR9ZcNnC4eBWV9Y5Vhr?= =?us-ascii?Q?MBJHNPQmW5MmeqpgYshjRR5TD0zIgfWrSZNVcq/5lxGW+nFgQ0xAUuhNDPNg?= =?us-ascii?Q?3/8kkTBTAnEV+MJQQ+Bi/RnpYbs4RnJMZTg3M06EFPeb8mZ+JyMya/pjCplZ?= =?us-ascii?Q?BF3XPba41NQSUIdr5da6w3svh/bW1T7uD4U1n7U40h+ry28+0eIwFi8G0KOp?= =?us-ascii?Q?oG6SvAm5gx4rwEUZVOj7CAa03onQ4ygeFKN1a4+MdnnDmSbchH629FuorhXq?= =?us-ascii?Q?ejXHANY8uBPu+G0MGEFAx0LENJe+mBPdoBw7ymeVkFJfN2e9VhveVQv4IbEv?= =?us-ascii?Q?0i6gGCtEVu/+xIdAh2YhKIkNe8eAqYFMGh7+ympUL7NHlHVDFl/zXTPqE8AC?= =?us-ascii?Q?6Th7A+8sjPZhEwluWxjJfeGCxzMZLrBfz+dThXOwzqxribn4/sHXZzIe6j2g?= =?us-ascii?Q?ktGdVpa/L1+jxv1Hoj9ZPUTwBQm9F1PKaZNM3Zh9+rGrUFuCHsuHq7C+eHfI?= =?us-ascii?Q?lGJGwYLlfFx2vw9fvCozDWl+6jvpFve0XzLy?= 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)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:39.7524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a52b7ae1-fb37-4843-b829-08ddb88e18d4 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: BN2PEPF00004FBF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8223 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367485661116600 Content-Type: text/plain; charset="utf-8" This will be required later by x86 code in order to do early identification of boot modules when booting off a DTB. Not a functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- xen/common/device-tree/bootfdt.c | 18 ++++++++++++++++++ xen/common/device-tree/bootinfo-fdt.c | 16 +--------------- xen/include/xen/bootfdt.h | 7 +++++++ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/boot= fdt.c index 0d8d9ea357..8218c0a10b 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -4,6 +4,24 @@ #include #include =20 +boot_module_kind __init fdt_node_to_kind(const void *fdt, int node) +{ + if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") =3D=3D 0= || + fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D=3D 0= ) + return BOOTMOD_KERNEL; + if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") =3D=3D 0= || + fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") =3D=3D = 0 ) + return BOOTMOD_RAMDISK; + if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") =3D=3D 0 ) + return BOOTMOD_XSM; + if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") =3D= =3D 0 ) + return BOOTMOD_GUEST_DTB; + if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") =3D= =3D 0 ) + return BOOTMOD_MICROCODE; + + return BOOTMOD_UNKNOWN; +} + u32 __init device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt) { diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree= /bootinfo-fdt.c index 16036472f3..9b426c0a98 100644 --- a/xen/common/device-tree/bootinfo-fdt.c +++ b/xen/common/device-tree/bootinfo-fdt.c @@ -236,21 +236,7 @@ static void __init process_multiboot_node(const void *= fdt, int node, =20 cell =3D (const __be32 *)prop->data; device_tree_get_reg(&cell, address_cells, size_cells, &start, &size); - - if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") =3D=3D 0= || - fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D=3D 0= ) - kind =3D BOOTMOD_KERNEL; - else if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") =3D= =3D 0 || - fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") = =3D=3D 0 ) - kind =3D BOOTMOD_RAMDISK; - else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") =3D= =3D 0 ) - kind =3D BOOTMOD_XSM; - else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree"= ) =3D=3D 0 ) - kind =3D BOOTMOD_GUEST_DTB; - else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") = =3D=3D 0 ) - kind =3D BOOTMOD_MICROCODE; - else - kind =3D BOOTMOD_UNKNOWN; + kind =3D fdt_node_to_kind(fdt, node); =20 /** * Guess the kind of these first two unknowns respectively: diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index ad6b11cb6d..bc5fc995b0 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -143,4 +143,11 @@ u32 device_tree_get_u32(const void *fdt, int node, void device_tree_get_reg(const __be32 **cell, uint32_t address_cells, uint32_t size_cells, paddr_t *start, paddr_t *siz= e); =20 +/* + * Probe an FDT node thought to be a boot module to identify its kind. + * + * If correctly identified, returns the detected kind, otherwise BOOTMOD_U= NKNOWN + */ +boot_module_kind fdt_node_to_kind(const void *fdt, int node); + #endif /* XEN_BOOTFDT_H */ --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367491; cv=pass; d=zohomail.com; s=zohoarc; b=Tr/AJ6hGVVsM+wU769YNvI+5RzL7sxi5kMHy7kwHgnNo4NtywWYHB4WrjsE6xRmxuFj5wv3qMVjfCXWHloEPRer9LWGN8kG0jrKZl3+C59GlapWYUQEYyq3aatPdBW1YCU0Aug9SavVLe9nB0ISCUCB57nPeY6oTcTPcHj5bj9I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367491; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tuT5auniBWBe3EbEVSn/wjfpq4lUcqLO+iI/reuhCbI=; b=T61ycf57ZShdnc/bMu8R4TP592AoJ6qcCRtBdKHdQgYr62ATZOasU3LexVePVMjiRvAw4kJGPkJK5jgIYUbICMfVR0BtOq09zm5EJuflPiCr2DCue/pxOr3LBO6YPplWtMPHGdPFBfYutnEE1OK5afxaTAp2uaDIj9PMoiPqDMg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367491132710.6690873289629; Tue, 1 Jul 2025 03:58:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029536.1403355 (Exim 4.92) (envelope-from ) id 1uWYgW-0005VY-EU; Tue, 01 Jul 2025 10:57:56 +0000 Received: by outflank-mailman (output) from mailman id 1029536.1403355; Tue, 01 Jul 2025 10:57:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgW-0005V7-96; Tue, 01 Jul 2025 10:57:56 +0000 Received: by outflank-mailman (input) for mailman id 1029536; Tue, 01 Jul 2025 10:57:54 +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 1uWYgU-0002T2-DW for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:54 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062c.outbound.protection.outlook.com [2a01:111:f403:200a::62c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3add9fc2-566a-11f0-b894-0df219b8e170; Tue, 01 Jul 2025 12:57:51 +0200 (CEST) Received: from BN9PR03CA0293.namprd03.prod.outlook.com (2603:10b6:408:f5::28) by DM3PR12MB9327.namprd12.prod.outlook.com (2603:10b6:0:42::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.29; Tue, 1 Jul 2025 10:57:44 +0000 Received: from BN2PEPF00004FBB.namprd04.prod.outlook.com (2603:10b6:408:f5:cafe::c9) by BN9PR03CA0293.outlook.office365.com (2603:10b6:408:f5::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8880.29 via Frontend Transport; Tue, 1 Jul 2025 10:57:44 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBB.mail.protection.outlook.com (10.167.243.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:44 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:39 -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: 3add9fc2-566a-11f0-b894-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qfDNlIYz1OEgo38VOuqqLGEud+SLBTXNRJvweZ/3qyKYo33DOzjV4l1h4cb/bBNoWjijzQW9YKGhYdRwXINVkX6VGyvyCrjCg1ee0taOUMY5V5d9kL+0ZHbXJ573XeXJYCsJtANJsgjEuAh/q51JMamRXJsWjJdasiupih1yiyAiQxnEZCgf3HXqbgKfMwfoSWaQUp0PeCXL/ObIAOrfVxMy/p+FvRk5noAu2IxU3FlWjdjyKqrMYjcRYgLAcD6MpzA1lJTG5ji34Xqi19F560lhNNw3ARET/362+DAI+8mE/dNdm+opFtizCke/ztygqk2dt4mPFCGoQhFkFWKATQ== 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=tuT5auniBWBe3EbEVSn/wjfpq4lUcqLO+iI/reuhCbI=; b=X/3wz47KC9pvIXaLOMy7OHkGQAJsUCg6o0KM4BC313bVmEKUnDMeXHdhdfEu1xMht4pqylx306eZx8LD1GFACSDcfdFBp7sA62I9NUh3EFExdypKTXvuqfr0yC9vejMO45ZmhY4wDN1EOKp0M3DxriYhvL2QiuntlxVDTzO7KQ4rea/eU6Q/TeekK/TodROYKE+6lMSBvcuhKlpkgnmjI1TfgoHk4vrzL5f+nclML0Hnmg/6I4E0rMIJcMpK1pw7+h640sz85Lwum1KR6FFWqEbdiU5+A6xAsTkImeGD9yt9wegkUfrVztwo+CoiLh2yv8tuukCOEpCNGCBhwtWW0g== 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=tuT5auniBWBe3EbEVSn/wjfpq4lUcqLO+iI/reuhCbI=; b=DxyED2fHobxVOZ66VpXSZH8YiH8YZDDPZuvV0g4L1L/Txvw10iSed74yisgoMH6+IIJgf/1VAJLAf8STKO1fbugjDgcUpGKwrs44hO4djmu8WcVYBkgMr7lRu9SrXqwHiATWxwN6pPzWaHyUE6UqmubS6KSSj333hIsqHEGXlvI= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , "Bertrand Marquis" , Volodymyr Babchuk , Shawn Anastasio , Alistair Francis , Bob Eshleman , "Connor Davis" , Oleksii Kurochko , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Dario Faggioli , Juergen Gross , George Dunlap Subject: [PATCH v5 08/10] xen: Split HAS_DEVICE_TREE in two Date: Tue, 1 Jul 2025 12:57:02 +0200 Message-ID: <20250701105706.86133-9-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBB:EE_|DM3PR12MB9327:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b43eaad-aeb7-429d-bc43-08ddb88e1bd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9Qi5CMsHy1JVT2WAP7eRktqiG26we7SpDzijH72DnjE1uA6YzWzOzHgXwb7U?= =?us-ascii?Q?2Rgpoh6fYVh8pRsSoOexSRdFptehvs7J9LBX/LxyxrCH7XDoz8ti26EPBikw?= =?us-ascii?Q?/v74SoovdRokdbkqXlkidYk/jj3YfCFv9ervnKXVgSoG4i7D+87PdWHIf9Cb?= =?us-ascii?Q?sSHx907JWLnoow1jHt8zeBGIwcYhKhbD4SKbSBB6Fd3SLS/4btjdouoQELzG?= =?us-ascii?Q?r1Jw9jowR491RI8cTPpn6JWbVIY3BocCLCek5KjBx4x89YZ6/zNmVB45907q?= =?us-ascii?Q?R0PdsZjNubENeJpdUcgNR/9zEGynZM9h7R+mBI1RZfqXQjN/JYJjsbx0UOlE?= =?us-ascii?Q?mQYYF2tMBYg0b+Z43m5SF0ccESiVMRHJ1mNRmhAjYkvDsdHYrBfVfb99LjGU?= =?us-ascii?Q?JJsmr8zg67dTZ3ddENycR2r+ldNochazUfZFh+xNaqr90ZgJlTan/CofaN9x?= =?us-ascii?Q?WVyeLXFxtUBNT+OqgtXpK6KEv+Pfzab1HYp0J+2bSqulVMu01asiyAh//2Z2?= =?us-ascii?Q?7quO5QT4XG39vg9pUlxPk8RGNkBzN8p1FictcPV6iqvsu5eZjRVa6KuJvLhr?= =?us-ascii?Q?dAO2PPxetZCzJxi7M46EziQFLLvQmXQhXc5WgKsxFZZRVkn302ABhiZp3/z5?= =?us-ascii?Q?FykC5NLYzkoC+tdsNM3a0lyyEn37uErAZXG3iLz26FJKwfh6t88n3uoOXNi0?= =?us-ascii?Q?7uxdtyiRSs/nmeQm3/OTC3m1VzaH8ZCimXS0vXWIeula7iOFizvqqWTQJ5BE?= =?us-ascii?Q?YNSipAp6LQ0QWq7CqRVVnGi/g8oSjQGsXKpbsTprnsSSW+Emu8+WAgwsRJG2?= =?us-ascii?Q?MmjjDRhXZ9KApYi5bWv1wG+7t5/Exyg5pJ9KEu/OpXrK6WjlPhXU8bT4/3W9?= =?us-ascii?Q?K5E/zEf9+oIsYtW7DDMnN/dUKrUjATk3GinsFP9vwjmZu40ac+LY9d6ExABc?= =?us-ascii?Q?VqtspxhpwJZroqs3kh9gfRemE806SwnajesWNG/QOr1HZG6XhSqlV2JVmwh7?= =?us-ascii?Q?n7ae2/wqywCVmG4c0Z/etZYduUMXbJGRHJ4vrdR8keFdZBwj41Aim9ejh/a/?= =?us-ascii?Q?YL/Qo+F8eSesAKM0qijgRKU0HqFFr0N3yMXCvGC/8nr0UmzbSohiVG87lVBG?= =?us-ascii?Q?K1EHuPdNJINvGhr7phQaFzU/hpjLsmGoAGyCai6u4uFgwDDMUk1hLJTqlhua?= =?us-ascii?Q?0AKxCePxju55eqOObZPOXZ0jDkPIbJGRbyKf5G9URBNsvCxlWLZPnBMUMYZh?= =?us-ascii?Q?1m7PwwU0nE6UMpFklb9S5HS1GAAxL9kEVt9G2raMejPJkb9VJFgskwzhYEmK?= =?us-ascii?Q?0Eiv+ebUQsOVgaBbnhP/WNUX7EEhTSnDBmyk6DBd1iMS17pcrTnuqrvp24C/?= =?us-ascii?Q?A3xA5YRLF27h1S7HcG6Mm3XJHvszvaOiADunCy8S1CLcpcp7HrMgXyI3/P1Q?= =?us-ascii?Q?mcEFUbFRuwBkHpwmJUZd2LUzImTqG6ojJ2LFdIN0KMWmKuuB0AXpXf8WOO+7?= =?us-ascii?Q?uqhBYU5e2Drsxc96T9prPcyK+Fjvl57wp6hx?= 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)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:44.7639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b43eaad-aeb7-429d-bc43-08ddb88e1bd1 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: BN2PEPF00004FBB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9327 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367491997116600 Content-Type: text/plain; charset="utf-8" Moving forward the idea is for there to be: 1. Basic DT support: used by dom0less/hyperlaunch. 2. Full DT support: used for device discovery and HW setup. Rename HAS_DEVICE_TREE to HAS_DEVICE_TREE_DISCOVERY to describe (2) and create a new DEVICE_TREE_PARSE to describe (1). Have DEVICE_TREE_PARSE selected by both HAS_DEVICE_TREE_DISCOVERY and DOM0LESS_BOOT. Add a dependency on STATIC_MEMORY for discovery, as it relies on the memory map itself being described on the DTB. Signed-off-by: Alejandro Vallejo --- v5: * Replaces the old "xen: Rename CONFIG_HAS_DEVICE_TREE to CONFIG_HAS_DEVICE_TREE_DISCOVERY", though it renames largely a rename. One could imagine STATIC_MEMORY being adapted for x86, but it's no small amount of work, so I shan't. I didn't add Stefano's R-by because the patch seems functionally different even if its diff is very similar. --- xen/Kconfig.debug | 2 +- xen/arch/arm/Kconfig | 2 +- xen/arch/ppc/Kconfig | 2 +- xen/arch/riscv/Kconfig | 2 +- xen/common/Kconfig | 13 +++++++++---- xen/common/Makefile | 4 ++-- xen/common/device.c | 4 ++-- xen/common/efi/boot.c | 2 +- xen/common/sched/Kconfig | 2 +- xen/drivers/char/ns16550.c | 6 +++--- xen/drivers/passthrough/Makefile | 2 +- xen/drivers/passthrough/iommu.c | 2 +- xen/include/asm-generic/device.h | 10 +++++----- xen/include/xen/iommu.h | 8 ++++---- xen/include/xsm/dummy.h | 4 ++-- xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 6 +++--- xen/xsm/xsm_core.c | 4 ++-- xen/xsm/xsm_policy.c | 4 ++-- 20 files changed, 49 insertions(+), 44 deletions(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 38a134fa3b..d900d926c5 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -92,7 +92,7 @@ config VERBOSE_DEBUG =20 config DEVICE_TREE_DEBUG bool "Device tree debug messages" - depends on HAS_DEVICE_TREE + depends on DEVICE_TREE_PARSE help Device tree parsing and DOM0 device tree building messages are logged in the Xen ring buffer. diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 3f25da3ca5..74b16f7167 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -15,7 +15,7 @@ config ARM select FUNCTION_ALIGNMENT_4B select GENERIC_UART_INIT select HAS_ALTERNATIVE if HAS_VMAP - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_DOM0LESS select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_STACK_PROTECTOR diff --git a/xen/arch/ppc/Kconfig b/xen/arch/ppc/Kconfig index 917f5d53a6..5bedf6055e 100644 --- a/xen/arch/ppc/Kconfig +++ b/xen/arch/ppc/Kconfig @@ -1,7 +1,7 @@ config PPC def_bool y select FUNCTION_ALIGNMENT_4B - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_UBSAN select HAS_VMAP =20 diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 62c5b7ba34..8fd3c314ea 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -2,7 +2,7 @@ config RISCV def_bool y select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_PMAP select HAS_UBSAN select HAS_VMAP diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 6d784da839..98f6ea8764 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -14,7 +14,8 @@ config CORE_PARKING =20 config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT - depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS + depends on HAS_DOM0LESS && DOMAIN_BUILD_HELPERS + select DEVICE_TREE_PARSE default y help Dom0less boot support enables Xen to create and start domU guests during @@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool =20 -config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDT =20 @@ -154,7 +159,7 @@ config NUMA =20 config STATIC_MEMORY bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED - depends on DOM0LESS_BOOT + depends on DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY help Static Allocation refers to system or sub-system(domains) for which memory areas are pre-defined by configuration using physical @@ -553,7 +558,7 @@ config DOM0_MEM =20 config DTB_FILE string "Absolute path to device tree blob" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERY help When using a bootloader that has no device tree support or when there is no bootloader at all, use this option to specify the absolute path diff --git a/xen/common/Makefile b/xen/common/Makefile index 98f0873056..d541fbcf49 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -6,9 +6,9 @@ obj-$(CONFIG_HYPFS_CONFIG) +=3D config_data.o obj-$(CONFIG_CORE_PARKING) +=3D core_parking.o obj-y +=3D cpu.o obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o -obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) +=3D device.o -obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device-tree/ +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device-tree/ obj-$(CONFIG_IOREQ_SERVER) +=3D dm.o obj-y +=3D domain.o obj-y +=3D event_2l.o diff --git a/xen/common/device.c b/xen/common/device.c index 33e0d58f2f..0c0afad49f 100644 --- a/xen/common/device.c +++ b/xen/common/device.c @@ -11,7 +11,7 @@ =20 #include =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY =20 extern const struct device_desc _sdevice[], _edevice[]; =20 @@ -56,7 +56,7 @@ enum device_class device_get_class(const struct dt_device= _node *dev) return DEVICE_UNKNOWN; } =20 -#endif +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ =20 #ifdef CONFIG_ACPI =20 diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 9306dc8953..31b4039049 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -623,7 +623,7 @@ static int __init __maybe_unused set_color(uint32_t mas= k, int bpp, return max(*pos + *sz, bpp); } =20 -#ifndef CONFIG_HAS_DEVICE_TREE +#ifndef CONFIG_HAS_DEVICE_TREE_DISCOVERY static int __init efi_check_dt_boot(const EFI_LOADED_IMAGE *loaded_image) { return 0; diff --git a/xen/common/sched/Kconfig b/xen/common/sched/Kconfig index 18ca1ce7ab..1fb622e6cf 100644 --- a/xen/common/sched/Kconfig +++ b/xen/common/sched/Kconfig @@ -67,7 +67,7 @@ endmenu =20 config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERY help Creates cpupools during boot time and assigns cpus to them. Cpupools options can be specified in the device tree. diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 6b4fb4ad31..c1c08b235e 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -34,7 +34,7 @@ #include #include #include -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include #endif #ifdef CONFIG_X86 @@ -1766,7 +1766,7 @@ void __init ns16550_init(int index, struct ns16550_de= faults *defaults) =20 #endif /* CONFIG_X86 */ =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static int __init ns16550_uart_dt_init(struct dt_device_node *dev, const void *data) { @@ -1845,7 +1845,7 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIA= L) .init =3D ns16550_uart_dt_init, DT_DEVICE_END =20 -#endif /* HAS_DEVICE_TREE */ +#endif /* HAS_DEVICE_TREE_DISCOVERY */ =20 #if defined(CONFIG_ACPI) && defined(CONFIG_ARM) #include diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Mak= efile index a1621540b7..eb4aeafb42 100644 --- a/xen/drivers/passthrough/Makefile +++ b/xen/drivers/passthrough/Makefile @@ -5,6 +5,6 @@ obj-$(CONFIG_ARM) +=3D arm/ =20 obj-y +=3D iommu.o obj-$(CONFIG_HAS_PCI) +=3D pci.o -obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device_tree.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device_tree.o obj-$(CONFIG_HAS_PCI) +=3D ats.o obj-$(CONFIG_HAS_PCI_MSI) +=3D msi.o diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iomm= u.c index 16aad86973..c9425d6971 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -638,7 +638,7 @@ int iommu_do_domctl( ret =3D iommu_do_pci_domctl(domctl, d, u_domctl); #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY if ( ret =3D=3D -ENODEV ) ret =3D iommu_do_dt_domctl(domctl, d, u_domctl); #endif diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/dev= ice.h index 1acd1ba1d8..3bd97e33c5 100644 --- a/xen/include/asm-generic/device.h +++ b/xen/include/asm-generic/device.h @@ -6,7 +6,7 @@ =20 enum device_type { -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY DEV_DT, #endif DEV_PCI @@ -26,7 +26,7 @@ enum device_class struct device { enum device_type type; -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY struct dt_device_node *of_node; /* Used by drivers imported from Linux= */ #endif #ifdef CONFIG_HAS_PASSTHROUGH @@ -37,7 +37,7 @@ struct device =20 typedef struct device device_t; =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY =20 #include =20 @@ -87,9 +87,9 @@ struct device_desc { int (*init)(struct dt_device_node *dev, const void *data); }; =20 -#else /* !CONFIG_HAS_DEVICE_TREE */ +#else /* !CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #define dev_is_dt(dev) ((void)(dev), false) -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ =20 #define dev_is_pci(dev) ((dev)->type =3D=3D DEV_PCI) =20 diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 832775754b..5483840645 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -230,7 +230,7 @@ struct msi_msg; #define PT_IRQ_TIME_OUT MILLISECS(8) #endif /* HAS_PCI */ =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include =20 #ifdef CONFIG_HAS_PASSTHROUGH @@ -288,7 +288,7 @@ static inline int iommu_release_dt_devices(struct domai= n *d) =20 #endif /* HAS_PASSTHROUGH */ =20 -#endif /* HAS_DEVICE_TREE */ +#endif /* HAS_DEVICE_TREE_DISCOVERY */ =20 struct page_info; =20 @@ -355,7 +355,7 @@ struct iommu_ops { int (*get_reserved_device_memory)(iommu_grdm_t *func, void *ctxt); void (*dump_page_tables)(struct domain *d); =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * All IOMMU drivers which support generic IOMMU DT bindings should use * this callback. This is a way for the framework to provide the driver @@ -403,7 +403,7 @@ struct domain_iommu { /* iommu_ops */ const struct iommu_ops *platform_ops; =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* List of DT devices assigned to this domain */ struct list_head dt_devices; #endif diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 9227205fcd..12792c3a43 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device( =20 #endif /* HAS_PASSTHROUGH && HAS_PCI */ =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) { @@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice( return xsm_default_action(action, current->domain, d); } =20 -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ =20 static XSM_INLINE int cf_check xsm_resource_plug_core(XSM_DEFAULT_VOID) { diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 24acc16125..abeb4b04ad 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -125,7 +125,7 @@ struct xsm_ops { int (*deassign_device)(struct domain *d, uint32_t machine_bdf); #endif =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) int (*assign_dtdevice)(struct domain *d, const char *dtpath); int (*deassign_dtdevice)(struct domain *d, const char *dtpath); #endif @@ -535,7 +535,7 @@ static inline int xsm_deassign_device( } #endif /* HAS_PASSTHROUGH && HAS_PCI) */ =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static inline int xsm_assign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { @@ -548,7 +548,7 @@ static inline int xsm_deassign_dtdevice( return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath); } =20 -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ =20 static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machin= e_bdf) { @@ -789,7 +789,7 @@ int xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size); #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * Initialize XSM * @@ -839,7 +839,7 @@ static inline int xsm_multiboot_init(struct boot_info *= bi) } #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_dt_init(void) { return 0; @@ -849,7 +849,7 @@ static inline bool has_xsm_magic(paddr_t start) { return false; } -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ =20 #endif /* CONFIG_XSM */ =20 diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index 93fbfc43cc..7f67683839 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -81,7 +81,7 @@ static const struct xsm_ops __initconst_cf_clobber dummy_= ops =3D { .deassign_device =3D xsm_deassign_device, #endif =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) .assign_dtdevice =3D xsm_assign_dtdevice, .deassign_dtdevice =3D xsm_deassign_dtdevice, #endif diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 6a53487ea4..78bad6e56b 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1456,7 +1456,7 @@ static int cf_check flask_deassign_device( } #endif /* HAS_PASSTHROUGH && HAS_PCI */ =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) static int flask_test_assign_dtdevice(const char *dtpath) { uint32_t rsid; @@ -1517,7 +1517,7 @@ static int cf_check flask_deassign_dtdevice( return avc_current_has_perm(rsid, SECCLASS_RESOURCE, RESOURCE__REMOVE_= DEVICE, NULL); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ =20 static int cf_check flask_platform_op(uint32_t op) { @@ -1981,7 +1981,7 @@ static const struct xsm_ops __initconst_cf_clobber fl= ask_ops =3D { .deassign_device =3D flask_deassign_device, #endif =20 -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISC= OVERY) .assign_dtdevice =3D flask_assign_dtdevice, .deassign_dtdevice =3D flask_deassign_dtdevice, #endif diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index f255fb63bf..b7e864a874 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -25,7 +25,7 @@ #include #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include #endif =20 @@ -166,7 +166,7 @@ int __init xsm_multiboot_init(struct boot_info *bi) } #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY int __init xsm_dt_init(void) { int ret =3D 0; diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 1b4030edb4..3f04375347 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -24,7 +24,7 @@ #include #endif #include -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY # include # include #endif @@ -65,7 +65,7 @@ int __init xsm_multiboot_policy_init( } #endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size) { struct boot_module *mod =3D boot_module_find_by_kind(BOOTMOD_XSM); --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367493; cv=pass; d=zohomail.com; s=zohoarc; b=GzGBe9KWbsTm4xJY0+WScIHk/34vOX0BSUZwo2DPHx69FDexv2J1n1BOckC4lAw+f4p6HaO7C279AZWTnHicr/tkyxVBMCy4QXROMrtA9YvNgmdbf31Xinr0/7bmgU4xg87zWXnfqx9hoxTmQAWJvlqadZNiIb1/d1OsOv9tw0U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367493; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vdbXRG3gJ+6nR7yDyC6zWhnGw42chIOCn8pFzN7c4+0=; b=No6tPMEcv8oET9B7gj/exWZp5HGVkG3pksDso49asTyqX/kP0wwpQEfSfJoafv+ewwuINmUCG8EoJN/55pZ+SkAcihi5ZSS3aBgEeBfDJABnjgW3nOTpQg5p7PUAKHR2RSYBhDomse8xvCgK5qVGZFatMLM5pMI0o7CWLLH4mBE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1751367493339373.3885143397682; Tue, 1 Jul 2025 03:58:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029532.1403345 (Exim 4.92) (envelope-from ) id 1uWYgT-000522-3D; Tue, 01 Jul 2025 10:57:53 +0000 Received: by outflank-mailman (output) from mailman id 1029532.1403345; Tue, 01 Jul 2025 10:57:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYgS-00051f-U0; Tue, 01 Jul 2025 10:57:52 +0000 Received: by outflank-mailman (input) for mailman id 1029532; Tue, 01 Jul 2025 10:57:52 +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 1uWYgS-0002hE-A7 for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:52 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20607.outbound.protection.outlook.com [2a01:111:f403:2416::607]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3b98cfea-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:51 +0200 (CEST) Received: from BLAPR05CA0026.namprd05.prod.outlook.com (2603:10b6:208:335::8) by DS0PR12MB7780.namprd12.prod.outlook.com (2603:10b6:8:152::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.30; Tue, 1 Jul 2025 10:57:47 +0000 Received: from BN2PEPF00004FBE.namprd04.prod.outlook.com (2603:10b6:208:335:cafe::78) by BLAPR05CA0026.outlook.office365.com (2603:10b6:208:335::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 10:57:46 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBE.mail.protection.outlook.com (10.167.243.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:46 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:44 -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: 3b98cfea-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NJTKSQMSRHRhDBTjyN9oEOVanmrCBtBsni9eKdODEW3xNK+EM2tC6brRzQYzoJy36zvKrdhiIeHCmNlqllaZ4Tsb2gn6TowrIWvz62UmJguPUOH4J9xnsqAIvjYDmILyRZCJwWW2rO4h2PzvTklXPst6fYrpDiTushRNKngQImpvnuWl6eqS9m35OPoe6k/rU6Gu15pVE6hBnUFDYgJBn3K32PJIyY9/u/aIx/d7nqfwZjvB96NSBtTZcXth1n5d5YghfMXmSoQzdfbGThbADy1taNNxviHQMtIDCaC/PsFwrKRG5kFK0DEX2UfwxtseIDsoIip6aZAHUO2lyWOh5g== 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=vdbXRG3gJ+6nR7yDyC6zWhnGw42chIOCn8pFzN7c4+0=; b=RLQvFoXxJpLb0U5TJpcYH+oJIKdfGg4uEaIBvWkHmBfZVT+/3i6JvnQ0qw2CHtPDQ550kOdrhcjqpKrmFAReUsiLGh9nz3PZ2g0slgS5PjGZzADXRx1vKrZxZbC356diecg1Pf6WYob7rjE3IJ5ftkKZ7wlbtGzbIWcJ/l8aCWJPmeN+h+pZS0BdqRnrcW3aZ9GsLViQGisdlsazmH5lNWFfaljNKO8cGQemFQQI2vjMvlX144pwptdjhH9x0Q/HzBVKyxH8HyAyjs2aNt5LC+tPW/JtPdVajkoxYnOaUmQS1ikgJDnJrprf59hEKoOKTS1nLobXUw/o15mFJV3Q3g== 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=vdbXRG3gJ+6nR7yDyC6zWhnGw42chIOCn8pFzN7c4+0=; b=10tzgWr4W5OLbop2fLDcvSc7tN2nBQDGtkGfkvXUI1MlXXc6wOAin3gCygB2nQiZypCigi3i3BkCbWeQhOVWgobr2UAsbtpy9ZGYnhVg8f9RJiOv3/k1W8VP8rkbTHMUT93HkR9CWKhyTqRT5O8VesQWb22CJR+myVHg/4+G/1k= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: Alejandro Vallejo , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel Subject: [PATCH v5 09/10] xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} Date: Tue, 1 Jul 2025 12:57:03 +0200 Message-ID: <20250701105706.86133-10-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBE:EE_|DS0PR12MB7780:EE_ X-MS-Office365-Filtering-Correlation-Id: 77276ea8-546c-410d-4e82-08ddb88e1cf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sb85+aQJPTVz6ofWyKmrWKdKwD1lmeWUnzA0hAjNYcgYyQaBr8Q9BaGuZwt8?= =?us-ascii?Q?fXixx/GKSKzPuTYKhp6gn3A5FboYrXYDzPkOT8cuVBD3E9oCRq9OnKAQrKdx?= =?us-ascii?Q?hD6ECdgy8BMj58al8DYOw4//v9bzwRfDg38ZIqME8uElpI8Vs++GL9rwMUGv?= =?us-ascii?Q?ygTp3DzHiV4ldWBHI2FIjJCgypdyRBMd2hYkO46t+InLpLCoPysTS+wjmzyC?= =?us-ascii?Q?qcOKboTKSXAy22h5ixCHukP5Q291RGHCoskuDhEPUqv3bG6lsJ0i97661eZg?= =?us-ascii?Q?ofOaohtx3jPf1wZKkpwSWNmj40+eAy0W4TeFEy2QqiN5NH6Hca+TGlMzIRnq?= =?us-ascii?Q?Jv0eeJRREiUdy8SXg7rpdArVukT0D91HurJMj3I6jWUyjTD96+FvXqSiX+hR?= =?us-ascii?Q?lY9Ie/JNAgnbUcFmnRpib6IEC4+5rlh1LPIaSqZ+kp9lhlVMQnu7SAAkZG4f?= =?us-ascii?Q?S933rXQD/eEKGU+lss1j4E2POrvZOtnaEplX0TF4UKGi87vHvmgDXYL29I12?= =?us-ascii?Q?Efbog/cf/4WN0WBYdBPCXoSJEW3j+MoxDSlAKqCkfHWN4zrdyOs9bg3ghk+n?= =?us-ascii?Q?sqmCnardgX6U/Xe/8DiuWE1NiN9lfVEDHcAKxIOUULkIrBQWlcJxTobT8mLe?= =?us-ascii?Q?tlJsTg3a85i/Mx4saqpzO9Q8EE3JuVEefsdK3WA4kzldAUjl9G2MsjAvECPW?= =?us-ascii?Q?oE2KhEmAxcK6kMNlFZNKW9CpR4AsdfwIi0sgoIskPAME4g23iYeCa4ezt517?= =?us-ascii?Q?Rxt1gibufASZQLPDSYOrUzHp3ZX2WhqPWcZCwXad4EBS3LE1skjKNt8uxm0X?= =?us-ascii?Q?uK59lQJpAcCkAIA371kqQCYeOQNeOeMgUi8S8ZXqDI+Al7+zuj8OGTRg7TIA?= =?us-ascii?Q?6h1IXKNoOWegbSgQIBjLG72SmQ90liIvG9ZjWoUAg9ATVzV5J/4ikvFzuuh8?= =?us-ascii?Q?Z7oDRSPSP05vvaSmSPHK2PGMbbfLQxX6wQdp+zuNPMhWdRuHryr3bZeXnow8?= =?us-ascii?Q?z6VXxDCgp8PaUBfoa1yTVlpOgyAAyvt1gI5buDL7gAVwh+tbdtBBSYUmnY/f?= =?us-ascii?Q?EpcyZXvn+C4gXLpwSajyodza2qOXBFrqxaCZOaF9PHD+sm9nXe8P+csN0qUQ?= =?us-ascii?Q?lYBZNx33QMZAGS08+kH4ayLV58SM99k8aYKkgi3mILY8HmLqe25q9K11SdnN?= =?us-ascii?Q?8x6LNSU2EcnOIsYH/ac2SWf+4UWy4Nhb3JKmI0BkehHJtt9c5thGwoglJ81c?= =?us-ascii?Q?lqYhTOMlduvgUf/m7fIjtJjtsBwoOw0kQdzaGrpYW0IeJsArSZriKCZcPL6N?= =?us-ascii?Q?Y+dtdiSrJfg+n+g4aaC3nDA8ZUJ0fjvbcLo4H2RqO0nCFcOHvUisykxSWD7q?= =?us-ascii?Q?DsCxBWxZ8BLkBrOTn1Jitr47ryVZlGYAhL770F7PGkM3EtTQ5raMwK8los4E?= =?us-ascii?Q?MdLEaICbrUt6mIc9IlU4yE0judIHyuOYCwEdl5aiPkltoQ7UREA6Vtk/6ccJ?= =?us-ascii?Q?sDGuBGY3LydI43UHiHb6RReiD4Ahc7qjVErs?= 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)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:46.7022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77276ea8-546c-410d-4e82-08ddb88e1cf9 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: BN2PEPF00004FBE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7780 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367494061116600 Content-Type: text/plain; charset="utf-8" Architectures that don't discover devices via DT may skip anything to do with device_t during the DT unflattening phase. Make device-tree.c stop requiring CONFIG_HAS_DEVICE_TREE_DISCOVERY so it may function with CONFIG_DEVICE_TREE_PARSE alone. This allows CONFIG_DEVICE_TREE_PARSE to unflatten a DT ignoring its devices if CONFIG_HAS_DEVICE_TREE_DISCOVERY is not selected. Signed-off-by: Alejandro Vallejo Reviewed-by: Stefano Stabellini --- v5: * New commit message to make it more general --- xen/common/device-tree/device-tree.c | 2 ++ xen/include/xen/device_tree.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/= device-tree.c index 725ff71646..741e2ce585 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -2029,9 +2029,11 @@ static unsigned long unflatten_dt_node(const void *f= dt, ((char *)pp->value)[sz - 1] =3D 0; dt_dprintk("fixed up name for %s -> %s\n", pathp, (char *)pp->value); +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* Generic device initialization */ np->dev.type =3D DEV_DT; np->dev.of_node =3D np; +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ } } if ( allnextpp ) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index b6d16756fc..ace7fc3274 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -108,9 +108,12 @@ struct dt_device_node { */ struct list_head domain_list; =20 +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY struct device dev; +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ }; =20 +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #define dt_to_dev(dt_node) (&(dt_node)->dev) =20 static inline struct dt_device_node *dev_to_dt(struct device *dev) @@ -119,6 +122,7 @@ static inline struct dt_device_node *dev_to_dt(struct d= evice *dev) =20 return container_of(dev, struct dt_device_node, dev); } +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ =20 #define MAX_PHANDLE_ARGS 16 struct dt_phandle_args { --=20 2.43.0 From nobody Fri Oct 31 03:52:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751367700; cv=pass; d=zohomail.com; s=zohoarc; b=mHBzGL9oquHZVP7BDxGC4oSvIFxxwuq//+xwJ2fZUIPWuqOKVPdYEWBntS4YDbFOfpcSjgNYfNb3dRyX/LDKjQFiMUb+Rok2zEoEIwQrQgGjMiXZELYiviJ6CJteG2uDAXWE5AtcKcfsjqN9LKrdQVkLxfd06CI0XP4fqYs3hS8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751367700; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/D3EzT/oj4KFimtajf3Jv4n8dk1VuE6ptlYhwqGVnrk=; b=WFNYfykRZOwYKAt3FOXILQRhhX5HZJpGIahlRF/Ei4lzrhEW63rQ5bneFl9r3Gv1z4lWGa+/DfAzAd3x3A9+eEQjKljO3T2wQ7EIxSWflzgudmLhQWmSsPhlIhrcmBE3gJPPoZ3QHcbW11E8yZwDWZklQPYJ0nWaE15b62fDOj8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175136770067036.642524774473145; Tue, 1 Jul 2025 04:01:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1029576.1403365 (Exim 4.92) (envelope-from ) id 1uWYjt-0000UG-1s; Tue, 01 Jul 2025 11:01:25 +0000 Received: by outflank-mailman (output) from mailman id 1029576.1403365; Tue, 01 Jul 2025 11:01:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uWYjs-0000U9-Ur; Tue, 01 Jul 2025 11:01:24 +0000 Received: by outflank-mailman (input) for mailman id 1029576; Tue, 01 Jul 2025 11:01:23 +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 1uWYgU-0002hE-GZ for xen-devel@lists.xenproject.org; Tue, 01 Jul 2025 10:57:54 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2061d.outbound.protection.outlook.com [2a01:111:f403:2407::61d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3c7efa3d-566a-11f0-a313-13f23c93f187; Tue, 01 Jul 2025 12:57:53 +0200 (CEST) Received: from BL0PR02CA0120.namprd02.prod.outlook.com (2603:10b6:208:35::25) by LV2PR12MB5798.namprd12.prod.outlook.com (2603:10b6:408:17a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.30; Tue, 1 Jul 2025 10:57:50 +0000 Received: from BN2PEPF00004FBF.namprd04.prod.outlook.com (2603:10b6:208:35:cafe::97) by BL0PR02CA0120.outlook.office365.com (2603:10b6:208:35::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.19 via Frontend Transport; Tue, 1 Jul 2025 10:57:49 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FBF.mail.protection.outlook.com (10.167.243.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Tue, 1 Jul 2025 10:57:49 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) 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; Tue, 1 Jul 2025 05:57:46 -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: 3c7efa3d-566a-11f0-a313-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EJqr+6Rg+GVrv4uM073oeLERo3AWOL1CTbO4WL/P8L1YAhmGYVcNlAgdACnCM64K5EMUFtMb8q64xZZ15yfD/O45eaaw51sA8rQKdRzwKxoTo19RWQAXgNjAOnTG5G1/88V3Vxdw6xd/zucD4jrjJtO6oM3/TToSkQEg24K7FaL+E5/S7sBw9r8Nue+dG3mNJDVzWHFhw9jEUH/X4CH1HCCut9c0hVDkq+ioJXNWMbraOaVfTZ10bWO44b0ivADezZph1jP9t6SuBqIXgcjA/9ESFRAkeaSJ1xmcJ93wRJQ4ItYHlTs6cuMhMhr6WPH6UDJdWVZlI5tOJgzjopiysA== 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=/D3EzT/oj4KFimtajf3Jv4n8dk1VuE6ptlYhwqGVnrk=; b=DfkCG0zcFxVyos41r60OLpL1k4JReyVkZqjoiYprVqnkDvjvDIrJ/BkFaeAzkx/WgKu4QQ6elX/p49qwgEWASpdolJkT2vBlzn7L4aqfioKTzhvObrLFjFG1/pcpB/ZQutKIN50wHv6DWEV++85cuXR7awKmpHbV+qjOPDR6EmDoJGSgSD0eIHF1fUsiPNbzSdowjnAyNhUquZUPfoRRPpiyeZG9jWPICwFstxyPtMpV/j9u80AYnJ7BrMIGIf3G/xO2BNtDSX7csx6P1h+wkWuJqBEhM65NVRZuWZWbUGmagnbrf9tcIvnyXkHA+BGnK+q/ydarZSkfCEbgHcLM+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (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=/D3EzT/oj4KFimtajf3Jv4n8dk1VuE6ptlYhwqGVnrk=; b=C96idvL0BGHpoBndJGpiWG4YXsaHltKEIEt4w88HIWHJJV2mOhXsMdItVtg/we8LcFklFUgOEvCdDV/9tpnM2yvmdR/TqITGcEIDCpEODfHoJf5wmjNlTE1uaQ/80yJ78qHcoTDp2KaNUbv1OFPnpR6iZXdHgFWmb0I1YrGdpLE= 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: Alejandro Vallejo To: CC: Alejandro Vallejo , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , "Bertrand Marquis" Subject: [PATCH v5 10/10] xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/ Date: Tue, 1 Jul 2025 12:57:04 +0200 Message-ID: <20250701105706.86133-11-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250701105706.86133-1-agarciav@amd.com> References: <20250701105706.86133-1-agarciav@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FBF:EE_|LV2PR12MB5798:EE_ X-MS-Office365-Filtering-Correlation-Id: c16886f1-c114-41dc-3180-08ddb88e1e94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?l60/3Cist5nvfD2qUC4E+JTIHoBjE85gBku9koLHN08rxbGjb+p3A1Q5heZk?= =?us-ascii?Q?xCc70ntVj6Fq3e/s/EWSWH7dSGEdZ0MX1CvYlqMaXOnfWlLidT1ZrCtEnhN+?= =?us-ascii?Q?l65oychHe+y8PJP7QO/C0H0bJ5yJRpNOLwyoTA/015w19LPy+cwtA/KVUSQr?= =?us-ascii?Q?LdFF/ooiFtKUmQ0KzNFczBr+TrCQ7vgl5/asy/UdXJANhjbfk4mKHLG73YJj?= =?us-ascii?Q?L40RnLf8KKaY6Es2/Gmx/UiSwnzzSTdRDM42hLRqmGlD3knO+n18fFLkBlRP?= =?us-ascii?Q?I2fo+RFQ7g21ToCM9+U5XX2TJ5AAc4Jlj+LiBvvwnEaN8vTcciRd50evQUd5?= =?us-ascii?Q?xLM9YfDbITaBzmcHFRAIqV1CJNQfPqvg4ul9cECqWt/2MPsBqCn+hagFpd3S?= =?us-ascii?Q?9+uV19SIXqZICUHWNaVFHQOgJKM/l/hfF7od392K2t41Qjo/DT5pluEdWixL?= =?us-ascii?Q?lOtMuT1esYsP92P221JeozYe5fcVKVBvA+yzrWtj6f4KPYIz198k6rAEBpXO?= =?us-ascii?Q?w92VuIZId2mOjnK27LkJSCNneUy+osIDszUsNzDDrB1WMd2z2AUcTQFCWacP?= =?us-ascii?Q?ZUzyBWSn9nXl5bRIXSzpO1IzvvU65U/p4wZ541eUJZpwpUjDD9bgQEkOPZoZ?= =?us-ascii?Q?aU6B2gLs+LYI9SH9F8yQblVzOMZdurIaYj/K3XPBmLMNAc/TK8pb85zCchNC?= =?us-ascii?Q?aB2J2zFKCC0suYlal7m1oWqko5QaDLmK0c8HXF1+tQPLC2ZCNmLs6L7pxNob?= =?us-ascii?Q?UBh1Uua++bM/Wd9f+wlKI+AjTT4xDjpKPGgu4d9cfDJ+jdqB/ggCg8gUMuuJ?= =?us-ascii?Q?gmjkRukE1Rr5ht2JSAwng2qV7oxMqr9k+Lr6exkG68iAjp1hppHl/UmtdOjB?= =?us-ascii?Q?ComopVS1VPsECNwbjS2inmr2FAHeZCFnXcgwzhw16dlJdYyrE6bTLPafgvWq?= =?us-ascii?Q?OjqsmzyWZ6DH5UiVPa70JFhrxBfpI3QKqyJ0KHhmMscOLtfyMwg7wdwKdNlw?= =?us-ascii?Q?R1WN/VchnUVGr5Tp4RnMtS3OBbSdZNt1I5PLDYYcCddFdC/BP1BJtu7odNxn?= =?us-ascii?Q?8mFjKx45ePNvppw/geeck4DJKbQ3w+0he0gFsN9OwlH2h7fG7BvffcUSbIL5?= =?us-ascii?Q?H2G7KPE1e/6Ozke5yeyWXNwKQx0jjBFoV5HgZ73ogrc89fXpO5UDZ6YygHOf?= =?us-ascii?Q?66H7JLl3Ma1fhLq4j2bDd/i/eg4JbbYurZfyPuKIByF1rtZ0MjZnSgejyVxB?= =?us-ascii?Q?T/I4bxgD/j3oQsAhatpR5f+6C9z4zasy/jdQGt/mIRCmUtDYRf4KyfH00s4z?= =?us-ascii?Q?ME8CCl9Xps3GUau4Yc+b5isnYvj7XVggNE5Ilwo6Gwap999ckUDri2RlVCKH?= =?us-ascii?Q?i8xUmUT5Q/FcL+PK+Ov1T9CakM7qe/JxEUeRrk/FNlzEqSSkFGL6/LigIS2J?= =?us-ascii?Q?3zQGPWEMNkZP65NvekZ7wsbAYj29HLnH7lafmnPKHf+A1RraWAcQ/MR2L0rr?= =?us-ascii?Q?oyI4dZJNK7SgSwNMztigCwOm9mG3FALoAJ7R?= 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)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 10:57:49.3940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c16886f1-c114-41dc-3180-08ddb88e1e94 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: BN2PEPF00004FBF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5798 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751367702720116600 Content-Type: text/plain; charset="utf-8" This allows bootfdt.c and device-tree.c to be usable without CONFIG_HAS_DEVICE_TREE_DISCOVERY. Gate everything else on CONFIG_HAS_DEVICE_TREE_DISCOVERY. Signed-off-by: Alejandro Vallejo --- xen/common/Makefile | 2 +- xen/common/device-tree/Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/common/Makefile b/xen/common/Makefile index d541fbcf49..265468d751 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -8,7 +8,7 @@ obj-y +=3D cpu.o obj-$(CONFIG_DEBUG_TRACE) +=3D debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) +=3D device.o -obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D device-tree/ +obj-$(CONFIG_DEVICE_TREE_PARSE) +=3D device-tree/ obj-$(CONFIG_IOREQ_SERVER) +=3D dm.o obj-y +=3D domain.o obj-y +=3D event_2l.o diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile index 8abc069c4b..e399242cdf 100644 --- a/xen/common/device-tree/Makefile +++ b/xen/common/device-tree/Makefile @@ -1,11 +1,11 @@ obj-y +=3D bootfdt.init.o -obj-y +=3D bootinfo-fdt.init.o -obj-y +=3D bootinfo.init.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo-fdt.init.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D bootinfo.init.o obj-y +=3D device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) +=3D domain-build.init.o obj-$(CONFIG_DOM0LESS_BOOT) +=3D dom0less-build.init.o obj-$(CONFIG_OVERLAY_DTB) +=3D dt-overlay.o -obj-y +=3D intc.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) +=3D intc.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) +=3D kernel.o obj-$(CONFIG_STATIC_EVTCHN) +=3D static-evtchn.init.o obj-$(CONFIG_STATIC_MEMORY) +=3D static-memory.init.o --=20 2.43.0