From patchwork Tue Apr 8 16:07:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54A16C369A2 for ; Tue, 8 Apr 2025 16:11:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942853.1341952 (Exim 4.92) (envelope-from ) id 1u2BXT-0001Q2-GF; Tue, 08 Apr 2025 16:11:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942853.1341952; Tue, 08 Apr 2025 16:11:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BXT-0001Pq-CN; Tue, 08 Apr 2025 16:11:03 +0000 Received: by outflank-mailman (input) for mailman id 942853; Tue, 08 Apr 2025 16:11:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVb-0000a6-RH for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:07 +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 cb399aa2-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:06 +0200 (CEST) Received: from BL1P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::18) by MN2PR12MB4078.namprd12.prod.outlook.com (2603:10b6:208:1de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.21; Tue, 8 Apr 2025 16:09:00 +0000 Received: from BL6PEPF00020E5F.namprd04.prod.outlook.com (2603:10b6:208:2c7:cafe::2b) by BL1P222CA0013.outlook.office365.com (2603:10b6:208:2c7::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.19 via Frontend Transport; Tue, 8 Apr 2025 16:09:00 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E5F.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:00 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:08:57 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cb399aa2-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WB1dLP+M9CyLN0EchSSgcFU1bt7bKHNX0+gReExpwYuDHQdQcmwAjUCaqa0TuFmYy9XAQ70IliNTQ5X8iE9dV4O82NTmjCGax3I+V/1/Bj15mZlVmwxPU8ZpPMD/SETYvpxPu2C/FJbcdrL0V7wxqAvAyEuvVsDElB8ZgywT/JR7CfwcOaFGJ9w/I3Vt09x5SN879SWpQ4179uuszZMJ7Hngh+zFAqoz6dX3BUDt6c37kHvZI6LblyKHY+3HvME6xVqAgDNtZcLqFKdywafVR5SrAMoCDp4Vl5ZSB8wdohRprRCKlm8WIX3Z8/aIFPcJOgZ/0irzyxgwYKF6qupE+w== 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=TxHxjqnfxZWF/z08CaV5pCzCkt38zC1qSAYIboC5Tdo=; b=G8qz/fJhEaaDDPbarP/Y9SkctfwkHSZMsocc0dy3FFKbb2rJLQpxeiUaUc1TEWtzV+//azW/6IplV6gj//sci9WudN3qbxDXv/xIrwmIQpEf0RPthuJOLzeQEWfhQoTDO9K2GN4S+lJLjiz9kgwB18EWWGMVtcJxTjpQ5PFHRGiRPThwHazcbiEoPm/+NDihASHg5GGDfQt0sAoYVX8O2Ujh+syY3V5X1C9MzOK171EhiPsCGrZf8RDKVtoL1eac7z3ao5dG8367iNJxQIPsI6thc8EAmeDQPkkbfPoeJXGDqooup52hBDgGuhZk8iApK5RX+E/qzWn0SEhsRNapgQ== 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=TxHxjqnfxZWF/z08CaV5pCzCkt38zC1qSAYIboC5Tdo=; b=T9nMagcUB5sKvZKTwKJALLHrxBY/uaK69pnAncPPAKuZb+GV5nYQNN90+GW1XaP0Yu+0G0QcIiXGijyo3IRgLJ5CK/dFF00w0Rk7BH4/XPGxKuCrBcYvuydbCsrydEEEeMdPzGglHGQFpD1fiGMeIr4IGvBd4i+FPHOZqX2xZJg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 01/16] x86/boot: introduce boot domain Date: Tue, 8 Apr 2025 17:07:23 +0100 Message-ID: <20250408160802.49870-2-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E5F:EE_|MN2PR12MB4078:EE_ X-MS-Office365-Filtering-Correlation-Id: 30f7d27d-86f7-452c-5934-08dd76b7ac6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: aHCZo9h1YIlltGgdRECrmi9LmUTe6tG2gdZpYzIdPlmHTH3CFkLTAQgpw5RZQ5NkMbpwBqLb05JjlD1vYuKTANMzezSJr8QmYxkw5uYY07eB565ABODnfu96sk2xmxQNNuMSKPgRB77SI7+RjX6LFWP9GWeJ1NuM4aeU8fCoH9rlY1OvHyUq3Iu0nauvjgz8bl69RbRdmVduvt3XviMDwn5Jm0BDgBrQS6UMfaeMR9sZllcexs4La1slTnVx7Ew51rZ923Af25wShk1vaEi0qEON8C9qc2TCzr2PlCXxmuygn1852VEMWZQ1LOQACF5FDyIEUMAx1Sli4qgAPwZRqeMg3oqmA8QxFEU6nWjVkctNGU54KF3tOezBHvgxxeYsXmpO0s3suimm0KpPJRbvky4t832AJaNOIkeabjWWfuiIrSauDUQ+0/jFe1lgwx0YDPlWEKKb5tcg/Y2LgaMDLqfPKNfAU7MQeoOhTm0zUrURzbBIwPS1n2nipMcQod1npH9DsBBhTedGI2emNISlybUihOS1EkGQreAXtX5FbbKOq1UwcE2NaqSMX7cLE55m+b2V6LPjvOC+8fACLq1jSEoQX9FtJeiDVNqBRnDQns+IYqzi/trZnuZFlfyg9DuW0kkeSoTEQjNOneSwAEXskGSvA3fsFveL6S/XNs3Hq+X+5la85dAIoY1kF3+u/NzkujTJLf+n1RF9CH9az8RYV/p91X66XN4YjK3InYXIjdnED/r5D9LA/tq5DsVrCRFmru0cxADovI/YIkSsCeym+/0C/XiX4ZrndVybzJ3Vxq2/8zrvPy0zzPucQysG3joBqtLiz2NR0LSsx5vqz1bZar2ha4pgao8igYTF49DWs9Ctbh90E4sVKy0ILzz4wZDA3GZ06tQ/QYe9bK/agcuor0aJa7z7P20ox8JqZAAHUGPTpEUZP2EROtIdCPHDUEX90eGVRFn6dZw4IjcrTHS+MKx1Yg2vDUAEd8ZmeuwUx2Mh9ZFCyOyFUHx7f2n87M7kJQHWaKShkMJe1ov4CTOtOGef1K9fStOvN3r5o+i3gm9STmfktCG1mYbQtmO4IISt+Ad8KaGSuo8SRks8XpvUxKkSIbE76tN29fppLQUpZeCgeUjWdfCD2D4f3+NcpWZTC9RpDUBlz+y8AgALheEO/wMWKm2Mbhx2TvAmMAMR6GsvbuucJA+U6DaVw5RBt1wtSckcX44DGrKcVa4twOiLCZW2dh1qPW2yhiI6zAW+JzQ5/kFa+61YKTXpbKfJM2lC7SNS9wjxxItmN2UhYXv3klzNU33TD2ID7lgLEuGg7Dj1nc0+VYZH5NT/zwpIApa0a79Nu7M6t6mgYdlLMASVDHrgt50wpym0opjnUy3Bm4w4ru0gOy6GhqJzJG2udN6zIdVvxR9ij4LGUCwi1xyYeHZ3E6EN07c9l7OkMfUGWrMp/p2LHhrX2VQsirSXrdWI6zZZHvmwFsuZ+AJteESBkfAgjhM1ydxqCxNkbsgLi3+wqHZbihMoGcfdcXC5Ij/b 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)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:00.0171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30f7d27d-86f7-452c-5934-08dd76b7ac6e 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: BL6PEPF00020E5F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4078 From: "Daniel P. Smith" To begin moving toward allowing the hypervisor to construct more than one domain at boot, a container is needed for a domain's build information. Introduce a new header, , that contains the initial struct boot_domain that encapsulate the build information for a domain. Add a kernel and ramdisk boot module reference along with a struct domain reference to the new struct boot_domain. This allows a struct boot_domain reference to be the only parameter necessary to pass down through the domain construction call chain. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk Acked-by: Jan Beulich --- v3: * Rename bootdomain.h -> boot-domain.h * const-ify boot_domain parameter passed to construct_dom0() * Rename boot_domain.ramdisk to boot_domain.module --- xen/arch/x86/dom0_build.c | 8 +++++--- xen/arch/x86/hvm/dom0_build.c | 23 ++++++++------------- xen/arch/x86/include/asm/boot-domain.h | 28 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/include/asm/dom0_build.h | 6 +++--- xen/arch/x86/include/asm/setup.h | 4 ++-- xen/arch/x86/pv/dom0_build.c | 24 ++++++++-------------- xen/arch/x86/setup.c | 24 +++++++++------------- 8 files changed, 69 insertions(+), 53 deletions(-) create mode 100644 xen/arch/x86/include/asm/boot-domain.h diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8191d90a22..0b467fd4a4 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -614,9 +615,10 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } -int __init construct_dom0(struct boot_info *bi, struct domain *d) +int __init construct_dom0(const struct boot_domain *bd) { int rc; + const struct domain *d = bd->d; /* Sanity! */ BUG_ON(!pv_shim && d->domain_id != 0); @@ -626,9 +628,9 @@ int __init construct_dom0(struct boot_info *bi, struct domain *d) process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(bi, d); + rc = dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(bi, d); + rc = dom0_construct_pv(bd); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 9fd68df7b9..2a094b3145 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -644,9 +644,11 @@ static bool __init check_and_adjust_load_address( } static int __init pvh_load_kernel( - struct domain *d, struct boot_module *image, struct boot_module *initrd, - paddr_t *entry, paddr_t *start_info_addr) + const struct boot_domain *bd, paddr_t *entry, paddr_t *start_info_addr) { + struct domain *d = bd->d; + struct boot_module *image = bd->kernel; + struct boot_module *initrd = bd->module; void *image_base = bootstrap_map_bm(image); void *image_start = image_base + image->headroom; unsigned long image_len = image->size; @@ -1328,26 +1330,17 @@ static void __hwdom_init pvh_setup_mmcfg(struct domain *d) } } -int __init dom0_construct_pvh(struct boot_info *bi, struct domain *d) +int __init dom0_construct_pvh(const struct boot_domain *bd) { paddr_t entry, start_info; - struct boot_module *image; - struct boot_module *initrd = NULL; - unsigned int idx; + struct domain *d = bd->d; int rc; printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); - idx = first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( idx >= bi->nr_modules ) + if ( bd->kernel == NULL ) panic("Missing kernel boot module for %pd construction\n", d); - image = &bi->mods[idx]; - - idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( idx < bi->nr_modules ) - initrd = &bi->mods[idx]; - if ( is_hardware_domain(d) ) { /* @@ -1385,7 +1378,7 @@ int __init dom0_construct_pvh(struct boot_info *bi, struct domain *d) return rc; } - rc = pvh_load_kernel(d, image, initrd, &entry, &start_info); + rc = pvh_load_kernel(bd, &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h new file mode 100644 index 0000000000..5e1e1a0b61 --- /dev/null +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -0,0 +1,28 @@ +/* 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__ + +struct boot_domain { + struct boot_module *kernel; + struct boot_module *module; + + 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/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index f8b4229130..3afc214c17 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -11,10 +11,14 @@ #include #include #include +#include /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 +/* Max number of boot domains that Xen can construct */ +#define MAX_NR_BOOTDOMS 1 + /* Boot module binary type / purpose */ enum bootmod_type { BOOTMOD_UNKNOWN, @@ -78,6 +82,7 @@ struct boot_info { unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; /* diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index 2d67b17213..ff021c24af 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,9 +13,9 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); -struct boot_info; -int dom0_construct_pv(struct boot_info *bi, struct domain *d); -int dom0_construct_pvh(struct boot_info *bi, struct domain *d); +struct boot_domain; +int dom0_construct_pv(const struct boot_domain *bd); +int dom0_construct_pvh(const struct boot_domain *bd); unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 5c2391a868..ac34c69855 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,8 +26,8 @@ void subarch_init_memory(void); void init_IRQ(void); -struct boot_info; -int construct_dom0(struct boot_info *bi, struct domain *d); +struct boot_domain; +int construct_dom0(const struct boot_domain *bd); void setup_io_bitmap(struct domain *d); diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 96e28c7b6a..b485eea05f 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -355,7 +355,7 @@ static struct page_info * __init alloc_chunk(struct domain *d, return page; } -static int __init dom0_construct(struct boot_info *bi, struct domain *d) +static int __init dom0_construct(const struct boot_domain *bd) { unsigned int i; int rc, order, machine; @@ -371,14 +371,15 @@ static int __init dom0_construct(struct boot_info *bi, struct domain *d) struct page_info *page = NULL; unsigned int flush_flags = 0; start_info_t *si; + struct domain *d = bd->d; struct vcpu *v = d->vcpu[0]; - struct boot_module *image; - struct boot_module *initrd = NULL; + struct boot_module *image = bd->kernel; + struct boot_module *initrd = bd->module; void *image_base; unsigned long image_len; void *image_start; - unsigned long initrd_len = 0; + unsigned long initrd_len = initrd ? initrd->size : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; @@ -416,22 +417,13 @@ static int __init dom0_construct(struct boot_info *bi, struct domain *d) printk(XENLOG_INFO "*** Building a PV Dom%d ***\n", d->domain_id); - i = first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( i >= bi->nr_modules ) + if ( !image ) panic("Missing kernel boot module for %pd construction\n", d); - image = &bi->mods[i]; image_base = bootstrap_map_bm(image); image_len = image->size; image_start = image_base + image->headroom; - i = first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( i < bi->nr_modules ) - { - initrd = &bi->mods[i]; - initrd_len = initrd->size; - } - d->max_pages = ~0U; if ( (rc = bzimage_parse(image_base, &image_start, &image_len)) != 0 ) @@ -1078,7 +1070,7 @@ out: return rc; } -int __init dom0_construct_pv(struct boot_info *bi, struct domain *d) +int __init dom0_construct_pv(const struct boot_domain *bd) { unsigned long cr4 = read_cr4(); int rc; @@ -1096,7 +1088,7 @@ int __init dom0_construct_pv(struct boot_info *bi, struct domain *d) write_cr4(cr4 & ~X86_CR4_SMAP); } - rc = dom0_construct(bi, d); + rc = dom0_construct(bd); if ( cr4 & X86_CR4_SMAP ) { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d70abb7e0c..ddb10ea03d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -992,16 +992,9 @@ static struct domain *__init create_dom0(struct boot_info *bi) .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + struct boot_domain *bd = &bi->domains[0]; struct domain *d; domid_t domid; - struct boot_module *image; - unsigned int idx; - - idx = first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( idx >= bi->nr_modules ) - panic("Missing kernel boot module for building domain\n"); - - image = &bi->mods[idx]; if ( opt_dom0_pvh ) { @@ -1028,11 +1021,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->cmdline_pa || bi->kextra ) + if ( bd->kernel->cmdline_pa || bi->kextra ) { - if ( image->cmdline_pa ) - safe_strcpy( - cmdline, cmdline_cook(__va(image->cmdline_pa), bi->loader)); + if ( bd->kernel->cmdline_pa ) + safe_strcpy(cmdline, + cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader)); if ( bi->kextra ) /* kextra always includes exactly one leading space. */ @@ -1054,10 +1047,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) safe_strcat(cmdline, acpi_param); } - image->cmdline_pa = __pa(cmdline); + bd->kernel->cmdline_pa = __pa(cmdline); } - if ( construct_dom0(bi, d) != 0 ) + bd->d = d; + if ( construct_dom0(bd) != 0 ) panic("Could not construct domain 0\n"); return d; @@ -1263,6 +1257,7 @@ void asmlinkage __init noreturn __start_xen(void) /* Dom0 kernel is always first */ bi->mods[0].type = BOOTMOD_KERNEL; + bi->domains[0].kernel = &bi->mods[0]; if ( pvh_boot ) { @@ -2129,6 +2124,7 @@ void asmlinkage __init noreturn __start_xen(void) if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; + bi->domains[0].module = &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Tue Apr 8 16:07:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3D36C369A2 for ; Tue, 8 Apr 2025 16:11:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942872.1341962 (Exim 4.92) (envelope-from ) id 1u2BXe-0002LM-O2; Tue, 08 Apr 2025 16:11:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942872.1341962; Tue, 08 Apr 2025 16:11:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BXe-0002LB-Ky; Tue, 08 Apr 2025 16:11:14 +0000 Received: by outflank-mailman (input) for mailman id 942872; Tue, 08 Apr 2025 16:11:12 +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 1u2BVc-0000a6-RN for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:08 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20615.outbound.protection.outlook.com [2a01:111:f403:2412::615]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cbb9afe1-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:07 +0200 (CEST) Received: from BN9PR03CA0526.namprd03.prod.outlook.com (2603:10b6:408:131::21) by MW4PR12MB7013.namprd12.prod.outlook.com (2603:10b6:303:218::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.27; Tue, 8 Apr 2025 16:09:01 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::45) by BN9PR03CA0526.outlook.office365.com (2603:10b6:408:131::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.35 via Frontend Transport; Tue, 8 Apr 2025 16:09:00 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:00 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:08:59 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cbb9afe1-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NvA8xnCHX6oY1DnXtoLNZ2GSqM4yuSunyTC/d6mpn9FgCib5yAEhYl0AV8cxfvZHxrnkWEPu6KavvHe57Q4D77dMH7K9FmalIZ6gghWHxw2b/6zEdOcxq7uAvwXjTjuSxQFZ/0GTh35l5IOfNBHFYhRoESKQHhOlnswi7ZocEeG8Yhm93dxpqpKVUtNDpgpWsTLb5QBBxYNf9R3JlMad7VcQoBU4zLqPF2eu381kK2gwR7o+FCnf9PQ4HWzKJjRo8hyKGXw+NMq7uzOhlw6OjkfHg8WmbP+eBdPV/e6GFHmbJu35anxYRsk8MAs7d4UjCblAe6Oh1mvNAz1X4tGsQQ== 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=Q4NLg8ZGB5ywF9hUuTTn4esEKLdJ7mThXS52DT8LHzo=; b=WkzqqgHWk6YmuRxoOp0UxkmpDuRlt0Vap64OKyH3EIc4J2nAeJY4xTzNVBZGiDNX7nAYxLnWaBBOMUxM/97da/xi+Z+yWM4beNiGzyJRNxQJrjatZ43+CaPlmM+CNP4JfzFQz6hJab+QP0p5u8A3DjtJcDxT+lHYp3pQwufAJyu3pFy69N1R0w9ocHzbq2ESMg3MemguNNbbO38gd0urhCMtG2P0xabOWAyEiaitvrI0IIKFt1dtEq2zRYB1ORgDbsxUU+t4Teq57DIxGg/FfKFGEbrQFettdwlzXbC9aMWt49pasoZIytIxbEytIrI/7sx0B+khpPtlFpr+5PVJ9Q== 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=Q4NLg8ZGB5ywF9hUuTTn4esEKLdJ7mThXS52DT8LHzo=; b=eD+Rn8EI6hfo6VaJwgIiXes92jo1SbP07RXGSEpUvBWxYWdJlUWDf0kzqAE/2ejpDUhl8Yk6qTNdmt8lF4L15ZjVo3QFSBd/zDbDLd8POLLNYIVcyvp7wGhepa+lT1xi2sq7U88giMdDrOES/ibHteBfWtoTcOpXn1RqmKXvpdc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Alejandro Vallejo" Subject: [PATCH v3 02/16] x86/boot: introduce domid field to struct boot_domain Date: Tue, 8 Apr 2025 17:07:24 +0100 Message-ID: <20250408160802.49870-3-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E66:EE_|MW4PR12MB7013:EE_ X-MS-Office365-Filtering-Correlation-Id: 96384393-4263-4c29-aeea-08dd76b7acdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: pab5bAnRK4kM2gptm1hiuNSEuHsWHTujALoHLnBWLH5OgU3NoH6K5l0a4zFxJyAXhYLy+CUeVTlh6s+Takd7BMlty328WmcQ1F8DP2SGtdG+w9l12jY1Yto6pWQbI/mSUbcM5okBrqqSCIBm+IlRAUiejxv8VDuExkzBDxv9d5QptTKRKZ8P+hQvqb+S4QNRA4CvBiDFOaRFi7ujjwR/Zssx4E6wuHL+e5qd88WtULWGc2EMyqFV7ychm0I6KGv4BYtNJdeLlw7WcpCRkz2PuOyEcesE3fJiMRHaFlgAgiSU3FEzV+cb+dyX7AeeI6gizgE/QiC++zHHEiQcgF3TbTTvaWe/pNeH+tidUJWtttFsG1HPbzj7KsWIqWboZLqC/l4hWUVmvbZJlH1fgykHwr7wbzJH2/HzmenhYivpYsYZmP+wNmsydRZlKPBGHOashTCekXhMyD6mrqrrKnqx27x1hW1wbsuIIzTRQN6rREgh99cpfPdptL3Y0OI8BS/GowR47GZczoOFV1d0TJo2R1Arb0tapjeIDdGITtvbKuf0mis2he8HIlM/+4uCKFbcQxPb2H5zbrmkDazUUzCEAsYgdCOHKbaBzoJnr3tdSxM0coy27c7pwZda6Dk2wQ7RMjWN9pYYGYOmapbULZagqkIzEo9PvulTOnWZT4E/OJrH3TQf9jmg22ZoyASpDo1/DW/KHGvuENIZMZinZUnGLkOywPBVSK4nalrxODNhzgCESXXxtYBTs37IMyTRJD1CAC9CB/e8vFshSNNDW+uJvvWW5HyqZSa6VtulC4X7QYScZsTH5RFVeK79pl0ouu7eKLm/B2RO56teuURI9NbWSx8nYkqYZQaJec/oFwdT8wM+ET1tP9sZKst4plK5sMKbOXemOufAoDHGgeOdXtV130kueEJvLTrH9yyofI8OKF61lozKBaQhEZ3LTj7Row5egpLghazbYE7BUSErfYGR2fJj23Egn5C7abi4ni45xGBCvbtCqltvoI5wCkduFjUZoN9w+omyNBYCHgugw8Kwf3QRgA5X2m5yx3j8WTTGrEWVSFePXCuCcDxiL3FlENjL9UHKJB/j6Wa5fQaAixl0Hg+jAvvumL/R2d5it3CcDVYB/NQuScSoVQXY2XrSC4aOBtl/lrK4+r8RiLuldZhbY2sbXykpnUgLavFECi6DrOWKn2PIaPteYLMLAgQPBzOS4du102/WpZnq/LfeF1MfuHljr4KB6y4CYGn/tyBeh8ZSwqe+WE0K0Uq4xNtzK94cdVQbZ2Y73r7G1YcAdcV4FUNy7ub58p/ZsNaohpoKyZ5lolVGNZhKAwjaBtvgd/8ZR1zd/76LSVDtB28IpDg6/EjlT6OcHy3L0+MZCg03AWlQW2V1No5zREc2WyoLcXswok4jSxmxiXeMpAkSxu5uFFrq2Otmc7xTGLxhmLXlA1mo5kRlYw7SCrMXnDbxLhACyxXKoG5GHsTV6kCue/Wp+w== 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)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:00.7442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96384393-4263-4c29-aeea-08dd76b7acdf 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: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7013 From: "Daniel P. Smith" boot_domain stores the domid until it is used to create (and allocate) struct domain. d->domain_id is not available early enough. boot_domain domids are initialized to DOMID_INVALID. If not overridden by device tree, domids of DOMID_INVALID are assigned a valid value. The domid will be optionally parsed from the device tree configuration. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo Acked-by: Jan Beulich --- v3: * Initialize all boot_info.domains domid fields * Re-write commit message to justify the new domid field. * Use "%pd vcpu 0" in error message * Move xen.h include (introduced in v1) inside ifdef guards --- xen/arch/x86/include/asm/boot-domain.h | 4 ++++ xen/arch/x86/setup.c | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index 5e1e1a0b61..fcbedda0f0 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -8,7 +8,11 @@ #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; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ddb10ea03d..585316f1ca 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -295,6 +295,7 @@ static const char *cmdline_cook(const char *p, const char *loader_name); struct boot_info __initdata xen_boot_info = { .loader = "unknown", .cmdline = "", + .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { .domid = DOMID_INVALID } }, }; static struct boot_info *__init multiboot_fill_boot_info( @@ -994,7 +995,6 @@ static struct domain *__init create_dom0(struct boot_info *bi) }; struct boot_domain *bd = &bi->domains[0]; struct domain *d; - domid_t domid; if ( opt_dom0_pvh ) { @@ -1010,15 +1010,15 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid = get_initial_domain_id(); + d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); init_dom0_cpuid_policy(d); if ( alloc_dom0_vcpu0(d) == NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating %pd vcpu 0\n", d); /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline_pa || bi->kextra ) From patchwork Tue Apr 8 16:07:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 713C2C369A6 for ; Tue, 8 Apr 2025 16:09:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942757.1341851 (Exim 4.92) (envelope-from ) id 1u2BVe-0002td-5l; Tue, 08 Apr 2025 16:09:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942757.1341851; Tue, 08 Apr 2025 16:09:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVe-0002tW-2r; Tue, 08 Apr 2025 16:09:10 +0000 Received: by outflank-mailman (input) for mailman id 942757; Tue, 08 Apr 2025 16:09:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVc-0002e3-E0 for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:08 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20611.outbound.protection.outlook.com [2a01:111:f403:2417::611]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cb4e7e22-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:06 +0200 (CEST) Received: from MN2PR01CA0046.prod.exchangelabs.com (2603:10b6:208:23f::15) by DM6PR12MB4435.namprd12.prod.outlook.com (2603:10b6:5:2a6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.35; Tue, 8 Apr 2025 16:09:02 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23f:cafe::e3) by MN2PR01CA0046.outlook.office365.com (2603:10b6:208:23f::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.36 via Frontend Transport; Tue, 8 Apr 2025 16:08:48 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:02 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:00 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cb4e7e22-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zTFE9824XvjfiH9b3+ZuyHYaPZ9x+mdyDjtaNaXJyzFz45xfCg3mKadTGtLtz6Ean3dI35GVZN8unTiTwMtv2WGkcN1VBFeMAYK5wpIAuNHuWn5BXvQ/+fu2Jt87RJm+VKlXUJjbOx0WUjiEfH7bXE7HmZPNYwhgwG7ZyKjlfKdVBiQfoxY5c3U+5G2YbTcfpfajge1OengPM1cx7QJCiOySfaoCJvxlsu6+VHZMdmLZu5OQmf2qeSf18CY/cFKFOIaxY5hrZ6aNee7bFJGiLcpN5FScT7Mo8S1sNGS+YFZ/z3+SR1Fe5qeoPe/7jnwrPVU7Ua8d6RfMF0tal1Fflg== 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=acKtpqdz5rKNc8zWQXTuBR08dJPveEi+YEopFwkWo8w=; b=cYxBvsoiFYFvShJOAx8rx1mebMqsaMRyVFt/upYe4UmEz9OvsOJqYU5E6yjhfDb78OjTzI3c/S1BtKhvyZhoXNZDPkWCYb/7wSfyn/fgiPpVemsghKmkTvQpkE/aEb7y+lJzLdGUQf0CUoWEFLDq7TvTLljOO5y8k+t+49PLFDSpzEIsXAjqr1ipOVByXXR+BFN57UstEkuXlUWbr1o/rCEGIXoA5zT+ZFqwliE2EeKP4KqU2SwHpRvm1ODmuOYQjgddzaIA62vxzhl63Z3evyGf5JaaHqBDL4b+k4K3D91+J7Hfv6G+7L4NroNp4hD7Wzx1Y7EzjahRFtlvs8qOhQ== 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=acKtpqdz5rKNc8zWQXTuBR08dJPveEi+YEopFwkWo8w=; b=bi0exNWpXUr5omJEPM2wf6OflVwNrnUga3X7wCXenMJb84FP/hG0q1no+xB5oVLmyxcEyqbpo+3FdTi+tEUW7Bcnatep/ukd32SkYVL2reoO2cScfVdqKp+mEQ+NjomKgzWAvOejs+9gU5jzP0p5L86jPjjZVXn8owlsbWBh+NE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Alejandro Vallejo" Subject: [PATCH v3 03/16] x86/boot: add cmdline to struct boot_domain Date: Tue, 8 Apr 2025 17:07:25 +0100 Message-ID: <20250408160802.49870-4-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|DM6PR12MB4435:EE_ X-MS-Office365-Filtering-Correlation-Id: 9435efbe-6024-4f3b-8173-08dd76b7adac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: f63r3c4TkUhcP5Z+KKCL7F1L9SWwsmAWYFqyKhZvVqXX7AeCDYgFHKSap1aiQWX55EHZ3TybxLZnS6HRptJ9Z+23Sry7Wg49QHP39vE6diMb3TgpKKnTmpOkyGErlL/EuJD47+waHttjTSwWnsGdHON4vQ9dNCtYt1/ukA4lQHAhF25yb9a+Ukp9+HeEKI84Wk6M+QpSfD9nKjOdcvHogXoUAiuSQGZm6diNhBh07pyaaDA6qvIgJHC4dRqHX9GWDyLLdH8+ecC0ppLW9BzFx8rpzOZ0dvKaevSX/8SQwAy3HAqCA2e4U5Ay84FQMeTh6RvSEuo7M9IGsm9IKpQjR81n9mP3k/bAFQKqcQKdF7L8Cx9i0EPHH3QbfLh3wofZSJ7XOaPuUENx01wZjAa8tv+FeOd9sJueDfDtXDsonNksm5WD0nUMf1g4aUv5ZmHj79fJQ/pEdJs8AdlMlgvTkLaukOGHfTpVwNJ5UHpFS0cipSOqWeOfzCrNjIWnKZDdH7jhuOVF2OwLdI94GtCHoc5rWes19LL0RDvmYSBp08mzD4E1YUxdRAtkAA4d+vDs55CIA5cHvM7mSgjkNHhZZULtlM1ck+fATvaXCwAl9UGz17OQKFx9Y9+pi66Iatzl12/oFNoFWwEQD9qZXFPBi2AVamcItWQY/lHOHh4oyU4F7fkQz9tQrBtt4x17JjA7TztJjpxF+54vZe/mKBmpKiCaTM8JY0T64NZtygThlngfm0hBVdEO1dQnF9bNfnUvL+VFoyQOdp+GW8KtuADQvB2YPF+kybEJQnnahEsnO7FJHG52Fxy2Q0d2gGwqLIjxOWNfbxxjpz/PCzadx1s/eQ3wlveDCaYZbLg35k2QMCOWGeKtIAfv1/xoQQ5xLV6cfG/1gD1w73Cp1wpxCmNlAynZ2s3tc+M2x5qfmPfFDz9F5HSYXwwvHMDq3jxRW5sA1VkZZvY2eXNIqOug/blnGo0CNTGWFKnGA8EszQm+5O7orYqdEnhTexM2BKhpwhAJ5oT2fkkbgQLjeRus4upkaW5CfxcaNsE0O9tmQj3ew9ibIO1XSVdAaRAoq8Krn8hsCKFZ0Z1IWSkY6++lZqORtYnUi1EZ4IGz5lCpcVkIzvc0hwG3TC3NLNUnZcb2UsLpzcLGEWyJMXM80lQw6TOSVgPr1Gfw+2z8qwvgUjTqD1sod6Jzk/rM4rwrpJZPs0tUYnERJJx7ncBshtxwxFQaELsLDERQIAVSRfg3KVfH7Wej0CNBAMdWyi2LzUnufoo3lZItALnmYuGAwbKSgZ2a/UXh8ArgcGC67cWoawDRlaJ+lUECDbCRkn4JwOnLXApD3XICVOjyANQOlr1CV/Z7Xai3w0jTULPRWhNb1nI5H6nxI+mWv1pVLJtFexpLifjJ1ipmUs702foAXSW/er+2InKBVfeejzbbbZP/6FSRea1mP/PRGVWH8oL5YVXjw7wJAF6zprGbi75+Pw+zFt75ZuNU8nqYauojYAQSuvJ8Ou8= 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:02.1022 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9435efbe-6024-4f3b-8173-08dd76b7adac 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4435 From: "Daniel P. Smith" Add a container for the "cooked" command line for a domain. This provides for the backing memory to be directly associated with the domain being constructed. This is done in anticipation that the domain construction path may need to be invoked multiple times, thus ensuring each instance had a distinct memory allocation. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo --- No changes on ACPI cmdline handling on PVH, as it's orthogonal to the purpose of this patch. v3: * s/xfree/XFREE/ on failed construct_dom0() to avoid a dangling cmdline ptr. * Re-flow hvm_copy_to_guest_phys() into a multi-line call. * s/bd->cmdline != NULL/b->cmdline/ (to homogenise with the previous cmdline pointer check) --- xen/arch/x86/hvm/dom0_build.c | 12 +++---- xen/arch/x86/include/asm/boot-domain.h | 1 + xen/arch/x86/pv/dom0_build.c | 4 +-- xen/arch/x86/setup.c | 50 +++++++++++++++++++------- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 2a094b3145..ebad5a49b8 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -653,7 +653,6 @@ static int __init pvh_load_kernel( void *image_start = image_base + image->headroom; unsigned long image_len = image->size; unsigned long initrd_len = initrd ? initrd->size : 0; - const char *cmdline = image->cmdline_pa ? __va(image->cmdline_pa) : NULL; const char *initrd_cmdline = NULL; struct elf_binary elf; struct elf_dom_parms parms; @@ -736,8 +735,8 @@ static int __init pvh_load_kernel( initrd = NULL; } - if ( cmdline ) - extra_space += elf_round_up(&elf, strlen(cmdline) + 1); + if ( bd->cmdline ) + extra_space += elf_round_up(&elf, strlen(bd->cmdline) + 1); last_addr = find_memory(d, &elf, extra_space); if ( last_addr == INVALID_PADDR ) @@ -778,9 +777,10 @@ static int __init pvh_load_kernel( /* Free temporary buffers. */ free_boot_modules(); - if ( cmdline != NULL ) + if ( bd->cmdline ) { - rc = hvm_copy_to_guest_phys(last_addr, cmdline, strlen(cmdline) + 1, v); + rc = hvm_copy_to_guest_phys(last_addr, bd->cmdline, + strlen(bd->cmdline) + 1, v); if ( rc ) { printk("Unable to copy guest command line\n"); @@ -791,7 +791,7 @@ static int __init pvh_load_kernel( * Round up to 32/64 bits (depending on the guest kernel bitness) so * the modlist/start_info is aligned. */ - last_addr += elf_round_up(&elf, strlen(cmdline) + 1); + last_addr += elf_round_up(&elf, strlen(bd->cmdline) + 1); } if ( initrd != NULL ) { diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index fcbedda0f0..d7c6042e25 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -15,6 +15,7 @@ struct boot_domain { struct boot_module *kernel; struct boot_module *module; + const char *cmdline; struct domain *d; }; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index b485eea05f..e1b78d47c2 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -972,8 +972,8 @@ static int __init dom0_construct(const struct boot_domain *bd) } memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( image->cmdline_pa ) - strlcpy((char *)si->cmd_line, __va(image->cmdline_pa), sizeof(si->cmd_line)); + if ( bd->cmdline ) + strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line)); #ifdef CONFIG_VIDEO if ( !pv_shim && fill_console_start_info((void *)(si + 1)) ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 585316f1ca..83cb66e309 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -978,10 +978,30 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li return n; } -static struct domain *__init create_dom0(struct boot_info *bi) +static size_t __init domain_cmdline_size( + struct boot_info *bi, struct boot_domain *bd) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; + size_t s = bi->kextra ? strlen(bi->kextra) : 0; + + s += bd->kernel->cmdline_pa ? strlen(__va(bd->kernel->cmdline_pa)) : 0; + if ( s == 0 ) + return s; + + /* + * Certain parameters from the Xen command line may be added to the dom0 + * command line. Add additional space for the possible cases along with one + * extra char to hold \0. + */ + s += strlen(" noapic") + strlen(" acpi=") + sizeof(acpi_param) + 1; + + return s; +} + +static struct domain *__init create_dom0(struct boot_info *bi) +{ + char *cmdline = NULL; + size_t cmdline_size; struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, @@ -1020,20 +1040,24 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( alloc_dom0_vcpu0(d) == NULL ) panic("Error creating %pd vcpu 0\n", d); - /* Grab the DOM0 command line. */ - if ( bd->kernel->cmdline_pa || bi->kextra ) + cmdline_size = domain_cmdline_size(bi, bd); + if ( cmdline_size ) { + if ( !(cmdline = xzalloc_array(char, cmdline_size)) ) + panic("Error allocating cmdline buffer for %pd\n", d); + if ( bd->kernel->cmdline_pa ) - safe_strcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader)); + strlcpy(cmdline, + cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader), + cmdline_size); if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + strlcat(cmdline, bi->kextra, cmdline_size); /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + strlcat(cmdline, " noapic", cmdline_size); if ( (strlen(acpi_param) == 0) && acpi_disabled ) { @@ -1043,17 +1067,19 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") ) { - safe_strcat(cmdline, " acpi="); - safe_strcat(cmdline, acpi_param); + strlcat(cmdline, " acpi=", cmdline_size); + strlcat(cmdline, acpi_param, cmdline_size); } - - bd->kernel->cmdline_pa = __pa(cmdline); + bd->kernel->cmdline_pa = 0; + bd->cmdline = cmdline; } bd->d = d; if ( construct_dom0(bd) != 0 ) panic("Could not construct domain 0\n"); + XFREE(cmdline); + return d; } From patchwork Tue Apr 8 16:07:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37A05C369A5 for ; Tue, 8 Apr 2025 16:09:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942759.1341863 (Exim 4.92) (envelope-from ) id 1u2BVf-000396-HO; Tue, 08 Apr 2025 16:09:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942759.1341863; Tue, 08 Apr 2025 16:09:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVf-00038x-Cn; Tue, 08 Apr 2025 16:09:11 +0000 Received: by outflank-mailman (input) for mailman id 942759; Tue, 08 Apr 2025 16:09:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVe-0002e3-4R for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:10 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20617.outbound.protection.outlook.com [2a01:111:f403:2415::617]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cc8054cc-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:08 +0200 (CEST) Received: from MN2PR22CA0003.namprd22.prod.outlook.com (2603:10b6:208:238::8) by SA1PR12MB8841.namprd12.prod.outlook.com (2603:10b6:806:376::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.33; Tue, 8 Apr 2025 16:09:04 +0000 Received: from BL6PEPF00020E61.namprd04.prod.outlook.com (2603:10b6:208:238:cafe::78) by MN2PR22CA0003.outlook.office365.com (2603:10b6:208:238::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.19 via Frontend Transport; Tue, 8 Apr 2025 16:09:03 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E61.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:03 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:02 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cc8054cc-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iku/gousZ21/CoWtL7lDRJ2yxYjsJmDEo6Nji6wFn4aNP/7BW4pts9DoxmVkjaMw7EawiRofc3Chkt8owRbWqhiPe5jZ3QRjiYFCZWxWXPM5xjqK3BnTQd+uMth9Mk/A0QnsG1zjTsB/oM2gNOdMac8H7f67uKiBUL24enDT+mG+yKK2i874owUwQwmZUE35uUb3q54qbU4r+7OHNcoIAdZNK3zF2p7j9vWF/nJSGgXPWe4jXfWAanOHxLJ0WfHeFEHCBPmVzLLo2Bth+4EQpX6OzuTJLYectXad0OkfvoEBHnXU/on8Rd93H2CqXh+ka+kcM5lZQYv9wO1fYKU/tQ== 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=OCvGl5qSWPYcGWEgjrtQ/PCpkzIvwhogP31QetCQZRo=; b=AAz08EdfsOsDqAM5n9sr1f7qlqM1XjUcZVrqqCv1Nj6XpXH9ue9mWvSsHwYW0qlycTf75JCJv+Z6kXLFSm3cYZ4aFB68PFFM16+4tPO410g69Uj8vuNKcU/jFqdwfYcFmDztWfhD06ROalbdUB5OfLddPCrKLZ5PkxRPQkuMzWomaSbPFzySULMs4rxtU1MnG+Wd0j5yv+L77DWjXywNYaAZdVoYzBgbsYy2EhZcXThyP7Xzqztd40plxpV0E8Js1gvpjWeUYqjebrQyfnoG7N4F2iy5YnNhSFnb6HkzvXzSTubaC/guAR+Wc34wJbIw9dZeHuC+//pgroc8LJVLUg== 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=OCvGl5qSWPYcGWEgjrtQ/PCpkzIvwhogP31QetCQZRo=; b=lGbrErOSaF+06/NWLGw6hf27+tbSIKW/vhkjPRLkfXDoqqjGOEKnP1zV26RDQsYZKHSmUcxVUiNpKt3uA49Q+6EnneSptOoxnDNDv/qDouOFES3ltLbx0ssPflYVnVzFK1p4z325RYqxfXmURT4BZPx3qRG4HVDnqDmAgRBKEL0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , Andrew Cooper , Anthony PERARD , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 04/16] kconfig: introduce option to independently enable libfdt Date: Tue, 8 Apr 2025 17:07:26 +0100 Message-ID: <20250408160802.49870-5-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E61:EE_|SA1PR12MB8841:EE_ X-MS-Office365-Filtering-Correlation-Id: eb043a52-d5fc-42c7-9be7-08dd76b7aea2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: dVjgg1Wek5nh/RpX9n3dW4BeXfcxPzsrooILqrwAZp2qRIVVwZ11ghX4Pfqv5c14qo4i96f+GmbUShJEqkJHndJqzlGvFDMMd+3bHDIET8fURTfigTmIx+3QDrnmQP2o1rfXHa5/6qZ4NHW6HINFVz496skXY62+5yUzL/9c8J6eNGFcqeR5hrvSj0p0s+G6xsABWB1UKQdy8mlAyOepBaViK3oIyDlBC45tmOMlOxkjxyTOuu9gQVBCceNBerPiigGSc/1sRHSitLqvnjBVkqltr1u4Ht4bUodBc0dEf5jU4LAOVoLakCLZ7JcDtZyWA0p9ptfrypONBdML1aCsYK7Ui/yyVkA4dcD7HHDPVKsb3XGzCCV68Ba72fNlPUR9dqvn9vUrjE83CFtAYhwGfjBlBd9MjfRJcvjskIzPrYZny6Qcgo35ZjYDrNBOsTSetrj5iag92DiYnNbEATEemZ35B9dEsi2zVk1YAu1AENhT6uPzw4LZMgh80kKe0eAl8ptXEFnlkiqUbFDxdmg6Z/rrnqFuAtdkpU+61fkCteOOZOkRtacbz+otEz4njdkzhcMRBBUa1CmWumD3GSZasEbbzXHMqu2s6oqIqVf6m/5szApzKC4RPS9wzfj9aXDnk0fGdwwmmwPblx39WnZN9XqqDEXDla9Red6VRAwAMcEBDlmBX8GIBJfWp0PEDWhxhKnWQ+mSN5BVkYeVv8iY8TV++NzexciDMIDjI/YKOSe+rPOLVxYkld78tDoKwBmmJGpfcOSwLvNk8NddMSWtCcZDcdf/H/0GzAyj85tMEwENlo0dZBOnvDQJBWE6D3O2+MRQVn1I8Zs6vRcSw7kJKDm0Jv2W5ky09QuUNWaarGVx05rg+yHI0yNvLX4SG5IMo0RM/jXAML06n0z8d8c3F+LPH9D/ECrCBMWJZZyUj7LqVNgZ9F1Jv44MQPqyUsN/GDMIXFy2emuZxBA0tByf5LYHtV1ObIgvxXlz1U08vfya1ELQLplvqSTQVoZA+i4WTW+3oXucBsJkhq2z1xK/WnE5DAFfdVy/VqoVVsOPG02NC7btmKuU0bcYdDhHpIjvs6FINhh0XPWCsPT+j6Zue2Jef/JcS5WtVuowjyMdfHQEIy6z+ZqWZV1B8wNp9dFdlERA7AGEqOmdDJwJODXVlJhfllNsga/DWs+/Kz1f3XE5RE3gaBc9qZN6q0Hx2N4FdPBvCU3EGsQKLWe4WaCTXD2DeqqZfJ9mbuLHxLO3yzLvmBwZiYGYpX0zcYEgNnpICUT0RLy+lzTXSHtupF/XfIm14T5r/y6kltOKnM30xWhPAN1z2ODmjYgXvFcu51Yj1/akOWyTxvKyh7Q7UPoYIl9Uy3kuKJvYGQHZZx8LQ7gd64s3UQOsi5nS/eseUiiX6+5FPrOJgJpThGtrD+teJxKajI4fS9j9jPYbOF4XAzk3IcgKyb0XXS4TwlRm6O08kPeew6R2wZhda5l+QuJZPw== 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)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:03.6994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb043a52-d5fc-42c7-9be7-08dd76b7aea2 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: BL6PEPF00020E61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8841 From: "Daniel P. Smith" Currently, the inclusion of libfdt is controlled by the CONFIG_HAS_DEVICE_TREE kconfig flag. This flag also changes behavior in a few places, such as boot module processing for XSM. To support the ability to include libfdt without changing these behaviors, introduce CONFIG_LIBFDT. The inclusion of libfdt is then moved under CONFIG_LIBFDT. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk Reviewed-by: Denis Mukhin Acked-by: Jan Beulich --- v3: * Use CONFIG_LIBFDT instead of CONFIG_HAS_DEVICET_TREE --- xen/common/Kconfig | 4 ++++ xen/common/Makefile | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 06ae9751aa..00f74b1e32 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -72,6 +72,7 @@ config HAS_COMPAT config HAS_DEVICE_TREE bool + select LIBFDT config HAS_DIT # Data Independent Timing bool @@ -106,6 +107,9 @@ config HAS_UBSAN config HAS_VMAP bool +config LIBFDT + bool + config MEM_ACCESS_ALWAYS_ON bool diff --git a/xen/common/Makefile b/xen/common/Makefile index 9da8a7244d..5a9041b0ee 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -79,7 +79,7 @@ obj-y += sched/ obj-$(CONFIG_UBSAN) += ubsan/ obj-$(CONFIG_NEEDS_LIBELF) += libelf/ -obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/ +obj-$(CONFIG_LIBFDT) += libfdt/ CONF_FILE := $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(objtree)/)$(KCONFIG_CONFIG) $(obj)/config.gz: $(CONF_FILE) From patchwork Tue Apr 8 16:07:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C08CC369A4 for ; Tue, 8 Apr 2025 16:10:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942784.1341891 (Exim 4.92) (envelope-from ) id 1u2BX2-0006W4-FP; Tue, 08 Apr 2025 16:10:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942784.1341891; Tue, 08 Apr 2025 16:10: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 1u2BX2-0006Vx-Cg; Tue, 08 Apr 2025 16:10:36 +0000 Received: by outflank-mailman (input) for mailman id 942784; Tue, 08 Apr 2025 16:10: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 1u2BVe-0000a6-UD for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:10 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060a.outbound.protection.outlook.com [2a01:111:f403:2418::60a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cdc17917-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:10 +0200 (CEST) Received: from BL1P222CA0030.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::35) by DM4PR12MB6589.namprd12.prod.outlook.com (2603:10b6:8:b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.35; Tue, 8 Apr 2025 16:09:05 +0000 Received: from BL6PEPF00020E5F.namprd04.prod.outlook.com (2603:10b6:208:2c7:cafe::46) by BL1P222CA0030.outlook.office365.com (2603:10b6:208:2c7::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.35 via Frontend Transport; Tue, 8 Apr 2025 16:09:05 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E5F.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:05 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:03 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cdc17917-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T/tnOfkI3kiJBebYNjMhCJbJJPaGPYM5ntz3/E6ssWTNw0KXV3LKOX8TgXlS1DKn0cH8Nrl8yNoQVlipE7NIRw1cCQP1K0PKhiAcddVyixcSn0ppVc5Baj8PIzJIA+ShcJ3XbJ1SMOdTPKzWDAc/chbfk++mE7N4oXU0eDRjxKcJ+qOPDnL5knlzgRJ318/mRCjGtWAHj1J6V7vA/lTMaW8a44fAQaXx9gK0ZCVEhkvTepfixxpm99NyvH6cWUUF5kKOjAIsIoSFEBPMczPA+6ESOYJsFylYkow1h3T4TSbjtM9lgyr5ytSNyBjFUtQTBGXLp4sfPpixmwpKgq5lwA== 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=WEwRiBF5EEuyNhZaJK9NgqTmDdKtu/qhdxHFkSWjIjY=; b=cAaJe5t2v5Njo/uJthgv5iMkfNomo8KJDEzDInTPHtVigGZSKuPugaTzFwhANXLush4rVP9CqfAqSaZwGEpRQxz1aBD+Gc5aipbuj6+Kw7ZCe3jUkmrpLC5ibbuJH7dd4OI4pguj2+NUVZQMdCQFV/r1s9Ba+vlrXF8LAHPAs8bqe37nz5laHeEFLt06WNPVi5Ko43lgy9Gx5H0TOJeyEkcxk9sc0XJ8ioOINbiz20TzLrMUp5AZGnwbyDQ2fzqAZy2b4ZYKanlCKVrDoI+1INxUXLZEe8rdUUZObaxriRBv0PQm0sQGZdvA2Y2RqnCebX74QigwWb3vtCJwVcscPg== 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=WEwRiBF5EEuyNhZaJK9NgqTmDdKtu/qhdxHFkSWjIjY=; b=Hx+r1VO4O6tAMBFBf5xeYKB//Ymk5D4cV4lBsqQr5CjR2j2f7eD1RqlLBZVNJHiBkzvILLzNd3vzQkfU0tVdr5jiznEEz5F2JZUMBlZ0+rv7hwlmhbC0hEDg4jMzmaF3xg0xYe0jJpw2VT4Ogzr50fFHeqQrfo/BrgtiwaY4K54= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 05/16] kconfig: introduce domain builder config option Date: Tue, 8 Apr 2025 17:07:27 +0100 Message-ID: <20250408160802.49870-6-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E5F:EE_|DM4PR12MB6589:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c88989f-380f-4e36-965c-08dd76b7af77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: Ax3ue7Ha9sftU37v/Of1ciIA2S0GfnxJsxv8z3DvkX5KIh+LdDhWusVa+kOJ/gSTcTj7Rie+34pYi0MoZjGIbzk8k0kgg5ZRlGOhRa5zhszP+1qUj3x/fCIPCD5kgQjb4UhVe0fb/nKCQ2XbW2J8i448S8VaTlefWskwAE32K4BNbLP0c9itJNotMTgieavd/naTcjr4XmRbPmYuJ7SVRz65YFFbt8USpqsw/qlf724N9YLmvuoWTCGePUcX1k422PJPWlQHWuQNrSgX1oqdWBqGfSow/N6QuqDGtr9NZ/FGd3vbTdpyDrSJrtGJXvBnyW6vHpuA45wn8g5b9pilNMgV/8Efh86Ps8Dhl0vqTYT6eevcP/f21yCb992QErh+WjLv9Jke3sszp8eZOYhVMUzYI3i7YVG1qcX9AKADfKwQb1/D88LKrfxWuQGLO42XfKlABA1AOeWkQCchPui8dhT5xjDy3ZkVmVgR6aMr2lomIXtLVhlG3Gp6wF9F6LsxHsBMPv68RG19vMyTbHcQ1KObcMy+YkMqiA9buCn3ehmQrwmaTc+hlKBxXHoVsvnCgQtqIj/xLb2wGBI+GF6Wqf+qK8nq8pzsuASVP8eHykpEPNSi7wThHjBSy2oJfclu9HfQe8vqceRZb87Bti2I4epDtlUV0PiP4BHFWduB4hTI0VKh6j6WlwJUu4WGuQ29tpyDeTuISFw26EdDC+UVnyefcwo3EeNj8FGb5JkKlMQxiWHeBU62GkCT7ascgyOUhQaNcJjXdNeGh96N2adwgEFu7q8RF7pSgYrCwOlOWwcWAGc5ep/CJcDi3tHBjkmQXIOMGY7DI11+woSBugTXZrk+T6d/c05YunqqrfaLIxEvaFdOMlSIoGhaf4r5h4Ht+eWHQKYW/gIdxmzWgYfo+sHZ1xnPXqktBovgpQFmDw+EDLUPioMokkt0t7KZ+XHR/d6vscka2IpxIJz7eJc8JdkSTX4hB1jI3tWMWhxempdV9HYPDWBRUxUnRCAnZGMSj55lQrxvu7/0MU91weJEXdbojAuDItZMXdu80cyQLeklnyvRFrlcTXrOyk75we6hRNrQbMDpgWdYbOUvTdjRzHsyRlWcWDtFxCxnUwYD/vRCFZJ/APGlJX8/F5NWXzmXNiKCN+Z6sv+s2Gz/MBEDnd+idBISplFErENpykaIv+nVRXVN30SjGho2OcSCbzj+o5jz3XowBS2+X6SHih9TAaqLZl80YwMlHxA1e2lvVE2AWoB07ZwkId7VBd4meb/HRFUqZVvPBRVvpuOqvw0daYUM8l+v/KvCE94elwdIE+kWSrIsJbxJsHDgnOAG/cIOtwogTo7+gA6FUUBbqpC6SLltV0NXc9AKFm7v+Ii9nVEHjRhZ2ldWQeICukaA0c3WKszk0xUZVUJIOEkIMthCN7iFdXAeWX2Ql/pCWwGfX/TuOFHdzaIsWHKUgIM6tcO+JSDC39qJEb4sM/ECRsOBpQ== 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)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:05.1108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c88989f-380f-4e36-965c-08dd76b7af77 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: BL6PEPF00020E5F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6589 From: "Daniel P. Smith" Hyperlaunch domain builder will be the consolidated boot time domain building logic framework. Introduces the config option to enable this domain builder to eventually turn on the ability to load the domain configuration via a flattened device tree. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- v3: * Minor s/_/-/ in the "source" line --- xen/arch/x86/Kconfig | 2 ++ xen/arch/x86/domain-builder/Kconfig | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 xen/arch/x86/domain-builder/Kconfig diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index de2fa37f08..a31002324e 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -321,6 +321,8 @@ config UCODE_SCAN_DEFAULT Enable if you have a Linux-based dom0 with microcode attached to the initramfs. +source "arch/x86/domain-builder/Kconfig" + endmenu source "common/Kconfig" diff --git a/xen/arch/x86/domain-builder/Kconfig b/xen/arch/x86/domain-builder/Kconfig new file mode 100644 index 0000000000..8ed493c3b5 --- /dev/null +++ b/xen/arch/x86/domain-builder/Kconfig @@ -0,0 +1,15 @@ + +menu "Domain Builder Features" + +config DOMAIN_BUILDER + bool "Domain builder (UNSUPPORTED)" if UNSUPPORTED + select LIB_DEVICE_TREE + help + Enables the domain builder capability to configure boot domain + construction using a flattened device tree. + + This feature is currently experimental. + + If unsure, say N. + +endmenu From patchwork Tue Apr 8 16:07:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78BA0C369A5 for ; Tue, 8 Apr 2025 16:09:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942761.1341872 (Exim 4.92) (envelope-from ) id 1u2BVi-0003RO-OV; Tue, 08 Apr 2025 16:09:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942761.1341872; Tue, 08 Apr 2025 16:09:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVi-0003R6-L1; Tue, 08 Apr 2025 16:09:14 +0000 Received: by outflank-mailman (input) for mailman id 942761; Tue, 08 Apr 2025 16:09:14 +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 1u2BVh-0002e3-UH for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:14 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20621.outbound.protection.outlook.com [2a01:111:f403:2407::621]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ceba2474-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:12 +0200 (CEST) Received: from BN8PR03CA0020.namprd03.prod.outlook.com (2603:10b6:408:94::33) by BL4PR12MB9507.namprd12.prod.outlook.com (2603:10b6:208:58d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.34; Tue, 8 Apr 2025 16:09:07 +0000 Received: from BL6PEPF00020E60.namprd04.prod.outlook.com (2603:10b6:408:94:cafe::e1) by BN8PR03CA0020.outlook.office365.com (2603:10b6:408:94::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.35 via Frontend Transport; Tue, 8 Apr 2025 16:09:06 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E60.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:06 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:04 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ceba2474-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j2EnC5HEsJVdsX3IcTEtl3bxSwm0uFg/8pTfgTPHFG9Is3+o/nOUIymDU7baeCnwKs4v/OkLIrNEO3JHFGb3sNRtPlHe5y+3BcsoqEQVOjOQizGBWfcjocJCf1j59abuC5R0MPkJkCsr6bjyuNm/9R7Bl7CDpOlmyt6Vftif1hzDVshyJwbM0kYzRRCd9RK1LhLDlFMNto1DsoPs8ZEQgOQ5uyONqvjOKPo4+EebPo734IpjelzYyzvvBRJLb6HW7XM9X+5ibMVgfXRCL/NysYLxxcxH3CYtOy4LMg+8p/trzEe4OmUPuvN37CD2WrN+Q4RvWrnmx2+0BkkUvUUCpA== 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=FHwz8UwybMYOVzVonk4njjqdjxliscrCFkwYeqNUQrU=; b=wVIfwK1fJsAkZ6/6UEAvdUw15CsMQ7FzlJqmcF6T7MfBv3PErptXfk7umncnHst+vSHe9sP1DoeKT+aeG/CFSHytvVFJIlSOH2oYcTfRONbDI2ceNe+q4YVrE0sZQ67TH/WKEM2uI7FG7sBl2hjiIItBhQCbUfmznTqG151dvOZfoy/53/QORnthN79cxnMygX4qtU4j7n78LwdK4cxF8/BK+JB7zDH3Ucwu/yofDEFkrAvGZIiGxLxe5yfEpVy7bEfLEPCAxZhHlrVOfQaRO6LJFbrexdgjY8DKvs7gtYITMwXtWhb/NQ06wpm/6bR3NgkSCzYm6GTYOUxhEHS9ow== 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=FHwz8UwybMYOVzVonk4njjqdjxliscrCFkwYeqNUQrU=; b=wbPF9eyDV3510sWrB8+OuTfgInoUEEmjhu2hTSTJqtREgSGhzvPSh5dYU5AbiasHmlY/Xw46ETWUV2Ya8xJ26rF+5nzaavEfUWYDkenXwTPmhyULsymvbr+HMmVimCXTp+lCcOv9RxI7bh5a1GCTipMMu6XhfZBNymGord7O5Yw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 06/16] x86/hyperlaunch: introduce the domain builder Date: Tue, 8 Apr 2025 17:07:28 +0100 Message-ID: <20250408160802.49870-7-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E60:EE_|BL4PR12MB9507:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ba40aab-c975-4942-bceb-08dd76b7b05f 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: pRIQx3L6Zr5vtukdo/I3MD1QPHS2VVLzdwaHysj76rw0bnZMA0ZsLhT5nvEDDX0G02QG3Hs1va215dOLU1VUaWHIEXHkC5/TwgT4gnvPchbYJ3Nzw33w7f3w7+aZXBcbBlKXfcoDDBCi9c+mHIXo/41KhMe80nuXZ8LgP7H9RhXXJHX0GpjvgvRgGApzR/nC+AZ0NYk7EG1gknAVtLbEG9wQH1Ks0ASC8fZydFyS9KD+smQGk+SDkn2DRJceKQZs6ik9sRVfacSiYKOl20phoD9ZzcGFsh26zBYq1AJ80uCdHybhmnAv13FgExpsyn5qP2fYpZMcX0dPQ1+i2bgiRc3E4YE5kltAP48XrHOKKja9eSc1bFTcGmiIneFP7zTtNDb1bGpxAncvM9ERkFkaAlJfaSDsNlqdwZxXvJP9PsPtj+egDYoCZb/penLslDxFC4pFedYuOb0YGs842H4T1IO2dFCQ9Y2jJZKsUudDaC+wOKdSO90+2ihX2sPbQVgqgzN8mKejWCksAVbEI2JxELp9pGPXyVzmrR/fsYKcGdrIgvfIgmB4HTmjN7Yrlo87idGcG7OZkaTPW0A3EIWUOsCFWDjV6sf6+CYbq5sP3dSMXLLTfWLNwcqYn2l5niAzt9jfPu5rEZKeHpw0IzSRt04kdZRMTSgZMOXNkknZTwbB1lvu52CwTn5mUBNDN9SR6hcqAqtWvw+flTPDBXUGXjZ0uldnv/RpL6Khhrtv/vWu9M8yJZb23kEVEfhGUyJxdFu4jIA2RI1tNcSUr3GJesyFYZph24GoUg0AVNCTI5DXuiqo7YG9O+dRQaJD1uAU45lqR+hnwMiXuyIHMCD+n8ZJFb15nKyZCPOvAvuL7NehUW/Fltuf2I/2/gvPJ9CTzydrYi+dNGt45SJVXpbhFlEBe88sOAYuNZNxTjcDtHQ026/Dsnm5/XuHMOI/xn16NxEVZL/NX9/0ccyiQhfW+NjL9LyUbdaczqoDTqd81zy76UVpu/WC0zeaeH/eoj2Z0q1bO8YsJ7T5EvzqFeDS3qaMZ3xrEXnBMbc/T9SPKE8EFPp66deC7qfk/EwduHsEU61U2vdqD8HTwfM9Rm0SMZD4SqM9Dat7KAUFeW06PAi72SPnG/yItQRiCExxgRERJMv/LCqZ1E4KxxTG1wok3Y8d5JDPvG8cXc8VYFZzNfHwuLkE8ZbudQ2Trg/8uCr56lpRkpReCEOlQTife2I2E9rjMQwEqZMOwr9lCN7aul2NC/93Q0ta7HewhlGNEEF/ZmkCfDF0fweri2lemnRY4PqnSZzzpAOMlbcr3Vddmr9I/4cIwbJFkZ5l/eOUnNtAHaxloBGuOe2Bt1enqggAcJnY2tm6tUw6M150PyoC/MNtAQAN5fcRj0KDv00Icnatm946RN/OQwKeKeIf8wvb1oYbTNHTQsTv80uZ2NOl+0Sn8BnIWViIkCDCMDYrzd0K8ssPJ0W+PIHjxCHuUMTQIw== 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: 08 Apr 2025 16:09:06.6166 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ba40aab-c975-4942-bceb-08dd76b7b05f 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: BL6PEPF00020E60.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL4PR12MB9507 From: "Daniel P. Smith" Introduce the domain builder which is capable of consuming a device tree as the first boot module. If it finds a device tree as the first boot module, it will set its type to BOOTMOD_FDT. This change only detects the boot module and continues to boot with slight change to the boot convention that the dom0 kernel is no longer first boot module but is the second. No functional change intended. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk --- v3: * Move obj-y += domain-builder/ * Remove blank line in Makefile * const in has_hyperlaunch_fdt() * CONFIG_LIBFDT rename * Use boot_info forward declaration * Rename domainbuilder.h to domain-builder.h * Add fdt NULL check --- xen/arch/x86/Makefile | 1 + xen/arch/x86/domain-builder/Kconfig | 2 +- xen/arch/x86/domain-builder/Makefile | 2 + xen/arch/x86/domain-builder/core.c | 57 +++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.c | 37 +++++++++++++++ xen/arch/x86/domain-builder/fdt.h | 21 +++++++++ xen/arch/x86/include/asm/bootinfo.h | 3 ++ xen/arch/x86/include/asm/domain-builder.h | 8 ++++ xen/arch/x86/setup.c | 17 ++++--- 9 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 xen/arch/x86/domain-builder/Makefile create mode 100644 xen/arch/x86/domain-builder/core.c create mode 100644 xen/arch/x86/domain-builder/fdt.c create mode 100644 xen/arch/x86/domain-builder/fdt.h create mode 100644 xen/arch/x86/include/asm/domain-builder.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index f59c9665fd..deae31d627 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,6 +1,7 @@ obj-y += acpi/ obj-y += boot/ obj-y += cpu/ +obj-y += domain-builder/ obj-y += efi/ obj-y += genapic/ obj-$(CONFIG_GUEST) += guest/ diff --git a/xen/arch/x86/domain-builder/Kconfig b/xen/arch/x86/domain-builder/Kconfig index 8ed493c3b5..51d549c20d 100644 --- a/xen/arch/x86/domain-builder/Kconfig +++ b/xen/arch/x86/domain-builder/Kconfig @@ -3,7 +3,7 @@ menu "Domain Builder Features" config DOMAIN_BUILDER bool "Domain builder (UNSUPPORTED)" if UNSUPPORTED - select LIB_DEVICE_TREE + select LIBFDT help Enables the domain builder capability to configure boot domain construction using a flattened device tree. diff --git a/xen/arch/x86/domain-builder/Makefile b/xen/arch/x86/domain-builder/Makefile new file mode 100644 index 0000000000..b10cd56b28 --- /dev/null +++ b/xen/arch/x86/domain-builder/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_DOMAIN_BUILDER) += fdt.init.o +obj-y += core.init.o diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c new file mode 100644 index 0000000000..d6ae94f45c --- /dev/null +++ b/xen/arch/x86/domain-builder/core.c @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024, Apertus Solutions, LLC + */ +#include +#include +#include +#include + +#include + +#include "fdt.h" + +void __init builder_init(struct boot_info *bi) +{ + if ( IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) + { + int ret; + + switch ( ret = has_hyperlaunch_fdt(bi) ) + { + case 0: + printk("Hyperlaunch device tree detected\n"); + bi->hyperlaunch_enabled = true; + bi->mods[0].type = BOOTMOD_FDT; + break; + + case -EINVAL: + printk("Hyperlaunch device tree was not detected\n"); + bi->hyperlaunch_enabled = false; + break; + + case -ENOENT: + case -ENODATA: + printk("Device tree found, but not hyperlaunch (%d)\n", ret); + bi->hyperlaunch_enabled = false; + bi->mods[0].type = BOOTMOD_FDT; + break; + + default: + printk("Unknown error (%d) occured checking for hyperlaunch device tree\n", + ret); + bi->hyperlaunch_enabled = false; + break; + } + } +} + +/* + * 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/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c new file mode 100644 index 0000000000..aaf8c1cc16 --- /dev/null +++ b/xen/arch/x86/domain-builder/fdt.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024, Apertus Solutions, LLC + */ +#include +#include +#include +#include + +#include +#include +#include + +#include "fdt.h" + +int __init has_hyperlaunch_fdt(const struct boot_info *bi) +{ + int ret = 0; + const void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + + if ( !fdt || fdt_check_header(fdt) < 0 ) + ret = -EINVAL; + + bootstrap_unmap(); + + return ret; +} + +/* + * 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/domain-builder/fdt.h b/xen/arch/x86/domain-builder/fdt.h new file mode 100644 index 0000000000..8e62cd843e --- /dev/null +++ b/xen/arch/x86/domain-builder/fdt.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ +#ifndef __XEN_X86_FDT_H__ +#define __XEN_X86_FDT_H__ + +#include + +struct boot_info; + +/* hyperlaunch fdt is required to be module 0 */ +#define HYPERLAUNCH_MODULE_IDX 0 + +#ifdef CONFIG_DOMAIN_BUILDER +int has_hyperlaunch_fdt(const struct boot_info *bi); +#else +static inline int __init has_hyperlaunch_fdt(const struct boot_info *bi) +{ + return -EINVAL; +} +#endif + +#endif /* __XEN_X86_FDT_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 3afc214c17..82c2650fcf 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -27,6 +27,7 @@ enum bootmod_type { BOOTMOD_RAMDISK, BOOTMOD_MICROCODE, BOOTMOD_XSM_POLICY, + BOOTMOD_FDT, }; struct boot_module { @@ -80,6 +81,8 @@ struct boot_info { paddr_t memmap_addr; size_t memmap_length; + bool hyperlaunch_enabled; + unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; struct boot_domain domains[MAX_NR_BOOTDOMS]; diff --git a/xen/arch/x86/include/asm/domain-builder.h b/xen/arch/x86/include/asm/domain-builder.h new file mode 100644 index 0000000000..b6d9ba94de --- /dev/null +++ b/xen/arch/x86/include/asm/domain-builder.h @@ -0,0 +1,8 @@ +#ifndef __XEN_X86_DOMBUILDER_H__ +#define __XEN_X86_DOMBUILDER_H__ + +struct boot_info; + +void builder_init(struct boot_info *bi); + +#endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 83cb66e309..e5d78bcb48 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1281,9 +1282,12 @@ void asmlinkage __init noreturn __start_xen(void) bi->nr_modules); } - /* Dom0 kernel is always first */ - bi->mods[0].type = BOOTMOD_KERNEL; - bi->domains[0].kernel = &bi->mods[0]; + builder_init(bi); + + /* Find first unknown boot module to use as Dom0 kernel */ + i = first_boot_module_index(bi, BOOTMOD_UNKNOWN); + bi->mods[i].type = BOOTMOD_KERNEL; + bi->domains[0].kernel = &bi->mods[i]; if ( pvh_boot ) { @@ -1466,8 +1470,9 @@ void asmlinkage __init noreturn __start_xen(void) xen->size = __2M_rwdata_end - _stext; } - bi->mods[0].headroom = - bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); + bi->domains[0].kernel->headroom = + bzimage_headroom(bootstrap_map_bm(bi->domains[0].kernel), + bi->domains[0].kernel->size); bootstrap_unmap(); #ifndef highmem_start @@ -1591,7 +1596,7 @@ void asmlinkage __init noreturn __start_xen(void) #endif } - if ( bi->mods[0].headroom && !bi->mods[0].relocated ) + if ( bi->domains[0].kernel->headroom && !bi->domains[0].kernel->relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { From patchwork Tue Apr 8 16:07:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 344F1C369A4 for ; Tue, 8 Apr 2025 16:12:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942939.1341992 (Exim 4.92) (envelope-from ) id 1u2BYH-00056U-KH; Tue, 08 Apr 2025 16:11:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942939.1341992; Tue, 08 Apr 2025 16:11: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 1u2BYH-00055q-HJ; Tue, 08 Apr 2025 16:11:53 +0000 Received: by outflank-mailman (input) for mailman id 942939; Tue, 08 Apr 2025 16:11:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVm-0000a6-NQ for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:18 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061e.outbound.protection.outlook.com [2a01:111:f403:2415::61e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d1025b54-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:16 +0200 (CEST) Received: from MN2PR19CA0049.namprd19.prod.outlook.com (2603:10b6:208:19b::26) by PH8PR12MB7136.namprd12.prod.outlook.com (2603:10b6:510:22b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.27; Tue, 8 Apr 2025 16:09:08 +0000 Received: from BL6PEPF00020E62.namprd04.prod.outlook.com (2603:10b6:208:19b:cafe::bd) by MN2PR19CA0049.outlook.office365.com (2603:10b6:208:19b::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.34 via Frontend Transport; Tue, 8 Apr 2025 16:09:08 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E62.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:07 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:06 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d1025b54-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZYv05iQfg6WNmc1bIHo5vDF2Q0LmqRD+mWgqb1Whyd0mS/iNzBR4vFhC5HX17l/X5z0pZe7fv3K079K860uDphwX5ajzQJH9xHZ5+Mx5aJ1uo72JgWWI84MgUQ1FJezEpcE2dJb8YRQpnAMCqxg4T3FvjK+pGYOApjyCiNsppt4MrGrAcQXFqg5Chz5qxHcBvhpcLSkYMVb7iiId3RnatG4dxbJN14HKiri1Baw70F3bqznIbu6tRnivVnbV3gq4O0OzgsIAhHDZIOjOgvl2P2hQAGSScBtzHmtQ2xVJ9hxlTQPDoYd8xXh3YXyNmvDgybsYJ+UJNfvCq1SOLIEKNg== 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=q6cqyaPQF4iDLIVBSm6nomktyAk6q6RkbIKN0PzBBQA=; b=w3PHCRiooqcq4Xy7BJZ0SNEe5wyJi/dzX3LZHlyMY/1ZN+aKAvt9vWEwtAXVt43m+UeuU6gRCUNlWNqLp0TKcMX3xUp+kGoY6SKvhdsIcLO4IUcUU5BJKSssPSuD0n0ZlHsvYoZ1ShKKKY/1yJGmLPpW1CzNcrtx0AsZ8+3pVcParcaqE1/7sK/VU4fpxUK7X/QOrGu81fC5ehnFxd5Amt896jRJ3Oihtd4r2Qe+e/8h1bnvf5vzOcmesG5nQYbDq7ytKrMHfyVHzZ85YU0t+qz8jKvFMWI3WoBn6BO/NJzKlWB0BMXc6EN55djL+8YyeIuHyvmUMgDHReOJ3i7RHQ== 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=q6cqyaPQF4iDLIVBSm6nomktyAk6q6RkbIKN0PzBBQA=; b=VT/nT6ftY3IbZ1thVqecK0sGHaO91L8a3VlAjzkQJc56hrdQ+roHLq1PF+0xjKjP5uK/kXRdq6QG43qHW+LF6cY4K96ZYV61CdxCW5bXRQ9mciPRjkRWuI5PQgguteyCyS/Y7q896UKNhUtaVkd7TWyJDeeFQ+iCWU97eJOzje4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 07/16] x86/hyperlaunch: initial support for hyperlaunch device tree Date: Tue, 8 Apr 2025 17:07:29 +0100 Message-ID: <20250408160802.49870-8-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E62:EE_|PH8PR12MB7136:EE_ X-MS-Office365-Filtering-Correlation-Id: 149656ee-e74d-4016-ea66-08dd76b7b11c 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: ntUiWpIzt6KRziyhPOKTQ8SpYjcidUG5MPmV7il90PZRrzOG9HRPxbeQaR19wBukGlAvynOyhpny0lvC68whUvXx1jeu0YSxKUXJomYAaGTBKMHA5vUQNB3wpEee3z+9spmB7Q1QLG70GwYO1Q0zTi11QaBpv50j1Bphu9H8lXYljvzI0l9DX2jcRh5EP2wHgIPAV/E2YSb9o7D1kd7EgHpqe+6wOwiROIULtOjDEjV+mRM/I8r5kLjbCUZWGpBGVqpKzMPCFy1ajVtf0Cz0DN3HshS69e4UAc6JyqpPBHxNNKxc9Q6LWx6InypxjTgP1wJagGn24bankEa+kWYIX69soLXm0+R1XdEyKtOb2jw7+P6YzeftOaniFH1pcQsojJ1vdXH9hJZZ4DxY9KFccQfQHPFYyDRInc8NBFBHYe1G09+h7YfKySCWPwZ3myqNWC+ApfiPFTHuUO3+ZjZc4BGLu54ixMwLzqePIBirVIltZQ/gOCqvg6QHAUizVqMQzfjFhkY1cJ5YcSD8HO6NBIQG9bXYNEE5p/IXOAm2KEwZzUOUeAEJDdENjAaKJpjyr1x5ZdrttW8HjmRmivZYaEfjiLCHfot428w5TIFEqn56E9mfCRWm7q5y8rAujnSXQLDXJdk8Ryrgr/Hixt23COUkrd1YhH7deFYqIdiqbUwXTanDCC2u7aPNbIt6RPrxW/cNKGFC17sfmcl8mG4acL+tnANvW+zw0kjIH5sdLCdSdRA+IGHz0Sk098j6o6uZ0oxnrsGzo8rfBlPHE+6vVl27+OlBkvPSQlnSOcMKOwcfLXV8RJMpBb+dc8sRX06ki7kmU28Mbipso82sDKersQVN3ZD7tPf2ylcJ9YVWsvhGeyNOWiOqIjPlODdJCaPtWMry2adKRzHth1LXA0uDHAyXEBd/N7Sg6/afl6+oTNpQOOxQfPhYgF2zA/3pJlWyvwesIneFZGgq8olz+Hf4RoiNgmuFPvgyq0tOJrXnYXLOEWTEFLnY5sTfs9IFEk5V4xhKJX1zRxB/pXwAb2hxmEFNCu11dxPYcK05qIkWuknlAdgB+MUQ7LiFQkWObrq9U9wjErTz9SX12n68/bT4Nf174x7f0TeOI5lMUvi/Q6hzbuhmbfBFipjAwWSduoSa9qB7qmSbCOlEEakE4qhWe5WNZQq1qLahgbAW1tPcnJiTPYyEwpIOXrRdAs3PfcapUQenqJuTq1rulOVEh8rNsvyRVZUXIp5AP5oi/Lj29uz07jwYtBsYejTRgTGxEX0OQJFAX4/+eavH78XfpoKM0nODjgmsQha5sKyJcyN9nw43uIT9P+CpSJpa0eSRcxZMmn/QLH5y+Kvi6il2sKh1XzkMUtMB2vnvqgnIok6MZZ1hRH6XkdeG44NpIZH9kvE9l0/R7u9TIAqdy3Znp2EVeGOz2LpETZNBC7mT3A/L7yX6EN6dO/+O7m5HNXHGG1W3ozitqrA+nap0tOxkNywjf8CZ4MWoRBWZWVPxUtzRgdI= 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: 08 Apr 2025 16:09:07.8564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 149656ee-e74d-4016-ea66-08dd76b7b11c 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: BL6PEPF00020E62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7136 From: "Daniel P. Smith" Add the ability to detect both a formal hyperlaunch device tree or a dom0less device tree. If the hyperlaunch device tree is found, then count the number of domain entries, reporting an error if more than one is found. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk --- const not added to walk_hyperlaunch_fdt bi since it is updated while walking the device tree. v3: * Add a blank between declaration and statement * Add const to void *fdt --- xen/arch/x86/domain-builder/core.c | 15 +++++++ xen/arch/x86/domain-builder/fdt.c | 64 +++++++++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.h | 5 +++ xen/arch/x86/include/asm/bootinfo.h | 1 + 4 files changed, 85 insertions(+) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c index d6ae94f45c..c50eff34fb 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -44,6 +44,21 @@ void __init builder_init(struct boot_info *bi) break; } } + + if ( bi->hyperlaunch_enabled ) + { + int ret; + + printk(XENLOG_INFO "Hyperlaunch configuration:\n"); + if ( (ret = walk_hyperlaunch_fdt(bi)) < 0 ) + { + printk(XENLOG_INFO " walk of device tree failed (%d)\n", ret); + bi->hyperlaunch_enabled = false; + return; + } + + printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); + } } /* diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index aaf8c1cc16..4c5b7747f5 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -13,6 +13,36 @@ #include "fdt.h" +static int __init find_hyperlaunch_node(const void *fdt) +{ + int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor"); + + if ( hv_node >= 0 ) + { + /* Anything other than zero indicates no match */ + if ( fdt_node_check_compatible(fdt, hv_node, "hypervisor,xen") ) + return -ENODATA; + else + return hv_node; + } + else + { + /* Look for dom0less config */ + int node, chosen_node = fdt_path_offset(fdt, "/chosen"); + + if ( chosen_node < 0 ) + return -ENOENT; + + fdt_for_each_subnode(node, fdt, chosen_node) + { + if ( fdt_node_check_compatible(fdt, node, "xen,domain") == 0 ) + return chosen_node; + } + } + + return -ENODATA; +} + int __init has_hyperlaunch_fdt(const struct boot_info *bi) { int ret = 0; @@ -20,7 +50,41 @@ int __init has_hyperlaunch_fdt(const struct boot_info *bi) if ( !fdt || fdt_check_header(fdt) < 0 ) ret = -EINVAL; + else + ret = find_hyperlaunch_node(fdt); + + bootstrap_unmap(); + + return ret < 0 ? ret : 0; +} + +int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + int ret = 0, hv_node, node; + const void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + + if ( unlikely(!fdt) ) + return -EINVAL; + + hv_node = find_hyperlaunch_node(fdt); + if ( hv_node < 0 ) + { + ret = hv_node; + goto err_out; + } + + fdt_for_each_subnode(node, fdt, hv_node) + { + ret = fdt_node_check_compatible(fdt, node, "xen,domain"); + if ( ret == 0 ) + bi->nr_domains++; + } + + /* Until multi-domain construction is added, throw an error */ + if ( !bi->nr_domains || bi->nr_domains > 1 ) + printk(XENLOG_ERR "Hyperlaunch only supports dom0 construction\n"); + err_out: bootstrap_unmap(); return ret; diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builder/fdt.h index 8e62cd843e..1849656571 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -11,11 +11,16 @@ struct boot_info; #ifdef CONFIG_DOMAIN_BUILDER int has_hyperlaunch_fdt(const struct boot_info *bi); +int walk_hyperlaunch_fdt(struct boot_info *bi); #else static inline int __init has_hyperlaunch_fdt(const struct boot_info *bi) { return -EINVAL; } +static inline int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + return -EINVAL; +} #endif #endif /* __XEN_X86_FDT_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 82c2650fcf..1e3d582e45 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -84,6 +84,7 @@ struct boot_info { bool hyperlaunch_enabled; unsigned int nr_modules; + unsigned int nr_domains; struct boot_module mods[MAX_NR_BOOTMODS + 1]; struct boot_domain domains[MAX_NR_BOOTDOMS]; }; From patchwork Tue Apr 8 16:07:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DBE5C369A5 for ; Tue, 8 Apr 2025 16:10:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942803.1341926 (Exim 4.92) (envelope-from ) id 1u2BXC-0007lv-P9; Tue, 08 Apr 2025 16:10:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942803.1341926; Tue, 08 Apr 2025 16:10:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BXC-0007kx-Hg; Tue, 08 Apr 2025 16:10:46 +0000 Received: by outflank-mailman (input) for mailman id 942803; Tue, 08 Apr 2025 16:10: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 1u2BVl-0000a6-NA for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:17 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20619.outbound.protection.outlook.com [2a01:111:f403:2009::619]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d18f198b-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:15 +0200 (CEST) Received: from MN2PR19CA0071.namprd19.prod.outlook.com (2603:10b6:208:19b::48) by IA1PR12MB7519.namprd12.prod.outlook.com (2603:10b6:208:418::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.21; Tue, 8 Apr 2025 16:09:10 +0000 Received: from BL6PEPF00020E62.namprd04.prod.outlook.com (2603:10b6:208:19b:cafe::b5) by MN2PR19CA0071.outlook.office365.com (2603:10b6:208:19b::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.31 via Frontend Transport; Tue, 8 Apr 2025 16:09:10 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E62.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:10 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:07 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d18f198b-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YTTlj3+45Pb8UqfujkGECq3peB1bsGS7aVzM+kJaDweVl5iqinCPtwILl6zj7VhGYYsUFBdzZNH9oF5ImnfMUfQhFLiLTElk8cuvIRC+0HKkejuNAfIr01SY1hzneC1qDfgXQcmNMr8AgxsHCZRIvDsHDU+YEMwK08EgbhANCIKDFp+kbNKeiGkURis04FuqUny5MDPCMIi6mQMGnv1oAAUMbrgB1oEcfUTMw780bi8v0MMufTzmrrcbPmKRpPYBEg4BUvioq+GApL8dhIPC89O3jMYouijcix9/qfhmplm731KuDbmI4+XYD6bbSJtXIghr4OxZzPbqtnjFMjt8jA== 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=wb1RbJ/A2HZQ4CDL4kSnK/cd53lOCjG7RRR6aRmIDv8=; b=g+ZEibhEY85r/1ZFS0Lrngy3JXrM1sNBwdVL33tVpnANTbeeaNCJ6uOvYdwQ9pNX+ymvxKZEoeFw2BOlDsirxLSjwbcU6l4KZhD0UMQFf1vNyalBGWlsGR9QB6sAue049ogPPN0vfm8Udb1lyLoTjfmqlaqIG/8kwYI6k/lx9OEWXIalboebn/TbBJQ1/5wcu8YRgOr8JDLafayOB46x7Sy6AhSCv3CnmcXwwewEdzMtS+lyY668VzNACxMRxbUsphjrBUhSbWooYYq3j2w1jroTOCUv2P2+KXkbWXvTyUXGItOGoIL7Zf+CloWNdCqtxilTBjvQMZ03YupQ78W1pA== 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=wb1RbJ/A2HZQ4CDL4kSnK/cd53lOCjG7RRR6aRmIDv8=; b=clOW0deNOJXpVcoG8LROfwvL7j89FUIhN5jHLGRAmMUz6QMYHc0CeBNwTbefsCUNyhGYyZs+M8JGaikEBBxKoOAH6scps0VNsOHUv0odWmtzqRDSQr0xrq7wE8Sat2ecPRtcHn6HtLdFi8uqc8dgFuEJMX0Qqt40SIIvvvZIOuo= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: Alejandro Vallejo , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Bertrand Marquis Subject: [PATCH v3 08/16] x86/hyperlaunch: Add helpers to locate multiboot modules Date: Tue, 8 Apr 2025 17:07:30 +0100 Message-ID: <20250408160802.49870-9-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E62:EE_|IA1PR12MB7519:EE_ X-MS-Office365-Filtering-Correlation-Id: 7710856c-f113-438c-15c5-08dd76b7b26d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: lRS/MJfbxThgBCfrh9sB6htGmo+nylnZs0PHtP98YJ2DnDuqPqca8vd9gkl3rnmMFsbLd0Y1ZcLBiVeZ3Su4QCtZ4iuZw3hAfPJ92tPZLxmTecblm7AuN71EjEV6ZH7HruxjtmmUT2SsX0XnOopVnwOdj1KXvHJJUYVHQ/Pzo6Vw0FunKz9yT6Zqt8Mege/ZjkjN507h16+ApNH5iqIAK6W91Nz7I481PykxE7IrSdFCtJtVw1hfPOTfn3Ls78242z/4I2TnaL1z+p5rnc+w4/vM2nmJf38Oa51aimSliFNHHV99+cntY83i9LKUbIl4Nn8iOBhgXr+V09WICIQnmWjIOzuZsjQbJ16ak+Pvcm1EveiG3TcuCot0jKPM7ngy2hcMwAE6/J0EMZWMCfqn5oQ7LUM7Wgcd4//QJ3wMAMmNCiE/jrlAb54NFsu4w9G26iG+ZV0P5z1kyaR7gZfKU6zXiecALfyOB9Njn9xHwKwTQPZsqL6VoDR2g97bmD4MfZpE39gOqfhTWJ9/wMxuQe2ihVyi+GjUtIt5fgqtp94rJjGUbFamrmQlyEimOUy1W0mNEqP4005VfVNkrFQdOZrefeKmblI13FBfEEbIXGc3udr3u+Sjn1fHMS1YBl7CFm0UQTt4nd/6bdplfA8yE6gHC9cI+B5COTQLitbgmkkU0Z2gqczOQ3ULWT8kguEq45wLSYaVYZM6OzepixepmPG+5q+uezKKVXoO1Uiah1mYxAGTXkCW5guqLolsNGqFLi0xCiOaQxonkUlRPS8fStvPaHaTD5PeEOSEtEPJzGXah8MPDxSdSGuC41vUU2aAWeyLCVJ5XxAiDqmxvciIhInzO3PcvfchWj6YJzwfk6xv2KwH77QH+x6kWDboFbRNOlzRf2M8HubsXNtYaK+CERL1nwx0VQAhfP+4lZcTMl7Irl9LqLLBhTLDGO+gFvnv0SmPu7rAHuPm9Qy1A/UjD07qS8M9XUK6T7KtgZFYNbGz1fE2/ZBZATnHYZJaMkEp1ubfQVsE0DtnRIHLypaC6LfLdrdLUU1nK9TXFWPF/hLhWtFEaoKFRCT94Ip5YFMx6dGmyuzDiV8z+HA998/hUaYNVMLGNnQNc2NEEStDu//7gXxRLj0ilq4RaV7cEGW/KDlyk9ZctsxLCGCo1nroOxTz2ycchxzgxj2lCsMWWy/RRAiHC6rEWOKneP1HA0bhPCUdkTTv/yl4MmdP6Me+a1/67RiNTdsnEh9ndZmd1Htdbp5+LaI+gNp+N8OD5etocURkz5+jxES+d6hR15GP5QzNX64J+8puXR71wlCugRwP6118+VSi3gtQWUI1IMLaxdLZYlPb/9Tn9Tutx2l2BrUluUiFaj+QwrXM5tJG1RlQNm9ENIX+tS75hhdrZKNDapkmOjya38N6/++fBgBa21Xuoy6Bm6216m0UcKXBCqtU54YLJ1DEZnUhgpH+b4zDdCVwqQtrYILhtW+8a2RI2Q== 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)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:10.0597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7710856c-f113-438c-15c5-08dd76b7b26d 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: BL6PEPF00020E62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7519 Hyperlaunch mandates either a reg or module-index DT prop on nodes that contain `multiboot,module" under their "compatible" prop. This patch introduces a helper to generically find such index, appending the module to the list of modules if it wasn't already (i.e: because it's given via the "reg" prop). Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo --- v3: * New on v3. * Subsumes much of the dup code between kernel/initrd patches. * Changes previous behaviour in v2 to look into "reg" and "module-index" props, rather than just index. * Use addr_cells/size_cells rather than size_size --- xen/arch/x86/domain-builder/fdt.c | 142 ++++++++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.h | 2 + xen/include/xen/libfdt/libfdt-xen.h | 57 +++++++++++ 3 files changed, 201 insertions(+) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 4c5b7747f5..9ebc8fd0e4 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -13,6 +13,148 @@ #include "fdt.h" +/* + * Unpacks a "reg" property into its address and size constituents. + * + * @param prop Pointer to an FDT "reg" property. + * @param address_cells Number of 4-octet cells that make up an "address". + * @param size_cells Number of 4-octet cells that make up a "size". + * @param p_addr[out] Address encoded in the property. + * @param p_size[out] Size encoded in the property. + * @returns -EINVAL on malformed property, 0 otherwise. + */ +static int __init read_fdt_prop_as_reg(const struct fdt_property *prop, + int address_cells, int size_cells, + uint64_t *p_addr, uint64_t *p_size) +{ + const fdt32_t *cell = (const fdt32_t *)prop->data; + uint64_t addr, size; + + if ( fdt32_to_cpu(prop->len) != + (address_cells + size_cells) * sizeof(*cell) ) + { + printk(" Cannot read reg %lu+%lu from prop len %u\n", + address_cells * sizeof(*cell), size_cells * sizeof(*cell), + fdt32_to_cpu(prop->len)); + return -EINVAL; + } + + switch ( address_cells ) { + case 1: + addr = fdt32_to_cpu(*cell); + break; + case 2: + addr = fdt64_to_cpu(*(const fdt64_t *)cell); + break; + default: + printk(" unsupported sized address_cells\n"); + return -EINVAL; + } + + cell += address_cells; + switch ( size_cells ) { + case 1: + size = fdt32_to_cpu(*cell); + break; + case 2: + size = fdt64_to_cpu(*(const fdt64_t *)cell); + break; + default: + printk(" unsupported sized size_cells\n"); + return -EINVAL; + } + + *p_addr = addr; + *p_size = size; + + return 0; +} + +/* + * Locate a multiboot module given its node offset in the FDT. + * + * The module location may be given via either FDT property: + * * reg = + * * Mutates `bi` to append the module. + * * module-index = + * * Leaves `bi` unchanged. + * + * @param fdt Pointer to the full FDT. + * @param node Offset for the module node. + * @param address_cells Number of 4-octet cells that make up an "address". + * @param size_cells Number of 4-octet cells that make up a "size". + * @param bi[inout] Xen's representation of the boot parameters. + * @return -EINVAL on malformed nodes, otherwise + * index inside `bi->mods` + */ +int __init fdt_read_multiboot_module(const void *fdt, int node, + int address_cells, int size_cells, + struct boot_info *bi) +{ + const struct fdt_property *prop; + uint64_t addr, size; + int ret; + int idx; + + ASSERT(!fdt_node_check_compatible(fdt, node, "multiboot,module")); + + /* Location given as a `module-index` property. */ + prop = fdt_get_property(fdt, node, "module-index", NULL); + + if ( prop ) + { + if ( fdt_get_property(fdt, node, "reg", NULL) ) + { + printk(" Location of multiboot,module defined multiple times\n"); + return -EINVAL; + } + return fdt_cell_as_u32((const fdt32_t *)prop->data); + } + + /* Otherwise location given as a `reg` property. */ + prop = fdt_get_property(fdt, node, "reg", NULL); + + if ( !prop ) + { + printk(" No location for multiboot,module\n"); + return -EINVAL; + } + if ( fdt_get_property(fdt, node, "module-index", NULL) ) + { + printk(" Location of multiboot,module defined multiple times\n"); + return -EINVAL; + } + + ret = read_fdt_prop_as_reg(prop, address_cells, size_cells, &addr, &size); + + if ( ret < 0 ) + { + printk(" Failed reading reg for multiboot,module\n"); + return -EINVAL; + } + + idx = bi->nr_modules + 1; + if ( idx > MAX_NR_BOOTMODS ) + { + /* + * MAX_NR_BOOTMODS cannot exceed the max for MB1, represented by 32bits, + * thus the cast down to a u32 will be safe due to the prior check. + */ + BUILD_BUG_ON(MAX_NR_BOOTMODS >= (uint64_t)UINT32_MAX); + printk(" idx %d exceeds maximum boot modules\n", idx); + return -EINVAL; + } + + /* Append new module to the existing list */ + + bi->nr_modules = idx; + bi->mods[idx].start = addr; + bi->mods[idx].size = size; + printk(" module[%d]: addr %lx size %lx\n", idx, addr, size); + + return idx; +} + static int __init find_hyperlaunch_node(const void *fdt) { int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor"); diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builder/fdt.h index 1849656571..e8769dc51c 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -3,6 +3,8 @@ #define __XEN_X86_FDT_H__ #include +#include +#include struct boot_info; diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index a5340bc9f4..2259c09a6a 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -13,6 +13,63 @@ #include +static inline int __init fdt_cell_as_u32(const fdt32_t *cell) +{ + return fdt32_to_cpu(*cell); +} + +static inline uint64_t __init fdt_cell_as_u64(const fdt32_t *cell) +{ + return ((uint64_t)fdt32_to_cpu(cell[0]) << 32) | fdt32_to_cpu(cell[1]); +} + +/* + * Property: reg + * + * Defined in Section 2.3.6 of the Device Tree Specification is the "reg" + * standard property. The property is a prop-encoded-array that is encoded as + * an arbitrary number of (address, size) pairs. We only extract a single + * pair since that is what is used in practice. + */ +static inline int __init fdt_get_reg_prop( + const void *fdt, int node, unsigned int addr_cells, unsigned int size_cells, + uint64_t *addr, uint64_t *size) +{ + int ret; + const struct fdt_property *prop; + fdt32_t *cell; + + /* FDT spec max size is 4 (128bit int), but largest arch int size is 64 */ + if ( size_cells > 2 || addr_cells > 2 ) + return -EINVAL; + + prop = fdt_get_property(fdt, node, "reg", &ret); + if ( !prop || ret < sizeof(u32) ) + return ret < 0 ? ret : -EINVAL; + + if ( fdt32_to_cpu(prop->len) != + ((size_cells + addr_cells) * sizeof(*cell)) ) + return -EINVAL; + + cell = (fdt32_t *)prop->data; + + /* read address field */ + if ( addr_cells == 1 ) + *addr = fdt_cell_as_u32(cell); + else + *addr = fdt_cell_as_u64(cell); + + cell += addr_cells; + + /* read size field */ + if ( size_cells == 1 ) + *size = fdt_cell_as_u32(cell); + else + *size = fdt_cell_as_u64(cell); + + return 0; +} + static inline int fdt_get_mem_rsv_paddr(const void *fdt, int n, paddr_t *address, paddr_t *size) From patchwork Tue Apr 8 16:07:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F68AC369A4 for ; Tue, 8 Apr 2025 16:11:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942919.1341982 (Exim 4.92) (envelope-from ) id 1u2BYB-0004aV-DX; Tue, 08 Apr 2025 16:11:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942919.1341982; Tue, 08 Apr 2025 16:11: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 1u2BYB-0004aO-AB; Tue, 08 Apr 2025 16:11:47 +0000 Received: by outflank-mailman (input) for mailman id 942919; Tue, 08 Apr 2025 16:11:46 +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 1u2BVk-0000a6-Mx for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:16 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20617.outbound.protection.outlook.com [2a01:111:f403:2414::617]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d110691c-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:16 +0200 (CEST) Received: from MN2PR19CA0045.namprd19.prod.outlook.com (2603:10b6:208:19b::22) by BY5PR12MB4083.namprd12.prod.outlook.com (2603:10b6:a03:20d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.21; Tue, 8 Apr 2025 16:09:11 +0000 Received: from BL6PEPF00020E62.namprd04.prod.outlook.com (2603:10b6:208:19b:cafe::b7) by MN2PR19CA0045.outlook.office365.com (2603:10b6:208:19b::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.36 via Frontend Transport; Tue, 8 Apr 2025 16:09:11 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E62.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:11 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:09 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d110691c-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hzm/TIM1ny5JgA7mzykF9Vyeavjk9uTGOAmJc8QZ1cQkLOnwKqJYEHOgL5brX21equcvMMycejEnVNJJ6sqDgG1QkRq5jg5EunMgAVg2/98X2jwc23SuQLf4Ev8j42xhPfblnecvtp4Ixc4M/2MdKfSV8AH+Et/XCtu6+cz0OcuKezwpvCeQMgSfUO/nIT8OlmeJgLXVeu1BCu8iieBBrrGtkQTwQSsZnc3iUxzaN23zWE7wW+zhrIav10DdsRM6hyzk0FJGOsZ+VVp04zOs03RfxO9jc3oBwJByUFALU+wlz9/wa65+NhjwchvDTGVd/XbJAD6BWNafzzIcIfG4Wg== 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=YluEnmN5WD5jS/lkB8HBr2wUzOPxNHNZCrXAZnkx2Wg=; b=Xuc7uRtvpgRIGGP2DcqcE2drWDL+0DBfQDPU5eQ3WVUOdj1sKCYYIUv/ru+hyWMzb2822t5KxPTUrzWfmSMpwDQ4Yq1vZkgkwdvb/L4GwSTiMYd1DOslJvRBulpibPCyfIeCyfaVaQ/c5BaayVJG8B+lYP+MbU4vu3CkF7Qf+0eO0JErufRK8xCKCDx/i7M4erAqzi74zWkoFqru81hC8EY1Zvxji+iyUATz44eQ3WhYo3N1Zf4wq1z0R1vtTJPbTKLXY78q6t3judwQNM2dRh3Y6ixqepEE+iG5SKD5eRCXIprX0DtUhM+2p/5p8rjJxZYa8/oK8f7lDL/JvQaSlg== 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=YluEnmN5WD5jS/lkB8HBr2wUzOPxNHNZCrXAZnkx2Wg=; b=nx84FO/8Ix2pseCt7b6yqX+aKzS8mLqBW4RyDEpKJEycqtqvnc5P2bdcyETBB+pKkWdwzZFG5HJJa6NITD6SWHdxZcyTj8UUDuvQD2kIKHoQlRWkWE+qHrd0Kd11QXey7jK32CPXKzUw7kxc8iaOwHSAjE9T7uGtWkCcdKbQTJI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Alejandro Vallejo" Subject: [PATCH v3 09/16] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Date: Tue, 8 Apr 2025 17:07:31 +0100 Message-ID: <20250408160802.49870-10-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E62:EE_|BY5PR12MB4083:EE_ X-MS-Office365-Filtering-Correlation-Id: b0545932-d22c-4e9e-fa44-08dd76b7b313 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: +2Ml4vNicD7HtgRvk5bbZzEPQyWKatkoFyXXhKYJpJzbhGYiM/NCeLjNRitWmS1EKQTGfAptR7Sy+ZsvG6ykHdsLW+jJZC+QM2ym2ZNMW1JZQfk3jma888B6QIkwyp7hs8inA599uUVcroW6LSCEy9b9ylc8HbxX+px9nirJ1e66lAaj4dmgZ+rkFhkTN623hRFvLsU20Jdu3AWHtuGn3V+/8H6mm5TfYPi1dmffzomclxEYhvzzN7oEPmhREx3rAPQ+zN4YbzUluNCCNGRN4T3o5DBtFSNIzelhRTePigWFiBmn9rWKGzWnD8Dcz3wZVNp7eDf92Rz7wc/tfW4HDO+X80bSEc+O50gFYsfq5CK4p/ip2jaSL1Dm8Dntxt2Dz4B8hAUp2MDn0/wHHcpSLCf/e2x9XkwvFdjkAnjGVze9DSt3i/yCLTJpakBBViJ13ufTfVwQ8o2h0kcFhfvlTEmtLz4Mzl4nrTSCGlly82bsda2RxNZ4QOplIAIiaJmO0zFeTUCsZCvpOqZAsrp4mo/gKvBx9lXYykArP6Pwvjxho6+E+5rZwBVk81jQTl8/ReyrfsZnDqtkIZIHgA4MHelggRKgaxpXop72Rf9q3Xgag7PrZ2hd/b7f65SiiLlylYkbAE9pe/gGkJG2WmTOH/g9U52yX+6gK1VKPdU+3FS+SoFG8ywZeLt6UrQ2EFM5x2NKVizW2i6ySnB8AsbsTu7b+FRJC2uMTVQZABso1uDyCwuT8c68uxyVfTQfM1NsZLTiwAvZBBSMnYnLq5zXi/FcG4G+SRsMVDJtFl1D63rJg9M0e9wfJtQ0A/8H7dtPH/tqIqqfECZwlcSxATVpfBvp//3/kRCj3eB/wjIqQWAKsMqPUzIQIaRLRsnFt21Xd+rFZtNNhZlv5UAwpMOGoz4qo7Bvujd+Hg+60qRlIoyZ4sdc4N3VD8L2QtzWDqTdZQybBE54NP1338Oh9Woh1Q+QSEZSMf8naUZDJLthHrdvA7MmN8tmeHWDB0SJes+/NMcpYo04lrWXtMPZhjxxP5WNS3a23dQ7Ku+gBFp6BOaVfdrjRm0mdiSfYMC1ryhlROwG5GdIuylUtVeGA/4iyLwHQp/hrJkao3w/F00vdYK5HqnL8Mp9WiEZvj3fpXqyfa4j0++WB/dvZCqcYiO5DQzD0L0we+xjL7Nq02cGxWnUr8tmIeqta0mIgh2KYNLteo6E1FMnmEWNlEU8ek+CfV0WGA1C0Prs27uxyPuosGpM3o3ZsbtfoZg3ZuXbp5E9WmeGUlWYuyEvJgCyT2unk5s5svQRbPA3M5JuXxFG5+RbvXf0KxLMgXxJEW1qaBFs4gZ28n0UF1/R2VT8rpobygqOa+IzHe8zJ/hfRxcmeHrDIDFev7U4krmReDu+ooEOVfdGxuZ4aUwJ7FfSY0Y21bp1jAu/HqaDZOi5Qb9yqyFObANsXFrJr/2oyW9KjPcI2/TRchuE6CY5akkKoKFltJ3IbjMfLWLfuDj/mHzG7TgDhnr/eqhQezCZhM4da0ua 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)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:11.1533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0545932-d22c-4e9e-fa44-08dd76b7b313 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: BL6PEPF00020E62.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4083 From: "Daniel P. Smith" Look for a subnode of type `multiboot,kernel` within a domain node. If found, locate it using the multiboot module helper to generically ensure it lives in the module list. If the bootargs property is present and there was not an MB1 string, then use the command line from the device tree definition. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo --- v3: * Add const to fdt * Remove idx == NULL checks * Add BUILD_BUG_ON for MAX_NR_BOOTMODS fitting in a uint32_t * Remove trailing ) from printks * Return ENODATA for missing kernel * Re-work "max domains" warning and print limit * fdt_cell_as_u32/directly return values * Remove "pairs" looping from fdt_get_reg_prop() and only grab 1. * Use addr_cells and size_cells --- xen/arch/x86/domain-builder/core.c | 11 ++++++ xen/arch/x86/domain-builder/fdt.c | 57 ++++++++++++++++++++++++++++++ xen/arch/x86/setup.c | 5 --- 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c index c50eff34fb..eda7fa7a8f 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -59,6 +59,17 @@ void __init builder_init(struct boot_info *bi) printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); } + else + { + unsigned int i; + + /* Find first unknown boot module to use as Dom0 kernel */ + printk("Falling back to using first boot module as dom0\n"); + i = first_boot_module_index(bi, BOOTMOD_UNKNOWN); + bi->mods[i].type = BOOTMOD_KERNEL; + bi->domains[0].kernel = &bi->mods[i]; + bi->nr_domains = 1; + } } /* diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 9ebc8fd0e4..a037c8b6cb 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -155,6 +155,52 @@ int __init fdt_read_multiboot_module(const void *fdt, int node, return idx; } +static int __init process_domain_node( + struct boot_info *bi, const void *fdt, int dom_node) +{ + int node; + struct boot_domain *bd = &bi->domains[bi->nr_domains]; + const char *name = fdt_get_name(fdt, dom_node, NULL) ?: "unknown"; + int address_cells = fdt_address_cells(fdt, dom_node); + int size_cells = fdt_size_cells(fdt, dom_node); + + fdt_for_each_subnode(node, fdt, dom_node) + { + if ( fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 ) + { + int idx; + + if ( bd->kernel ) + { + printk(XENLOG_ERR "Duplicate kernel module for domain %s\n", + name); + continue; + } + + idx = fdt_read_multiboot_module(fdt, node, address_cells, + size_cells, bi); + if ( idx < 0 ) + { + printk(" failed processing kernel module for domain %s\n", + name); + return idx; + } + + printk(" kernel: boot module %d\n", idx); + bi->mods[idx].type = BOOTMOD_KERNEL; + bd->kernel = &bi->mods[idx]; + } + } + + if ( !bd->kernel ) + { + printk(XENLOG_ERR "ERR: no kernel assigned to domain\n"); + return -ENODATA; + } + + return 0; +} + static int __init find_hyperlaunch_node(const void *fdt) { int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor"); @@ -217,9 +263,20 @@ int __init walk_hyperlaunch_fdt(struct boot_info *bi) fdt_for_each_subnode(node, fdt, hv_node) { + if ( bi->nr_domains >= MAX_NR_BOOTDOMS ) + { + printk(XENLOG_WARNING + "WARN: only creating first %u domains\n", MAX_NR_BOOTDOMS); + break; + } + ret = fdt_node_check_compatible(fdt, node, "xen,domain"); if ( ret == 0 ) + { + if ( (ret = process_domain_node(bi, fdt, node)) < 0 ) + break; bi->nr_domains++; + } } /* Until multi-domain construction is added, throw an error */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e5d78bcb48..00e8c8a2a3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1284,11 +1284,6 @@ void asmlinkage __init noreturn __start_xen(void) builder_init(bi); - /* Find first unknown boot module to use as Dom0 kernel */ - i = first_boot_module_index(bi, BOOTMOD_UNKNOWN); - bi->mods[i].type = BOOTMOD_KERNEL; - bi->domains[0].kernel = &bi->mods[i]; - if ( pvh_boot ) { /* pvh_init() already filled in e820_raw */ From patchwork Tue Apr 8 16:07:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6126C369A2 for ; Tue, 8 Apr 2025 16:09:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942764.1341882 (Exim 4.92) (envelope-from ) id 1u2BVp-0003ts-VC; Tue, 08 Apr 2025 16:09:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942764.1341882; Tue, 08 Apr 2025 16:09:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVp-0003ta-Rh; Tue, 08 Apr 2025 16:09:21 +0000 Received: by outflank-mailman (input) for mailman id 942764; Tue, 08 Apr 2025 16:09:21 +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 1u2BVp-0002e3-2K for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:21 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061f.outbound.protection.outlook.com [2a01:111:f403:2414::61f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d27b591a-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:18 +0200 (CEST) Received: from BN9PR03CA0485.namprd03.prod.outlook.com (2603:10b6:408:130::10) by MW4PR12MB7029.namprd12.prod.outlook.com (2603:10b6:303:1eb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.29; Tue, 8 Apr 2025 16:09:13 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:408:130:cafe::a7) by BN9PR03CA0485.outlook.office365.com (2603:10b6:408:130::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.28 via Frontend Transport; Tue, 8 Apr 2025 16:09:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:12 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:10 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d27b591a-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u97Z9tswxDynWTJ0P2xJi4olEUT79AMaBaeIAt8fO0AVaVnX9MScET3eAY6NQ29h07pcwk8Z349m+jRAs2zfVvc8I4po19UsZVWdOyy9IvRT3NTmYuaUDJldgV/WosRU5UnVVFhJzB0Yvd8pjsjWRfJTMkfx5yOhj9Yl+3TDf5c1Um4QjCwG2oWy4QLR6dgqlSwPOueJeUFARPcpHFzKnO5q3xWiAUjKY6YE4GmrO0oSv8XHxQwmIEhW+S0eYjVE9J6jZRbokhG52j3FEzu4nQwithT8IVvTJ8YtmEigz0TYA7O4c281s82aUwCxwZGrg11TvXmr9gLNUHOT1c7rHA== 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=5IZT8fNpajJpPrD7JBt6IyOdueLZGX88E8xJcZfVlwc=; b=GFkEAeB3TN9g9Pb/JPrI11vFKvWFPHIuTrvIakqXcd8wW6YZScxsu8IrH4ctvB7OWAkTVX22KcL1r9RJ6zbAssKBe7bZp4IS0uczRpRhDfEiHbRNHNmnteHOhRfUsnKL0eT808r90R1kMf+ZiQ26852e6LRuSXyU7Dj3NbLGKese7MfHQ2IPDLaebe3x75by1mPeo0IjOoTCwAwleqy0FR+osmtYQOdkF0K4xKsv28XNr+hvRSynZYYU+Yi6kQq0UB9Sw0qn+SOmLr+S/Y15ErP5UjvEI/PjEt+f50+ST5eaZZIgU9w1HOmR1Vivn787sUpwlFQ4dESBItVSq+ZDzg== 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=5IZT8fNpajJpPrD7JBt6IyOdueLZGX88E8xJcZfVlwc=; b=m+mJlxQsMuipny/vZ8/aMYk4QoesBp9bHpJI5r6ToSsIMQpzgxxxEUy/uqwhUXG1lzS0ILXY/34CGeKHn36hXg/wvZFy65xz10NlH5vUHD3e9ROJ1xAUK9VKP0NCaQxnLr0/ApW6xNsVEK6xXGxHSiAsAaRPuIbvrp2iNlEswz4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Bertrand Marquis Subject: [PATCH v3 10/16] x86/hyperlaunch: obtain cmdline from device tree Date: Tue, 8 Apr 2025 17:07:32 +0100 Message-ID: <20250408160802.49870-11-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|MW4PR12MB7029:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bb02b01-e390-40e9-8096-08dd76b7b3e1 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: 99+rsnMGmGWMdeTo798rlZdfyoQ4p9YvaeFf6W0jy7OV96r32yKeRwIUm90o9fqDs72/3F7hGOukME7ghpJFBJFOAY1bW6YaAhvjEfLC2FjlshJdW0F+oyMsYFpYMLNp87hR5wcKRgoNTUEn+Oh8qASK88r47m21y2B+8O0drks+SYU+jcq0dymY5wOJOydZO9I31n6WtFNNT07JSoxr2g0k7BOsuKoVtKb6X7lC+Ga4t21qmN0DF+VgVLj8pq71Y89adc63wzKNImaxvFOGaBcOP+62H9XwMBAzh5KE/74fGruuDMKdIGrozyZcYX9iu+nQc6lUBBu+LvqeR4lOzgF2bfoEmi/IyA/np+BfSkgS0FT0MDSs/2pfqrAzrISVl8kLB7oZX17WPCpEyZp3/z9OIeaxA1eW2WWpBxn5GS5xFKr+LPIcxkF+Z7LzjbnCB/kNf9maQHjiRs86rGNIu5SOY87vz1WhfHnUXXksHZi2dRmtFSWPwE6w9xl+I6b99f3vFSdKpHgz82ZuaBRMyzTkufwh3lc9rwwzdyxes6FptoPdUUJwzI2EA6w42KX3+rtr/XcIuSkbx2LwYgUERWJND8u9Dq12c7/aRFW6vXxfpNVkw6lyVKasfPlHmzsPyaf4zZa7zxWNgu5Fc/OWjmht+amYVaZ2nESSBI/0uXjG+0CN9FV0ipBDC3cw2LD9+aTMUb/2Nru7X72P/OK2B5BIX4TtfYpx2biC8NhCTBBomj5JC/TLWTELHKZA3bApPydBlmAgDk5Eoo7S438nROrO8cO1fnMQP7iSDA7PVEc8hsY5BNqjSMKHYQYvvrp419J5ArMgc/Bf1dcsH3V97tCi5IhapTGjGl9s3799CE+BRypbSCLLxvWMQm0ouXGonq1Zm/b/vwDZHNtDVGpypyIiBPYyTTvZLA3mYUutxe1v5uVNEXQmXRNmGPDHouhEuVwIMMY1yQVQSG0rgx+uWqj5LGdCQb/8vbYLjEOC0qdpYbAEUyKdmnM+G4Py1z1t4D7a2U19P8u4luGSkVdSX6thbNGJBXVBxarRBYflIaBOF8pnC31tzHQSDMAyzvqLp6DtVqCdegr+oXnMm9lHoqzC9RCrDO/uuKGPtRhlNqoyRGRoQ3hzocpqX/cLtAZLoYYla87GwZQgdMLnbfrLbWMdoeA0YUjUUm88s3lLCKAYJ2DAOaO7zoqOTb6gqSFz5MdgtthdGgN+qrJGfiqDSCbQddNRvTSS4C7WnSS72ptrg007Xe1xDHJ8/J8hcdT54fSwEfERTjTo3e9jplFGn88RNIlmAKhFQEZvpuECqFUeNgzq+fHXvfa/JyXjbHATxYyXXOLJwmOCWq2MoZuJAxbBFcridmy9gZO6nnMhNAezzsP/FdXrnVCNRIjPNdlFwj+mVxnpHQ388HOSwzkrLTTvNJmBARdgCIEiZYDb2UiE0jzwDZY6Yk/WzV4KtSAksMXE30jYiBWfrk+nMosvbMiP4+KP1Lu15lxMEFPmQ50= 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: 08 Apr 2025 16:09:12.5002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bb02b01-e390-40e9-8096-08dd76b7b3e1 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7029 From: "Daniel P. Smith" Add support to read the command line from the hyperlauunch device tree. The device tree command line is located in the "bootargs" property of the "multiboot,kernel" node. A boot loader command line, e.g. a grub module string field, takes precendence ove the device tree one since it is easier to modify. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk --- v3: * Rename to fdt_get_prop_offset() * Remove size_t cast from builder_get_cmdline_size() * fdt_get_prop_offset() use strcmp() * fdt_get_prop_offset() return bool --- xen/arch/x86/domain-builder/core.c | 28 +++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.c | 6 +++++ xen/arch/x86/domain-builder/fdt.h | 25 ++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 6 +++-- xen/arch/x86/include/asm/domain-builder.h | 4 ++++ xen/arch/x86/setup.c | 12 +++++++--- xen/include/xen/libfdt/libfdt-xen.h | 23 +++++++++++++++++++ 7 files changed, 99 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c index eda7fa7a8f..510a74a675 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -8,9 +8,37 @@ #include #include +#include #include "fdt.h" +size_t __init builder_get_cmdline_size(struct boot_info *bi, int offset) +{ +#ifdef CONFIG_DOMAIN_BUILDER + const void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + int size = fdt_cmdline_prop_size(fdt, offset); + + bootstrap_unmap(); + return size < 0 ? 0 : size; +#else + return 0; +#endif +} + +int __init builder_get_cmdline( + struct boot_info *bi, int offset, char *cmdline, size_t size) +{ +#ifdef CONFIG_DOMAIN_BUILDER + const void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + int ret = fdt_cmdline_prop_copy(fdt, offset, cmdline, size); + + bootstrap_unmap(); + return ret; +#else + return 0; +#endif +} + void __init builder_init(struct boot_info *bi) { if ( IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index a037c8b6cb..bc9903a9de 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -189,6 +189,12 @@ static int __init process_domain_node( printk(" kernel: boot module %d\n", idx); bi->mods[idx].type = BOOTMOD_KERNEL; bd->kernel = &bi->mods[idx]; + + /* If bootloader didn't set cmdline, see if FDT provides one. */ + if ( bd->kernel->cmdline_pa && + !((char *)__va(bd->kernel->cmdline_pa))[0] ) + bd->kernel->fdt_cmdline = fdt_get_prop_offset( + fdt, node, "bootargs", &bd->kernel->cmdline_pa); } } diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builder/fdt.h index e8769dc51c..91f665c8fd 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -12,6 +12,31 @@ struct boot_info; #define HYPERLAUNCH_MODULE_IDX 0 #ifdef CONFIG_DOMAIN_BUILDER + +static inline int __init fdt_cmdline_prop_size(const void *fdt, int offset) +{ + int ret; + + fdt_get_property_by_offset(fdt, offset, &ret); + + return ret; +} + +static inline int __init fdt_cmdline_prop_copy( + const void *fdt, int offset, char *cmdline, size_t size) +{ + int ret; + const struct fdt_property *prop = + fdt_get_property_by_offset(fdt, offset, &ret); + + if ( ret < 0 ) + return ret; + + ASSERT(size > ret); + + return strlcpy(cmdline, prop->data, ret); +} + int has_hyperlaunch_fdt(const struct boot_info *bi); int walk_hyperlaunch_fdt(struct boot_info *bi); #else diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 1e3d582e45..5b2c93b1ef 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -35,11 +35,13 @@ struct boot_module { /* * Module State Flags: - * relocated: indicates module has been relocated in memory. - * released: indicates module's pages have been freed. + * relocated: indicates module has been relocated in memory. + * released: indicates module's pages have been freed. + * fdt_cmdline: indicates module's cmdline is in the FDT. */ bool relocated:1; bool released:1; + bool fdt_cmdline:1; /* * A boot module may need decompressing by Xen. Headroom is an estimate of diff --git a/xen/arch/x86/include/asm/domain-builder.h b/xen/arch/x86/include/asm/domain-builder.h index b6d9ba94de..7518b6ddf3 100644 --- a/xen/arch/x86/include/asm/domain-builder.h +++ b/xen/arch/x86/include/asm/domain-builder.h @@ -3,6 +3,10 @@ struct boot_info; +size_t __init builder_get_cmdline_size(struct boot_info *bi, int offset); +int __init builder_get_cmdline( + struct boot_info *bi, int offset, char *cmdline, size_t size); + void builder_init(struct boot_info *bi); #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 00e8c8a2a3..ca4415d020 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -984,7 +984,10 @@ static size_t __init domain_cmdline_size( { size_t s = bi->kextra ? strlen(bi->kextra) : 0; - s += bd->kernel->cmdline_pa ? strlen(__va(bd->kernel->cmdline_pa)) : 0; + if ( bd->kernel->fdt_cmdline ) + s += builder_get_cmdline_size(bi, bd->kernel->cmdline_pa); + else + s += strlen(__va(bd->kernel->cmdline_pa)); if ( s == 0 ) return s; @@ -1047,9 +1050,12 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( !(cmdline = xzalloc_array(char, cmdline_size)) ) panic("Error allocating cmdline buffer for %pd\n", d); - if ( bd->kernel->cmdline_pa ) + if ( bd->kernel->fdt_cmdline ) + builder_get_cmdline( + bi, bd->kernel->cmdline_pa, cmdline, cmdline_size); + else strlcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader), + cmdline_cook(__va(bd->kernel->cmdline_pa),bi->loader), cmdline_size); if ( bi->kextra ) diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index 2259c09a6a..e473fbaf0c 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -23,6 +23,29 @@ static inline uint64_t __init fdt_cell_as_u64(const fdt32_t *cell) return ((uint64_t)fdt32_to_cpu(cell[0]) << 32) | fdt32_to_cpu(cell[1]); } +static inline bool __init fdt_get_prop_offset( + const void *fdt, int node, const char *name, unsigned long *offset) +{ + int ret, poffset; + const char *pname; + + fdt_for_each_property_offset(poffset, fdt, node) + { + fdt_getprop_by_offset(fdt, poffset, &pname, &ret); + + if ( ret < 0 ) + continue; + + if ( strcmp(pname, name) == 0 ) + { + *offset = poffset; + return true; + } + } + + return false; +} + /* * Property: reg * From patchwork Tue Apr 8 16:07:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03B3FC369A2 for ; Tue, 8 Apr 2025 16:10:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942801.1341922 (Exim 4.92) (envelope-from ) id 1u2BXC-0007hm-D9; Tue, 08 Apr 2025 16:10:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942801.1341922; Tue, 08 Apr 2025 16:10:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BXC-0007hb-8N; Tue, 08 Apr 2025 16:10:46 +0000 Received: by outflank-mailman (input) for mailman id 942801; Tue, 08 Apr 2025 16:10:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVu-0002e3-31 for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:26 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20610.outbound.protection.outlook.com [2a01:111:f403:2413::610]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d38f3911-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:20 +0200 (CEST) Received: from BN9PR03CA0492.namprd03.prod.outlook.com (2603:10b6:408:130::17) by PH7PR12MB9076.namprd12.prod.outlook.com (2603:10b6:510:2f6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.34; Tue, 8 Apr 2025 16:09:14 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:408:130:cafe::95) by BN9PR03CA0492.outlook.office365.com (2603:10b6:408:130::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.34 via Frontend Transport; Tue, 8 Apr 2025 16:09:14 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:14 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:12 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d38f3911-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ezPBTCeETVSnIvFFWmbV+rrkrnLkUpUGc1tfd+KO3Hgs1ki/ts+7PvjPrVzjAujvzf0+kffdYXaTirI2w+tUIGhH8QFNGiZiT42gvPePlG0anYpHmXQfQvV/vu7cUN0axgMcALr7PwfNAxQlQk/WasIxAsPGz8wDIGyotjhibBinOCRDipM1myCgYxegqEoGTtV6sjbf4F09Nkfh380WJr078n0YzjsrZYF9Z8tPeFrDJ07KRjNIHYc0KBHsT/KLFIXru2sDcBAjDVimHTG6Zcyf67UrhPj5NwK0UIy1iMz4Wjn/vgLu98lJyvb77fz0waaKcGqSZH2mel7FFY3LLQ== 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=7NFIwj6TuPe9D1STJbnh5mSq1JDjK37GAwCKyt0ngHY=; b=pYyXtixKPr6xiXzkMSOiinUixmtjTLeV3Jxk1U+xL57OzmkK75+1Lyyy9BXj20JekEAqn4SZZqaQnl1r7XW7cr6Oyl5Cc8JpaVT73AH+JnVbNI2oa3OWs40YI3gafxMK4IyHPYOdQxogHtJNxkG5qxK4Hwio1/YvuI/4eiaRYZ0rUw8YAPm0D5PfnBeKpH+mVtAu4FhJlIfdJUUfOQO8r80RL27UbZK7FJIT+fAnV5/wJwGfzhM1mhOTqRYUyLZ1IPJ9oT9dI9Aa/Ae2ZmjiS+9RgcaHVWv+yfx5RGIVaB3O2RVIIBjWfmiKQFqEXoY4OkDHWkiqhePa3SkMgMWXaw== 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=7NFIwj6TuPe9D1STJbnh5mSq1JDjK37GAwCKyt0ngHY=; b=VtYlkubDmEV9MszuyKXjx0S9VM2V+4Xfp/h69OEfXJlpmsTMW5hGggKOYdKa8XoLQwLfCXXmIjxeCrOPgFoBhbWihYS5vKLg7LR950xXPjdo0JhvgYUBXGdKKSTlixbya36qFA5GXzEs4rdxcyGOJxLiH/OmXWxiTdeYT7R3Oc8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Alejandro Vallejo" Subject: [PATCH v3 11/16] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Date: Tue, 8 Apr 2025 17:07:33 +0100 Message-ID: <20250408160802.49870-12-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|PH7PR12MB9076:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dfb7b7f-e2c6-4e57-74b9-08dd76b7b4d9 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: /Ny7UKNNSHGJ6VDYCJEO8tFlSeQFczLDNw9HyEjKB2jzNYCuRuzaT0whr/ne1LnCpRAc+8BCqu7ZIQ0fYLCEUP2u4il42jqevvqUAEXbHZFl+MTRY/qvP+XFE68tXhJGNoCkkwlybedymmTVE50jn6PI6ivc3GBR7Tt8PbgprLtZFYu5NbC4+mtByLqBa4pcQ2veN8RTOJ7aKM926mtt0uQCZZCJI/gZV83cHY9yWz6vAWVQQ7xn+yXgCn+amh9rrebj9Q6zk0/gFNSTB6qNfaHLc118+KOF8xZHguhJY3kbi+yrWgOAGAosSjIDLJ2Ojzv6En6TyLepxOrXZtoytWvQKPliyJmIz2SVJVB6TuHBXwv+9m4ncVZgCiQY/aEdHANr8LtrFyyKanCmrqeDej5MbdUWJfSsfT8gQ+9W/EWpjBzCrcPrqexXpmvhE9YH4c+lJtK8OatZ5IT6kWzASqGSsOJrnY6AzOzJ7eWxS8yUBBxtxEXh9eE99JJQVlD1xNC1/ta6xtJmCs2o7nMS+0z3PKA0qH7IoaFyzDa8R3m+nm2LBmQfAJeVG/IaVXujW4VLlGrHgPul1HiegNw+dL2q0Cn/45ijm1I5MqNqtCBf5LCr3rIVhpQfDVgVgOZzfr3VEhg5p9+3FCH/dHuN7cxVeVsCToYls6OYVv2qshxywKlh8K4JHFHHBfOFmT9uBRiI/6qewtvts9TRxBx2oodrIPIQV1UCFiYlyCaG0JvSoj72AkFCh4zXXKA175MpvqiEAmWNM5nzmaS0JF5r574MyjTpeQTMDbcpVd0YXsAgxHxgG6HoMFfgittlJQe13mhD0CO/GtdFK2aGV17cLW+DgNXTMzIkVIIYXTvQdjrgWXwLAbiOFJExSGfs6dNCHcIYQdkfRKOD8MYc6fNO2caB2yr+X5EBvhwZWM3RA0P5ImZBJnZVYX+nOTq1cfZcuqJis2wdViuCEe6m1gtVbzZWAdHi07+ISzBW8+kC+SjGnd/NlbmbfuZuu+/zlNctWCLTT2RJrI3TS6D1WTjiCO6mvkYcN2ppdphdRUowIfWDyA4BgdWeE2JnbTuDXqV6Ty8kjILr52jAfXqtzNWBdZZmjmc5NG7lBsUArbk6JJWaSudpmotwK3z4Rer4W/WFvGfXAnbywCQhMnI/Vu7Qek6Z5K6R0wlz7P01U2aWEIWWnJOvn00JE3YVdw1JcPXIBijUH0xhEOqXGAg2e4+a0M6F9S1Xg6WQ43d5lsV3BUK71Ic4RnQ5MjvLpViTltAp/jTDvVqVjH/YlRBZ73tfpsnGeZm2vpReFFKBj5vpM1tMaFOysto1RZJPLWT4wcWk0o+Xg05ccFyT1vtKQ9n+JKtaHpg0R/LGpP0pqo6W318JMFvGZUtrTt4++oz/HPvfT7aJhXfE8eshs/TE37DeV6J30+KD+5Pfb+o+SlvkQI8qPtTbEy4r9RvxO4MuygI35mpzeNXBXLLNBZhTOf0TB95sKQLfZdS8JkruOMaKn2Mjh3rXz69G0TlqqTV4ixXc 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: 08 Apr 2025 16:09:14.1408 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4dfb7b7f-e2c6-4e57-74b9-08dd76b7b4d9 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9076 From: "Daniel P. Smith" Look for a subnode of type `multiboot,ramdisk` within a domain node and parse via the fdt_read_multiboot_module() helper. After a successful helper call, the module index is returned and the module is guaranteed to be in the module list. Fix unused typo in adjacent comment. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo --- v3: * Reworded commit message to state the helper postconditions. * Wrapped long line * Fix ramdisk -> module rename * Move ramdisk parsing from later patch * Remove initrdidx indent --- xen/arch/x86/domain-builder/fdt.c | 29 +++++++++++++++++++++++++++++ xen/arch/x86/setup.c | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index bc9903a9de..0f5fd01557 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -195,6 +195,35 @@ static int __init process_domain_node( !((char *)__va(bd->kernel->cmdline_pa))[0] ) bd->kernel->fdt_cmdline = fdt_get_prop_offset( fdt, node, "bootargs", &bd->kernel->cmdline_pa); + + continue; + } + else if ( fdt_node_check_compatible(fdt, node, + "multiboot,ramdisk") == 0 ) + { + int idx; + + if ( bd->module ) + { + printk(XENLOG_ERR "Duplicate ramdisk module for domain %s)\n", + name); + continue; + } + + idx = fdt_read_multiboot_module(fdt, node, address_cells, + size_cells,bi); + if ( idx < 0 ) + { + printk(" failed processing ramdisk module for domain %s\n", + name); + return -EINVAL; + } + + printk(" ramdisk: boot module %d\n", idx); + bi->mods[idx].type = BOOTMOD_RAMDISK; + bd->module = &bi->mods[idx]; + + continue; } } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ca4415d020..3dfa81b48c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2149,11 +2149,11 @@ void asmlinkage __init noreturn __start_xen(void) * At this point all capabilities that consume boot modules should have * claimed their boot modules. Find the first unclaimed boot module and * claim it as the initrd ramdisk. Do a second search to see if there are - * any remaining unclaimed boot modules, and report them as unusued initrd + * any remaining unclaimed boot modules, and report them as unused initrd * candidates. */ initrdidx = first_boot_module_index(bi, BOOTMOD_UNKNOWN); - if ( initrdidx < MAX_NR_BOOTMODS ) + if ( !bi->hyperlaunch_enabled && initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; bi->domains[0].module = &bi->mods[initrdidx]; From patchwork Tue Apr 8 16:07:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4857C369A2 for ; Tue, 8 Apr 2025 16:11:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942916.1341971 (Exim 4.92) (envelope-from ) id 1u2BYA-0004Ii-4a; Tue, 08 Apr 2025 16:11:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942916.1341971; Tue, 08 Apr 2025 16:11:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BYA-0004Ib-1f; Tue, 08 Apr 2025 16:11:46 +0000 Received: by outflank-mailman (input) for mailman id 942916; Tue, 08 Apr 2025 16:11:44 +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 1u2BVt-0002e3-2y for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:25 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20604.outbound.protection.outlook.com [2a01:111:f403:2416::604]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d33a58f2-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:20 +0200 (CEST) Received: from MN2PR01CA0065.prod.exchangelabs.com (2603:10b6:208:23f::34) by PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.31; Tue, 8 Apr 2025 16:09:15 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23f:cafe::a4) by MN2PR01CA0065.outlook.office365.com (2603:10b6:208:23f::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.35 via Frontend Transport; Tue, 8 Apr 2025 16:09:14 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:15 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:13 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d33a58f2-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KiL40FDYM+sAb2Gj7EPkLHEeAlLCoSSgPLEoAggtvHDcsAJqQtXj2x4Hey20hGFy4H8suVzfjdltgCpWc+VO9CGuLpuldk8OlKjAStSB41HHxb4Af9x300zna8sSgxrhN2xTseffbFZZ/S3+F0aKNsNNfFyZTv0WFqtw8jghIU6sqhfnU/3I3Ev2YtUz6ZGMrZT2sX07etRriTTWeMuMqH9VuPMiTu9XdQOJ68MAx9k5kJptEj6hdqWyx+Z5ZnDuOYtWtvr0LJNTTfO4GmVXFnTujXEEAP+l/5gR4X41hKYytDNtq0MGKVnULonNM8m1tI226dJJe1MVq11ur8x+tg== 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=7R69kvWM740SS/m0F4d2VLUkfGCEI/pSnhi9Oh+3y0I=; b=woaG0MEXOW8J/HuZc9dETNUWPaF+RJAnTwYKkAGzRPWKCOLSUky87R6UHQfMy1pjnidzn/N4WKSrder9Svi02+fi1ISWe69pbnm+gQhCz7Je+mI4ItXfDL8uzLQnqRNuaWfYgBYHlYKC2E1x5vz68gJ2GPXiMDLIhFCgUsr2dM5bMg163fLw1Uh9ClBDIEj98T+eP2vtzLmCsGtY3UU8HAtL9w7UpW1WppcPv6+KsKjExb4sGiANkZxKL7gtv5IVuSqA/tDr4eL1C3dUXaPXagjl21sLLCXTZZnfdVrp7tHf03hyClqyt6ZAxdlz5uW40wSJkyuL9gYHgqprbj0v7A== 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=7R69kvWM740SS/m0F4d2VLUkfGCEI/pSnhi9Oh+3y0I=; b=LFjbPpV0rKY5Om0YSskgXjTX83gfXV5Hi8+yPb+ZZiwg4mS4u4colR8ziE1jCYHIjJkONz7XghZ8MGaKJOlcdRHiH5ZBGOGoeNBRFFPbuDTzCEzDLYAkpaXY8xlObX/fItshAKWpFU9bd/ViRIypgSayo6RsO7NKXqO/hdMXHB0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Bertrand Marquis Subject: [PATCH v3 12/16] x86/hyperlaunch: add domain id parsing to domain config Date: Tue, 8 Apr 2025 17:07:34 +0100 Message-ID: <20250408160802.49870-13-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: 5aff5e69-8e2e-46b5-a062-08dd76b7b5a0 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: rKkTUdZdIJJrdZL68IABjrqa+X/hqkAXN8RbzdR3mYPJU94dddoDX9uK9fyhcmROn2sDf3fZ8CWFz/Gv5s+xvdvxXp1d/peYK52EmB2engyZ8s2e+0oO+SQxaD8IX8f3eP9jTFm50+uCjKMsRDwZudjjsqw6F4uE2QIp5JS0ipyAKDT6VXJr7B7zcMIi1XaJzMDJjD1Tmt0DqTWalPklpw3Kwi7q2fpPS4Ikce45Dl+6mfQPLH0mJtNriHKXbzd/CoLnIH3yMot7+QPiw6qAKpkfamdST6RvZFiVfxaZKwVO222hHOcDhGYoBtLzKg64JCVmVcLmyJ57XvmJDVMsKIEEvY53OAdXdtE7rkgMp/7g8IXmvhHOVQKQ1h+v+pbmcLx9RlqGZq7E9f9bEduIzb/bl+R6bg6nklZM4tJKOn9Drp5QStXPL0P8J2sTfmMBt6RO1GhzMoJ/n8ZlfoM5O9wseMOd9sxx4Gy8Vlsp6n6YUF6BeKBl9iFY4CHrwxDMX02uxW7QgBdziZMyrJKZlmL77Fg2Vaw73iRH4hA/Zx6tdPlMH5JQxfWBVgVJYBhyVrOkfqSrkA4Ecak8BqnABy332RzPZk4nAnLj9O+Ev8PAtHaEfGRND1/VnV+K9NTMm9y+G1I6EMeoU5sJjk4Ju9gO10pmJwek3YYDK3exJ/bhbAjrvLf/nhqB9EydcqHOh5kOcRhlGPWf5IQOmaNnEybdlVIcGIK2u6sdIcAwqKJrqfWGw09UiYi9JTQQS3lwfCETvj5O9nKc1qMH8qsSAAWCrwUyOaOGG/Y2678dw60r6vOfhek8F/zEIuynr+pSKYG2c2uGnO7/sSS+yDtv7AjC9S7YXDqOeQMCMf1lz6AfA1+LscwZ6z3WBuT5zN6ZCR2TX76ra4ZDq5uSwFDT89YAGECI4s38UqnOc04j429+0HVWOxN0uNjQ2r7mHry/OQxQ0gTDEkV9KRpkBHJvk0IYF4wknmvcCPsihT8KBu1uM4mCjyyst5EEryt1VhJbGKbsBjdFLtFTLwXFukSMhX+qsT3T6YQ0ua8e/xGyKUsqyEDaRlSWpD3q32HxFGPeQOXAvzLng2fF82vm1NhhQRlto8N1wWO9cROX3Y6/h05YHdSXID9ewGiYO3lWeCxA1juFP56fU7rEInd6PKFUAweIplLE4mjZ1Kkn3UBgvwzQ0R5QJMDpssnX614q8hsVcwhOB7Qqac0d+azKT48TghyiZhbRbFIWOM1rZmWjmX4hRmJETp+ScMZT90tT4rNnWJsxIEuzrFbByDPc0yhYJ5h09e57dVwDdZQQc+kZjmaEflZB6XtMUc2PaGTJHqK5W+kDiwCpDJy1WepXmTCTUFzVNdW/JJSEQqMAvNXefymrRmz0iIvJzwthZHyJQPiRLD9pJJw1jyCgeeO1M73ReYRiQUAXM3r1rDUieffeeW75xhgUdleQ7o7czJKLcTV4VwuypKTTiJCHhWThkGhTDg== 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: 08 Apr 2025 16:09:15.4461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5aff5e69-8e2e-46b5-a062-08dd76b7b5a0 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 From: "Daniel P. Smith" Introduce the ability to specify the desired domain id for the domain definition. The domain id will be populated in the domid property of the domain node in the device tree configuration. Signed-off-by: Daniel P. Smith --- v3: * Remove ramdisk parsing * Add missing xen/errno.h include --- xen/arch/x86/domain-builder/fdt.c | 39 ++++++++++++++++++++++++++++- xen/arch/x86/setup.c | 5 ++-- xen/include/xen/libfdt/libfdt-xen.h | 11 ++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 0f5fd01557..4c6aafe195 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -158,12 +159,42 @@ int __init fdt_read_multiboot_module(const void *fdt, int node, static int __init process_domain_node( struct boot_info *bi, const void *fdt, int dom_node) { - int node; + int node, property; struct boot_domain *bd = &bi->domains[bi->nr_domains]; const char *name = fdt_get_name(fdt, dom_node, NULL) ?: "unknown"; int address_cells = fdt_address_cells(fdt, dom_node); int size_cells = fdt_size_cells(fdt, dom_node); + fdt_for_each_property_offset(property, fdt, dom_node) + { + const struct fdt_property *prop; + const char *prop_name; + int name_len; + + prop = fdt_get_property_by_offset(fdt, property, NULL); + if ( !prop ) + continue; /* silently skip */ + + prop_name = fdt_get_string(fdt, fdt32_to_cpu(prop->nameoff), &name_len); + + if ( strncmp(prop_name, "domid", name_len) == 0 ) + { + uint32_t val = DOMID_INVALID; + if ( fdt_prop_as_u32(prop, &val) != 0 ) + { + printk(" failed processing domain id for domain %s\n", name); + return -EINVAL; + } + if ( val >= DOMID_FIRST_RESERVED ) + { + printk(" invalid domain id for domain %s\n", name); + return -EINVAL; + } + bd->domid = (domid_t)val; + printk(" domid: %d\n", bd->domid); + } + } + fdt_for_each_subnode(node, fdt, dom_node) { if ( fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 ) @@ -233,6 +264,12 @@ static int __init process_domain_node( return -ENODATA; } + if ( bd->domid == DOMID_INVALID ) + bd->domid = get_initial_domain_id(); + else if ( bd->domid != get_initial_domain_id() ) + printk(XENLOG_WARNING + "WARN: Booting without initial domid not supported.\n"); + return 0; } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3dfa81b48c..db7280225e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1033,8 +1033,9 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; - /* Create initial domain. Not d0 for pvshim. */ - bd->domid = get_initial_domain_id(); + if ( bd->domid == DOMID_INVALID ) + /* Create initial domain. Not d0 for pvshim. */ + bd->domid = get_initial_domain_id(); d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index e473fbaf0c..3031bec90e 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -12,6 +12,7 @@ #define LIBFDT_XEN_H #include +#include static inline int __init fdt_cell_as_u32(const fdt32_t *cell) { @@ -23,6 +24,16 @@ static inline uint64_t __init fdt_cell_as_u64(const fdt32_t *cell) return ((uint64_t)fdt32_to_cpu(cell[0]) << 32) | fdt32_to_cpu(cell[1]); } +static inline int __init fdt_prop_as_u32( + const struct fdt_property *prop, uint32_t *val) +{ + if ( !prop || fdt32_to_cpu(prop->len) < sizeof(u32) ) + return -EINVAL; + + *val = fdt_cell_as_u32((fdt32_t *)prop->data); + return 0; +} + static inline bool __init fdt_get_prop_offset( const void *fdt, int node, const char *name, unsigned long *offset) { From patchwork Tue Apr 8 16:07:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA2D7C369A6 for ; Tue, 8 Apr 2025 16:10:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942790.1341913 (Exim 4.92) (envelope-from ) id 1u2BX4-00072U-0L; Tue, 08 Apr 2025 16:10:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942790.1341913; Tue, 08 Apr 2025 16:10:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BX3-00072D-Rc; Tue, 08 Apr 2025 16:10:37 +0000 Received: by outflank-mailman (input) for mailman id 942790; Tue, 08 Apr 2025 16:10:36 +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 1u2BVv-0002e3-35 for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:27 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2060f.outbound.protection.outlook.com [2a01:111:f403:240a::60f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d3aba9fb-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:20 +0200 (CEST) Received: from BN9PR03CA0530.namprd03.prod.outlook.com (2603:10b6:408:131::25) by DS0PR12MB7803.namprd12.prod.outlook.com (2603:10b6:8:144::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.32; Tue, 8 Apr 2025 16:09:17 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::3a) by BN9PR03CA0530.outlook.office365.com (2603:10b6:408:131::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.35 via Frontend Transport; Tue, 8 Apr 2025 16:09:16 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:16 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:15 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d3aba9fb-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UdCaeadaga/CoZqVYEn2x44Nm2wo/heEarKxYfLnGBTe4PrBB6wh81fP9+N44+AIWW9Q3cvAwugTA+lQ3c69js0Rfy6QdnNj5baQY984UzZE9kl4lb0i5e7X8kdo8G5j1MTnNEoMAAFOYnSFRITXVc2FroA4Hk24jnzga685MmjXFX61q9EWOhiTAaz3yrqZRiG4k8BqAhasrehjyiwO/Er/grvy97ypeP0sOerVqnj8h2w567l26Yj/M9dJeLkmJx97evtn1CYSEXWO3iL8ryKB7utk8hWiUXTuwmLiS5Ywv+yHE4U6TyeeZJzvg8QDPppFL5XirnkDPJnZgTJ1ew== 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=YUHvqkyFXiMT58qSmIkpj+5p58vEJmweFPsH29sLZII=; b=kvewH/UVjnHvrIc3xwGpQSYltAWVIASMD0gSutvusu/PygvN41zAmnQ4mVbVYLN4L6AK2Wnfef6jU7YUlv4NzBX6zEGo14RC41jZdInSl1VacdAlEpBPzyRR5ONMArQpDcZ8mCIjko3eQy3qVG8bVbkR+lHEVs7z0Qtqzru9QdXfgLAcb3pWJkJfnzkQm3b+JZMz/Il0o20/8URWP7qSkymEEKnf51cFGwgTiQsQDcJIV1I52yrZEtF6dhLB/uJib87XKpLW6xsCKB+gJ5HqYmWI7SJF5k1kRJ5hPItvfJX3xTh8+VDFZpYtRw8Neu+TvFZrgInshTXQ1SUp3sqvCA== 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=YUHvqkyFXiMT58qSmIkpj+5p58vEJmweFPsH29sLZII=; b=CJFCpZEe3tpyhi8zcIzC/HIal2qpTN7srcYFkxcHAlJqQ3rn48oxZFjrYyHPxPBpLT9v7iW4Sofbfkng3ZzS4R/w4mbMEy8ftqQZ/AGRpPsthAURmJ0+22vws7GyC8EdAJFGn4ZB/4C3HBJXCCyIqIvgsFyuUr5YV4lo5aYc/VI= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 13/16] x86/hyperlaunch: specify dom0 mode with device tree Date: Tue, 8 Apr 2025 17:07:35 +0100 Message-ID: <20250408160802.49870-14-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E66:EE_|DS0PR12MB7803:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ad9f13a-63f9-4287-67a9-08dd76b7b677 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: 7VAA3jQoTbS6bbrurXBzprDBoFkXAxuDClcJM95BAJUpp9g3goJ2YIbZzpttOfqdz69gUoejsyDZtTXVemgNDrR1zbTvK0xFHDBkO5dkWs0DcoUVueojFyBobYRmc021SRZYDgMYMHx+xEqKWY4Eb9vyUvMeGWU+WluP2uRVH+fjv+PMlFOFUpOphzTZ6Qj6paAnRO96KMtvii1IfKe534IB+agZPY6Qx9AN5YHqw7LcEc/5gpnAi428H6XkUnPUJkDb1bgUBsdo1w3jOCGLXyCTiPKkwxQwwtEF77EW5XKk5Kdilue5YXApL1TTeOlHCvpTfp2SAPHRSPO7cOHTLEI9O4xPXKmIC2RcyrWAnwA8u2E8q8FPKI599BlTQGE37lBa4Z8FIRzedzvt1XNYbUGyEQfwBGYXYpOU7t6J3+FEGGinKIzuIIK+B9lTUs0pXNDsYsMZpvgvgg/pFo/tSXigt5GUzT6JV9+M1Aq8qFXgJkJjdxrW4+HnMnVPo7Fxnhx0ZsN+ZJq9HsjRt110IVuGN0XwDahuFe/vHA/nvDN1P63nkjXBv1yluDJWMi40yWwgKb30AL0NTyVsO8GdBSn6upVHb1Fo0Y7jnBw3pamYhBKp8VhaJ46rt0etntpEis8C9/ey7NR1Ve8FwuafMjqaznTByLJdL8ks1yK37/lDxiWK/GRkU4sVaUinXqE4GEFd2L/31GvEqc9VgqCuLBR1n9pd2eNoJITeqQJhb5ZQ4TyAaYLoqbgVRWY011F5fhxRFM7HoA1WWRDZjAyd++jr1E/MLfFkwIs3zTxG9yR4pLbzxsn4pl93XqIy2MTbgabb2rgEsoh9TPjoA/Fe/yA0l6JCWek0NQLW6fAiph7XAOqluBLfrcsNEOI8gEeclG7e78T8sH+gLZMUmXgKP+/21H9W37JWviir89mgj5AYT+6rNeJ2MtNmZdMjoLeDOC868sUODXcRl9wp5sIIwGbI5fXNKFjaBXg2M2cwxHB3Qte/ZfR+qcFIVIAhuI/n4qTaxQ5FMTdiBrs+HQZyQgwMbgNi/cNEwJ7yUWTcyWvOdnrx1RtP8jjcMzKp3/HL3ybcqrMTN+wOzf9zD/nL34xTGHafWpnojweDq4Ml2Ngyinv1sKZD1auZIV4xpz8CMJYf6zYUQgQopBk2mkfmT59iGXzjO2pIPjn2Kg+oZ86z80UfwwGxA2FRm/0QJoknQPVwTNg8mneFw0OWOCxiW1n/ia99mvuc1I406HZKsphTj7VhdwV2iwVuvTsMMQS8YRWLmc4jAtXfT5zrHLAVE2DcULAG7Klq5NbWcmS9waKNhWJCeHQ/trv9v4k5FNYQpy9y/TpgpRN4l6Oyc2ERV+89LyKjKOB9oKaBWbfK1/vkg0rnHLv9YhSrXar2r4uqd9FkTztXPiXG0b2uCwhFOtktGR+e+l+25UuERzFjI1ER9G3U34GP8s3dZ438JNjRgCKEQi1IOonI+m2HPSrRK66LA5ovH757wISI2+6ALTw= 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)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:16.8537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ad9f13a-63f9-4287-67a9-08dd76b7b677 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: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7803 From: "Daniel P. Smith" Enable selecting the mode in which the domain will be built and ran. This includes: - whether it will be either a 32/64 bit domain - if it will be run as a PV or HVM domain - and if it will require a device model (not applicable for dom0) In the device tree, this will be represented as a bit map that will be carried through into struct boot_domain. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/domain-builder/fdt.c | 19 +++++++++++++++++++ xen/arch/x86/include/asm/boot-domain.h | 5 +++++ xen/arch/x86/setup.c | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 4c6aafe195..da65f6a5a0 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -193,6 +193,25 @@ static int __init process_domain_node( bd->domid = (domid_t)val; printk(" domid: %d\n", bd->domid); } + else if ( strncmp(prop_name, "mode", name_len) == 0 ) + { + if ( fdt_prop_as_u32(prop, &bd->mode) != 0 ) + { + printk(" failed processing mode for domain %s\n", name); + return -EINVAL; + } + + printk(" mode: "); + if ( !(bd->mode & BUILD_MODE_PARAVIRT) ) + { + if ( bd->mode & BUILD_MODE_ENABLE_DM ) + printk("HVM\n"); + else + printk("PVH\n"); + } + else + printk("PV\n"); + } } fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index d7c6042e25..e316d4bcde 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -13,6 +13,11 @@ struct boot_domain { domid_t domid; + /* On | Off */ +#define BUILD_MODE_PARAVIRT (1 << 0) /* PV | PVH/HVM */ +#define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ + uint32_t mode; + struct boot_module *kernel; struct boot_module *module; const char *cmdline; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index db7280225e..4127a0105d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1020,7 +1020,8 @@ static struct domain *__init create_dom0(struct boot_info *bi) struct boot_domain *bd = &bi->domains[0]; struct domain *d; - if ( opt_dom0_pvh ) + if ( opt_dom0_pvh || + (bi->hyperlaunch_enabled && !(bd->mode & BUILD_MODE_PARAVIRT)) ) { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | ((hvm_hap_supported() && !opt_dom0_shadow) ? From patchwork Tue Apr 8 16:07:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35278C369A5 for ; Tue, 8 Apr 2025 16:12:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942942.1342002 (Exim 4.92) (envelope-from ) id 1u2BYO-0005hE-3b; Tue, 08 Apr 2025 16:12:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942942.1342002; Tue, 08 Apr 2025 16:12:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BYN-0005gq-Us; Tue, 08 Apr 2025 16:11:59 +0000 Received: by outflank-mailman (input) for mailman id 942942; Tue, 08 Apr 2025 16:11:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BVs-0000a6-Oa for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:24 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2413::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d5d57d58-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:24 +0200 (CEST) Received: from MN2PR01CA0040.prod.exchangelabs.com (2603:10b6:208:23f::9) by CH2PR12MB4232.namprd12.prod.outlook.com (2603:10b6:610:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.33; Tue, 8 Apr 2025 16:09:18 +0000 Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23f:cafe::7) by MN2PR01CA0040.outlook.office365.com (2603:10b6:208:23f::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.36 via Frontend Transport; Tue, 8 Apr 2025 16:09:16 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:18 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:16 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d5d57d58-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ITcIlD5CBdN5LFC5ku2hqX5axGvK0f6Dy0Cxfpc9pydjdeA8JSyK1fVHR69dEMa66cu3h++bL8Lc/AikrLjOx14igsXuhYzLack4EVOo1oVhrvcXz1OPuiVZ/JzAPBzEhydTsdiOaVkRfOuQywB2KdIRbTIbM+rq9UWGNmoBPzVBakUR8ESVuaQcettm3/Ya7Qkm6TmlnWpcwEYqik34OxPaFtJpBYHOQ9EqjKQqXczxeuPvV2ILnn/H9u1b8zfOryb1pfrKLfhFwcmnxFI3OvHf+80fczU2LK9O0TXEY5MiBwjvtHzcw5S5Zljj+o5rpknt2gTK5MYhuRgyGBPQog== 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=Q9NqCvhzPSD0hg2V+P7263fYM6c1xFTV40UkgAV5Gpg=; b=on6XfXXK3xXIFo8BQ5QdX3ej0EA7fQNuW68gyHFlTX5jaM1FegepuwPWzk8tOg9Un7h6sKEEpbKUNiYIl96IhL52TMxjl2M+55c/6tGoXrKHkIWhATIZCpv7HbrDRgKJEYdMAyvUfcdKFku5oYQYcDLIJH+5giFn03CnmbKwFzhxnXkLlVYTL9t3kKRjf/D1940PxeiQ1IzvzigO4sJM0FrzwL6m4WanDmAQIAnKou9tIuYOYbgUfsZis0azLb7ekMOtzEMhXSFk8nCKUxSHhpSe9nA7GHm6k4wMF53U0E//Lrs6xaq7OxPnr23Zjnyol/9d6QBPjxU3lcO/iOpxZA== 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=Q9NqCvhzPSD0hg2V+P7263fYM6c1xFTV40UkgAV5Gpg=; b=mDsCbLNR5hS98/Ljo0KT+91xSsHi08fRKsiR31hstL/fN9S/XhdTLr0NS1YJBqBr6M+5KTbVXy0tH8k+BpFqEa8gA0oMeMN2onlOV8zXq3zb143sZ64KczMo61kMQZJaHqXyHpFixs0iJRO6kR0ILRt8/Lr/K0tUkFDT16yLa2Y= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Bertrand Marquis Subject: [PATCH v3 14/16] x86/hyperlaunch: add memory parsing to domain config Date: Tue, 8 Apr 2025 17:07:36 +0100 Message-ID: <20250408160802.49870-15-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E64:EE_|CH2PR12MB4232:EE_ X-MS-Office365-Filtering-Correlation-Id: 376e6127-eb51-4e3e-79a6-08dd76b7b75e 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: Bla8YJp2JkIBzboNjM2FCCWfyHpRLA6GbDW29tiT20MsFRp5FEiHTy8u8FjlpSPcbg3lAabHvlMsdrXRsm03stZk1Rg8bLUwVgiLH/yYJQ0o2eY7Ocyt0HHzAqynNL74115GkxrSxmKkwYqyfHnIIKhlgXA0lGJJ7qSLPktZL0AgE8dUS1hzxIhfIiEAL/PGFa+ain+foWAo/j4vV1If2wmwSjzVkuycI2oynrDANbS3wvwo3tWdcLQVMWzBcess0OCyrwH2A6yJWohlIIeyqMyfRDp+rSpk9PgZUz8V9Fl6PCRz0o3xJE7fbCfiZtIpNbH8TulPFEO7S9euO+Q/16hTVIvdEcIhZgyvIZ6+NdNgtpbiFFID75Nmq2a+CLi5mq7TdIGjB3/fpXvFS/6DN8mfMoijcz/krH0LQQtVg/oUgqChz/ZsM3ilI7E0kyjnw4a6Enl+vARkV5mz0vynamFK/srObrKGy2k2AqB6ggLdLvkx5s//JZKFlKAquMg4knycz6VDBsospRZIQHRpTXFNl4u1WCs/1OjhRZogo27Zs54oqOZGlHI51vMjhnZid1B3vq0ys0oOT+DAE1LdrocCBAhtzu7hayyt+wa3wQLzIsckA2irl5PDM1xeZIs3xI21UsreYbdC+xJU5+rt7Y67pvxGD1df7mdPxMonxdQZEfedk9rywAic5qJvk3vR0e4vnraxKMuJpydb40SdJZTG2IBXhejciUepWy5seTpvjO38DKsboWQw7r/cqmSXtjGz02ysr5ti9k9Lo488rQDUTNBKQyKc3+Si1WWdNHyDHfRVpvVulHw2GHkuBpHbZwu5ftRUgzPI3LJsIHKIMl1XV2qOK30IZ9CX4FdBXKPji82db0a/74MD5dUVSWb1MbtgpKnRPyVPsNTCCk/Y8lL1M8CFFFmaHoXakh1alibmfqUqonncO9CSB5ueTA9KJbvwQcW27ycPyCpYhP5ErKjyJMxc2OZaij58N7nM65Vzn8dBCIuufWEO2k6u9/v/ti/YEq+ygjHLdueavPeeprxsVxbVGr/3sIRSYl7eN6U2vwH7uqU8YHQegFlPEyUsvrfis9cfH6o5Ms7C9RG72hOkT43FIzX7LcRux64W6nSER/CrXBpxvq1HzyLpCH2s1gQWryodzK9sm660AGDVSNzehlU3zluE6SZqTHCvpIr4T4CSTT8RD8FyX+Mbk/P/ErVgXPS+5523+3HJaijqex72uFDIqYRhGx5cMvHhV1UK1d7lFiUlrMZ+1wPxHyKG/3/0gCdVoja0rZBsBJwG5l+0BE3VYgsFXVrcgTky6RDy05UvMxwNS2rZ63A9TKIbKD4z4xOTKb+mKWG29uRe5CPUjSjqN5Fu4jvQMOOH6QXIrdkafPIWtAcwC7oM0Z92DbATIFNDx/fuKlB8YQixqAwIMGahWsh/tXP+eyEB6Bu38EEQRjvBPoD/p2cQKtR4g8x1pxWfYZEScac9qai5TLFY8taJDgLmURwPFcZmARw= 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: 08 Apr 2025 16:09:18.3524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 376e6127-eb51-4e3e-79a6-08dd76b7b75e 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4232 From: "Daniel P. Smith" Add three properties, memory, mem-min, and mem-max, to the domain node device tree parsing to define the memory allocation for a domain. All three fields are expressed in kb and written as a u64 in the device tree entries. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 8 ++++++ xen/arch/x86/domain-builder/fdt.c | 34 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/boot-domain.h | 4 +++ xen/include/xen/libfdt/libfdt-xen.h | 10 ++++++++ 4 files changed, 56 insertions(+) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 0b467fd4a4..36fb090643 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -627,6 +627,14 @@ int __init construct_dom0(const struct boot_domain *bd) process_pending_softirqs(); + /* If param dom0_size was not set and HL config provided memory size */ + if ( !get_memsize(&dom0_size, LONG_MAX) && bd->mem_pages ) + dom0_size.nr_pages = bd->mem_pages; + if ( !get_memsize(&dom0_min_size, LONG_MAX) && bd->min_pages ) + dom0_size.nr_pages = bd->min_pages; + if ( !get_memsize(&dom0_max_size, LONG_MAX) && bd->max_pages ) + dom0_size.nr_pages = bd->max_pages; + if ( is_hvm_domain(d) ) rc = dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index da65f6a5a0..338b4838c2 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -212,6 +213,39 @@ static int __init process_domain_node( else printk("PV\n"); } + else if ( strncmp(prop_name, "memory", name_len) == 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) != 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->mem_pages = PFN_DOWN(kb * SZ_1K); + printk(" memory: %ld kb\n", kb); + } + else if ( strncmp(prop_name, "mem-min", name_len) == 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) != 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->min_pages = PFN_DOWN(kb * SZ_1K); + printk(" min memory: %ld kb\n", kb); + } + else if ( strncmp(prop_name, "mem-max", name_len) == 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) != 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->max_pages = PFN_DOWN(kb * SZ_1K); + printk(" max memory: %ld kb\n", kb); + } } fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index e316d4bcde..fa8ea1cc66 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -18,6 +18,10 @@ struct boot_domain { #define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ uint32_t mode; + unsigned long mem_pages; + unsigned long min_pages; + unsigned long max_pages; + struct boot_module *kernel; struct boot_module *module; const char *cmdline; diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index 3031bec90e..da43e12e38 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -34,6 +34,16 @@ static inline int __init fdt_prop_as_u32( return 0; } +static inline int __init fdt_prop_as_u64( + const struct fdt_property *prop, uint64_t *val) +{ + if ( !prop || fdt32_to_cpu(prop->len) < sizeof(u64) ) + return -EINVAL; + + *val = fdt_cell_as_u64((fdt32_t *)prop->data); + return 0; +} + static inline bool __init fdt_get_prop_offset( const void *fdt, int node, const char *name, unsigned long *offset) { From patchwork Tue Apr 8 16:07:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F1E1C369A2 for ; Tue, 8 Apr 2025 16:10:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942786.1341896 (Exim 4.92) (envelope-from ) id 1u2BX2-0006aJ-NM; Tue, 08 Apr 2025 16:10:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942786.1341896; Tue, 08 Apr 2025 16:10: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 1u2BX2-0006ZA-JO; Tue, 08 Apr 2025 16:10:36 +0000 Received: by outflank-mailman (input) for mailman id 942786; Tue, 08 Apr 2025 16:10:35 +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 1u2BVu-0000a6-Oh for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:26 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20626.outbound.protection.outlook.com [2a01:111:f403:2405::626]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d6e62563-1493-11f0-9eaa-5ba50f476ded; Tue, 08 Apr 2025 18:09:25 +0200 (CEST) Received: from BN9PR03CA0510.namprd03.prod.outlook.com (2603:10b6:408:130::35) by DS0PR12MB7581.namprd12.prod.outlook.com (2603:10b6:8:13d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.46; Tue, 8 Apr 2025 16:09:20 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:408:130:cafe::48) by BN9PR03CA0510.outlook.office365.com (2603:10b6:408:130::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.33 via Frontend Transport; Tue, 8 Apr 2025 16:09:19 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:19 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:18 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d6e62563-1493-11f0-9eaa-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D6Rzp27zm8TH/hdxXoB5AbyMZLsU/atAprbomog0ckPL72ogew3cbqwFcsVnwPw9yKLD0LDPFhmzhfuTj+zNqSRlYG/GFQpEcgpNOXXPZ77IDK8TXN6Ez4YmLXquBafN6XHzb9SRubI9eAhaxt/GBHtik6rPhXMSQbYzLd4E0Dn28yk8vmfLRkvN6c8nWMq0YSKq7mysz//inMHrJOC8OamAC1eQRP6X2TVpb1J+USs8xaL4TRAC7wus4PczWgsv9qEjXsSk4iF1exsNTsby8wcMVzMqvs9rkntRrgARteppkEpw/z4RB/0VsjZCJFuQzmYcMdPGAXYV8Fc+Lrqy/g== 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=/2WAAf2kiNnaQf/e9i4d409O0E4TYYx6jvhe7n69gtg=; b=dZPb+H09vWs1AAhAECvBM9lO+ciAv/gHbtsgnjgEXuTsUnQseJGgsf2M9C1a/dq/RABnbpCP9L/+c2b+zIs0S9kXB7tsU4hXoAxx8TjCwedOqfwB/UIO/nU+LE7dMWsYcK+hRQvV0dFqab3AUzsZbGQeixGwQpk8zMmc3yn3A3OAtqBJRsgUkU70xpKN9ournZCHkGspiCo174hICwAOhAgj1I/QW3/KLmlMr5Yqk6TqnvDqRBOeFLbP6wUEEUDiBdr0befGZYSmnfaj8F/PrrRWAdYYtvSht6jyn6RH3l60bQkUhaP1246M68bzmbh1kaFUEqvCk3i2kA08hKtgUw== 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=/2WAAf2kiNnaQf/e9i4d409O0E4TYYx6jvhe7n69gtg=; b=i2hbGrF1CDOPX+36KE8VUAQ8/GG2ZJ8TaiwrnkhCOXPzCwHz3nKiBBShDnD09EI3DbxhGSEaCKsSUUm6mICqT4MRflne17smdUSqlYsEXFlSqXr0BLKLE156qAsVGNcsAUYUFKCWUO88uaeyjLmKUztVhF8dkPkznK5B4/jtlg4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 15/16] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Date: Tue, 8 Apr 2025 17:07:37 +0100 Message-ID: <20250408160802.49870-16-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|DS0PR12MB7581:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e75752e-cb38-46f7-4ba6-08dd76b7b83d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: eSmrjKGXkNeppS5kka0jrKiBJyN4m8LUkjDHu0wWV4831Rq2R2SHSi5M8Eo05M5TIvdOu82M0ww6F3uBY7d5Mnr71Krsx8J+OZ5/UwzpYQ3X5fpLBN+7fT9PKgja/ksGdMhQy6tzp5ghrSbkzoVfVUctmHV3Mbi0g3kCWiPxF6oeUI/T5NpqOxwySPKTIbylitGg1Ylr2mYVMk3+ODAWUslsE0xgzHqWxzMQjuLqxfDUA/uR6vXwa6zNE8EBpOdpYfbHcKEpOmKSsNAoVziM3HuvfnyQh9nq8WGxYCYLW5gY5Z+ROXwjuhpxrSZIKnU0bp1cRpTmqx7acmH+8c/5WAkeUk2L7PMLH/hcmrfMGr/l184DcXYyPT31KgsB8cLRBePLeVaQ3OsKsKpHsw2AQDW289ObnnaUiCOVyZQqk5DyiYqkJTCCcVk/IQJjxFcz9ARKHR0RmSiM9MIs13KtqpC0LWfZdkOPmjriSWAP0eQWvX16VjpaOZSZ/OKRzG65PVO9uH40t7ZgNQZtde5lLAjtIOnkCL6Q+2OlOMhlCYY2o4dv85o/OXdb7NXz1B0hpllhPVN+vhQlITdUwMqRPrDppthqhODrRyk8c5KCl74PcNRruvhchwqUf/B0TiELgDczgWic5Su9JEJFwoM3ej+HbuUytvR74/akr60EqVqyx8HkRX8EgieVPVv5O3M4GniQdM9ZWEWxeV3HkaWYLKIeTQVh6HCnxIvLzPFkY2W9seabsN2jXIEpE1XzVGQO3z3jT+4dUHGtrXArNvDSzRtsasub9Aax3dTO3hbiTd2zOFrrrkYFpFlAI2hmHETmExuG45mND2I82PgY5Uwgani4Tq6CkktGH4PB/x7AdsoizAD6ijmEEhwolv8dlEghl8nn0fM1f5lCVzq+S4UgGulucezozSCCSQ3592/s4EQOjY/h2mXi3OkIwZDrbkYt4AHdm5HUQhyJ019ZVOZ2pKh5vEDNlNRcsNz+UPLwofmRu8F1CCPfopamLQKY7Xy9YgocbkeiEey20PFxqkiapIiRScYVZE49LeFQLORrtpWby/YSEIyaY5Dibi3kvNFDrABh/v29Wpb9Q6wY0Tr81aI9l3T3vUub00TKPGGX8o14a/RQUO7IEGK+WRuPTl/kscCsNZG/SRkJwMNEqRmyzDOTZDIvNfQpsyaDmvMCevVdQGjroQcqeOweZfxwMM/CD8dg3LvhU7cwpCJDb9igc3/B24o6SSMGQmhnbeCkH3DHXHX70kGD0OrySxKdw8J5efToI8N/JArgcPhSAOpi2zPlwyH68/oZtWaDmm2OwH9GrgI6WBW8v/lsD4lG6w5wc5ADJOn2aTXpgTeYy7D5C/lIVXTntimTdODg530bycEnjt0/xn25WdZUcMZHLkQ0seediM7nIiTwyaI7uNPeUN8Fmmg7zbjL+krnCHMhs6hoCyqdVN2hofI2QU2SoukR5OkiVEgGopeZdb85e0mxuwyvcRALOQXpt1KTPRqJd9NzNogRVyYXVDSBC72QIwEH X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:19.8127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e75752e-cb38-46f7-4ba6-08dd76b7b83d 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7581 From: "Daniel P. Smith" Introduce the `cpus` property, named as such for dom0less compatibility, that represents the maximum number of vpcus to allocate for a domain. In the device tree, it will be encoded as a u32 value. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 3 +++ xen/arch/x86/domain-builder/fdt.c | 11 +++++++++++ xen/arch/x86/include/asm/boot-domain.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 36fb090643..7b3e31a08f 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -635,6 +635,9 @@ int __init construct_dom0(const struct boot_domain *bd) if ( !get_memsize(&dom0_max_size, LONG_MAX) && bd->max_pages ) dom0_size.nr_pages = bd->max_pages; + if ( opt_dom0_max_vcpus_max == UINT_MAX && bd->max_vcpus ) + opt_dom0_max_vcpus_max = bd->max_vcpus; + if ( is_hvm_domain(d) ) rc = dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 338b4838c2..5fcb767bdd 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -246,6 +246,17 @@ static int __init process_domain_node( bd->max_pages = PFN_DOWN(kb * SZ_1K); printk(" max memory: %ld kb\n", kb); } + else if ( strncmp(prop_name, "cpus", name_len) == 0 ) + { + uint32_t val = UINT_MAX; + if ( fdt_prop_as_u32(prop, &val) != 0 ) + { + printk(" failed processing max_vcpus for domain %s\n", name); + return -EINVAL; + } + bd->max_vcpus = val; + printk(" max vcpus: %d\n", bd->max_vcpus); + } } fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index fa8ea1cc66..969c02a6ea 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -22,6 +22,8 @@ struct boot_domain { unsigned long min_pages; unsigned long max_pages; + unsigned int max_vcpus; + struct boot_module *kernel; struct boot_module *module; const char *cmdline; From patchwork Tue Apr 8 16:07:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 14043340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACE7CC369A4 for ; Tue, 8 Apr 2025 16:11:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.942826.1341941 (Exim 4.92) (envelope-from ) id 1u2BXK-0000KV-1P; Tue, 08 Apr 2025 16:10:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 942826.1341941; Tue, 08 Apr 2025 16:10: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 1u2BXJ-0000KA-Tk; Tue, 08 Apr 2025 16:10:53 +0000 Received: by outflank-mailman (input) for mailman id 942826; Tue, 08 Apr 2025 16:10:52 +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 1u2BW1-0002e3-3e for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 16:09:33 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20602.outbound.protection.outlook.com [2a01:111:f403:2408::602]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d74ffb5b-1493-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 18:09:26 +0200 (CEST) Received: from BN9PR03CA0485.namprd03.prod.outlook.com (2603:10b6:408:130::10) by PH8PR12MB6673.namprd12.prod.outlook.com (2603:10b6:510:1c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.21; Tue, 8 Apr 2025 16:09:21 +0000 Received: from BL6PEPF00020E65.namprd04.prod.outlook.com (2603:10b6:408:130:cafe::69) by BN9PR03CA0485.outlook.office365.com (2603:10b6:408:130::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.28 via Frontend Transport; Tue, 8 Apr 2025 16:09:21 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E65.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Tue, 8 Apr 2025 16:09:21 +0000 Received: from xcbagarciav01.amd.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, 8 Apr 2025 11:09:19 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d74ffb5b-1493-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KhKWTPh5+j5ubY28Lc8y3jGM9Q0MXXLh54mpD5gHAMO0+i6MleGisXfDKlGgCf6AftSm9n1D4PCnTSAORjWATgLT1YV4XRTrNMYJ9ZjJPyaouGb1/xcx8PqIoGywNa2J4CKPk/mY5HFwaomZmqPZ+ofcmqTYrNhi3OtLZK1ek3XEwkSKOUbeOg5GyMzYfrVrtj0IP1hPvJ/A+iJs07VvXVChBJzDHjbQvjuduCY1dWLs3AY11GJJFM/afPON/oPPgt6j6SY12m4uoYWk3bRHeidmYeKYIgVq4irgsfrJdvfxsM0CVVqMoDG86fyoSmUUUS8FRdmAhnyGrifo52JDVQ== 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=CdZjJno4ZP28T5tdzAN4JY6E44clyK3Mj7hHKvRrs5s=; b=lB7ZIj1ZIiXVAmchV7DjXZCmzB1VDTbIJhDqluy9kMKiRTdzvx5a/5KgQdE5XcYCskbzmADEP/+a8flGm6ArLBgOj6dPzyNwL6dDlO/co20ktRxkErKAeY0j6/PJrN0SOv+4QvfPl4xSzvKkYpR9iSd75eqCudLtHjMueX0UI7cFuTEWsuuXLGbtWKZK73u4ojRaDK4vI5w5TxloQhRdefhaGWACiHj0V8uRTcRHbO6p4GLCHMfbcnRY1a+bxpkb4JZDcsJ4qrOgLTdyTroFe99HxzKydwXnMBOUxzbKjBKuz8v6lsiWNkXhBztVw/q7Ze5lskQlse+zshZ4LiW1pQ== 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=CdZjJno4ZP28T5tdzAN4JY6E44clyK3Mj7hHKvRrs5s=; b=dfwvcWzQDr/phsYUaUxulKPOYesaO0TXOMIIgcrA1B2aa952Ug7Dgjrvas5kVHoFEQ0qTVGlgwZi7IqmQMu0FAv6Odrjt7mXf3OeeU/8vgIoEK29M48iHn4DWQ/tztgoJSJUWZJ9Rot8lMv0INr5WoS5sfsEsiFUqV+eHS8nLuA= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Alejandro Vallejo To: CC: "Daniel P. Smith" , Jason Andryuk , Xenia Ragiadakou , "Stefano Stabellini" , Michal Orzel , "Jan Beulich" , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 16/16] x86/hyperlaunch: add capabilities to boot domain Date: Tue, 8 Apr 2025 17:07:38 +0100 Message-ID: <20250408160802.49870-17-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250408160802.49870-1-agarciav@amd.com> References: <20250408160802.49870-1-agarciav@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E65:EE_|PH8PR12MB6673:EE_ X-MS-Office365-Filtering-Correlation-Id: 5767b228-3ba6-4589-58cb-08dd76b7b929 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: rSS4UDZQQUy8bV8VFukunITNWbb0gAtrNnAustEYq+J9v26STnFrAGFdEgd0zbIfM9PmKWjmaYbkm9PNTMWQ+PxDAwY2QPtxOM/JaGWtM+bIKAJaIDJkMjsfRoBj6bDC/jHksj2wqNoU0XavYUNZDCRrAxG/gr2GML2n4+lZd0cC+O4b9tlvZ4XXckAkuq+vfF8mj0Jizwzz4sqiiH3E61YZm7QQcpvMd5uiY7VmRohC6vq1mzfN1Ghk1pqhlYK2T7LPY2fs+T1+i67Zg5CwOfPGHCUkaaEbEx7Nm/gdXAITt+NhR2D02T5GHdvs8QP3wdJPQmPwQs0ZMGQ1MMbI9T6AwX28XEeUoNTiPCKd+yJW1ziZa9whe6zdK3l5gHlG33VU7EjPJ25DgcUQyMGNRoBmEYGHCJWcjOHotxqFbJx6GTqjJuKfMC9Gqnx0CHR4rn+nQwWq0qf7e86WDia9fr/FLrjvgX5kFw9vhOTUFSgCw4bN0J+s0luY5GalJS+Ya9h2/8Bw3O53Oaylnb01V6pULQLSKH9ilVoHbwE1OYP/n0N94Wdmasi3gP9H7MZzd4VQaisoABqr/d2LcQ5p8/b8Qgyyvp6Q5jUCQm3g+7UICjLJgRo3a+/PYsQvmso9XXGtIV5LTy6vD1QblXZA2mbjcRycpYPG/XLbdFkYxp26n5jhyHeLRTiMaYyt2aQyyE7SwHSe3CSAk0hAHlh8Jm3Ycnu9NahYn+ScFctD+eav+6m3g/BuG+3CyPxAA8LHXyIcP6Xp5YZc1tpmqdVhSfmyWW4GtU+LcgjlbsOMA2Y9dmqrgLtb4NUCOeHxjnfp+19FGP3TnAhD8LxmaYivOtknmTCup8YtI5f1Keo59y+xAHDSUFt4A9X+ZSA+gqLgedscdgw3G8TZeC0O5kGA3wXajM42O5JdF2pkmVICI9KTcRTrhkEsbGNQpO0PAX67ssh8fqs4ZlhMxBqx4VeXAzOzxxh/PbN5K2Ed3hd/GXaNoAITghoszhXt4dg6L9bHRpOGTjm7Ecuy6pqen7ulwNm1+oPkRb8pDuHMCGY0qT5XDn8ciuilIZYghOvop/vLh4h36Xl4N+8aA2RFRcmcu/UT8gnv0ynj77BATEpXIWD0VIE9HLSVObhYRY7J9N+O2ibPynW1LHxjrD0lKelm1LadlwuWEe6/zdQh804/w4KwZ5rAMKK7TUlYtRGBYHca6u3anbo+fMQfgiC92sVvxxEqpAmCZYfj9gdNnjZRm78IOcMqQ64cbNV+YqRjBoO653bBCP6thWo8vOuysPFsEcg5ij8scofpmJN3HQVMT8aDh7gpoMAF9WjRw8yY8qbexUxJRZipOC/VHdjj26kl2g/lokiWwADE5rMu1prTCAjWkDvpOcxyPrpsBm2L5J14Um7zKYebIbn+m1p5fLgY+O5Rm7jw9iMOZtyO+SvRIREneOv26hRiD9KP9U1DJ4NoA8CxaCeqfhCuoXfXrTgGYA7rUXlFawQsa+KU/YKzoSZd7Px+MRM1WEqoeamdAKxY 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)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2025 16:09:21.3752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5767b228-3ba6-4589-58cb-08dd76b7b929 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: BL6PEPF00020E65.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6673 From: "Daniel P. Smith" Introduce the ability to assign capabilities to a domain via its definition in device tree. The first capability enabled to select is the control domain capability. The capability property is a bitfield in both the device tree and `struct boot_domain`. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk Signed-off-by: Jason Andryuk --- xen/arch/x86/domain-builder/core.c | 1 + xen/arch/x86/domain-builder/fdt.c | 12 ++++++++++++ xen/arch/x86/include/asm/boot-domain.h | 4 ++++ xen/arch/x86/setup.c | 6 +++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c index 510a74a675..6ab4e6fe53 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -96,6 +96,7 @@ void __init builder_init(struct boot_info *bi) i = first_boot_module_index(bi, BOOTMOD_UNKNOWN); bi->mods[i].type = BOOTMOD_KERNEL; bi->domains[0].kernel = &bi->mods[i]; + bi->domains[0].capabilities |= BUILD_CAPS_CONTROL; bi->nr_domains = 1; } } diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c index 5fcb767bdd..dbfbcffb0a 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -257,6 +257,18 @@ static int __init process_domain_node( bd->max_vcpus = val; printk(" max vcpus: %d\n", bd->max_vcpus); } + else if ( strncmp(prop_name, "capabilities", name_len) == 0 ) + { + if ( fdt_prop_as_u32(prop, &bd->capabilities) != 0 ) + { + printk(" failed processing domain id for domain %s\n", name); + return -EINVAL; + } + printk(" caps: "); + if ( bd->capabilities & BUILD_CAPS_CONTROL ) + printk("c"); + printk("\n"); + } } fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index 969c02a6ea..29a7d806de 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -13,6 +13,10 @@ struct boot_domain { domid_t domid; +#define BUILD_CAPS_NONE (0) +#define BUILD_CAPS_CONTROL (1 << 0) + uint32_t capabilities; + /* On | Off */ #define BUILD_MODE_PARAVIRT (1 << 0) /* PV | PVH/HVM */ #define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4127a0105d..7e1a26b4d2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1006,6 +1006,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) { char *cmdline = NULL; size_t cmdline_size; + unsigned int create_flags = 0; struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, @@ -1037,7 +1038,10 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( bd->domid == DOMID_INVALID ) /* Create initial domain. Not d0 for pvshim. */ bd->domid = get_initial_domain_id(); - d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + if ( bd->capabilities & BUILD_CAPS_CONTROL ) + create_flags |= CDF_privileged; + d = domain_create(bd->domid, &dom0_cfg, + pv_shim ? 0 : create_flags); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d));