From patchwork Thu Apr 17 12:48: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: 14055514 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 4A871C369D2 for ; Thu, 17 Apr 2025 12:49:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957512.1350621 (Exim 4.92) (envelope-from ) id 1u5OgD-0005Df-Fj; Thu, 17 Apr 2025 12:49:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957512.1350621; Thu, 17 Apr 2025 12:49: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 1u5OgD-0005DY-CC; Thu, 17 Apr 2025 12:49:21 +0000 Received: by outflank-mailman (input) for mailman id 957512; Thu, 17 Apr 2025 12:49:20 +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 1u5OgB-00057t-Rs for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:19 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20614.outbound.protection.outlook.com [2a01:111:f403:2405::614]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5efa2e51-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:17 +0200 (CEST) Received: from CH2PR05CA0038.namprd05.prod.outlook.com (2603:10b6:610:38::15) by SA0PR12MB7461.namprd12.prod.outlook.com (2603:10b6:806:24b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.22; Thu, 17 Apr 2025 12:49:12 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::ab) by CH2PR05CA0038.outlook.office365.com (2603:10b6:610:38::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.22 via Frontend Transport; Thu, 17 Apr 2025 12:49:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49: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; Thu, 17 Apr 2025 07:49: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: 5efa2e51-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tpBVcqgZcMnETPrK/8TagwUfAxZzD6rbE3iMGjaXRmyq2CZyAtoTS0SY7rsZpI2a6bsmoI1TuQcrAR4j7jKuBEY/CtzkEeENSL6jfgVhzvAENyIQccNpOiH3tjdV7pTp04Skg0pXxGfho77VsbnNSrqDOpRLHDOYroOtWnrJ4V8e9BN5LyI0+guAXTNwtBBcvDNPnLID+ql3G7+s2LO+hlEP1uL0obXQNp+zTIeEir/CGrko9DjeyOzx2ydoPZwfE+frDFXDewtpjD+p0OYccSnphIEgICJNCiGXgGHryQ6Az7BDBAHIUzPEwoyUdObg40AAdtO/Tad6Pg3CWGIvig== 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=SPTSOCD5V92BOMtpj6x7Vs6EoxoU/PucsJHEdi/GDEU=; b=E9vp2QUnhsmeh0V5sS4Uwh876ewtu3TX7bt+HqjT26nsWh0PbK6n5xyCXcS0btiK6nYh3pYE9nke1/Oyg7dCB+Wc394jiP+UNP2SdtJ55gA4OXaVqrVOxkeoysgfJf5yR/bUgVsYPbyvOlFcNgk5QUXghejQspDvsoAP8j7lVuFTKHPMLAbn2Wc9zW8a1q7wI56C9g3+VeGsxeRiS30YT5dJlsSOVOgovXFystGmdMaP8Gc/jsbnRsnDmkkbW/h9PmjR0OdJkx4ZfbpRIF0dmUbxfCYy1r4aLg0cCzOINYUhhFED8cRO5nXS8Fx4vhRkYWDWYAYDvdVIp37tdjdIQA== 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=SPTSOCD5V92BOMtpj6x7Vs6EoxoU/PucsJHEdi/GDEU=; b=vFm4zTQvQV6WFU71ZWPLWsH8z6SH8pBD6vx8RRsqplyv3dUIlMlqDkXJDlnTse6MtinK/w0Y38srVfBJv7If00Aay26Y+Jh+sZnotm5z3XWb9CVlxhcxzBOtK7rpL3aPA0YUL0qdc8A6OyGcjzUP9NASwQeXrToOV65xKkDmINc= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Jason Andryuk , Alejandro Vallejo Subject: [PATCH v4 01/13] x86/boot: add cmdline to struct boot_domain Date: Thu, 17 Apr 2025 13:48:23 +0100 Message-ID: <20250417124844.11143-2-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|SA0PR12MB7461:EE_ X-MS-Office365-Filtering-Correlation-Id: e847c6ac-a9e8-41d9-e2ff-08dd7dae40ef 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: HabIPN4LFXLzCVihku2mav3DP6yKG1Nv54GAXd/PcJva65VWN0PbHzxr4eakoz4LdgcoGPIvEZFxBzqVBUZSpi+B1dL2pjN0DKPAl6v9TtDjJNB4A92d7eEIWEeF4r4Cz732T2+kI8NZ2GgF0ulMbPrWPYpD3AhQ+qQ65bp8uR5YFDZEEdxNLxot7OcTV7olPkUPjn7rMQPrDDoTGLF9yZ+D0CL3Gt6jeqPMHMsse0z91hGzmAA9KC9cpcaszO2L771b1GpYXA/R3sDRPQJnTtUilCO9vYU4AkwlFhmyhWdQ880HaJ8JpwcQgk/Usvf6zWj0J3q/S2nvG9fIzs2JZO7NDyu0mmh8RdxDRrPFl6M4UtszUaoOLkp4EHdHXwk7XaHrlGwTAG+YPTqXKEirgNFStXJrGtvJCtIEhMBmHL56NPNatNM6DstTGo/oKrPre/Rbp/PoC/KrJ3+XZZQ5CQ7hKFqPPHBwNez4KhXaiI9QgnqeZvHrzj1YNTbMMg6ObFJa/lDuxdzzegQdMAFu9mxpux5S7N1f6J204ePjjiqMJHKvCYWJ9797eAA4uMTF4yyNDxO2Uf1oBPfp3due1Y8hXn6es98FIZzlkl9iLSlHIcDVDjPC3RLxn5ccYF2Ffp1ELY4szMGXBzn828SmfktqHrfZ76x5jouf9xCq2H0DE6pS3/vVCE0z9CTsPcf3TynKtFn8nTKLe0oRuu5O051zaoKwWFNJDIXIo4BQ7eW3hbTaOkRq2u9aSu7NoqRaX9ez+fPWnTuBY/ZWyl0BYKSI6hnHgECIVBtgioj4p/Ts1B0Ly2z1FInovCXi1peyDrrLVIcRWBFwPva6A3LGeZRtT0u5on1qGFOnAPRfSkjLT/pCegAcJZPA5CEBHyoNSdLaeZyfp/8psqGB9GYS/0oOHx+0PxIAOvNsN2oDQgWwsDoqdE7SgTWWWJ/12iRXb5zl1XRQMu7Kb1uxgQkNinRqTfO7j+tKoYE0LUrU1Xn7/6hk/AlyEPlX/u+evAImlZsbRkaQY7pV6plK1fpnV/xwyhT2tnaWHisPyxdF9x4zwZ0G7Z7YUQlr5w9L21G83e/T+zsZh58kzSBFcQCey5XIX8aL+kkDI1lUaouTN8srMSPZGKcjUBsyFXxVQNOJVa86Ee3hzzfF+LVGGVJidFNaD+ZI3n98oRu5soRcarFgizxRPINNpoMuHk0mZ3P6AaLysoA1V3k586axGBaE8U/rnirS8Hw1SmQJkJQJLDzJOUkAj3RoRYDJYC7GG6pzJuf6KjKRTbO+1xN+LyuPw/4+rrsRVpJoSNaENKlfd04J+P7MX/1B6cYDZhc6qLcq9wz+nj0FF6aqr61SX1dekAQkEFwTNIeafWISe7dsWKG3DsSh+h98nsgqn1eOOf+LOxrnrfdDB/2HIZdx6Vothng3cv+9xbDgvx1OZzK8PqZ0cV9zpAlI6QqueZMU/TbOhmht8bXIiVMnD2Wk3a8/fCjHbccKMNeUd2X75b05C4RLeppg8dgaXsEq1fGIDoJE 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: 17 Apr 2025 12:49:12.3029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e847c6ac-a9e8-41d9-e2ff-08dd7dae40ef 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7461 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 Acked-by: Jan Beulich Reviewed-by: Denis Mukhin --- v4: * Manually nullify bd->cmdline before xfree()ing cmdline. * const-ify arguments of domain_cmdline_size() * Add cmdline_len to pvh_load_kernel() --- xen/arch/x86/hvm/dom0_build.c | 31 ++++++++-------- xen/arch/x86/include/asm/boot-domain.h | 1 + xen/arch/x86/pv/dom0_build.c | 4 +- xen/arch/x86/setup.c | 51 ++++++++++++++++++++------ 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 2a094b3145..49832f921c 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -653,7 +653,7 @@ 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; + unsigned long cmdline_len = bd->cmdline ? strlen(bd->cmdline) + 1 : 0; const char *initrd_cmdline = NULL; struct elf_binary elf; struct elf_dom_parms parms; @@ -736,8 +736,7 @@ static int __init pvh_load_kernel( initrd = NULL; } - if ( cmdline ) - extra_space += elf_round_up(&elf, strlen(cmdline) + 1); + extra_space += elf_round_up(&elf, cmdline_len); last_addr = find_memory(d, &elf, extra_space); if ( last_addr == INVALID_PADDR ) @@ -778,21 +777,21 @@ static int __init pvh_load_kernel( /* Free temporary buffers. */ free_boot_modules(); - if ( cmdline != NULL ) + rc = hvm_copy_to_guest_phys(last_addr, bd->cmdline, cmdline_len, v); + if ( rc ) { - rc = hvm_copy_to_guest_phys(last_addr, cmdline, strlen(cmdline) + 1, v); - if ( rc ) - { - printk("Unable to copy guest command line\n"); - return rc; - } - start_info.cmdline_paddr = last_addr; - /* - * 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); + printk("Unable to copy guest command line\n"); + return rc; } + + start_info.cmdline_paddr = cmdline_len ? last_addr : 0; + + /* + * 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, cmdline_len); + if ( initrd != NULL ) { rc = hvm_copy_to_guest_phys(last_addr, &mod, sizeof(mod), v); 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 3c257f0bad..4df012460d 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(const struct boot_info *bi, + const 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 %pdv0\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,20 @@ 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"); + bd->cmdline = NULL; + xfree(cmdline); + return d; } From patchwork Thu Apr 17 12:48: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: 14055508 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 78E72C369C2 for ; Thu, 17 Apr 2025 12:49:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957513.1350626 (Exim 4.92) (envelope-from ) id 1u5OgD-0005Fw-OT; Thu, 17 Apr 2025 12:49:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957513.1350626; Thu, 17 Apr 2025 12:49: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 1u5OgD-0005F8-Iw; Thu, 17 Apr 2025 12:49:21 +0000 Received: by outflank-mailman (input) for mailman id 957513; Thu, 17 Apr 2025 12:49:20 +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 1u5OgC-0004z9-81 for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:20 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062d.outbound.protection.outlook.com [2a01:111:f403:2406::62d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5e9ced41-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:16 +0200 (CEST) Received: from CH2PR05CA0068.namprd05.prod.outlook.com (2603:10b6:610:38::45) by SN7PR12MB7833.namprd12.prod.outlook.com (2603:10b6:806:344::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.35; Thu, 17 Apr 2025 12:49:13 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::39) by CH2PR05CA0068.outlook.office365.com (2603:10b6:610:38::45) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.15 via Frontend Transport; Thu, 17 Apr 2025 12:49:13 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:13 +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; Thu, 17 Apr 2025 07:49:11 -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: 5e9ced41-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LfBHU4xP3XXqWV57k5LaHxKKvFAY76m7MYpfFqvD81H/NE16m5JZxdlKTiEm0YvKq7jVcG7QhE8CpouEaniCWuVHOY3bTqeDEaBCxBLyX94URj8i533AMDIlID39/a8F3P6Dqr7EUOWGWREcR6JDYJYWVsVD+AsFzglLhKAjZsMXXKncJ/O03591Gt3Blk8kn0dWEYZLKEWLVqLVrfp9VR4ZxrVgby9RLGdzPzpDYJ7+Q1G/thEUEIMlcKqPabgL6+dD+lUxcdtwtBf4Z2PrUuAcxflFKsG24C0uCuzxcuW+DEUKmJ/Q4pLiXAnGMObDtoDSPRr4xHaM5JHTtyyIqw== 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=iIYq/gaN+DmB5Pd6q8CgN7KNVQO3TY8xLL5l0FVWPA8=; b=cY9sgqJEIprYbYmH6tA/g/BZ1+0GGMRVT55A+h1RyJoi14kXtItTznTsGWX1HuHISdLKiUcRDRuqParjKDwmlYxInGhc/nEkU3pOTRbYw2jTIp7ljah1M4T7hIWzc5chouz5eRTvTVNB0y7dq22NJz+oeAxM2BG9WC01B29LpDxPhAPiwLUJ2Ez9FV+a1jvN4ISvQbfmqOYVhrjbWHBTJSZJVcIeBpTRj/I57EKG6FD9KykHcGV/M9NJgcIhSysFU5SuGD2o1KiWqrhQxU9op5tY44n8nEKBVEHziW9Yavw4apPOEnpPeDLpetdSBXCs7yns73TyBtgurSVWrMUEYA== 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=iIYq/gaN+DmB5Pd6q8CgN7KNVQO3TY8xLL5l0FVWPA8=; b=RT33a3zqGYh9BeE2jtKizGLjVWmzEeD3JYnLxlqRkiNtfxnQX9nGItTQd9iBxceZ32OZGRWcfGdKl9Mgyv1Qx5TdR8HrGJjGL+05yIzT3A77bcyCloymZZI2cXXK2RwnwNsaRXgZH9EAQY6V+HG+hsiYJzKiUUD8mDbeFCkto/A= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , Alejandro Vallejo Subject: [PATCH v4 02/13] kconfig: introduce domain builder config options Date: Thu, 17 Apr 2025 13:48:24 +0100 Message-ID: <20250417124844.11143-3-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|SN7PR12MB7833:EE_ X-MS-Office365-Filtering-Correlation-Id: f6bf1418-6478-459a-f154-08dd7dae415e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: YXo2npJ4/9XnMBhHmc6l8IRa10rv67uZ7WDFj8j/ivb3zX3pG+QfZuH6LjTM7Mhn0l0GBblonLd0YUtFCuKCtJtt3sGKGExcMVJAwWPYehZ/tvMqRid4FNg36/vUwn93ulHgPS6Wpzarn9qlCxl0FseHv8hFNv3Aw0qjGijS1PZYU92s8rf6E7l+M33XmCuLkneYEPV7gcUvs4GU1hTIVvCb8/06ayeQeGtn7U30WzF1zTsmrJR4tJLWdPmSQFbgzQXjRB9lAIX3psJGsXd9shHed0de9f1k2CLkOu2kS3H79S/x/QElbM/JM22kQXDq76KWMjbZ+LQN40wv38G+WtW9DY28p0vEAO+u0H6baohkHfsVEUzq46qn5mYdAZqts847g4gtrnR3zC6dqz8zPThAXFxjcptAnkmtk49N/+p/DfVy75EGmHY6dnOJvlOgUT25UJHpHdZov+FJRvAzxwml+lQ4PskNew3XsV5dwtkKQFghCo/+VEueoStoM2ASQHy5z3bGsI+qJrBHm3xdkfvMH/yOHIlNzVnCr4XZiZoFkb1e72PAcWhWEWKqF/oKObk7oWmuNe8G8THrhF7rYzjieexgUk/Z/Tyj+1ZR/3OWWD+AUCTYvgaoIKCHvBUI20WMULY2EUeezaj5de113PjmMh8Ggy1y8NcIbGMt9sG+b0xmNf3ZEPi9KVWC/Wfn+u7z95/WbcRNiQ0Dc9baIUy6eBgGMar5lOLI1PAg3RkZbXDLNpcMXMl1ZBwfjPBlrwOyNVP39pjEv9a4lquO8R6D80ZHxrMPWwQl1nLK9XbLCPN0QIgNZYtzRk5lHEoa7YpMxhCOfsdirc6NX2ae/7E3+7phXqGSD2O1cBGZatr2FwF3XPKooilIjIfGFFB6C2Jco1qD9HnO1Pif+mwsAM3Tg2AuCdyvErE3hPSoOTy1kdzHO1WcosDGcjEi66WRCkSWtG1mIiJUt2o7DAWTLz+4IS43t0BUzMpCxf9uForvmD2Zv3YAobElaZ78JyRTJf7/0i7ESirjlk3qAysjn0L1KjQ96FYBudQK8MP4j7X64bV6NM28G1J+Q3c/s8P94+2ASpmRAgTDjRBWOyGt7Mp+hXxNsVjV6GCpJ5khSaAn2tq7paBw9yR3q4Bi//zAkDRgsA+5hpbh2lN1OMYRERZNQBxxXurzxu0pYjKpDCwjcgx+7eTyTxQvSniBD5640rgEZcwG0weszqLFCixT8TNt7VDr3lFBhHFH1NthcJ76pGDpZZ/LZHlQ6Z0gs3nf+jwZmoMrLARJDUBeaiL3+f4lQkQmro5XtVyGtXSKpJ7H3E/QuBx6fMiSHyDkJTxQyuMjiTcd6+XAWf4U3BCysyAqemPXu63YdDcBaKvkxDMo1QGcEUSIykwAQ4S4cSEsxcgxhnV9GEMnW1cycWXqZp3sGkrTcyr/g0cBelL3G5QuNdOZbN1iC0p0uUb6YVAR/9kqC4RtLu8u8P3sg/6WXVs1RWccbYrRZF6Umh4kD4+Ty4QdDCI7n1/osUnYoiNU X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:13.0349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6bf1418-6478-459a-f154-08dd7dae415e 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7833 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. This is common code, but it's tightly integrated with boot_info, so the whole builder is gated on CONFIG_HAS_BOOT_INFO, autoselected on x86 only for the time being. Signed-off-by: Daniel P. Smith Signed-off-by: Alejandro Vallejo --- v4: * Moved from arch/x86 to common/ * Present the domain builder submenu for X86 only. * s/LIB_DEVICE_TREE/LIBFDT/ * Reworded Kconfig to be a bit more user-friendly. * Dropped Jason's R-by, due to the new Kconfig option. --- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 5 +++++ xen/common/domain-builder/Kconfig | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 xen/common/domain-builder/Kconfig diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index de2fa37f08..67de2decc5 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -15,6 +15,7 @@ config X86 select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME select HAS_ALTERNATIVE + select HAS_BOOT_INFO select HAS_COMPAT select HAS_CPUFREQ select HAS_DIT diff --git a/xen/common/Kconfig b/xen/common/Kconfig index be28060716..5c9d4eb3ab 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -67,6 +67,9 @@ config GENERIC_BUG_FRAME config HAS_ALTERNATIVE bool +config HAS_BOOT_INFO + bool + config HAS_COMPAT bool @@ -144,6 +147,8 @@ config STATIC_MEMORY If unsure, say N. +source "common/domain-builder/Kconfig" + menu "Speculative hardening" config INDIRECT_THUNK diff --git a/xen/common/domain-builder/Kconfig b/xen/common/domain-builder/Kconfig new file mode 100644 index 0000000000..5b137e4c2b --- /dev/null +++ b/xen/common/domain-builder/Kconfig @@ -0,0 +1,18 @@ + +menu "Domain Builder Features" +depends on HAS_BOOT_INFO + +config DOMAIN_BUILDER + bool "Domain builder (UNSUPPORTED)" if UNSUPPORTED + select LIBFDT + help + Xen has a built-in mechanisms to automatically construct domains + (like dom0) during the boot phase. The domain builder is an enhanced + form of that mechanism to enable constructing predefined domains + described on a flattened device tree. + + This feature is currently experimental. + + If unsure, say N. + +endmenu From patchwork Thu Apr 17 12:48: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: 14055511 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 58D9DC369C2 for ; Thu, 17 Apr 2025 12:49:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957515.1350651 (Exim 4.92) (envelope-from ) id 1u5OgH-0005x1-BS; Thu, 17 Apr 2025 12:49:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957515.1350651; Thu, 17 Apr 2025 12:49:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgH-0005wm-61; Thu, 17 Apr 2025 12:49:25 +0000 Received: by outflank-mailman (input) for mailman id 957515; Thu, 17 Apr 2025 12:49:23 +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 1u5OgF-00057t-JK for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:23 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061a.outbound.protection.outlook.com [2a01:111:f403:2418::61a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 615e353b-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:21 +0200 (CEST) Received: from CH2PR05CA0059.namprd05.prod.outlook.com (2603:10b6:610:38::36) by BY5PR12MB4099.namprd12.prod.outlook.com (2603:10b6:a03:20f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.22; Thu, 17 Apr 2025 12:49:15 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::2) by CH2PR05CA0059.outlook.office365.com (2603:10b6:610:38::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:14 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49: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; Thu, 17 Apr 2025 07:49: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: 615e353b-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hhuwYUafuAg8n8vKjCJYj3+zk4JItuql8wmU1HqjmshC7Tc6jcGKehTP8xaXc1FdRo8SzwKEXcDnyb6gg0Wcu3LBKLcFbLPmpKZKQnZlM3pMUPIbaY/oxRzFufXSo3Vuz2IV69OBHDUzFwDbSCAsnlyAm7rPDZJcOfJnZu16sVJVg9INKbVL4ICEzL4eZUPlEMdGLGqD+NF2e9oHCSsv/XM0gKJSEXgSOIfmhGweuX/D5/mHLDY6By5F1K7wCrymsXMBM9nZBY3BPWr2fszGW7kZOntIZVZPvGBjwGA6b6qS/7J3EciwYmfop0Fywt+e44dSnormBSXLMoJm78tldQ== 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=4OzobPr3TBqZbXRrQpQfQGC91ytT7XjCeEU/jQgkGLk=; b=q9wohMIuj3FPb2dU2auj7+qFUwIWVkBayF1Wt3jjKHvydGRPBjX8ha7lApHg26z2PsvCKDG9udF5ED8+YdwyzX3XWU5McdTzTs+6FgJkylA1UmvhaCqYVavX0Dn49ajgDNoqRzMEbofhQ1a/BLpNlPj6QgT2s6CH3PI/nzvccek10OK3i4VCYaWEASR8C1Pz1LVNpgqzuwWx3UR9TKWCvtZcPgL4IacjbkWMEyTU4p0FTQVVFy6vSy1VQSQDisteM/vcd1aPL/qPD8GiPsecIy9QZy/4NREZ3cfAC4YZq9ZA4ypu0IlsCq81aopJ24WG4Z5wOQfOCBUhBVBHBKrORg== 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=4OzobPr3TBqZbXRrQpQfQGC91ytT7XjCeEU/jQgkGLk=; b=ZAfmZeDUO4TGTGP/mPET409+nWohJzl4oKJbYWu6rtMS/umvbIdvb61Anw/1k2t+sRocl/so7iyhzzkSd+tauNlrgJDlKIkdtm0oNZWyQSbY3rfbpYvIMx/ilNE9REgYSE65c5qY4bYC3rN3SXcZ5sUACzohahpn8gCu83g1Sek= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 03/13] common/hyperlaunch: introduce the domain builder Date: Thu, 17 Apr 2025 13:48:25 +0100 Message-ID: <20250417124844.11143-4-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|BY5PR12MB4099:EE_ X-MS-Office365-Filtering-Correlation-Id: 19cc74c0-527e-4a6a-c130-08dd7dae4251 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: CbppMfsukHKOrqLnfK6Vj23sH6IXtzWrUIrrBgPvoles3zpLXnIZYt4BZ2PsecBdQMdB9EoawrV2mPku3e6MKIXj2gNK2Z9YzSZZ3mRyE/zK3yXtWlnKyumaBw8Jaa9124Fc2ag9n0q16RUP5MBRwXy8nOR5uLR94TPbmm7Nmf4X9UlP+L2ZpPgO3eJM/4Yz0Ys9Fhv2qerRPRpOYvHNRL5GyqB+CJIWY8pVBV+pZ1jqmFlJR7/ZQQSaohy7HJ9ULfU7fUEnaCnoCmNGPm+sFokb0YTQhX6lIbWlX671ArImRc+FcNseFQ+5/8f64br5rDUglIk+9kSBn5AWckilokd1tlJayr/AFbBUGGTD8FRqr5cqqr+w4sv1cGznzVzORyDKjnELEmqFLURHv1kYsYqx/pGoExKiuMMVHqRp7U0n1p3xqvlssWTddi3p4lZ918b1QJybxMGc4Zj/SEds+yTLB2gLzuTVpR/yHpE9VB1wpnw1PJVVQ0xreEkpsMk8I6fFYhLcJJtZ61zvGC6T4iRRH+jkyCAWCbcDd5HxZiMAzUA/udt4MRUAvuCDIwp81nffmdEc/kdNqfxA16r7qg1pAa3ze6LpzoHTZXqWyvQto0fC6z+W7nSZX6+Z0gDso/g6zPGF9UOngCSr2o+eUqgITxHHWMwVZx5Q2wqtkeke7pp2XIK4pNoQXYUPss5Nrv1+VZTRm+QSe4A1fJY1X7x9ZVfuUQsVTs8PfsmSCFdacmyW/Um9OuDS+8P4lviDq4MLI32cFBJiyrwW4xJ382mHMp6mXXocguUxHVLrNcaRDFMegfsFWGY+P/0HSfEkXIzMYGQgChECIlE+KgV6E/DJQHykW8ickqaYW658HSCWYJAB1bWBvGcxtIHWaq1lWWp7fDhWfyvurUavben76J8JG53Xi1q6bcmBDnJkVuAM7pfQB89+UZ7rlXme8dXvXTlAT4ZFyvAYb9IOAx6uNBwhaX7MHx46uHEoIS/mpq61C89RPiDv8rH/nglTYDVXPzCiKMM1ue/PW2IlaCeUGS3OZAGxqfNSK14eOTPshYIyb3WA/DGxFReC5o+gcJWLSN4jPmjBUyBeYTAQim6CL/djF4SV907QRah7pZ0p1IW2jy/3zxCFzw2xdxIiHAaThBiLJgxip+YXukdIKg/ZemRkAPbBfl3rXPhqqe8olNSsosIdKd92xePtMkMMN4yWV4oM/QpRaBafD+2QXUnVW12NPPUW5MYo7gBQj90PruIX8DbXF3pTJRto/VBT4Vb/mRomw6zY9UoMh0rmq6nNkE+D+yKdtIMZ4cx+hP08fQCfwHccwj6zIOhfvlAsYuPJiCtWetIliaonN3wy6xiHn19eoj/gbYxzRrotQFam66pSlDng4sAH0QTiMTZWK+5W3fufAROpy1FfRb4Oc+VRSQF6A1/p86mQNdkYDjS5XBDaTN7/Vgo9BwcxXe5kNQW9Cocgzrb2pGsbD40HKOLMJu/4FldnpDtr0fNFR6NE+5OR9JCChyxTygA/5/5bdRA2 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: 17 Apr 2025 12:49:14.6289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19cc74c0-527e-4a6a-c130-08dd7dae4251 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4099 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 Signed-off-by: Alejandro Vallejo --- v4: * Moved from arch/x86/ to common/ * gated all of domain-builder/ on CONFIG_BOOT_INFO * Hide the domain builder submenu for !X86 * Factor out the "hyperlaunch_enabled = false" toggle core.c * Removed stub inline, as DCE makes it unnecessary * Adjusted printks. --- xen/arch/x86/include/asm/bootinfo.h | 3 ++ xen/arch/x86/setup.c | 17 +++++---- xen/common/Makefile | 1 + xen/common/domain-builder/Makefile | 2 ++ xen/common/domain-builder/core.c | 56 +++++++++++++++++++++++++++++ xen/common/domain-builder/fdt.c | 37 +++++++++++++++++++ xen/common/domain-builder/fdt.h | 12 +++++++ xen/include/xen/domain-builder.h | 9 +++++ 8 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 xen/common/domain-builder/Makefile create mode 100644 xen/common/domain-builder/core.c create mode 100644 xen/common/domain-builder/fdt.c create mode 100644 xen/common/domain-builder/fdt.h create mode 100644 xen/include/xen/domain-builder.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/setup.c b/xen/arch/x86/setup.c index 4df012460d..ccc57cc70a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -1282,9 +1283,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 ) { @@ -1467,8 +1471,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 @@ -1592,7 +1597,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 ) { diff --git a/xen/common/Makefile b/xen/common/Makefile index 98f0873056..565837bc71 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -11,6 +11,7 @@ obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o +obj-$(CONFIG_HAS_BOOT_INFO) += domain-builder/ obj-y += event_2l.o obj-y += event_channel.o obj-$(CONFIG_EVTCHN_FIFO) += event_fifo.o diff --git a/xen/common/domain-builder/Makefile b/xen/common/domain-builder/Makefile new file mode 100644 index 0000000000..b10cd56b28 --- /dev/null +++ b/xen/common/domain-builder/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_DOMAIN_BUILDER) += fdt.init.o +obj-y += core.init.o diff --git a/xen/common/domain-builder/core.c b/xen/common/domain-builder/core.c new file mode 100644 index 0000000000..a5b21fc179 --- /dev/null +++ b/xen/common/domain-builder/core.c @@ -0,0 +1,56 @@ +/* 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) +{ + bi->hyperlaunch_enabled = false; + + if ( IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) + { + int ret; + + switch ( ret = has_hyperlaunch_fdt(bi) ) + { + case 0: + printk(XENLOG_DEBUG "DT found: hyperlaunch\n"); + bi->hyperlaunch_enabled = true; + bi->mods[0].type = BOOTMOD_FDT; + break; + + case -EINVAL: + /* No DT found */ + break; + + case -ENOENT: + case -ENODATA: + printk(XENLOG_DEBUG "DT found: non-hyperlaunch (%d)\n", ret); + bi->mods[0].type = BOOTMOD_FDT; + break; + + default: + printk(XENLOG_ERR "unknown error (%d) checking hyperlaunch DT\n", + ret); + 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/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c new file mode 100644 index 0000000000..aaf8c1cc16 --- /dev/null +++ b/xen/common/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/common/domain-builder/fdt.h b/xen/common/domain-builder/fdt.h new file mode 100644 index 0000000000..97a45a6ec4 --- /dev/null +++ b/xen/common/domain-builder/fdt.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __XEN_DOMAIN_BUILDER_FDT_H__ +#define __XEN_DOMAIN_BUILDER_FDT_H__ + +struct boot_info; + +/* hyperlaunch fdt is required to be module 0 */ +#define HYPERLAUNCH_MODULE_IDX 0 + +int has_hyperlaunch_fdt(const struct boot_info *bi); + +#endif /* __XEN_DOMAIN_BUILDER_FDT_H__ */ diff --git a/xen/include/xen/domain-builder.h b/xen/include/xen/domain-builder.h new file mode 100644 index 0000000000..ac2b84775d --- /dev/null +++ b/xen/include/xen/domain-builder.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __XEN_DOMAIN_BUILDER_H__ +#define __XEN_DOMAIN_BUILDER_H__ + +struct boot_info; + +void builder_init(struct boot_info *bi); + +#endif /* __XEN_DOMAIN_BUILDER_H__ */ From patchwork Thu Apr 17 12:48: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: 14055510 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 80443C369D0 for ; Thu, 17 Apr 2025 12:49:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957514.1350641 (Exim 4.92) (envelope-from ) id 1u5OgF-0005gg-VP; Thu, 17 Apr 2025 12:49:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957514.1350641; Thu, 17 Apr 2025 12:49:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgF-0005gX-Qf; Thu, 17 Apr 2025 12:49:23 +0000 Received: by outflank-mailman (input) for mailman id 957514; Thu, 17 Apr 2025 12:49:22 +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 1u5OgE-0004z9-T4 for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:22 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060c.outbound.protection.outlook.com [2a01:111:f403:200a::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6265ff7c-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:22 +0200 (CEST) Received: from CH2PR05CA0054.namprd05.prod.outlook.com (2603:10b6:610:38::31) by PH8PR12MB6841.namprd12.prod.outlook.com (2603:10b6:510:1c8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.36; Thu, 17 Apr 2025 12:49:16 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::78) by CH2PR05CA0054.outlook.office365.com (2603:10b6:610:38::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.13 via Frontend Transport; Thu, 17 Apr 2025 12:49:15 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49: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; Thu, 17 Apr 2025 07:49:14 -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: 6265ff7c-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EXlG+a1pNTTUr+pQM4CajbK+/5WSYT+W3uN+9iqEtyNOyNcmDp0eDrFeTF57iieFLvy27zNUIhDnujzpYXgOioUSGQWkuP09lQSwaZN3txD+QAgc2dC1Ae1gE50Hds0LvRmyP26KpSKcslLYBRcnGYUe9nr1aG8o4EYSpN3V0SpNn86ikVZr/ZnDorXr4NVyC0fHyaDh8dHJyK9gkmXu/DOhW8g8mfWDW8o5Pvmc0o5jKBOKpRgelyzRfDbYXVGvBZec7TPn6Dolj5bl9V6s/+DGp2IPyC6EWQ5hebvMkAdyHF/PMEcozQtKlfiYRTLwcVMvN3pm+nw29Wu4nI14EA== 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=BqcYxmLh/A5uCJx4yM7Ep5bOtDXg6ZeSzjmQRQDNChI=; b=oBCwm9lVkLRSv2RiBf7ZnJDhOshKkoWK9ftFDZlpEM3Wgqzc2PmFoV+UJ6k/xkaNoEkBPg3LkW5RkgCQKQjx2MudV2DTctR7n/3jZYKRuwqRejjlszA+bfC0YxtLDGU9CpQ35c+EZ8Pf9CEdW2IZVBdmtehrIDYOZzZJ4Cl8YVqzNbZ9yaCol1skId0PVlsCKWHM6Tx4U4dwTgqo8nceWTaFpxF1T5EImaCbh5KUy0jPVQoznH7pM8RQMr/5AQ3UCod8EYQUQBH7+7wDY0FKDMWu/YbH2XXFX4Ub+ojsDVgRTFBzwaxFkqB0kl+GFuUW5K7ad+OuuQ77bzGIjl5naw== 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=BqcYxmLh/A5uCJx4yM7Ep5bOtDXg6ZeSzjmQRQDNChI=; b=1CkrwIQnw1TnjHzKEoAhLCIGjXvaHmcBixI21/CUBH+4gVpWeSPvcMqEnJtq3m1K776KSB3aqGeAIhRF1GzPhVF19DaSHY7twPn9+lA83pMTB6rT7DSyKF7LvETKDHhRAYW+3fO2BHd7nnYMInpW9lz5QC2EuEk0272Ti2+6CX8= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 04/13] x86/hyperlaunch: initial support for hyperlaunch device tree Date: Thu, 17 Apr 2025 13:48:26 +0100 Message-ID: <20250417124844.11143-5-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|PH8PR12MB6841:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c18cbe8-275d-4ba3-0958-08dd7dae42f2 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: 2HYrgQ+1yz0Th2DSfVJOrOfG23L8Mvd+qXzH5T4jsvTPpCI7fdNlnJw8ZZiEsJ6hrUhpHIvBI5JFMnI3uv6Pn8aaMZg8NYGgBT/rUemb344LuQK4Mb3mmbDEp2EjizAOaSbUlewDuEENZfnVg4aQJk23DCUs7E+4zKUlLdgYXuLibfeMPSqZ6htFRzjMPoyveAqLPkWZFW7jYNTjmJ/SWeOaNIKdowmYuWBcGveaS4mz1Ij/eyaAQfcnJvCc2d8zl1QQKkluP/JVzDIl0g/G7b2WWIm/MJQAIlBfGQ2CjAmFm8u1U3AswT0XSqQoro9xNED9cdL0R2bo/Mn2nTORr7RHkp5P3wEbso9l/B2kB+h0CV2xasAFcDHU6GGqmveTXoutWqbaKjMyU/ELW1vCGRQx3/dStgN5llNjs87taJUGSxCdTIsimRAumYdaSdj7fE+VbU9Vrk12gUs1zNKfL20bBl4b3D+aFNaqaJkf0QsSD3JxBBuSmDXZHSubHV12iKnoXeat+pglCmMGDV90w72Ju8FmWQDRwwKteQ/pEP//tOTIMWAt9OyrDuhFj0hrMpwllXMms1kUb1w0+JRF56CAUhl3TQOMDJtmkjBJQ/Y7RxJpoGae0OkFaSm+Fc1yv+jI7bx8PnCxXrTaZeSAx9DqsDjrDhLJboFGA5w3/OFhQOGSLN8t8anweO3lm2owOPTpIG7NudAp9zntmu9EymE5RaHqdBAvX8f3Ldlnxx5lnas+TbcORqWndXN4RcWsvrPfBsk7IV7UhsXOVXHULaHdzI+BtNcVF6ybZfhRlk/1X35kVmnPSwW4yOmz9ckSA0lxUXxR78UNFFHas2bgXCsnLWkPeEKD2cpdufPxhaY1BSeUCm+/wPKlU46/9aJfjrMesIeFAKThIqKtCtz6E4PmzZNyjJUV9lc2zAp0WMXnfS3959DrtOulHCu9CtH+EYUn3+l+mRcQLJXVoUfuf5sermwgGgmqtWOihvT/Dtjh0ilVCBXpRR7hLBIWV9KeafT/T9QVknGvYfDMwhbDXOTOjppOJSVqvwp7YgFj/MGFjwFaIdZrz0Azksy/jxf7L1l8JPqgA9FLlOfdW0Ykr262bWLrqu9qqZlmYI694MCngqUt9sZLnwU9FqhO77nNcU6IWw8c597au0KoyIv8tgYolJIB9iI4PB0qK7pw1XRB2syJfB9vXK/DkIdGokSkEwg4I8Qeoi9D1ABbXjBXAn0vQMMPsooAEh2uUFIBcv9iJE9QNRVx1j2OlMFGCz90PUGmhHjEYHzVVnDK/Y7ipMta4uYoh2udtTh8yBDcWZEV6oR9qrLHmbf12M83qdPDYgR9pvfPQRzajN1pWWK0HKz/LhR3GyPDluPuoMZxHanpxZluQNNsV7PS0zbCRVQuDX28HC1BptnLCxNFPlybaZu9lToiLQCUI0awtqUYld7cfRDbvyrfSqnLSC6ozwBMUJ3OMLFndIwFsPFOP/Lc/9JUVNa/mtvdaJKUXy1alKYsK2AvQOyGyBL+r8yIVHlA 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: 17 Apr 2025 12:49:15.6794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c18cbe8-275d-4ba3-0958-08dd7dae42f2 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6841 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 Signed-off-by: Alejandro Vallejo --- v4: * Panic if we're booting on hyperlaunch, but walking the DTB fails. * Remove inconsequential "else" clause in fdt.c * Remove stub, as it's not required due to DCE * Use min() rather than open-code it --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/common/domain-builder/core.c | 11 +++++ xen/common/domain-builder/fdt.c | 63 +++++++++++++++++++++++++++++ xen/common/domain-builder/fdt.h | 1 + 4 files changed, 76 insertions(+) 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]; }; diff --git a/xen/common/domain-builder/core.c b/xen/common/domain-builder/core.c index a5b21fc179..3b062e85ec 100644 --- a/xen/common/domain-builder/core.c +++ b/xen/common/domain-builder/core.c @@ -43,6 +43,17 @@ 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 ) + panic("Walk of device tree failed (%d)\n", ret); + + printk(XENLOG_INFO " number of domains: %u\n", bi->nr_domains); + } } /* diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index aaf8c1cc16..b5ff8220da 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/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; + + 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") ) + return chosen_node; + } + } + + return -ENODATA; +} + int __init has_hyperlaunch_fdt(const struct boot_info *bi) { int ret = 0; @@ -20,7 +50,40 @@ 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 min(0, ret); +} + +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) + { + if ( !fdt_node_check_compatible(fdt, node, "xen,domain") ) + bi->nr_domains++; + } + + /* Until multi-domain construction is added, throw an error */ + if ( bi->nr_domains != 1 ) + printk(XENLOG_ERR "hyperlaunch only supports dom0 construction\n"); + err_out: bootstrap_unmap(); return ret; diff --git a/xen/common/domain-builder/fdt.h b/xen/common/domain-builder/fdt.h index 97a45a6ec4..955aead497 100644 --- a/xen/common/domain-builder/fdt.h +++ b/xen/common/domain-builder/fdt.h @@ -8,5 +8,6 @@ struct boot_info; #define HYPERLAUNCH_MODULE_IDX 0 int has_hyperlaunch_fdt(const struct boot_info *bi); +int walk_hyperlaunch_fdt(struct boot_info *bi); #endif /* __XEN_DOMAIN_BUILDER_FDT_H__ */ From patchwork Thu Apr 17 12:48: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: 14055512 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 30B51C369D1 for ; Thu, 17 Apr 2025 12:49:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957516.1350661 (Exim 4.92) (envelope-from ) id 1u5OgI-0006DO-L1; Thu, 17 Apr 2025 12:49:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957516.1350661; Thu, 17 Apr 2025 12:49:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgI-0006D5-Gr; Thu, 17 Apr 2025 12:49:26 +0000 Received: by outflank-mailman (input) for mailman id 957516; Thu, 17 Apr 2025 12:49:24 +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 1u5OgG-0004z9-O0 for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:24 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20611.outbound.protection.outlook.com [2a01:111:f403:2009::611]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 630b4218-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:23 +0200 (CEST) Received: from CH5P223CA0009.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:1f3::7) by LV3PR12MB9142.namprd12.prod.outlook.com (2603:10b6:408:198::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.34; Thu, 17 Apr 2025 12:49:18 +0000 Received: from CH2PEPF0000013E.namprd02.prod.outlook.com (2603:10b6:610:1f3:cafe::eb) by CH5P223CA0009.outlook.office365.com (2603:10b6:610:1f3::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.23 via Frontend Transport; Thu, 17 Apr 2025 12:49:17 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000013E.mail.protection.outlook.com (10.167.244.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:17 +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; Thu, 17 Apr 2025 07:49: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: 630b4218-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wILlPMYn870rliEbR/1i3RklnYKGNmYaYX/reZ7FESSksWE4J4v+wNes2pvY2L9eNt2n94kEPCJ81urwcC64+G3/mmN8Lt+v9H5WcnPsXDPWa+z5ISTIeoLTYf0tjxzgYOzMTH0RMY54jyOKudinETy7K9hUp8FuUdWxEGT+LHwoL7kOAG2Fwh2TrNVlEud+X9H8sUOxEzMIJixk92RTowumVVKH55F5Ak1A1r6rxVP/ktPyq3JR3QF4cEzLZp+kOREWXvilhyTqAeH79AZde0kGLLJodp6AktkwiVXSluCg0tHmPOditgqu4bOmblXGwkTkxIsgExvsMIsOEVxgbA== 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=t7xiK6PeKs5xPBbhZTz8eNtT12S/o7Uwx5Un9Jm+bck=; b=JIsucPzgWm80VIpoSGKRnejFGOl3jP/lRgfTX0W42ZcxpCllE1lN8sz00NbE/fT1MER6bOsY6+pQ0usbEKG1c+whF3zeDxG3AJmfNZogXEublqbICBmLeA1d7cn7q9KY2qiyCvofmmQmUxme8VY2Al6SXDy2ybzlzaQP4rVnm8kRrgsOcMjdOXLsH3YGHSS+Hhk3YHS2yBcr9AnvhozTtJ98U2q5+6lb2Pzn2EGg48oaVdpkdQ4El3xPWkoCQ9gY47eSsU5P4CMzjMnKyFkeQVdPjvm7xLKcDgaHvPcnz+USiGCu5+do3n82xXV1lVVA8MpH/DTIJ8fsZsAshaqFuw== 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=t7xiK6PeKs5xPBbhZTz8eNtT12S/o7Uwx5Un9Jm+bck=; b=YvBnkFGuhlFDt7MD4WBBQDkYnNgvjrXnwOh/5oXmhVA50ErJqk8OW3qBMgnILJiWvYEMWLL6k7m/8sF1RaItISTebMhg38enAQEyuUpbjME27M8KrB5HDCvAGFEfLv1XrUFbeGJrZPRcJbqItuzUsjBz5PeE6KnlzEnTA5fFNgs= 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 , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , "Bertrand Marquis" , Jason Andryuk Subject: [PATCH v4 05/13] x86/hyperlaunch: Add helpers to locate multiboot modules Date: Thu, 17 Apr 2025 13:48:27 +0100 Message-ID: <20250417124844.11143-6-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF0000013E:EE_|LV3PR12MB9142:EE_ X-MS-Office365-Filtering-Correlation-Id: 238d86d0-85ed-4b63-deab-08dd7dae43fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: TPWym8tWghJNn7u5VrAlE7czRNecaZSZxbjFfHDz/6FkdwsP6/xmIJStJ7HSnumC5JFQjPZH7LaS4QW+U6pETcGU+qm86T1ZDLqqYVy4xxOLXisEPO+wTOapBYiZ1VdCVAB7RD2xYWj3b/y5Covq3fGkdXhDzZZiDX7vkSCODIDgXsniV3hoznx5HI/h9gCvp7GS0gKkX864tvy5J7AeHEUUVQai+8OOBmUagmqbYuruyJA3ReX5E0ZJLY+Y965ztUYh1ozlXJer5CFJIqmaHqZRpELVh8XwmZKg6RWngnljvWMi1z3oWDi/rIVDVdwHEAF7xsUU40LaHuHWwiNaiSx0m8lioIeiF6u5b4T3eGNQCy5HhsmWuz2UOg9+AnXh9Yjbtl996oyx5hQTOc2jfXQnpMyQBbzEKWphxI4XOYw7xady0VjsOB2lRtfWHTNwT6E8KeiW275qcdxPRmR/FTj+vj5oPkv06in1gL/eeeN6HiGyAJI72CTzETSIhB2ERjT1DIDf+HldfeRHfHukdXVzuaALWfXXoTx8SeuEMn/FjMm5cK1ESCeS9RyyP/UkbonLhkxozr10QR2kUBPqIaiVEJOxH99kQGsZCCJS5P5HZovjWSkPLRUbvTKl0KWnznr8q7yVFv4auooxg72XBN5gfBzEyjb6bCfXvpddia4mHGuiyqjcV18FvmSjcp+nB5528uG9f2Aa+eaAhywyfTwYOaVqI0JTpaelPq6ulNtEV4E6vT5IMUB+UJAaIabPzuG1Toc0Qf6CyBhIhqyD1zz1rml1CFjydHRvicxTbBCz3TuHklLXh1Kqamnn6UBzqwgbeBHn8obLiUkIZ3336f5+MzsGiSOqz7L4elhdKf3Ot2lxBeNg15C6ICNI75VPUJoywIzMpj1zBmerVlC6OWzKwNSK52qlSj3c/09l3e/UvYkPlrQb3Zc4YZo6VG4PNRwyp9S5Kwu1FeD3/PpiL32HyvWY6uwPQVwq37j6gd9Nx8rWEGObkK2AkTDlFwIHQ6nHj11Mr/pZ1smpOssN/XeKLGaNB9e03C7Ynl8kHsLrCIMBCBQ4GWxck2kf0a5DOr6rmSmme+X12SUdnwg1SAayWjDrhMU9mTEA7ES6lOqhBIqQoBGAnDyIC+jTsncj4zv0Ea/jCWnK+TlnD4GntwNJu1svjQ468brJ7KdwBE/y8LbFvwiPeKDL0Phd/Q0QCz7jVnMbgwfnlKIULQBLjaZJ4o+oWUexou1db47Fe2KKWXY+bchy67t7h5ZsHcOpgAsAog+rn2/Fj5iCJ4DPRKXAJ0hMgC8IQHYIKGfZf9HHh/M2zPm2sy15g10Qn8ucStTINtLcmRzgxhvyP3plpzLMlmy792FykT+Ykj2x6Ms9ObpOAg4EW7y4SFXbDhPbAAIR0dmhPHaQJSI0tw9UOOkqVtF4L+6tnEF1rEfTLVemYDr3rM1YFLv8RqST2MIhBo0hdztlyqyh8s7bT4qA649a+az+Y/wy+S3p5ZYOHd7iNbhJw6xpfwAKjeHQoow6 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:17.4206 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 238d86d0-85ed-4b63-deab-08dd7dae43fd 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: CH2PEPF0000013E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9142 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 --- v4: * Remove stray reg prop parser in libfdt-xen.h. * Remove fdt32_as_uX accessors. * Brough fdt_prop_as_u32() accesor from later patches. * So it can be used in place of a hardcoded fdt32_as_u32(). * Limited MAX_NR_BOOTMODS to INT_MAX. * Preserved BOOTMOD_XEN on module append logic. * Add missing bounds check to module-index parsed in multiboot module helper. * Converted idx variable to uint32_t for better bounds checking. * Braces from switch statement to conform to coding style. * Added missing XENLOG_X. * Print address_cells and size_cells on error parsing reg properties. * Added (transient) missing declaration for extern helper. * becomes static on the next patch. --- xen/common/domain-builder/fdt.c | 162 ++++++++++++++++++++++++++++ xen/common/domain-builder/fdt.h | 2 + xen/include/xen/domain-builder.h | 3 + xen/include/xen/libfdt/libfdt-xen.h | 11 ++ 4 files changed, 178 insertions(+) diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index b5ff8220da..d73536fed6 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -13,6 +13,168 @@ #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(XENLOG_ERR " 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(XENLOG_ERR " unsupported address_cells=%d\n", address_cells); + 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(XENLOG_ERR " unsupported size_cells=%d\n", size_cells); + 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; + uint32_t idx; + + if ( fdt_node_check_compatible(fdt, node, "multiboot,module") ) + { + printk(XENLOG_ERR " bad module. multiboot,module not found"); + return -ENODATA; + } + + /* Location given as a `module-index` property. */ + if ( (prop = fdt_get_property(fdt, node, "module-index", NULL)) ) + { + if ( fdt_get_property(fdt, node, "reg", NULL) ) + { + printk(XENLOG_ERR " found both reg and module-index for module\n"); + return -EINVAL; + } + if ( (ret = fdt_prop_as_u32(prop, &idx)) ) + { + printk(XENLOG_ERR " bad module-index prop\n"); + return ret; + } + if ( idx >= MAX_NR_BOOTMODS ) + { + printk(XENLOG_ERR " module-index overflow. %s=%u\n", + STR(MAX_NR_BOOTMODS), MAX_NR_BOOTMODS); + return -EINVAL; + } + + return idx; + } + + /* Otherwise location given as a `reg` property. */ + if ( !(prop = fdt_get_property(fdt, node, "reg", NULL)) ) + { + printk(XENLOG_ERR " no location for multiboot,module\n"); + return -EINVAL; + } + if ( fdt_get_property(fdt, node, "module-index", NULL) ) + { + printk(XENLOG_ERR " found both reg and module-index for module\n"); + return -EINVAL; + } + + ret = read_fdt_prop_as_reg(prop, address_cells, size_cells, &addr, &size); + if ( ret < 0 ) + { + printk(XENLOG_ERR " failed reading reg for multiboot,module\n"); + return -EINVAL; + } + + idx = bi->nr_modules; + if ( idx > MAX_NR_BOOTMODS ) + { + /* + * MAX_NR_BOOTMODS must fit in 31 bits so it's representable in the + * positive side of an int; for the return value. + */ + BUILD_BUG_ON(MAX_NR_BOOTMODS > (uint64_t)INT_MAX); + printk(XENLOG_ERR " idx=%u exceeds len=%u\n", idx, MAX_NR_BOOTMODS); + return -EINVAL; + } + + /* + * Append new module to the existing list + * + * Note that bi->nr_modules points to Xen itself, so we must shift it first + */ + bi->nr_modules++; + bi->mods[bi->nr_modules] = bi->mods[idx]; + bi->mods[idx] = (struct boot_module){ + .start = addr, + .size = size, + }; + + printk(XENLOG_INFO " module[%u]: 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/common/domain-builder/fdt.h b/xen/common/domain-builder/fdt.h index 955aead497..8c98a256eb 100644 --- a/xen/common/domain-builder/fdt.h +++ b/xen/common/domain-builder/fdt.h @@ -2,6 +2,8 @@ #ifndef __XEN_DOMAIN_BUILDER_FDT_H__ #define __XEN_DOMAIN_BUILDER_FDT_H__ +#include + struct boot_info; /* hyperlaunch fdt is required to be module 0 */ diff --git a/xen/include/xen/domain-builder.h b/xen/include/xen/domain-builder.h index ac2b84775d..ace6b6875b 100644 --- a/xen/include/xen/domain-builder.h +++ b/xen/include/xen/domain-builder.h @@ -5,5 +5,8 @@ struct boot_info; void builder_init(struct boot_info *bi); +int fdt_read_multiboot_module(const void *fdt, int node, + int address_cells, int size_cells, + struct boot_info *bi) #endif /* __XEN_DOMAIN_BUILDER_H__ */ diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index a5340bc9f4..deafb25d98 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -12,6 +12,17 @@ #define LIBFDT_XEN_H #include +#include + +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 = fdt32_to_cpu(*(const fdt32_t *)prop->data); + return 0; +} static inline int fdt_get_mem_rsv_paddr(const void *fdt, int n, paddr_t *address, From patchwork Thu Apr 17 12:48: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: 14055513 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 50B17C369CF for ; Thu, 17 Apr 2025 12:49:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957517.1350668 (Exim 4.92) (envelope-from ) id 1u5OgJ-0006HH-5J; Thu, 17 Apr 2025 12:49:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957517.1350668; Thu, 17 Apr 2025 12:49:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgI-0006Gc-R6; Thu, 17 Apr 2025 12:49:26 +0000 Received: by outflank-mailman (input) for mailman id 957517; Thu, 17 Apr 2025 12:49:25 +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 1u5OgH-0004z9-2N for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:25 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f403:2414::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 62de663e-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:24 +0200 (CEST) Received: from CH2PR05CA0040.namprd05.prod.outlook.com (2603:10b6:610:38::17) by SA1PR12MB7174.namprd12.prod.outlook.com (2603:10b6:806:2b1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.31; Thu, 17 Apr 2025 12:49:19 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::73) by CH2PR05CA0040.outlook.office365.com (2603:10b6:610:38::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:19 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49: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; Thu, 17 Apr 2025 07:49:17 -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: 62de663e-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZWnFNfdT1+KSaegWPA4BR98UyXmp7yQQ3XDi9QhcCaMpupXvkEnAzPtSat4P10cbL6EYfsZwGZd+qz6DmYZhERrk+GY2wBoO/ZD8FttzbuEFEY2cF5iXZIDtcBdNUeYM05LyejFKbPft8+LfGiWaQ+8cm2v2D97H1A+lGsacrwu0kJooh9MNMLdlOzuFTKoxWx02hk/MUaXDwzVR3wLh6JfriW8RiGgRLrv7w8FdBdmkwFZxd8RmKZ+lx/txHvQw7oo3J8RATu+O8Qf3YRolawDgejlPLyl9wvTgaRACJSJjb1ldTVGcSDw5NgZF8KR4wsTEMpTf/hg06pH+kImS7Q== 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=vfgmq0mrmtOhob94RrCghd2dAPQaF9U03DWaQIZKTC0=; b=SqBCNc6gdfdbAfhpOky+fqPQgZJEkssNiJUYIaXdQZNQ00qhvVj/KH8rRJELTa7jkp7aZtaOET7GfYJKa/pwAVpBRz/XgenotteMBjQ/3scheWt3+3R2YLwjPpJkJKskaVmu/25+EVPqqtNyUV2SRfAIjvmDLdBxzRGQPKrNYRb5nojGCZtzsrmtprJslQojVCqEVoWBxpDZ0DkBls44v0zgYj0aijtC8omFUmf1FDKuzED48XeKt8qYQz8I2IDlamlqL+eMz6eqUAz9rstrpEDp1TYAMLwVh3IJBOohb+gydKmEByF/ufZlZy2neleCQ+qOJ9B6uQv1J28CORzrzA== 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=vfgmq0mrmtOhob94RrCghd2dAPQaF9U03DWaQIZKTC0=; b=UCcEQrGUe5fXQGMbqOgYZ7CwqSNJ++WwWGFPQ2QrHrXzm8BQTB7T9brN/9jUb/LGc01Y/A+LkzTuwodJoEqVyw/79HGmBZnhHvoXZx2dRd7PhYVaggwUAIJttGkcfVaJ2DElYeTLeknrNjdGxUtnHjrT5mRAZC3dzBsN65jv1TY= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 06/13] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Date: Thu, 17 Apr 2025 13:48:28 +0100 Message-ID: <20250417124844.11143-7-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|SA1PR12MB7174:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bc230de-9344-4fb0-8b7e-08dd7dae44e3 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: 74uUej/9hen3CFr4c6NUSd96gybXUWMQtWIc9CVqtWKfysTMBAHrpbB2hVcc1YWORLNVLr1W5LXdaNbaxK6lXetIngitKqHR/Ih3jeOV5cRmGFZMzAiXwq3xnsNp10VGsjFQhm7XZw2jPybwUhMHyMuVXnZJ+l+hYiJE/F0uUw2kZU2VqVPsp/h0i1avItZGBZZB/2kIOiedPFP7gjYVNBXu9lJchZJZEcTX8FR+r3wMhwQQlW9YZHZQT0QUbtXkSpnBQZr79QpQ49IuEfU6FNsrcqfeGyzMTDDMFOsFgDtq64XVykwzPIIpMwL2f5r7xJKc36Yy845uNzu77qYsCgL8QXvAcPzK3UR7Atw4IK37wmElEFrEBcVLmtp22FT8z+hDOJtNWFuQz14b8wDmH/hE6Bhmn2dUgUOrT6VUOc4PaitIdHnFJyM57Ebuy6NuQ6Mp7B3sDeaEoHo5UHZgkpWOED5pN4tKPnDpfhGJkC4192FFsqV+4yDupOwWE7ayoIZ9LdwNpbf4yDpHTVM4hIWJbSPKc/f9VWeu+ZiuhLwMv1CdpWaz27o+PUZ9fk6df7gIaXYh7YFQsL8E66DRXCoWNRxwgxDbg0wQ3yZQNRxlRv7OPrgyEHzjBKQw+x0tXrxcXSeakizZymmTlhjmFOOdItFvM5DiDAdbTtXTCOSFEv+rBEAgpr/NdoIw/iWktatVw2vA4k5ECMqdf3oOCNwPYpo2Xd2G5wmU1Inr9qv0sdrk7v/Fv/oRGAiFN1tl179QGjSJl3hAa8esEnLZZUX4UJhJDw8Af6oNx5uRqABO5usYTO04CI60z8oeABhKlor7f7a0FfqskpxzRzgt3homkYeHufMsq1G61qe6c/9MTzV3j+u4uD6XIeXkQM7OYgILMRGv7L3lGalmP0RYE5fLchXrb5UeSMOIRgC5I0Sna0BQME0y7DVnbNcvvGCvsH/teV6Q0tKyv3gFN/wVlHupo/5BMnhapJ1+pnQDvUOys75qdDSqsfjfxnF3WpfU5SO98Koe69+dHC4LSqJ8nTg+5OEqjoe7oWz6Kjqc090v7nZb6ez9UX3xmJxw+eUBbJZWnvrtF6Eeb0r4t2XdI/ahUC0Qd6H9IV/SWQbek1mUMC1pQO9xfZy1F0/tc24ven/bVQZGa2GwI0grGl90zWbuCi0xjaneI078/hTlNH+tEZ4AwShFTAB1f6ki8MZoyS/NsOL7rIeWe3NmTZyKiMeHqfUBtr7Yhqv81dVjzRHOdTcQhgp9b0hja/SPDcykvR4FwxcbfVzkc8mC9I8jRIq1wKzyPB4iPabqSCf7HfK1gtEYfZi7Yl+dUxRlJFR9xbspwO9o0MYle6QPSRhXUi0ySAH/lUEXoB6kTSrfNYHT87kwbfZ78ptHD9NUyLgwOJ2ym6BYaukbiYcpOnv3c4FeHb4ReN7GEJRuCnObBXExzYM7YosSJlmSYCHEgz/XBz0yHKnwagqofab61fYyHVSt2NCRNsiP9/Rd6GhxCEzbWlZ66wz7AA6Jvj3os7LL 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: 17 Apr 2025 12:49:18.9377 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bc230de-9344-4fb0-8b7e-08dd7dae44e3 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7174 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 --- v4: * Stop printing on the fallback path of builder_init(). It's in fact the most common path and just adds noise. * Add missing XENLOG_X. * Simplified check to log error on nr_domains != 1. * s/XENLOG_ERR/XENLOG_WARNING/ on duplicate kernel. * Turned foo == 0 into !foo in the "multiboot,kernel" check --- xen/arch/x86/setup.c | 5 --- xen/common/domain-builder/core.c | 9 +++++ xen/common/domain-builder/fdt.c | 64 ++++++++++++++++++++++++++++++-- xen/include/xen/domain-builder.h | 3 -- 4 files changed, 70 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ccc57cc70a..4f669f3c60 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1285,11 +1285,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 */ diff --git a/xen/common/domain-builder/core.c b/xen/common/domain-builder/core.c index 3b062e85ec..924cb495a3 100644 --- a/xen/common/domain-builder/core.c +++ b/xen/common/domain-builder/core.c @@ -54,6 +54,15 @@ void __init builder_init(struct boot_info *bi) printk(XENLOG_INFO " number of domains: %u\n", bi->nr_domains); } + else + { + /* Find first unknown boot module to use as dom0 kernel */ + unsigned int 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/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index d73536fed6..1fae6add3b 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -89,9 +89,9 @@ static int __init read_fdt_prop_as_reg(const struct fdt_property *prop, * @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) +static 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; @@ -175,6 +175,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") ) + { + int idx; + + if ( bd->kernel ) + { + printk(XENLOG_WARNING + " duplicate kernel for domain %s\n", name); + continue; + } + + idx = fdt_read_multiboot_module(fdt, node, address_cells, + size_cells, bi); + if ( idx < 0 ) + { + printk(XENLOG_ERR + " failed processing kernel for domain %s\n", name); + return idx; + } + + printk(XENLOG_INFO " kernel: multiboot-index=%d\n", idx); + bi->mods[idx].type = BOOTMOD_KERNEL; + bd->kernel = &bi->mods[idx]; + } + } + + if ( !bd->kernel ) + { + printk(XENLOG_ERR "error: 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"); @@ -237,8 +283,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 "warning: only creating first %u domains\n", + MAX_NR_BOOTDOMS); + break; + } + if ( !fdt_node_check_compatible(fdt, node, "xen,domain") ) + { + 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/include/xen/domain-builder.h b/xen/include/xen/domain-builder.h index ace6b6875b..ac2b84775d 100644 --- a/xen/include/xen/domain-builder.h +++ b/xen/include/xen/domain-builder.h @@ -5,8 +5,5 @@ struct boot_info; void builder_init(struct boot_info *bi); -int fdt_read_multiboot_module(const void *fdt, int node, - int address_cells, int size_cells, - struct boot_info *bi) #endif /* __XEN_DOMAIN_BUILDER_H__ */ From patchwork Thu Apr 17 12:48: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: 14055517 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 0556DC369B2 for ; Thu, 17 Apr 2025 12:49:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957523.1350700 (Exim 4.92) (envelope-from ) id 1u5OgO-0007Mi-Jq; Thu, 17 Apr 2025 12:49:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957523.1350700; Thu, 17 Apr 2025 12:49:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgO-0007MB-Ad; Thu, 17 Apr 2025 12:49:32 +0000 Received: by outflank-mailman (input) for mailman id 957523; Thu, 17 Apr 2025 12:49:31 +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 1u5OgM-00057t-TA for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:31 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20608.outbound.protection.outlook.com [2a01:111:f403:2412::608]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65226245-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:28 +0200 (CEST) Received: from CH2PR16CA0008.namprd16.prod.outlook.com (2603:10b6:610:50::18) by SJ1PR12MB6098.namprd12.prod.outlook.com (2603:10b6:a03:45f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.22; Thu, 17 Apr 2025 12:49:21 +0000 Received: from CH2PEPF0000013F.namprd02.prod.outlook.com (2603:10b6:610:50:cafe::7a) by CH2PR16CA0008.outlook.office365.com (2603:10b6:610:50::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.22 via Frontend Transport; Thu, 17 Apr 2025 12:49:21 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000013F.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:20 +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; Thu, 17 Apr 2025 07:49: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: 65226245-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GGANWIW/tDTkARGihhIjAsTj1DaBDHeHBHb1CGzeG0nIcmXbecAXJZbJgsi6J8kAqH8zYO6lcsGJSxAmJHnarasdM3RvLiK6SL0WFVRGg366n7F272svod0ja5BR7vLC/mvtreVCW74G+uqDzqVrb+AgOEly9xuaF6PnYwrk90JaO0hxryUX9RjEiTtYSBCQZXygTdsocGraWCynFmwr5on//IzoO/09Qgi8ozrrQJ2k8AicpBrlIVfgMQ4erLFkZS6B7QHBhd5vEhgwcCK3HHVCkNpXlnsmQ8MdHdWL6n7pzjFMQHY4FAQ0oxnqJPcAcXnzJv2mzRRgNRt2ej+Q/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=VwdtaTKUcJ7iphGJ2Ou019xLpH/FNYvYZOqOgt0we5o=; b=oKxy0xNYDMQi7zo+qfjAfi22SeCIVwdfHMMuSZfhDN5fNCHIthvhB61l6mDe2RVAzbgo3QK3wmjp3UevazpwjSgU4e49N/GXfP4pLOokg2LMsVN9AqwX11jF/nOzrwqKMxGUfaRNMrAF2bh3LbCyjvcfKLSO8oheqTss79hRv5g9YH4SOuxQzsZJeI546YLj5PfHuyzxVvz+V0/cXFuUbEz4YhS00wToAvsb2bQo5WkOqAotRx6B1s5Q+m0FoI78bHqu/XLHrks0cd3nDS+XaS2KQK5kpJpfY1yDImjpu131wlmQkOfwQ6pxWF5ZkkKcnpThzWF7MzhegZQJNHMl5w== 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=VwdtaTKUcJ7iphGJ2Ou019xLpH/FNYvYZOqOgt0we5o=; b=AKEm7ZLMwLbetWQpW6VMMq8Mfdk7vmtPBCHz1+wd1IJuIenVhv8bC1pJ/CQY1z5BR5tx2c7bimPvUMGitn7i17PUSJ4i+0tf0yZ9In8Me4jYV3vbKou0zQ7/6ku7wk2M19ABti4mdrQ1PBY/egIGTBi3NjMtfQNhNjy2qnqzhFg= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Bertrand Marquis" , Jason Andryuk , Alejandro Vallejo Subject: [PATCH v4 07/13] x86/hyperlaunch: obtain cmdline from device tree Date: Thu, 17 Apr 2025 13:48:29 +0100 Message-ID: <20250417124844.11143-8-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF0000013F:EE_|SJ1PR12MB6098:EE_ X-MS-Office365-Filtering-Correlation-Id: ff657605-8552-4994-fd9e-08dd7dae45e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: 5r4FQlshaGn78myioCUcnEYixVnT9o1agHdODH5Quq4pDucUEuzZh6v7pI9I7QRZ7LK59e+DZOTSnXOIqRsyYH5r4YFNQ9Fboi2EriSkjJ1nq6757u33iUEk0S5b8l2rEbDKxSx55acnlapikKnFPF7uLmgPuzCZBzNLzfJk+mL9hnEWG8PoLuKiSJXx4PCjAFq3UUtzkiCSFg19b1BXpxEm1HRh7ybpnrWvhRd2DUZ4axvXBNTmsH9sFeV4K6A37XBLqPvYGJcY24n77V5ZMNkngrrfKC4cehM5d8U1zrLuZCC5J0xc8kR58CXArI3UPFwqmSrpkqX9tpJRloL0IgQkEL5g0N+uGG9a3cPXdAE6ZtMgTQUSxH1bzN1PVF7aEFWA8fV5bMmaajpEPZsrSy2vQEO67RvAT4bjn/45StbgrRVzEFIvgYrtf48PzQ+Eca87ZnT1ZS32HUJUTKjhb8McJHTgl03B8SQRhr12E52hrfVkH9YEGLVIQeDUuL2zbkNLOlMT2Ht9g3Kt8+LjFD5Uj3zrpcLp3RLpkn07Ug3Q9cYBOGZBRTI6nuJQDs85jWZ4tWY28V0ugwvHj/1gZtbw5+buF0JjuIckgsEjws4ieKnTaSKg1AVAGaVvJ0g5LClIYHXf7M0uYMotuPBpE4GM6DcO/0cpiO+76p0OsExdTVJnoTop/tX2wbivgDFHGdU/tQethC8EMhrXyOwzSZctwT3cygcYnwURmVBBYSJInbTXJ5xTIoCXdNIuFZfwb89yB32EghuvOZ3L9ddPrtJZijfSLeh6CGSHrEzmanraF2x46hkmfSYVj59M5/3q3BF+rymdIguLZGLqHwMjvoNB+63grG5aw3lURWxkzf36No3LOoBgW+rXPn3lVSaf2k2pHaybE1PxLSJDKHU4f1WoRCJI0kayskHcLn8LB49UsTUygZoi1pfk5vd92wQlzsvqg/6LxbmYh++qAQg8hDeer6i3obadjSO+GjAsGR257IosUR7GM0QU6ywsGDDHtsGyExnrhuSUuGAachngLlfKbbA7/PWumoYSPust0ej8TlVigLt1dgTM523uRv8wBt+ICGAAVMvG1vR5YNyhrTHUzKuXnG1ZmxNMaC61GMkUcncCbpvFE+9pUdsDasQGpGfedA5F+cIb1MhnPal3qRXP7lTg1morso9o/imo8JQ/t8IBUwzOyS4Shpu/kXLTwIUWAIH7nUeVde+JQO/b84PUCo77/7nNSeO/vyowAVFyH1DsBrvL1sGp7glTHnl632UimiczZjU5fVcUgBLP0AOkNXqqUjo8K00Jp7GSENmVVlTq0Y9kUwYBf1zjPCb+QoxSt7wCRzlxzuoifwRpwJGIricvWvS1JilxnxYA8oZN/JsLOLR7GcYUdyGv9VoZTjF9TZOt0EC7azRS4rjHs9DnOQkuEO/Chozj0ZC3jnif4B1XOslbWQQVzAts2Sh5slT5w+VsjilczdAxhx8E1X5m8bK8Zb8R0SHSLCbRkC2wf2zbHRUQGH5rB7JG7Ql+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:20.6192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff657605-8552-4994-fd9e-08dd7dae45e3 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: CH2PEPF0000013F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6098 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 Signed-off-by: Alejandro Vallejo --- v4: * Removed __init from header declarations. * Removed ifdef guards, as DCE ensures the missing definitions don't matter. * Removed ifdef guards from new helpers in domain-builder/fdt.c * Rely on DCE instead. * Restored checks for cmdline_pa being zero. * swapped offset and poffset varnames in libfdt-xen.h helper. * swapped name and pname varnames in libfdt-xen.h helper. * Turned foo == 0 into !foo in libfdt-xen.h helper. --- xen/arch/x86/include/asm/bootinfo.h | 6 ++++-- xen/arch/x86/setup.c | 10 +++++++-- xen/common/domain-builder/core.c | 32 +++++++++++++++++++++++++++++ xen/common/domain-builder/fdt.c | 6 ++++++ xen/common/domain-builder/fdt.h | 24 ++++++++++++++++++++++ xen/include/xen/domain-builder.h | 4 ++++ xen/include/xen/libfdt/libfdt-xen.h | 23 +++++++++++++++++++++ 7 files changed, 101 insertions(+), 4 deletions(-) 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/setup.c b/xen/arch/x86/setup.c index 4f669f3c60..4cae13163b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -984,7 +984,10 @@ static size_t __init domain_cmdline_size(const struct boot_info *bi, { 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 if ( bd->kernel->cmdline_pa ) + s += strlen(__va(bd->kernel->cmdline_pa)); if ( s == 0 ) return s; @@ -1047,7 +1050,10 @@ 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 if ( bd->kernel->cmdline_pa ) strlcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader), cmdline_size); diff --git a/xen/common/domain-builder/core.c b/xen/common/domain-builder/core.c index 924cb495a3..4b4230f2ff 100644 --- a/xen/common/domain-builder/core.c +++ b/xen/common/domain-builder/core.c @@ -8,9 +8,41 @@ #include #include +#include #include "fdt.h" +size_t __init builder_get_cmdline_size(struct boot_info *bi, int offset) +{ + const void *fdt; + int size; + + if ( !IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) + return 0; + + fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + size = fdt_cmdline_prop_size(fdt, offset); + bootstrap_unmap(); + + return max(0, size); +} + +int __init builder_get_cmdline( + struct boot_info *bi, int offset, char *cmdline, size_t size) +{ + const void *fdt; + int ret; + + if ( !IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) + return 0; + + fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + ret = fdt_cmdline_prop_copy(fdt, offset, cmdline, size); + bootstrap_unmap(); + + return ret; +} + void __init builder_init(struct boot_info *bi) { bi->hyperlaunch_enabled = false; diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 1fae6add3b..50fde2d007 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -209,6 +209,12 @@ static int __init process_domain_node( printk(XENLOG_INFO " kernel: multiboot-index=%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/common/domain-builder/fdt.h b/xen/common/domain-builder/fdt.h index 8c98a256eb..d2ae7d5c36 100644 --- a/xen/common/domain-builder/fdt.h +++ b/xen/common/domain-builder/fdt.h @@ -9,6 +9,30 @@ struct boot_info; /* hyperlaunch fdt is required to be module 0 */ #define HYPERLAUNCH_MODULE_IDX 0 +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); diff --git a/xen/include/xen/domain-builder.h b/xen/include/xen/domain-builder.h index ac2b84775d..ac0fd8f60b 100644 --- a/xen/include/xen/domain-builder.h +++ b/xen/include/xen/domain-builder.h @@ -4,6 +4,10 @@ struct boot_info; +size_t builder_get_cmdline_size(const struct boot_info *bi, int offset); +int builder_get_cmdline(const struct boot_info *bi, int offset, + char *cmdline, size_t size); + void builder_init(struct boot_info *bi); #endif /* __XEN_DOMAIN_BUILDER_H__ */ diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index deafb25d98..afc76e7750 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -24,6 +24,29 @@ static inline int __init fdt_prop_as_u32( return 0; } +static inline bool __init fdt_get_prop_offset( + const void *fdt, int node, const char *pname, unsigned long *poffset) +{ + int ret, offset; + const char *name; + + fdt_for_each_property_offset(offset, fdt, node) + { + fdt_getprop_by_offset(fdt, offset, &name, &ret); + + if ( ret < 0 ) + continue; + + if ( !strcmp(name, pname) ) + { + *poffset = offset; + return true; + } + } + + return false; +} + static inline int fdt_get_mem_rsv_paddr(const void *fdt, int n, paddr_t *address, paddr_t *size) From patchwork Thu Apr 17 12:48: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: 14055515 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 42E39C369B2 for ; Thu, 17 Apr 2025 12:49:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957520.1350681 (Exim 4.92) (envelope-from ) id 1u5OgL-0006nM-He; Thu, 17 Apr 2025 12:49:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957520.1350681; Thu, 17 Apr 2025 12:49:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgL-0006n6-Dc; Thu, 17 Apr 2025 12:49:29 +0000 Received: by outflank-mailman (input) for mailman id 957520; Thu, 17 Apr 2025 12:49:28 +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 1u5OgK-0004z9-8L for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:28 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061e.outbound.protection.outlook.com [2a01:111:f403:2414::61e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 653f2bf1-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:27 +0200 (CEST) Received: from CH2PR16CA0019.namprd16.prod.outlook.com (2603:10b6:610:50::29) by BN5PR12MB9511.namprd12.prod.outlook.com (2603:10b6:408:2a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.35; Thu, 17 Apr 2025 12:49:22 +0000 Received: from CH2PEPF0000013F.namprd02.prod.outlook.com (2603:10b6:610:50:cafe::67) by CH2PR16CA0019.outlook.office365.com (2603:10b6:610:50::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.15 via Frontend Transport; Thu, 17 Apr 2025 12:49:22 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000013F.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:22 +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; Thu, 17 Apr 2025 07:49:20 -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: 653f2bf1-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O7xLHoSs02xsyswghDSj7LTogm46+xq8gGxWIe+kXmhpJ/1l2SvrQ43RJEDpxF37e/tfvPY1RyHjCCGrGYLKQ4ZJmXN4rCvKUFwot/f2o+5beVpd67ENfeG5NptX6PaB3zbUcnm45I/yoNp9TUS0IOLbkadc9/5mgFUKGfAcKQenF3lIHJkDDUAAY+xuKsaqG90OATbBAc2Ye4M4MonL59/QaDdgjGtsv1oy15iXTRvqdsAsb4E5MC8+q74bT1f8yqOjEc9m1d99n9lYupVn0FUr5y4fee5gSB+sFlM9auofUPUUe4qtJN4SHHmtUMmPHyd/Brf0fHlVG5EqDoo8Mg== 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=tmoofm42WlgUtLxeqf60xNluT8/fPAszyhmDXROd35k=; b=h56v0n1PjLjBi6+5BGJYT9K0YvjuLVbUG9qfv/1Z+zxBVVP9wcI1fjpM3KWsGyeuNRdkBesDsonnEvK1BGygriyZOicvPb/D1Yvw4T/yyvnvAXWKRrS4Oqi4GzCVawG8oLmQ16yMlYx0drvSGfGW8iFf4M4s+qnI0k2NMCPOVRWoLkau0HcW+XgWH7ouxhQ1Zxsm9uRpelnTY6WZvxbKdS5g+FZLA07bIDMt6JfabHWSvlARjYp/jU8VlF5zqHy70sxItZZ+E7MzHiLGIHTDYTmNODP88CdmW7fsFeqVHBhmc0URnjNU2fm8tA9REH7PGHLxaW/Khfgrhp3PtjG0Tg== 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=tmoofm42WlgUtLxeqf60xNluT8/fPAszyhmDXROd35k=; b=3Ulx6tArJylhpkC6Yof6QkAa3YpZ9wNfAcYcDaqngjm5gLDraO66geQtQM+y8N66LarQcRfDEpI+esm2mC5COu9Y3sYnPzComoMOoQ51xTXTdj3XUCgm865JJDDI0RacPDlOrp4f8NznURqkDbRFrjTsFxAickWA5l/9CMXBl+I= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 08/13] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Date: Thu, 17 Apr 2025 13:48:30 +0100 Message-ID: <20250417124844.11143-9-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF0000013F:EE_|BN5PR12MB9511:EE_ X-MS-Office365-Filtering-Correlation-Id: ac4a6117-d7d8-49dc-101e-08dd7dae46c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: 3i/A/CdCnR7vthPolO6R6ICa/6U7g0U1T46bZNrYosRO4yEoXMSpJdN36zUvEe7k5VkYqA4+mJh/GvJheWEW1tqojeOevoqR4EOhlarviXd8AJV7hLnAiT0vrd9lAYIzDTSY1a3+VxjC5gLDrIOLmqqF0eYhkReTqlg6f2w8PB3y3gzEnEZSCF8dtkBgZqPLTMY0ELLEPynuWhBWub71Pt3QlywWcxp+ZCtDPgo0DRkjRG/Omf4lANdx1GpXVAQkOMaqAgeAdZvZZh+dlOX2EnxfYyD3b+V0gqdACiBGnxdIBw9iHmYrgpJhys7P99Re0GLolknzm3qYIbFSVZP0JFwr0aWr/Bm72kCMBFWvWEJZGiJ1BcKXFWhOglRV0eTjQ9Sa/SNrum5FI7CHB9xFjQGoPsKFJaE9dzoQz8FZ5HAkmBE1XdIyTrL09ld/DP1sayd1lZd9ajBGO1qcZYW5XhsFe+0Ndn6DH/z3Vx03lS9g2qdErVa9TtZTkhWEJY7mwNUEShu4m3x4w2ex+wuEGdsTUTX1AFO0MB0pP58JMAjK29LXwUU07a0PY1b31eU/wQzbKloFTzRMRfyNjfecE49u1xuwxeZed5vnBG2RGrfX9XHHFXVSXP8UiI8FknQCDBUd7EPFTaF/gy/9tA8aq2fE5zmdmIfuwthXlMo2Bj5uAYpPimuu56/0ogoNWLicweJ4u+umuQzlK5Cht4LV/kyLYkQzIVXtTBbJHGIUhJn5xOCVdxYVTb1fqVjpGosC9CJKVEbDtXAVGbSWth1X5DIhvcYztyntyVvy91/nGpu+ITRZv/Kuux92khpCOTCtnif/seP58Qf+iRVufKlFwWnRp1VyiYLvBCrXmnmrZuNGFskv7xiG/TEjWw9c5ZgGucq4zsg33mQITpUVqO07fnvKrQwRs58p8/Ez2qTF6RtZnsokUZ871IZuBz2UJOXBvga73ZP1jbCic3GsZGzI6jQjZ7DGPh54aVVmuGFeO+QJp3+4llm9+uqyVJpp64n+WyUyWKaSgNNhtGnV7cCz0PLTMIR3xFEQNOcc3OILylW/5fY/AnpC84O0TpbDSj0r7lNAih67AE51STXd4UFoNOzhv5+CXL0DXljsqOOIuTWKyhH2Gd7aG5Z6TmYJ9R/ufJSRUHSzKYGZVk4/uFLL6tCCcqjwh8xMegA6s53qN6M6tTQzA0S00lw/RNEa5QaV60uKUfWdeW4UnrAnfKCoSUHSm1VI4zpSCVmljA42w2qfhe+Ohu9H2+WsmvyNtIA6tTmXjKlU+oxLL+Grg2bdcE6/OmvvvaJFO75pbV2PFvQkYQ+YIPz9j53z2qC3B+VBQ7GkPL9GDloUMaGVhJ4+25OqgKsvBtYFUxw+ukzQ9vA+Ji1dfJ7+vNNMEGbe1plTya1WgzvDTRH1PdehRAmzzOZTo/c+nX4uEGbwE8T9UYaMuLqAFZUSs4MOmkxds7QjdQz75/FmZdim2wnJJO+uAjqaZeL99z8dXpACJ4ALYS0y/llSTnJ2bQ5KAwjl6dFD 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)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:22.0985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac4a6117-d7d8-49dc-101e-08dd7dae46c6 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: CH2PEPF0000013F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN5PR12MB9511 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 --- v4: * s/XENLOG_ERR/XENLOG_WARNING/ on duplicate ramdisk. * Removed stray ")" in printk * s/else if/if/ (because of continue) * Removed trailing continue --- xen/arch/x86/setup.c | 4 ++-- xen/common/domain-builder/fdt.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4cae13163b..76ceb5221f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2150,11 +2150,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]; diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 50fde2d007..c0f526a4ce 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -216,6 +216,31 @@ static int __init process_domain_node( bd->kernel->fdt_cmdline = fdt_get_prop_offset( fdt, node, "bootargs", &bd->kernel->cmdline_pa); } + else if ( !fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") ) + { + int idx; + + if ( bd->module ) + { + printk(XENLOG_WARNING + "Duplicate module for domain %s\n", name); + continue; + } + + idx = fdt_read_multiboot_module(fdt, node, address_cells, + size_cells, bi); + if ( idx < 0 ) + { + printk(XENLOG_ERR + " failed processing module for domain %s\n", + name); + return -EINVAL; + } + + printk(XENLOG_INFO " module: multiboot-index=%d\n", idx); + bi->mods[idx].type = BOOTMOD_RAMDISK; + bd->module = &bi->mods[idx]; + } } if ( !bd->kernel ) From patchwork Thu Apr 17 12:48: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: 14055516 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 79663C369C9 for ; Thu, 17 Apr 2025 12:49:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957521.1350691 (Exim 4.92) (envelope-from ) id 1u5OgM-00073J-QE; Thu, 17 Apr 2025 12:49:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957521.1350691; Thu, 17 Apr 2025 12:49:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgM-00072Y-MA; Thu, 17 Apr 2025 12:49:30 +0000 Received: by outflank-mailman (input) for mailman id 957521; Thu, 17 Apr 2025 12:49:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgL-0004z9-4n for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:29 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20628.outbound.protection.outlook.com [2a01:111:f403:2406::628]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 65bcd473-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:28 +0200 (CEST) Received: from CH5P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::11) by IA0PR12MB7603.namprd12.prod.outlook.com (2603:10b6:208:439::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.36; Thu, 17 Apr 2025 12:49:24 +0000 Received: from CH2PEPF0000013C.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::4f) by CH5P221CA0020.outlook.office365.com (2603:10b6:610:1f2::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.15 via Frontend Transport; Thu, 17 Apr 2025 12:49:24 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000013C.mail.protection.outlook.com (10.167.244.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:23 +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; Thu, 17 Apr 2025 07:49:22 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 65bcd473-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vHPlcpwvFKLLU6jznuSwnBDoa0O6eRXR40KZ0CA6fA7RVbse/ntZ7g6NdwRy7nMyZtJ6UnUbDIz7ecT6p7HjcEJjMFJ0q4JVV6F32q1WgHQ0veBVMB/MFmuLTtuUvM2/ZuEHF9x7daQsgMRoiD8njvSYBDtaCYntj7xfMslijgIzOCiipiA2J3ZEEU1lVBmCSH3py3dIjezN3vLxVX90NgaKGxGGJUJqhNOA3BulL+vtjm6qxmf9mzN3c2F5PMC5tkb6CaMJzAniUZlpxpnRVKrGT0ORmK29fdZtORxuMVJkivJU/0GU8h6EeivLt/Tt2oKN7TR33VoTRfVqxKxhFA== 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=m817Z8mbAQ6qi2tIdrjmLnKGXqF4Yyr5waBB1b3EjGc=; b=KKf9xXLmKx2hrLyD1A5lZni9rZc0lX7kOgtyRU4VfDeOMk0G/k4fPJA5zRIvwBMMbfMlkJgGUwW3lwEcLzuhlxrVXzj5yrhAu62hr643NJ/KnYG54mnAaJr89SHfsBRQxyXoSpDtvAO+wcTv0BXUnAvFhGgzG9kAtoll6Hk0ZboiIRjSeptS+PcBzFmffD/3Q2n9S3hk/5zizqZ4H/7ff5rQ0Gqtnz1pEE7N3xTQ7sqtaJJuS1YPVEcgo2bBtICvTK4FgGsVUNtE3zNHTv5fD79lBipD227AdVmFC5A0fW5acShU3/iNGuyBS4WF558vYxGvUQXFPvgCXgfL28mhag== 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=m817Z8mbAQ6qi2tIdrjmLnKGXqF4Yyr5waBB1b3EjGc=; b=pR3VH1D/veZm4y00LImEciU6PwlfTvvU5Uya3sjZ0QfccVSw3zcWIoopUoKsoegVqCbCuJ16KUX1EVE/+Rw8A+Etn6E9C3j72GqeRJnxqRWpGtpCq2pyIUSODZB5fltN7uJ5LZNKz6+LYamCISKYOb7KLbBrVKgrjYP7w09EPwg= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , Alejandro Vallejo Subject: [PATCH v4 09/13] x86/hyperlaunch: add domain id parsing to domain config Date: Thu, 17 Apr 2025 13:48:31 +0100 Message-ID: <20250417124844.11143-10-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF0000013C:EE_|IA0PR12MB7603:EE_ X-MS-Office365-Filtering-Correlation-Id: 31aa6957-a103-4e5a-088e-08dd7dae47bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: uBpcaXgDQ9GsVpY8VIjvBqeApBNHu15oiT3YtmvIy1IXhmjKNXvuyuaECnaVE+YBlgUOUKzWXxwpfRLRtWN53nrZ33kdrY+2iqz06eP5FeHpj+YqEyoTf5VhoTI5d3wyQ4ewK4NrBZumFHxJBlkIp/E3cbKCKYHKqtdbFlCp5bKgJg98IfOfUR0vqchi89EZiba+q8gcn4xLjWaeU7kTPUx3XQqczK3Im6BpZ3ANlw4JDsPhorMZQTjetJ3VuxGgWK1AwUVknXqPTripUqZ/YLxsArjt47rQZzO+t4WOoi3Fh32vOX2bCTCi/ceL30d6Kat+HyOlSDjnlitnnIbB5kqxiO07uhP2Hpalgglj/lmTnY/AGWqe064Sm6YIwoajAAJ19ywtubhUKHgOLuTaECpXBtTP4BVomBfrcKR/LsJmTLhNdMQQ/SfG8JWMUKNbked3+0q5vRi8ml6JXs0Bu4L0ZBNWT8n6ZS1yg2LxKbrNX8Y/crr+uxKUnuM6jwnrSDhe3MJ5Ms1fYChwTKG/QobcmbVjejfRQ0vnDTOvgIzvkbGIRo9wpqHezPjncXmLG+VNt4hdiKf2/K1FIRgM98/o8Vcp6K3/1t+h6z1TE6jcYM06kcxYi733Oz/DtR+lYl/VbK+GJ6S11KQZ+Oy6JDNhXrXNNKNHpxXNQ3T/b0bKAy6kmGmceatzpJleruA2x1v1pZydq5Ymjhsu1TybCjZZ/puAIQmw0QtxhazQjXSbwimSh1A+DLfICY78VmYL91TACkh8ZQBWSlmPgZfM02X6amNd9J8ikFdeM6QRxshXUT/3wIKNI3dQ7OOCEHBLHLbRfqjci/urylRmhqDx6TWtuPVSVftwPZ40JTxSQh+SKdLVnah4b3bsXAtFQGc+Ld5mEFPCqaaOcgqzgTzR4X8XWnmxq7KAaYdU5mMyXa4IoFSnz7D3i5Pg2gry4fytKRqNNu69GnPGg6lUvB+/HTnr6rSY5USGtn2lP4Ou8mNMrazBV2wseRT0lYCSrQ9oo9XImqylGhNryF3lFRxmsQX4WIpFFRrbG20d4WJcNBxZSX1PBxtFaW6hsbC6JrfIYZWBC7JrJaW+9edYW3eCeM4piKASWnNz4eYunuwd4VSehZfJ7FZ+rxHkmsLQprccnay5at9vQXP3xiJmh55Dr4ue7ZnPSIGzKS9eNGTOA5Fs4HIDL8+0AGkRYXvwXqL/hLRfKN6idgFc2XWOrmWonFkcAgauxuCXTLYoQNbrUo4sciM/ESZMdzJpoQqnCFtePQUkin56RJgtmWmsGo4GSvJwm0IltiF7/18RlX0tu5Duh418urBvdRXGfX3HEa309+5F6n1IUaKLRzX7ooN+eV+eBmGhf4z5NTjBnyA2OcN+A/N829LZIeyfdUCzoLdms27eMUqU/0mVCGIy8GMxU94Drx2CEEqHibckgooc6W1B5gZ07cfZ8eOf1511fypM6CnLpdEjllrEJ+cV00f8Z1awI7RhKkEdI4oYfAGB3vnmLXTP4ENAP1XBZFvLiSRx X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:23.7168 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31aa6957-a103-4e5a-088e-08dd7dae47bd 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: CH2PEPF0000013C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7603 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 Signed-off-by: Alejandro Vallejo --- v4: * Add missing newline * Adjusted printks * Checked domid node against list of outstanding domids. --- xen/arch/x86/setup.c | 5 ++-- xen/common/domain-builder/fdt.c | 51 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 76ceb5221f..04ad2d0937 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/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index c0f526a4ce..0d3c713041 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2024, Apertus Solutions, LLC */ +#include #include #include #include @@ -178,12 +179,54 @@ static 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, rc; + + 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) ) + { + uint32_t val = DOMID_INVALID; + + if ( (rc = fdt_prop_as_u32(prop, &val)) ) + { + printk(XENLOG_ERR + " failed processing domain id for domain %s\n", name); + return rc; + } + if ( val >= DOMID_FIRST_RESERVED ) + { + printk(XENLOG_ERR " invalid domain id for domain %s\n", name); + return -EINVAL; + } + + for ( unsigned int i = 0; i < bi->nr_domains; i++ ) + { + if ( bi->domains[i].domid == val ) + { + printk(XENLOG_ERR " duplicate id for domain %s\n", name); + return -EINVAL; + } + } + + bd->domid = val; + printk(XENLOG_INFO " domid: %d\n", bd->domid); + } + } + fdt_for_each_subnode(node, fdt, dom_node) { if ( !fdt_node_check_compatible(fdt, node, "multiboot,kernel") ) @@ -249,6 +292,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 + "Warning: Unsuported boot with missing initial domid\n"); + return 0; } From patchwork Thu Apr 17 12:48: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: 14055518 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 3CAC6C369C9 for ; Thu, 17 Apr 2025 12:49:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957526.1350711 (Exim 4.92) (envelope-from ) id 1u5OgQ-0007oz-Ss; Thu, 17 Apr 2025 12:49:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957526.1350711; Thu, 17 Apr 2025 12:49:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgQ-0007oe-Ny; Thu, 17 Apr 2025 12:49:34 +0000 Received: by outflank-mailman (input) for mailman id 957526; Thu, 17 Apr 2025 12:49:33 +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 1u5OgO-00057t-VK for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:32 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20622.outbound.protection.outlook.com [2a01:111:f403:2406::622]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 66556f52-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:29 +0200 (CEST) Received: from CH2PR16CA0008.namprd16.prod.outlook.com (2603:10b6:610:50::18) by BL3PR12MB6476.namprd12.prod.outlook.com (2603:10b6:208:3bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.32; Thu, 17 Apr 2025 12:49:25 +0000 Received: from CH2PEPF0000013F.namprd02.prod.outlook.com (2603:10b6:610:50:cafe::8f) by CH2PR16CA0008.outlook.office365.com (2603:10b6:610:50::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.22 via Frontend Transport; Thu, 17 Apr 2025 12:49:25 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF0000013F.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:25 +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; Thu, 17 Apr 2025 07:49:23 -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: 66556f52-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jwIJTLD9OVqEwMP8KxtzqZbOV7xRIokhNngxR04Eeh1wbe2A+w8ymVYhSJ26J7TQ6l5iVAedTNDbh+Ln641Sa8OWi5e9URcyxqmdnHr2XHkc9FmJvGgIbuLHY1HcI5rXWxV0aFkr6L4czX7RAg8YajXDbIHuanh8qSKMmZAWdTGS3umDdsqvZVsFGxzRUMyje05N4XzH7T3QhsteMkHrphvB2pq9DVwOTbWQ7ZPkZ1cfyq3PmL94u3A3dLYskgf2hzmsq9eBBRaeu+349r8cGvLp/IpCMXaFCBfNUD3LhTKjkzU+0f4J+3mbKSBD3x/Vxw7JKfJfjGvDDKrmbVyG5Q== 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=dG4dgkHyQpoSbEGo8ogLcSTekb2wVBJTPCULMiDnJuo=; b=KxBulFUNwwS2TXNlIRgBfUsvpX+2IWI3gJHeowuOiQz9Cdhjtu4tHAaC+JjUsFF0nMLP0IBter7sbM4G9GyU8h7CS8470Tba6azjYuaz58wl/hmYSx06QTnS6bdLcE8PlCrJ2AqDqfoElA9BOVkESC3qx8mD3QxcTIPfaPW89NVRvxPekuZZglXfjaeq4DYB/RKRc8KgGSarNeLFcf3t7NBKWT3DfoddGfuEbAxoW93ksvVgFpEuGIshp80pF0BbztIqgKwW2BCkuhuioZ1JaH8avdpe8wmD8iyuQOeEr1TkohTdm5hsW9cn7G+9pVytZlTrZ0EH8q5KpVYK4qS/yg== 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=dG4dgkHyQpoSbEGo8ogLcSTekb2wVBJTPCULMiDnJuo=; b=RvXc52CvSOhwDin8/ii7BvV2cQBfD3ApmjdrIVBaPWrXB8Sd950AILLr8pS3SizOyq4s3inW2llm6c1N4mj/wvuO6Uw1s2x6gYPr2QyHSHJ+M/4R4iNl28lya7NNKgZgGRjb8BfgTET5Y+wVYpzKGPzbLjeD/RECVu2H2OoBwwY= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 10/13] x86/hyperlaunch: specify dom0 mode with device tree Date: Thu, 17 Apr 2025 13:48:32 +0100 Message-ID: <20250417124844.11143-11-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF0000013F:EE_|BL3PR12MB6476:EE_ X-MS-Office365-Filtering-Correlation-Id: b0414358-6b72-439b-dfdf-08dd7dae489e 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: mcn6xeLl6irSjACIL8eBxZy5Tacmh1o8mM2n4iE8niSWdZkcIGxjvHHCnt5cppANWuchVn2AD1At1ZZL+Ex9FOXFg3AhHg1SZQAqn2X4Sq5TKzh22K8VxiUzxVS0/EYwMWtZNVfcU+R2xNd9AZHaLscInTtnoHM6l8Xjd9WDci3ptoslwotoyF3r5T92CU+KbLCQM7KwsbhGd7vi6wtn8z2qQZ/yEKROYUgUIQ/ZSuknOre0bunMjpasdM2C/oo2QymPrjmfs1MnVeFugENw340dDVIVlq+MwAgo5zndKIqFhA0DTpq9x3WB1Pj+CVErqzZ5CSL9RYKJVhejJfjnyEorUUAGTp46DSyrs/xDJhqMpaNQwiTOHzlGVuXKXI+vzbnjOmKbTrrxiePiH4zSRWwN1y08wqvYaWZ6KOU7aO5ugLxUo2o6T4lGOqAYalDpcnNlD43aYc8ZMzFnPMY7hPA/6xaqwelmXnd19I2KE2qLdSvlpFx1I1JeKsTnGZ60Gw9BLfl7BfCujfnpLaiYpGQCU2PCRFiDb9xP67/2AKNTnty2kKEI3hE1WV67xLqTlFkxSpUmQVjNhEo9zqE87HVBTeH5zndmmg5fj/rjG6zM7MRHihjMRNNN2IH6br9MKCUx7t9TEIoxDNlYQ0Kn43dMv6Zde4zUP4ZMEAITKfdtXLn+pactxEYhOJNC5AWIrf4iUWyWqARUqAiq+Pr1AwECGRbRHmuw3Pru59MDx/gm11GX3gOE3ikw7fwpdhX9hZqSvvV9L/D93Un7mp/EnOf6ug23cxYmGTkMlwAOCrqlsDB0ARw3maf95quLiyj1YDxY9vojPHL8AHqZZu0gz9MZ3pqY0nnOp4iG+l3Vw5saNOKkBLI4S/LCPoyFbfxhKvejYtPr5a7tKQBnn0YJlyUdmM77+aLzw2TahF7vpN9TdLtshY0MXGGi32NB/yHqKIC8o2T8qIWiDNZiUcZlY2h0fsIsI2g6kHCGbRoGvx4JQ5cnNooo9mx1p4JWoFN0JNEbaTlVZH+VryqyZBTiZjvgE+BX6g8WZleuS9ShZeEtLHIduWXYqK37pW4OlGP0DtLs8k15raVF9y4AKqOopjmZGhoL2rubYXMW+BELov4zWXBe+RdzPm2ISAVv0SuzT2J+7R9SOuou7S9RaeGUsv3Cuv0NsD2dZRXFfjgA0lyIR1RjDf9iBCmOnqaKvGXpLEJyclrNA83z4cJ4GIv+HAzj985BujS0OMCIEHVKu4cb/ERkzQYdnMG9JRRqjfOKpM6paxyBKEQPhX4/9JbyMrthaCo1Q3LDPK+xbclAiEfdauwHNe8MD5nOlJ54CGSdot33lzDW+R8mKq6ENklNzJnTgrk0CQqWY565c9Q8r4JnR4JXx6iOuYAeKuwg+UjIIsbYrXVtqgLxcnO5AmbPS9qqv7aNE1Ch+pk1Zv3UZClfaAWIozXYeqq5EDjPF9CNrFa1KUYhj8nyjFnD4ZeMoJMdGR56sbid/Ma+dnsec3CHnRqfbtO33XBaY6a9uiK8 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: 17 Apr 2025 12:49:25.1984 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0414358-6b72-439b-dfdf-08dd7dae489e 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: CH2PEPF0000013F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6476 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 Signed-off-by: Alejandro Vallejo Reviewed-by: Denis Mukhin --- v4: * printk adjustments * reject nodes with conflicting mode settings --- xen/arch/x86/include/asm/boot-domain.h | 5 +++++ xen/arch/x86/setup.c | 3 ++- xen/common/domain-builder/fdt.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) 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 04ad2d0937..05e3d2cf2a 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) ? diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 0d3c713041..6809c7f917 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -225,6 +225,27 @@ static int __init process_domain_node( bd->domid = val; printk(XENLOG_INFO " domid: %d\n", bd->domid); } + else if ( !strncmp(prop_name, "mode", name_len) ) + { + if ( (rc = fdt_prop_as_u32(prop, &bd->mode)) ) + { + printk(XENLOG_ERR + " failed processing mode for domain %s\n", name); + return rc; + } + + if ( (bd->mode & BUILD_MODE_PARAVIRT) && + (bd->mode & BUILD_MODE_ENABLE_DM) ) + { + printk(XENLOG_ERR " mode: invalid (pv+hvm)\n"); + return -EINVAL; + } + + printk(XENLOG_INFO " mode: %s\n", + (bd->mode & BUILD_MODE_PARAVIRT) ? "pv" : + (bd->mode & BUILD_MODE_ENABLE_DM) ? "hvm" : + "pvh"); + } } fdt_for_each_subnode(node, fdt, dom_node) From patchwork Thu Apr 17 12:48: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: 14055519 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 B0DA0C369C2 for ; Thu, 17 Apr 2025 12:49:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957530.1350721 (Exim 4.92) (envelope-from ) id 1u5OgU-0008Ls-6q; Thu, 17 Apr 2025 12:49:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957530.1350721; Thu, 17 Apr 2025 12:49:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgU-0008Le-26; Thu, 17 Apr 2025 12:49:38 +0000 Received: by outflank-mailman (input) for mailman id 957530; Thu, 17 Apr 2025 12:49: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 1u5OgR-00057t-V4 for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:35 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061a.outbound.protection.outlook.com [2a01:111:f403:2414::61a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 67218885-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:30 +0200 (CEST) Received: from CH2PR05CA0039.namprd05.prod.outlook.com (2603:10b6:610:38::16) by DM6PR12MB4188.namprd12.prod.outlook.com (2603:10b6:5:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Thu, 17 Apr 2025 12:49:27 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:38:cafe::f6) by CH2PR05CA0039.outlook.office365.com (2603:10b6:610:38::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.15 via Frontend Transport; Thu, 17 Apr 2025 12:49:26 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:26 +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; Thu, 17 Apr 2025 07:49:25 -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: 67218885-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e3lRq9AlwhuD0G7cUpmSLNIMS6TjH7dnhX6WipWOKUSkTHe0JVLX3DTjyHS4JNY1hZF8FlvCVQb0IAKkTF+Cth+zJom6ipPHZ0idNPjlO6ydWovyIwBmGpt4BWqO2oqDsG4+Dwmi1IqeDxxEktcQNRBkg85zlIq6JW4xxTprDuLKKzA7E0H8E3Xs6FjsDMGsE/NY8lNaTdB2P/PcEudAh/m7zxTrArUOJSYFIFW83nNTKG0emBXh7Bb8gHjEewMpPyXkEayXIwakGKL9U9g2+JcbIK3IWt66KDjSqi8kOAQbjLvUd6WTrQNj7pS7JWGXwCHFM0GC77faQxoL991ezw== 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=z/yFUwQX/dEkZnnw5BiTJ2SKezO+3EyIX2dnxAD2sCs=; b=b/5FZCdyhFCRBYEhl1IdqFcEJaEd2o5Mp3ktvLsNSv8XeM9lfGCNncxiaFqPn0ZX2DthtWuOOKn2blGDUm9XZkgiaQErG1mzPNX/AehgpL459ZVjbNJuQerHM4lUNtBl/EhDiJSMRAgb3/JAes9fnBosqHGDOjhzhiIvhfJTaWgkJtIvQy+YqyfuuUMhM3SGVHBrKuQXlAAzMQ3lWbKlsdXAwkb1O4QHjIhmlIpuRvAD5K/26N5ppvCPYOAvoDJDDZuSGKBbk7qn8Jpl6zSI+TVmo8dH7XshM4HuUS29uGvWrsASenrx4bbR1z9j2GanyFXkFhRtKb0CmOl9V/+3yQ== 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=z/yFUwQX/dEkZnnw5BiTJ2SKezO+3EyIX2dnxAD2sCs=; b=LR/+PfC6C9/asaSLRLk/Nuel99tgcgAApEuIzwr8M0BDcPT3/vTgoqw5T1CvAQbOdpBQ11gDJ3UVIlUWh9zpWph9vGdOT6RgK+ffpiIWS9RBPAP9ojU86PxfRmVWVnOSFwLuhy0lb+JdC2CJbo0mH/RXbAPLvpdDxH4uZhJXaBE= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Bertrand Marquis" , Jason Andryuk , Alejandro Vallejo Subject: [PATCH v4 11/13] x86/hyperlaunch: add memory parsing to domain config Date: Thu, 17 Apr 2025 13:48:33 +0100 Message-ID: <20250417124844.11143-12-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000140:EE_|DM6PR12MB4188:EE_ X-MS-Office365-Filtering-Correlation-Id: f7a5991f-ad2c-430f-6677-08dd7dae499e 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: mtTtxuezNaRm2FCl097rlX+1plkzs36OOBVVaS0ZRfFVJswuYrxvzBo6A37BkOcieoxJaIYSfCQVZAngqohquB8ARA2D6utXNBkIAR8lO7dL6XOz2knvQrC0+9bY8H91QeYJkzf/Yqs963UjIRmw+eTpjaGcyOC90hEk4+JE/ma5mfFzDG46VXx7oBNmqOAexwbshYo4NtLX2vO+sizyrU6Vd/GJIQxmyTJgpZI6tpNRkUXDpYygqeHYzjQxUrqZvf8EqtAOzavvRj21NbzTVefJ7mJuJA2AHaOWPL1YrJmtL8k9tFE8oDwbLYxWlDax0nmTSWuVK1F6BGL4++zv5W3RQ0lrrD+Q8FKv/aN6Rq7YTjg32N2jrWFidSUDabpkd7SqCgup4AAXlnqYRYJ0Vs9myPvvaMpIq6q5UJVZELiipUIsEbHksOHzAoj0I8ktBEMDuU2rp8/JGR/D0stzF8bzf5gDsZORcNaBVCtWtvztRQk26Yz1h0uXcfOF7Lgg8AqISn2rHcFDUDvuKzKF2nextZv9rYQusstpCoQojHIYvsVHdjjnwxVFdi/JuTQ4593UOAex7GDxSMg15ZvjrYriPbWlSjPriak5zDKuFppuAqps6E/C7xblBltsNn3Htlh8zDt1Y/vvKXUgOBLAgYL3asZpM2eGYosXc0tXLGwID8bip+410OjgfzZDqTrwIjNYJC9BvVEoZEOZ48dOzEmUf08RmY1isUfDwKEOFqQ2CcZrPeq74PH2TCXgOaSkAjgMdeJoHDurwPAoUfKgtloNlcw8OuI2aJEXB9efuKe7AkgHaq0Q+sSW4oFJ2wVBcx/0+2bJyBz/2mXnypHU7CGmiaWngLA272mqsCbO5Dm7Ii54bnz1cXubyJqyaYAuAjcMOfj62ivKKk26yboS4SRoSPHXXnPmUVGGY269Jk/+LB7j1ZZ2JjZVMKlkAep0Ti3phhigPlv9jWvYRWM6SipxeywQt305IBEdXTz08x4Eny8QLYo46OvFi2fg4+p4sh5aUCTcLhyNDnRsxetvr5Je2dBiMu+Zc84HnsEILmDfn0PJVz44SECd3kT+UTrAaqTb0C80vPTwvnX/AXQ7xtGSX1iZdQ2B8PAnwUqQfNPM/LLxXJYoN5TcjkcIdX524gSLq/kilq1UxtexAglOKzwQKIcuIwYatsTOUMo0SnbdUdW5rBgOR3v9RC7tog94CrBQjQN9yBK9ackHkb/2/X+/XxXf6Xwdc8lztOIU+jJMBYnJOO3LBtdk0j+lJKWdhQenLvcqQtTLq9HpDUvrln4n2PY68fFiMlCK7t2zZAuWJW5MwVd4c1pH1tEx+0vx0EbufuEXXXvgmWs5hJzPnmJZpDcYR6FMcH/2pj6jS0igdPAK51uFSmZGg1ngQBM0ACtyxSKNyrqXL3KvsxsaPqaEDxXTD0eussEXh4FBR20nmin4NR2DExICxQ/J/GdT74uyCmZ+3G9EToXSg12D0m/RoxW9RG/zUFudCghd7v7Gmj+3AWdTyLWIOrRZLM45 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: 17 Apr 2025 12:49:26.8718 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7a5991f-ad2c-430f-6677-08dd7dae499e 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4188 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 Signed-off-by: Alejandro Vallejo --- Can't use KB() rather tha SZ_1K, as that's strictly for literals. v4: * Don't override fdt_prop_as_u64() rc on error. * Add separate printk statements for each memory prop error. * Fix bug setting up dom0_size, dom0_min_size and dom0_max_size * Was overriding dom0_size on all 3 paths. * Pre-initialise max_pages of all boot_domains to be LONG_MAX, just as dom0_max_size. * Eventually dom0_max_size drops out in the bigger series, so we need that logic to be correct. --- xen/arch/x86/dom0_build.c | 8 ++++++ xen/arch/x86/include/asm/boot-domain.h | 4 +++ xen/arch/x86/setup.c | 5 +++- xen/common/domain-builder/fdt.c | 36 ++++++++++++++++++++++++++ xen/include/xen/libfdt/libfdt-xen.h | 10 +++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 0b467fd4a4..8db24dbc0a 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, ULONG_MAX) && bd->mem_pages ) + dom0_size.nr_pages = bd->mem_pages; + if ( !get_memsize(&dom0_min_size, ULONG_MAX) && bd->min_pages ) + dom0_min_size.nr_pages = bd->min_pages; + if ( !get_memsize(&dom0_max_size, ULONG_MAX) && bd->max_pages ) + dom0_max_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/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/arch/x86/setup.c b/xen/arch/x86/setup.c index 05e3d2cf2a..455dad454c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -296,7 +296,10 @@ 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 } }, + .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { + .domid = DOMID_INVALID, + .max_pages = ULONG_MAX, + }}, }; static struct boot_info *__init multiboot_fill_boot_info( diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 6809c7f917..90218d120a 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -246,6 +247,41 @@ static int __init process_domain_node( (bd->mode & BUILD_MODE_ENABLE_DM) ? "hvm" : "pvh"); } + else if ( strncmp(prop_name, "memory", name_len) == 0 ) + { + uint64_t kb; + if ( (rc = fdt_prop_as_u64(prop, &kb)) ) + { + printk(XENLOG_ERR " bad \"memory\" prop on domain %s\n", name); + return rc; + } + bd->mem_pages = PFN_DOWN(kb * SZ_1K); + printk(XENLOG_ERR " memory: %lu KiB\n", kb); + } + else if ( !strncmp(prop_name, "mem-min", name_len) ) + { + uint64_t kb; + if ( (rc = fdt_prop_as_u64(prop, &kb)) ) + { + printk(XENLOG_ERR + " bad \"mem-min\" prop on domain %s\n", name); + return rc; + } + bd->min_pages = PFN_DOWN(kb * SZ_1K); + printk(XENLOG_INFO " min memory: %lu kb\n", kb); + } + else if ( !strncmp(prop_name, "mem-max", name_len) ) + { + uint64_t kb; + if ( (rc = fdt_prop_as_u64(prop, &kb)) ) + { + printk(XENLOG_ERR + " bad \"mem-max\" prop on domain %s\n", name); + return rc; + } + bd->max_pages = PFN_DOWN(kb * SZ_1K); + printk(XENLOG_INFO " max memory: %lu KiB\n", kb); + } } fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h index afc76e7750..3054b48a83 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -24,6 +24,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(uint64_t) ) + return -EINVAL; + + *val = fdt64_to_cpu(*(const fdt64_t *)prop->data); + return 0; +} + static inline bool __init fdt_get_prop_offset( const void *fdt, int node, const char *pname, unsigned long *poffset) { From patchwork Thu Apr 17 12:48: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: 14055520 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 3B277C369C9 for ; Thu, 17 Apr 2025 12:50:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957571.1350731 (Exim 4.92) (envelope-from ) id 1u5OhP-0003dq-UR; Thu, 17 Apr 2025 12:50:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957571.1350731; Thu, 17 Apr 2025 12:50:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OhP-0003dj-RI; Thu, 17 Apr 2025 12:50:35 +0000 Received: by outflank-mailman (input) for mailman id 957571; Thu, 17 Apr 2025 12:50:34 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgY-00057t-Vs for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:42 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2060c.outbound.protection.outlook.com [2a01:111:f403:2408::60c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6a289ece-1b8a-11f0-9ffb-bf95429c2676; Thu, 17 Apr 2025 14:49:35 +0200 (CEST) Received: from CH2PR08CA0012.namprd08.prod.outlook.com (2603:10b6:610:5a::22) by PH0PR12MB7864.namprd12.prod.outlook.com (2603:10b6:510:26c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.32; Thu, 17 Apr 2025 12:49:28 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:5a:cafe::ae) by CH2PR08CA0012.outlook.office365.com (2603:10b6:610:5a::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.34 via Frontend Transport; Thu, 17 Apr 2025 12:49:28 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:28 +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; Thu, 17 Apr 2025 07:49:26 -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: 6a289ece-1b8a-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hqKBY9uuzrZeG8VyCQrcc2AMyuBdQy2crY0Zmvpln6yZAxEeuH13TNhe2fkgwFJRYVPBD1FHMxYNFjPHVofl94Hx1d8Fr4lI8dE+G9awf9VcGIe0Lwqb2At1Vba5k4l+64MPnVkHXIlPm3d9B/mGkhCa62SWx+pkyptfQ0QuF5KVT15SMD33UxUEwZ+Eptx5FSUOGFEVLhg3FXz797OYvUnfjPXzypW71vOWFaVlml38RyiEnx2y0sgyHbExvYTSJ63nQjhp9c6zueAUGuZt1/J6tH0b7aiNkB9DD6PQY3iDI2ysFodEUT6KuPuErBzsFeQcLEMFxgmTxJrni5bTUQ== 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=tIJkN+3c1EWUrjFtQMc+TsOgczooD2A+KBZlgPJDObc=; b=DyZ2BW+QhaeVdkoX5jUOl4iV2sQ/f8UX8tsUmKSI10SQVvS46L16P/MuWc/DZfMwHFRJmpbO6aor3qmGrXZhcLzAmwpSPljcuSXSFdP2GaSwPMCQKf2Cc7ooO5OLqekROMDzFzZwTKK4AtBVZhQaJePJZBn8PR+e6/vSD79Rxw6K20trnRYgj3MlECVFAD2YI0ytr4niImOIHYsF8SPywTEi3VUGSUPv68UhxJ2XRUDsWASlco1MmzKITvdMLVk0+BSkAB1hFJaj+2Adm4o+84pHEsEZk7+koWik0uTdgc/hzYUp1Ia20X06SxlZsMPKMCUoi5pqDpquLqANBxHKRg== 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=tIJkN+3c1EWUrjFtQMc+TsOgczooD2A+KBZlgPJDObc=; b=MlqXcHi4yRSvVMc60IUcAFy+cBgtOOrH7I+TaA1M/TWdgLMXrDIGaU0pMa72biv+DjlWv9kHRTPbIEDqEsN7RJ/vPP2d6/X1BgaNXuX377sAlJ1OpOlEKubtJtS4edx9hVUqItIXsyQeAHzt8t4juwo6d6NQcFpau9/DXALmF2s= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 12/13] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Date: Thu, 17 Apr 2025 13:48:34 +0100 Message-ID: <20250417124844.11143-13-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000142:EE_|PH0PR12MB7864:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f54461a-9e62-4578-e7f8-08dd7dae4a8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: ldXQztjZoEawu0Rkep53b/6TnfDeDTA+zW+BLNFsc9V1aV6rJXJQ/TbmJNK6D/vKmvNxCSNfAs468FzF4cDbIPibo9O6vcPVIVdSsCklF35PMxw6SDABGDtlGAJl2oye/ay7dAde+XRo+2riQzTmCjjMzoJJstk54HAOZc5ypw3FownB4ZhbMEQ3QRUsu6znItUJKcd2WXYBNThmopIQWBsCFVAjRTlIaLFBowXtt7GWcLf7a9W2q1ukYZeZsJB7i/DYjA4lR5IiktbZTfAYGp3+Tn7Ix6ptv0DT3gkxB6j0dlxmpq05+2L+jjm3M3KtD0cNorOOo7WQYijuJhzC1Fn9GL2UjMKd920HjbShLTjaX0Bek0+QaXOJjH2uxw4FkgfRchr71Nv/FnaKnycXVjkQdfHuXzDnpXO5xnjaMHimgjImJrNYdgl/UbU3H5X9uRzgMrVXmW1o1EYGc8x5VtQUpfSTZGAhUHsCKiNdhAJ4qyyQCQgGcUHkkQztUI0idRNk0ucBw7SaZH2q9Bo1yDTj1H8LXKeeQQLdfuorpd6biVZOgxRdo/+YxwUi928aO/zzQ/tZtYzTYjSe2oziNbt+90Cu1JOSALcZE3AHndS8aoBKSLkgyS7+Taxe15nEJAQAXf2CGux5iN9w4uGfh7uJaHkB/Z/FcOYoa/yYNuyKo3+C8aIhH9nTbj8G4ce4+NI4XfGoxd5UFl8skYrwQmsjY3dcvWaE+TZoq0T8kcm4ZWbHYYPfFixLxLOnM+pgmccuwetAUKzu3PSJ8SIdM68BJWVlaUiqDYmu7+XMa3V4WeJNH7xvY8oUs3QDTjcoGG7XdnRqfpYjukCJ6d9CKfEqPjnqQqFh6UnLykusNk30u/ZmxF5REHsPFCPZsE+f0E9CtUosS9Y/N75TBzDirYyqOhURooBTwsVBEy6E+xTsUgQLYj/n+NGezW7nD+3zlcjz6qWyfFbqggBdpn2qvMzb5v2p7TmMX8dz4z2c+nfvduwrXDWTTBuotsmtluS5bPJRZrftxiTOdMd8jmq2kReSI/Q6UMIoaFE8Qeqt2HU5KO1lPoQISbYkHkeCrQfQtptfj1TsmNG7aCaHOyde5qGmHHgpqajtPbXAXbeoTyvwDL+OtWsf+Vh2ERgvZJy7Upa82jGRH/S0FwpkGGy63ED/8O5T+L+PTdvArEWPyZ65CB9JrcofO0RK8OsLc9HnmMOe2FnI5fPjAdgyNSPa6VWJLRBByICJH9mPI64y5llQhj2HGMPLM0QOoExiMVxce1Yj88IqtkaaBhIm9cDEYJZA6+yXZMfanc0pVr25aqemY/UPjKdscKINqcVS2GVcKpGEDnB9qVXcmQGRjfGWZytY0emIRFlMo+T6ElRKvwMb2aBn3lycoWkwTx5Vie3tgmJCTIGQiCMljYekEvkn17Bjix9hT/onxZkhyCT+wpXc7k+IHKQ/nkyoOBi24CdsPPjtYBKSVnaUx5q/t8Psa8RVQ9IX7MII6n/SQtRUxCzZywubhx+V7zHBX4mn0vcW 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)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:28.4555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f54461a-9e62-4578-e7f8-08dd7dae4a8f 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7864 From: "Daniel P. Smith" Introduce the `cpus` property, named as such for dom0less compatibility, that represents the maximum number of vcpus 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 Signed-off-by: Alejandro Vallejo Reviewed-by: Denis Mukhin --- v4: * s/UINT_MAX/UINT32_MAX/ (cosmetic, but...) * s/vpcpus/vcpus/ in commit message. * Reworded printk() --- xen/arch/x86/dom0_build.c | 3 +++ xen/arch/x86/include/asm/boot-domain.h | 2 ++ xen/common/domain-builder/fdt.c | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8db24dbc0a..f734104c74 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, ULONG_MAX) && bd->max_pages ) dom0_max_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/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; diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 90218d120a..295ab6e8b3 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -282,6 +282,17 @@ static int __init process_domain_node( bd->max_pages = PFN_DOWN(kb * SZ_1K); printk(XENLOG_INFO " max memory: %lu KiB\n", kb); } + else if ( !strncmp(prop_name, "cpus", name_len) ) + { + uint32_t val = UINT32_MAX; + if ( (rc = fdt_prop_as_u32(prop, &val)) ) + { + printk(XENLOG_ERR " bad \"cpus\" prop on domain %s\n", name); + return rc; + } + bd->max_vcpus = val; + printk(XENLOG_INFO " cpus: %d\n", bd->max_vcpus); + } } fdt_for_each_subnode(node, fdt, dom_node) From patchwork Thu Apr 17 12:48: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: 14055540 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 BDC8CC369B2 for ; Thu, 17 Apr 2025 12:52:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.957648.1350741 (Exim 4.92) (envelope-from ) id 1u5Oiy-0005Kw-8Q; Thu, 17 Apr 2025 12:52:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 957648.1350741; Thu, 17 Apr 2025 12:52:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5Oiy-0005Kn-5c; Thu, 17 Apr 2025 12:52:12 +0000 Received: by outflank-mailman (input) for mailman id 957648; Thu, 17 Apr 2025 12:52:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u5OgR-0004z9-9b for xen-devel@lists.xenproject.org; Thu, 17 Apr 2025 12:49:35 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20606.outbound.protection.outlook.com [2a01:111:f403:2414::606]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 697859d8-1b8a-11f0-9eb0-5ba50f476ded; Thu, 17 Apr 2025 14:49:34 +0200 (CEST) Received: from CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) by CH2PR12MB4039.namprd12.prod.outlook.com (2603:10b6:610:a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.36; Thu, 17 Apr 2025 12:49:30 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:5a:cafe::31) by CH2PR08CA0016.outlook.office365.com (2603:10b6:610:5a::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.15 via Frontend Transport; Thu, 17 Apr 2025 12:49:30 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8655.12 via Frontend Transport; Thu, 17 Apr 2025 12:49:30 +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; Thu, 17 Apr 2025 07:49:28 -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: 697859d8-1b8a-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wVQc2Aeg9jbdv4EX449XO2GYgknC7hJ0/9ccEQBvUq8/bkyO7kFLFTwcFiqo9AduS39bLU2iMBwamfSPK+EU7YQP/We8C35mr02sMNqVgAKGmjWDWgm158UTGr4cAtcE7U2Prk41Pgxt7PIzWFremFqncq63x6wOoxRc0xP1yAuNG6HrrLeE+6FFveFDhd7yM462W1g1N0j7rD+seV90ZN2hWfPLrYMGaSmHHkvNjZDDM2m0AVKgFVUqWiFYtlQkYpLIjOuUJS7v9w1t5j3cX61oEoayiY3Ba+PhsqLp3g3XKmTMLnwA5awNF/KL/85QCJ1cZsJhgyCjyJ1jL9C0+A== 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=m2nnxNvapsA9yUyBZa5Q7RA8+C8ztd0XPgOdNnop0rE=; b=Jki6TgJ4RLsmvfpLE23ZazzmYtlrsWVy2xLSI7e/EcbTQrn9IT1bYOQLL1f4PFMgImb0e70Y5kx7GjuugkWpt6O7a9Miz2gYSIKlz/VOYm8P5AxHhNKcD2qDR+YG1rvFqjoNSOW0w1/LiHTzEgkdIvacd0WszMjco1lKPQqs7x9OW7KfJrwhBMNhyy81PtkwGYyD5wtxg5L36StdT+wb0jnONKy9M8zXSMZBiNUNZe6mYgO0waKKNttyuTRw9pAx/LuQTwtFLAaxgvCF/oyy/odNaIyct4SN9xr3SmgWVyYqQAA/Cg+k+m/HqOVbCd5P/YKuAYr0DCPKwQlrV0aodw== 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=m2nnxNvapsA9yUyBZa5Q7RA8+C8ztd0XPgOdNnop0rE=; b=Y7Lb8TaEFF9i5TTjvDyeMtuB15gIkOSCuRVsf/Gjjl3lvwT4ZhFYRCY/jj5FLiioSkS3Noj31Zosb3SNvPNuCoxGB/fXrrjZNBlo18rGPQmn5nuAKth4ewd2IXn4JwYnABjFyjgmAAGxGUE6kwpef8ucplNEcmnhVLiEdvpIs6k= 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" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini , "Jason Andryuk" , Alejandro Vallejo Subject: [PATCH v4 13/13] x86/hyperlaunch: add capabilities to boot domain Date: Thu, 17 Apr 2025 13:48:35 +0100 Message-ID: <20250417124844.11143-14-agarciav@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417124844.11143-1-agarciav@amd.com> References: <20250417124844.11143-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: CH2PEPF00000142:EE_|CH2PR12MB4039:EE_ X-MS-Office365-Filtering-Correlation-Id: f117c596-c7ab-4ac6-5e14-08dd7dae4b88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: IkFbHBk/L+k0Ki3LbIxisTfRBwAGVc02Zn/IBw1l6lJOJl37lJ2/ND++cLmTKUg3J1/E7cPxkU0XKd76EMOataaIpvRyvP51aqV1z+ztM32HHKSHuKbf4axV4FPirxqNtFiE+LD9t+SQ1Db8VhzaFixMwWgDndoyVJB+OWk+OhQ5jV5ENDNhzmwMHiGtWyHAgk9XcamU/c3r0NiDoZlJv1mkdBDe+S5SESI6G3MDUjS90nAugoVTKfTJnU0FPpcwNgtuAIRw2dQFVrsj1T+AqCrdhQMWrnAwhg6zQ1WK1bCq/V+x1RGjGDwftHecW5Qki9yzeS+pvfkrUO+0GAuTuDJkneOEEiqFRp/IjByQG+AQhV+uftOpgeMCBYMQI4XGdOz8VTtDxGEuEgVo4ZzA+Ddr0PjXnBOJ++vD+0lrhMMQnviWWGHatpA1uc09hnHnFCCupi2SiwmpAJZZ3YzSfVYCXHPkhM6YwxZJrNjKqklcrL+FXPqla+q8UhSrvgiP9cHyqlNHzQg9vi1uv0lrOTLse7aTSzyWwoExgSDc3P5T/ih15H8ZpaR4Pf5KwH6nyg07l3YkqutJRLIsUGQb9XDjVJpwJ82T/s6q9EM2aX8j9E8kOQ3i/WRuygDaWLFIp6i2sy4vEkmBoNoSiYh389x3mNBa2IZauYwKdEWXDu/eu76lFVwBEfnmXqSOOZErIOrUsS/4ENMWgHWob/gIiMQe81F2680FZISZYHuXPhoatHTvv8oXbeV0+q7BbOVQFBZ4nUbB2Y7XiHj+dqJ3aKedf0DL21Ymeeb2mqvgY1X9/OfJKB5+f8XeEfCKm73+n3f8vXy9gghHeaHsbHhXRjNrBWvaUgte1eDtzZHOtoFgzDXCSQJxG9VRym6Gn3JWx8OWYoy3sMpR71dt1jBRGA9dtNOGqOSZgD0WYa5KuDbhrK+b6MOeffRzn+25UY6clTbfvYfcPilp82jOYFBWKYrikE3vkRDOcyy+9b3IGQeNF0ifG4LbLgkGJ+t0u77mAFc3v2vca+g0uxbAicMNQrjk+bZJ/q0aZD6g5Oo9XSCtDpanXVURxRGoZN6DYHUwogQwkYybZjvLyOF2Q7JbrP2awC2Tp6pVcb/qLjC4gOE5omrv1B1rrMP8Glcr/gYaEHhanbmqZKT5a8MpZS8GCdEO194W1xB+Q9ANm7dvTZyJjkZDb5AOd2mLEoUmsXsCUGTcgwBQiGkZnsA4++BPAnIrf6XxI3j7LLkUZCnWx+0mChi1ALo7kYyfTJzH7cvWJnF+vmuK8iQDdkhy/8FUIKRSjBh2iEx0dU3vP9F8yWOC4nkxvah0zDKBQVaBmP5Q0V1mJUtxCut6ptR7SclDEutwnutE2uX4fVZ2BpH6hs4wMpmTFqA0kOYzdkStj5AAEfRGXTvJnqQzeyErMuFWj2rcMDl/oygJy4tYbghn7T06ly9C9Tbngh5+Cdi8ZGsVLwKiLw/f2i1KA+aJ8IBbk1J9UFF+q3QV/LcZDqWw5rx7fPbIwOicumHcyK0EuY96 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)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2025 12:49:30.0838 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f117c596-c7ab-4ac6-5e14-08dd7dae4b88 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: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4039 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 Signed-off-by: Jason Andryuk Signed-off-by: Alejandro Vallejo Reviewed-by: Denis Mukhin --- v4: * Dropped Jason's R-by. * Refactored caps printinng logic * It just wasn't xenlog-compatible as it was. * Moved pv_shim check to builder_init, so the capability is just not given. * And inlined the create_flags variable now that's tractable. * Validated input capabilities after coming out of the DT. --- xen/arch/x86/include/asm/boot-domain.h | 5 +++++ xen/arch/x86/setup.c | 3 ++- xen/common/domain-builder/core.c | 2 ++ xen/common/domain-builder/fdt.c | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index 969c02a6ea..5c143d82af 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; +#define BUILD_CAPS_NONE (0U) +#define BUILD_CAPS_CONTROL (1U << 0) +#define BUILD_CAPS__ALL BUILD_CAPS_CONTROL + 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 455dad454c..3cdd8bc2f9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1040,7 +1040,8 @@ 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); + d = domain_create(bd->domid, &dom0_cfg, + (bd->capabilities & BUILD_CAPS_CONTROL) ? CDF_privileged : 0); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); diff --git a/xen/common/domain-builder/core.c b/xen/common/domain-builder/core.c index 4b4230f2ff..d1a5d6125e 100644 --- a/xen/common/domain-builder/core.c +++ b/xen/common/domain-builder/core.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "fdt.h" @@ -93,6 +94,7 @@ void __init builder_init(struct boot_info *bi) bi->mods[i].type = BOOTMOD_KERNEL; bi->domains[0].kernel = &bi->mods[i]; + bi->domains[0].capabilities |= pv_shim ? 0 : BUILD_CAPS_CONTROL; bi->nr_domains = 1; } } diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c index 295ab6e8b3..3e3a84e2d0 100644 --- a/xen/common/domain-builder/fdt.c +++ b/xen/common/domain-builder/fdt.c @@ -293,6 +293,26 @@ static int __init process_domain_node( bd->max_vcpus = val; printk(XENLOG_INFO " cpus: %d\n", bd->max_vcpus); } + else if ( !strncmp(prop_name, "capabilities", name_len) ) + { + if ( (rc = fdt_prop_as_u32(prop, &bd->capabilities)) ) + { + printk(XENLOG_ERR + " bad \"capabilities\" on domain %s\n", name); + return rc; + } + + if ( bd->capabilities & ~BUILD_CAPS__ALL ) + { + printk(XENLOG_WARNING " unknown capabilities: %#x\n", + bd->capabilities & ~BUILD_CAPS__ALL); + + bd->capabilities &= BUILD_CAPS__ALL; + } + + printk(XENLOG_INFO " caps: %s\n", + bd->capabilities & BUILD_CAPS_CONTROL ? "c" : ""); + } } fdt_for_each_subnode(node, fdt, dom_node)