From patchwork Fri Aug 30 21:46:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785586 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 D2385CA101A for ; Fri, 30 Aug 2024 21:48:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786651.1196255 (Exim 4.92) (envelope-from ) id 1sk9TH-0004R9-Dp; Fri, 30 Aug 2024 21:47:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786651.1196255; Fri, 30 Aug 2024 21:47:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9TH-0004R2-8x; Fri, 30 Aug 2024 21:47:55 +0000 Received: by outflank-mailman (input) for mailman id 786651; Fri, 30 Aug 2024 21:47:53 +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 1sk9TF-0004BO-Gl for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:47:53 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 80cc9cb1-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:47:51 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054460817330.6426605494462; Fri, 30 Aug 2024 14:47:40 -0700 (PDT) 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: 80cc9cb1-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054462; cv=none; d=zohomail.com; s=zohoarc; b=VVb9AQHQzWR0Xi2YBkK8F9dotHc22hwmVT/LlesQD8Ep099R821c1DgywspI4LquG1hX93Kne+sbnH/DjXwPEPRdyxUN08DnabgJAXPouP59ITtCwrG2jpwejvBzQdo6GEOZO8VqHMDWQ5mqVHVzTaFmcYuDKA2y16NmlXCqWyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054462; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=M4W1+EbYZ1Civ9bhjGdGJrVHK5yOv98KXuuX61z+p3g=; b=cUpNh9U8LgPdyvJKQS3ji/lxd+zIM1Y9zDvfRHx3XDvMvc7/7OX1siznfG8ykfEmXHn7/4LNt8fKcUHr/BpB5snOhE4we4wysUw/fbxgciUHjPFu4I0CcOMf8LN/7hyz7LpZmzo74DaAciz4vK1cYWBWBYmjWHQOypEfbhGT25M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054462; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=M4W1+EbYZ1Civ9bhjGdGJrVHK5yOv98KXuuX61z+p3g=; b=sHHzHCuGHGQltokKpd4X2yRE+MQNFBUIgXNLNgudjrJQNsTEkIGzdG7ZgX53oL3G Bs570rYESGeIxMHp8DV4M1l39KusyOgGHF9Chuq8gA7oP2a0fLWfRdBdShtfHYeT/9G hpZ8ncIhIEf19P9+zBm6Hp478IrYnKcZY0nOar8Y= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: Christopher Clark , jason.andryuk@amd.com, "Daniel P . Smith" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 01/44] x86/boot: move x86 boot module counting into a new boot_info struct Date: Fri, 30 Aug 2024 17:46:46 -0400 Message-Id: <20240830214730.1621-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External From: Christopher Clark An initial step towards a non-multiboot internal representation of boot modules for common code, starting with x86 setup and converting the fields that are accessed for the startup calculations. Introduce a new header, , and populate it with a new boot_info structure initially containing a count of the number of boot modules. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 25 +++++++++++++ xen/arch/x86/setup.c | 58 +++++++++++++++++------------ 2 files changed, 59 insertions(+), 24 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootinfo.h diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h new file mode 100644 index 000000000000..e850f80d26a7 --- /dev/null +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Christopher Clark + * Copyright (c) 2024 Apertus Solutions, LLC + * Author: Daniel P. Smith + */ + +#ifndef __XEN_X86_BOOTINFO_H__ +#define __XEN_X86_BOOTINFO_H__ + +struct boot_info { + unsigned int nr_mods; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index eee20bb1753c..dd94ee2e736b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include #include @@ -276,7 +277,16 @@ static int __init cf_check parse_acpi_param(const char *s) custom_param("acpi", parse_acpi_param); static const module_t *__initdata initial_images; -static unsigned int __initdata nr_initial_images; +static struct boot_info __initdata *boot_info; + +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +{ + static struct boot_info __initdata info; + + info.nr_mods = mbi->mods_count; + + boot_info = &info; +} unsigned long __init initial_images_nrpages(nodeid_t node) { @@ -285,7 +295,7 @@ unsigned long __init initial_images_nrpages(nodeid_t node) unsigned long nr; unsigned int i; - for ( nr = i = 0; i < nr_initial_images; ++i ) + for ( nr = i = 0; i < boot_info->nr_mods; ++i ) { unsigned long start = initial_images[i].mod_start; unsigned long end = start + PFN_UP(initial_images[i].mod_end); @@ -301,7 +311,7 @@ void __init discard_initial_images(void) { unsigned int i; - for ( i = 0; i < nr_initial_images; ++i ) + for ( i = 0; i < boot_info->nr_mods; ++i ) { uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; @@ -309,7 +319,7 @@ void __init discard_initial_images(void) start + PAGE_ALIGN(initial_images[i].mod_end)); } - nr_initial_images = 0; + boot_info->nr_mods = 0; initial_images = NULL; } @@ -1034,9 +1044,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod = __va(mbi->mods_addr); } + multiboot_to_bootinfo(mbi); + loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name) : "unknown"; - /* Parse the command-line options. */ if ( mbi->flags & MBI_CMDLINE ) cmdline = cmdline_cook(__va(mbi->cmdline), loader); @@ -1141,18 +1152,18 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bootsym(boot_edd_info_nr)); /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) ) + if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods == 0) ) panic("dom0 kernel not specified. Check bootloader configuration\n"); /* Check that we don't have a silly number of modules. */ - if ( mbi->mods_count > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > sizeof(module_map) * 8 ) { - mbi->mods_count = sizeof(module_map) * 8; + boot_info->nr_mods = sizeof(module_map) * 8; printk("Excessive multiboot modules - using the first %u only\n", - mbi->mods_count); + boot_info->nr_mods); } - bitmap_fill(module_map, mbi->mods_count); + bitmap_fill(module_map, boot_info->nr_mods); __clear_bit(0, module_map); /* Dom0 kernel is always first */ if ( pvh_boot ) @@ -1325,9 +1336,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) kexec_reserve_area(); initial_images = mod; - nr_initial_images = mbi->mods_count; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < mbi->mods_count; i++ ) + for ( i = 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++ ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); @@ -1351,8 +1361,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[mbi->mods_count].mod_start = virt_to_mfn(_stext); - mod[mbi->mods_count].mod_end = __2M_rwdata_end - _stext; + mod[boot_info->nr_mods].mod_start = virt_to_mfn(_stext); + mod[boot_info->nr_mods].mod_end = __2M_rwdata_end - _stext; } modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); @@ -1412,7 +1422,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end = consider_modules(s, e, reloc_size + mask, - mod, mbi->mods_count, -1); + mod, boot_info->nr_mods, -1); end &= ~mask; } else @@ -1433,7 +1443,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) } /* Is the region suitable for relocating the multiboot modules? */ - for ( j = mbi->mods_count - 1; j >= 0; j-- ) + for ( j = boot_info->nr_mods - 1; j >= 0; j-- ) { /* * 'headroom' is a guess for the decompressed size and @@ -1448,7 +1458,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) /* Don't overlap with other modules (or Xen itself). */ end = consider_modules(s, e, size, mod, - mbi->mods_count + relocated, j); + boot_info->nr_mods + relocated, j); if ( highmem_start && end > highmem_start ) continue; @@ -1475,7 +1485,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules (or Xen itself). */ e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), mod, - mbi->mods_count + relocated, -1); + boot_info->nr_mods + relocated, -1); if ( s >= e ) break; if ( e > kexec_crash_area_limit ) @@ -1490,7 +1500,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( modules_headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); - for ( i = 0; i < mbi->mods_count; ++i ) + for ( i = 0; i < boot_info->nr_mods; ++i ) { uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; @@ -1570,7 +1580,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) ASSERT(j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; - for ( j = 0; j < mbi->mods_count; ++j ) + for ( j = 0; j < boot_info->nr_mods; ++j ) { uint64_t end = pfn_to_paddr(mod[j].mod_start) + mod[j].mod_end; @@ -1645,7 +1655,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) } } - for ( i = 0; i < mbi->mods_count; ++i ) + for ( i = 0; i < boot_info->nr_mods; ++i ) { set_pdx_range(mod[i].mod_start, mod[i].mod_start + PFN_UP(mod[i].mod_end)); @@ -2032,8 +2042,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); - initrdidx = find_first_bit(module_map, mbi->mods_count); - if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) + initrdidx = find_first_bit(module_map, boot_info->nr_mods); + if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2043,7 +2053,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * above our heap. The second module, if present, is an initrd ramdisk. */ dom0 = create_dom0(mod, modules_headroom, - initrdidx < mbi->mods_count ? mod + initrdidx : NULL, + initrdidx < boot_info->nr_mods ? mod + initrdidx : NULL, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Fri Aug 30 21:46:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785587 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 01BF3CA0EF3 for ; Fri, 30 Aug 2024 21:48:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786652.1196264 (Exim 4.92) (envelope-from ) id 1sk9TN-0004j1-JD; Fri, 30 Aug 2024 21:48:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786652.1196264; Fri, 30 Aug 2024 21:48:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9TN-0004iu-Gb; Fri, 30 Aug 2024 21:48:01 +0000 Received: by outflank-mailman (input) for mailman id 786652; Fri, 30 Aug 2024 21:48:00 +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 1sk9TM-0004BO-Ro for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:00 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8533de97-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:47:59 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17250544619691020.6911507983529; Fri, 30 Aug 2024 14:47:41 -0700 (PDT) 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: 8533de97-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054464; cv=none; d=zohomail.com; s=zohoarc; b=k1d4FRK7F8uwIJpTqyE+y8FsdfwNHiKb4oG6Oj8svyS1Mx4mDuDzj19fAv+wcAmM2M39G8drszEFyHOiFTG6mwqy/QERRlEgF81z7KCQw7mU3Xf6zYH1p0TLX6TEiA8XknDnJoM8tH/ySx3fLc6rBSm9qZ4BxHP7hOuO2tnqc+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054464; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=KAESHRPaE5VWyf1xY+l5m4fxgSkS1FQVX7bHFI04M2Y=; b=R7s9lqaXfp3RhPrhyRGwVnNU8DPAuxC7iNMeymPgEDC+t5G3AHbojj351+eycFhBc+e0SosR6a2pyhOva+H1Dqt1qn5JLxJgzXdsZFWVLTfRMkdhmzw9Uvl0H0PVdLaElz6gYLi+/bSAjBeFu7i5vli00Qx3ueakrcGNnb/VQQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054464; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=KAESHRPaE5VWyf1xY+l5m4fxgSkS1FQVX7bHFI04M2Y=; b=T0tOh+gFQViOt10PluDy2w7iaysThBZ5A1a3OMU14qMJs2f9DaSBNrdVV6804hfw QcuGVnmJzdePaI7RlJ+/Db2p7hKfPkZGl17xOBGQJy/12DhpRvcoHJC2foVDCAqqv56 TC0Ns/xjvRu1xtGzSXiQkbOA1dVPIYtPo8FEEhmY= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 02/44] x86/boot: move boot loader name to boot info Date: Fri, 30 Aug 2024 17:46:47 -0400 Message-Id: <20240830214730.1621-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Transition the incoming boot loader name to be held in struct boot_info. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index e850f80d26a7..e69feb1bb8be 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -10,6 +10,8 @@ struct boot_info { unsigned int nr_mods; + + const char *boot_loader_name; }; #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dd94ee2e736b..432b7d1701e4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -285,6 +285,9 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) info.nr_mods = mbi->mods_count; + info.boot_loader_name = (mbi->flags & MBI_LOADERNAME) ? + __va(mbi->boot_loader_name) : "unknown"; + boot_info = &info; } @@ -993,7 +996,7 @@ static struct domain *__init create_dom0(const module_t *image, void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { - const char *memmap_type = NULL, *loader, *cmdline = ""; + const char *memmap_type = NULL, *cmdline = ""; char *kextra; void *bsp_stack; struct cpu_info *info = get_cpu_info(), *bsp_info; @@ -1046,11 +1049,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) multiboot_to_bootinfo(mbi); - loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name) - : "unknown"; /* Parse the command-line options. */ if ( mbi->flags & MBI_CMDLINE ) - cmdline = cmdline_cook(__va(mbi->cmdline), loader); + cmdline = cmdline_cook(__va(mbi->cmdline), boot_info->boot_loader_name); if ( (kextra = strstr(cmdline, " -- ")) != NULL ) { @@ -1091,7 +1092,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( pvh_boot ) pvh_print_info(); - printk("Bootloader: %s\n", loader); + printk("Bootloader: %s\n", boot_info->boot_loader_name); printk("Command line: %s\n", cmdline); @@ -1184,7 +1185,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] = l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR); - memmap_type = loader; + memmap_type = boot_info->boot_loader_name; } else if ( efi_enabled(EFI_BOOT) ) memmap_type = "EFI"; @@ -2054,7 +2055,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ dom0 = create_dom0(mod, modules_headroom, initrdidx < boot_info->nr_mods ? mod + initrdidx : NULL, - kextra, loader); + kextra, boot_info->boot_loader_name); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Fri Aug 30 21:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785589 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 03D12CA0EF3 for ; Fri, 30 Aug 2024 21:48:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786653.1196274 (Exim 4.92) (envelope-from ) id 1sk9TV-00056r-T1; Fri, 30 Aug 2024 21:48:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786653.1196274; Fri, 30 Aug 2024 21:48:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9TV-00056i-PW; Fri, 30 Aug 2024 21:48:09 +0000 Received: by outflank-mailman (input) for mailman id 786653; Fri, 30 Aug 2024 21:48:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9TU-0004BO-Qk for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:08 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 89e4a070-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:48:07 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054463025557.548854351013; Fri, 30 Aug 2024 14:47:43 -0700 (PDT) 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: 89e4a070-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054465; cv=none; d=zohomail.com; s=zohoarc; b=kZfzSBiAOcWM1nNWw8G6aWDYpPkIo63VSHznsMdZ2tqCKj39rJ5gHMuBO18irh/KNd7mnxlzwXRgiMzhsOOTs/FPMtu497XfFgODVZAmSVjeCYoNseK5XEWWbfM0FinWWFw+vvzBmdhXaNeUAvjiF+CePNUbqszKR0tCF4sblEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054465; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qexd3Ieo0x5aB7CkcPEqhzSRdIxc4KHzWNUKGdjfDMk=; b=L8nQ3JmrkA4ybkEhwkoZFrMqtzpmqd8nXSww2zkjd2cp3Wi9cCR8ny91f6MqwV1v/7+lkj+2DUCgLXYEjVmBsh9RkbHQIY0WZ/yiK1apwAiDkTyuNvQrVaVB9VUH1fnPS6ltTzCQhWfdSWXA/egn1z7/HY2P95RKHv6Vvyp3Uk4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054465; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Qexd3Ieo0x5aB7CkcPEqhzSRdIxc4KHzWNUKGdjfDMk=; b=kKDzBb+ZDpO2+u840lmHk+yzp84/29Qyboj/exo/kudo2h9Ieg65aP9GRtqhDxzJ 07MU7U9q62rJim9GQL4XzZ91lUKyL8HpU799r2HDgAa8e18oHwI3EjZTddjgDofF6IO TrmJmuTTm6OuTZkg0VhLOg1bE2qVgI7i+I7Pgi+A= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 03/44] x86/boot: move cmdline to boot info Date: Fri, 30 Aug 2024 17:46:48 -0400 Message-Id: <20240830214730.1621-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Transition Xen's command line to being held in struct boot_info. No functional change intended. Signed-off-by: Daniel P. Smith Acked-by: Andrew Cooper --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index e69feb1bb8be..d2ca077d2356 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -12,6 +12,7 @@ struct boot_info { unsigned int nr_mods; const char *boot_loader_name; + const char *cmdline; }; #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 432b7d1701e4..a945fa10555f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,6 +276,8 @@ static int __init cf_check parse_acpi_param(const char *s) } custom_param("acpi", parse_acpi_param); +static const char *cmdline_cook(const char *p, const char *loader_name); + static const module_t *__initdata initial_images; static struct boot_info __initdata *boot_info; @@ -288,6 +290,13 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) info.boot_loader_name = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name) : "unknown"; + /* Parse the command-line options. */ + if ( mbi->flags & MBI_CMDLINE ) + info.cmdline = cmdline_cook(__va(mbi->cmdline), + info.boot_loader_name); + else + info.cmdline = ""; + boot_info = &info; } @@ -996,7 +1005,7 @@ static struct domain *__init create_dom0(const module_t *image, void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { - const char *memmap_type = NULL, *cmdline = ""; + const char *memmap_type = NULL; char *kextra; void *bsp_stack; struct cpu_info *info = get_cpu_info(), *bsp_info; @@ -1049,11 +1058,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) multiboot_to_bootinfo(mbi); - /* Parse the command-line options. */ - if ( mbi->flags & MBI_CMDLINE ) - cmdline = cmdline_cook(__va(mbi->cmdline), boot_info->boot_loader_name); - - if ( (kextra = strstr(cmdline, " -- ")) != NULL ) + if ( (kextra = strstr(boot_info->cmdline, " -- ")) != NULL ) { /* * Options after ' -- ' separator belong to dom0. @@ -1064,7 +1069,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) kextra += 3; while ( kextra[1] == ' ' ) kextra++; } - cmdline_parse(cmdline); + cmdline_parse(boot_info->cmdline); /* Must be after command line argument parsing and before * allocing any xenheap structures wanted in lower memory. */ @@ -1094,7 +1099,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) printk("Bootloader: %s\n", boot_info->boot_loader_name); - printk("Command line: %s\n", cmdline); + printk("Command line: %s\n", boot_info->cmdline); printk("Xen image load base address: %#lx\n", xen_phys_start); if ( hypervisor_name ) From patchwork Fri Aug 30 21:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785590 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 9C8B8CA101A for ; Fri, 30 Aug 2024 21:48:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786657.1196284 (Exim 4.92) (envelope-from ) id 1sk9Td-0005dp-6n; Fri, 30 Aug 2024 21:48:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786657.1196284; Fri, 30 Aug 2024 21:48:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Td-0005di-1v; Fri, 30 Aug 2024 21:48:17 +0000 Received: by outflank-mailman (input) for mailman id 786657; Fri, 30 Aug 2024 21:48:16 +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 1sk9Tc-0004BO-3H for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:16 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8e3c4ba0-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:48:14 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054464189234.4870791649007; Fri, 30 Aug 2024 14:47:44 -0700 (PDT) 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: 8e3c4ba0-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054466; cv=none; d=zohomail.com; s=zohoarc; b=GCB88FNkVAkVJ4OErzRK+V0XldeNho6qax4qz6noXdyBPG+ZAZnwX9dhj0fBKxmgtsHfJryPRpR2X8e/kS/NQzK3rnNmBK8tJ71U1lZjsHcNWa8EVJeVFlTI9PXxEdql7U7vIId4Tg21Fnj8GUmNAV2SC0fslgMKHqHBQ5jy1/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054466; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=AHDLb8T/b80h/7jv5pdrXG2adOVOnBNwTs0CHWLNuOc=; b=Scg75RdV6n6c7HabrT/rBUhqT/e7pXIXZnfox1qAgmkzEhp3nkLluGFwHQGv5mlTEO603hc5MbAAvLhtFhtQMJegvxX218U/sCfc3dzGWL8H+j+O6ZVXHRQOymGekBx7CmyPbe0Wn9nJOgPdxTEqqDg3UvnoOzZG8lNQvcsOkpM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054466; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=AHDLb8T/b80h/7jv5pdrXG2adOVOnBNwTs0CHWLNuOc=; b=X1YUFfg/0Gkk09gpid6a1UXiO/0l3eDj08+fSxYHIxheOGJHh8uxik4mGZemS9X7 DhfYvj6pFSP7crpfiAvd/PKM0yQgmQ3X9bnI1Kzg+VT6NK/fIkdOIFrKqu791PxFD6E LEKVCa7zdRbCstp3wa9P0IFqhuOrmwZ8vpm3WzAs= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 04/44] x86/boot: move mmap info to boot info Date: Fri, 30 Aug 2024 17:46:49 -0400 Message-Id: <20240830214730.1621-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Transition the memory map info to be held in struct boot_info. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/setup.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index d2ca077d2356..e785ed1c5982 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,11 +8,16 @@ #ifndef __XEN_X86_BOOTINFO_H__ #define __XEN_X86_BOOTINFO_H__ +#include + struct boot_info { unsigned int nr_mods; const char *boot_loader_name; const char *cmdline; + + paddr_t mmap_addr; + uint32_t mmap_length; }; #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a945fa10555f..c6b45ced00ae 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -297,6 +297,12 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) else info.cmdline = ""; + if ( mbi->flags & MBI_MEMMAP ) + { + info.mmap_addr = mbi->mmap_addr; + info.mmap_length = mbi->mmap_length; + } + boot_info = &info; } @@ -1200,13 +1206,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { memmap_type = "Xen-e820"; } - else if ( mbi->flags & MBI_MEMMAP ) + else if ( boot_info->mmap_addr ) { memmap_type = "Multiboot-e820"; - while ( bytes < mbi->mmap_length && + while ( bytes < boot_info->mmap_length && e820_raw.nr_map < ARRAY_SIZE(e820_raw.map) ) { - memory_map_t *map = __va(mbi->mmap_addr + bytes); + memory_map_t *map = __va(boot_info->mmap_addr + bytes); /* * This is a gross workaround for a BIOS bug. Some bootloaders do From patchwork Fri Aug 30 21:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785591 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 CA355CA101A for ; Fri, 30 Aug 2024 21:48:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786664.1196294 (Exim 4.92) (envelope-from ) id 1sk9Tn-0006FY-JU; Fri, 30 Aug 2024 21:48:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786664.1196294; Fri, 30 Aug 2024 21:48: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 1sk9Tn-0006FR-GI; Fri, 30 Aug 2024 21:48:27 +0000 Received: by outflank-mailman (input) for mailman id 786664; Fri, 30 Aug 2024 21:48:26 +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 1sk9Tm-00065G-3m for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:26 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 93724ef6-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:48:23 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054465277157.3636748835229; Fri, 30 Aug 2024 14:47:45 -0700 (PDT) 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: 93724ef6-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054467; cv=none; d=zohomail.com; s=zohoarc; b=hkPK0sEs6w6MyzjfL5eePRMtOl+7XRDZXnXEysR6hOmPZQp0i+YqQHaopu079OxveECVPhSL9jqzwNax5Z6hyI/xw7d+eXO3fthnnZvNpKjEgS2jUHN9zBOn3s63OpOYSh6m1JBYxXOg1cSJCvophvdgaza9z47Fv6XREhpyMEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054467; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=mTJb7A779pFDFU65rSxPgwx1Pg9D5EASEmZIOVhMBEs=; b=hFIlEOzWBo5HwsMzBvPdqr6stCKeAeAK6RteSAIa2+Mom5JQSymXgd+e3NkL7xp4uNTCJfbq6+7SMcpb0gxazsElqTTzrnIKKBKRyxK/Ak5LIY3O42T9Ua+Fn5o9shioPpyU0mO8GS2psmjELq94h+lwxz/uwrnlZRKLiSzUSyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054467; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=mTJb7A779pFDFU65rSxPgwx1Pg9D5EASEmZIOVhMBEs=; b=BnDNhT6E9IBxgN1VXSPCDDdxGikEmeMUGoqL9KYXIeObS5b5kpkTR5msUBxhNbmy 6kY/dk05jjaEQVwq9gL2a0Mp/UtNVS8+m03p9EhZx1PCitPVB+iuHxGyPD7VLCKGwC6 xiACIYvbAf4JE8euEXCZAB7GkkYX+m8PGb/3Ftms= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 05/44] x86/boot: introduce struct boot_module Date: Fri, 30 Aug 2024 17:46:50 -0400 Message-Id: <20240830214730.1621-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This will introduce a new struct boot_module to provide a rich state representation around modules provided by the boot loader. Support is for 64 boot modules, one held in reserve for Xen, and up to 63 can be provided by the boot loader. The array of struct boot_modules will be accessible via a reference held in struct boot_info. A temporary `early_mod` parameter is included in struct boot_module to ease the transition from using Multiboot v1 structures over to struct boot_module. Once the transition is complete, the parameter will be dropped from the structure. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 6 ++++++ xen/arch/x86/setup.c | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index e785ed1c5982..844262495962 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,10 +8,16 @@ #ifndef __XEN_X86_BOOTINFO_H__ #define __XEN_X86_BOOTINFO_H__ +#include #include +struct boot_module { + module_t *early_mod; +}; + struct boot_info { unsigned int nr_mods; + struct boot_module *mods; const char *boot_loader_name; const char *cmdline; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c6b45ced00ae..28fdbf4d4c2b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -278,12 +278,17 @@ custom_param("acpi", parse_acpi_param); static const char *cmdline_cook(const char *p, const char *loader_name); +/* Max number of boot modules a bootloader can provide in addition to Xen */ +#define MAX_NR_BOOTMODS 63 + static const module_t *__initdata initial_images; static struct boot_info __initdata *boot_info; -static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) { static struct boot_info __initdata info; + static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1]; + unsigned int i; info.nr_mods = mbi->mods_count; @@ -303,6 +308,14 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) info.mmap_length = mbi->mmap_length; } + info.mods = boot_mods; + + for ( i=0; i < info.nr_mods; i++ ) + boot_mods[i].early_mod = &mods[i]; + + /* map the last mb module for xen entry */ + boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods]; + boot_info = &info; } @@ -1062,7 +1075,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod = __va(mbi->mods_addr); } - multiboot_to_bootinfo(mbi); + multiboot_to_bootinfo(mbi, mod); if ( (kextra = strstr(boot_info->cmdline, " -- ")) != NULL ) { @@ -1164,7 +1177,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bootsym(boot_edd_info_nr)); /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods == 0) ) + if ( boot_info->nr_mods == 0 ) panic("dom0 kernel not specified. Check bootloader configuration\n"); /* Check that we don't have a silly number of modules. */ From patchwork Fri Aug 30 21:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785592 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 C9D81CA0EF3 for ; Fri, 30 Aug 2024 21:48:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786670.1196304 (Exim 4.92) (envelope-from ) id 1sk9Ts-0006f6-Ra; Fri, 30 Aug 2024 21:48:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786670.1196304; Fri, 30 Aug 2024 21:48: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 1sk9Ts-0006ex-OG; Fri, 30 Aug 2024 21:48:32 +0000 Received: by outflank-mailman (input) for mailman id 786670; Fri, 30 Aug 2024 21:48:31 +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 1sk9Tr-00065G-NV for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:31 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 97c23d19-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:48:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054466365953.1827755781716; Fri, 30 Aug 2024 14:47:46 -0700 (PDT) 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: 97c23d19-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054468; cv=none; d=zohomail.com; s=zohoarc; b=n1vzAdrh/oyymzXFaRv9pOKnwJwtAiTcbY4L6gTtrg/4p6m6n+KMDsrPryMXD1gkFIdQ5LtNdUXOSZbXgH1Pahaq8ObLts0809zhLFn01lUmynhWs33LZ7EpTOEPqOZKm79E1f9iPdL5KLOUKP/uGhxAZA7UqStmpeM578wkoMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054468; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=0gXaC5isg4IrQFsCJP9Fq77RhO29MxC4nrBXRRPDF6A=; b=Krfmu32iuu+u5S+3VHWecVIFHkV/yyapQqzJo6sUO2gTafSnjBR6FwLhjimkCHfWLeWU3pJ9QqxXZZwJna6Lu7vTJHOhSk91BqWsxtFoFnSIOoXAr+nkMGKjfYZ5DecZeJyQ4ssTI+FDY8rfJBifDxqi2hQeR3axKWIqjwm3Ypo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054468; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=0gXaC5isg4IrQFsCJP9Fq77RhO29MxC4nrBXRRPDF6A=; b=uppunk61v82ki+dFT/FCqIqRyq9dWDem9hk0pXj+dXLWsp6ezjWIq+I2UskrmvIn rHWO5A+QYDLGf7b3dQv9GxPETcA7lXWMtEbFzUCOxSkegebHf69BtdQbYh6E/N+Dzt+ 4gAx0rkCsmgHbg0dSI2SmCqG7EkIycZ0wDJGTENw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 06/44] x86/boot: convert consider_modules to struct boot_module Date: Fri, 30 Aug 2024 17:46:51 -0400 Message-Id: <20240830214730.1621-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External To start transitioning consider_modules() over to struct boot_module, begin with taking the array of struct boot_modules but use the temporary struct element early_mod. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 28fdbf4d4c2b..8912956ee7f1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -632,7 +632,7 @@ static void __init noinline move_xen(void) #undef BOOTSTRAP_MAP_LIMIT static uint64_t __init consider_modules( - uint64_t s, uint64_t e, uint32_t size, const module_t *mod, + uint64_t s, uint64_t e, uint32_t size, const struct boot_module *mods, unsigned int nr_mods, unsigned int this_mod) { unsigned int i; @@ -642,20 +642,20 @@ static uint64_t __init consider_modules( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = (uint64_t)mod[i].mod_start << PAGE_SHIFT; - uint64_t end = start + PAGE_ALIGN(mod[i].mod_end); + uint64_t start = (uint64_t)mods[i].early_mod->mod_start << PAGE_SHIFT; + uint64_t end = start + PAGE_ALIGN(mods[i].early_mod->mod_end); if ( i == this_mod ) continue; if ( s < end && start < e ) { - end = consider_modules(end, e, size, mod + i + 1, + end = consider_modules(end, e, size, &mods[i + 1], nr_mods - i - 1, this_mod - i - 1); if ( end ) return end; - return consider_modules(s, start, size, mod + i + 1, + return consider_modules(s, start, size, &mods[i + 1], nr_mods - i - 1, this_mod - i - 1); } } @@ -1447,7 +1447,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end = consider_modules(s, e, reloc_size + mask, - mod, boot_info->nr_mods, -1); + boot_info->mods, boot_info->nr_mods, -1); end &= ~mask; } else @@ -1482,7 +1482,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) continue; /* Don't overlap with other modules (or Xen itself). */ - end = consider_modules(s, e, size, mod, + end = consider_modules(s, e, size, boot_info->mods, boot_info->nr_mods + relocated, j); if ( highmem_start && end > highmem_start ) @@ -1509,7 +1509,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) while ( !kexec_crash_area.start ) { /* Don't overlap with modules (or Xen itself). */ - e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), mod, + e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), boot_info->mods, boot_info->nr_mods + relocated, -1); if ( s >= e ) break; From patchwork Fri Aug 30 21:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785593 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 E5FF7CA0EF3 for ; Fri, 30 Aug 2024 21:48:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786674.1196313 (Exim 4.92) (envelope-from ) id 1sk9U0-0007DY-4R; Fri, 30 Aug 2024 21:48:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786674.1196313; Fri, 30 Aug 2024 21:48:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9U0-0007D9-0h; Fri, 30 Aug 2024 21:48:40 +0000 Received: by outflank-mailman (input) for mailman id 786674; Fri, 30 Aug 2024 21:48:39 +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 1sk9Tz-00065G-3d for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:39 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c1d208c-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:48:37 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054467441405.8525706873397; Fri, 30 Aug 2024 14:47:47 -0700 (PDT) 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: 9c1d208c-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054469; cv=none; d=zohomail.com; s=zohoarc; b=hIA7N2SJZp89HintuCk+GAjbeXw1wAB4oYeGTSk2lJS5U9LoFNlQZzBCdw/eYsYnnZXkNN3pNzeNuWTkoeLuu1ppCn+UE22Ct2rq89eZI04Z6S0+WhIJQzlU5V46M4F/A+crL8HnA+pGB9tASmU6dtYuOLDzCkSO5+4ZjV22rZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054469; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=fxUow580sXI5NW+SdFuYYRTiCwP+vMd1bOEnrXKFUj4=; b=mCMqZzAeeWwKuBQbud9mZdBYmAMGXR3G3uMXd8c3M3LwJ6UX2YfQW9uzjiwEJ5A7Z41uhRE2QbY0mqMY9x9krSETPoBTaFghijgkEOtqPC4iNCUmf0Ph9xwUNOKeGG89OS7zAXMGs9FPO1IfHiSb4WNpW4xchDgNz32IlVLFHBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054469; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=fxUow580sXI5NW+SdFuYYRTiCwP+vMd1bOEnrXKFUj4=; b=nAiTT+NBAuq1xI+ZCeVXuPl9MrtoOoqzE4vnjoPfgYSGwDZWEbPI+yFmlVkogkpK x6Ha9alBUZJbRDFd7WPTlP4LBNUqq3uAfXrA6g0A79+q0Z/06zExLPPhvPWV2DeRHHY YwnsUSmN2k8KU3kfXl8jBWYE3tMuz5PHE3pC8hsc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 07/44] x86/boot: move headroom to boot modules Date: Fri, 30 Aug 2024 17:46:52 -0400 Message-Id: <20240830214730.1621-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The purpose of struct boot_module is to encapsulate the state of boot modules. Doing locates boot module state with its respective boot module, reduces globals and multiple state variables being passed around. It also lays the ground work for hyperlaunch where more multiple instances of these state variables like headroom will be needed. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 844262495962..3e0e36df096b 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -13,6 +13,7 @@ struct boot_module { module_t *early_mod; + unsigned long headroom; }; struct boot_info { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8912956ee7f1..fd6cc7fac907 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1031,7 +1031,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked = 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; + unsigned long nr_pages, raw_max_page, module_map[1]; int i, j, e820_warn = 0, bytes = 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done = false, relocated = false; @@ -1390,7 +1390,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod[boot_info->nr_mods].mod_end = __2M_rwdata_end - _stext; } - modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); + boot_info->mods[0].headroom = bzimage_headroom( + bootstrap_map(boot_info->mods[0].early_mod), + boot_info->mods[0].early_mod->mod_end); bootstrap_map(NULL); #ifndef highmem_start @@ -1475,8 +1477,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * decompressor overheads of mod[0] (the dom0 kernel). When we * move mod[0], we incorporate this as extra space at the start. */ - unsigned long headroom = j ? 0 : modules_headroom; - unsigned long size = PAGE_ALIGN(headroom + mod[j].mod_end); + struct boot_module *bm = &boot_info->mods[j]; + unsigned long size; + + size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); if ( mod[j].reserved ) continue; @@ -1489,14 +1493,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) continue; if ( s < end && - (headroom || + (bm->headroom || ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) { - move_memory(end - size + headroom, + move_memory(end - size + bm->headroom, (uint64_t)mod[j].mod_start << PAGE_SHIFT, mod[j].mod_end); mod[j].mod_start = (end - size) >> PAGE_SHIFT; - mod[j].mod_end += headroom; + mod[j].mod_end += bm->headroom; mod[j].reserved = 1; } } @@ -1523,7 +1527,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( modules_headroom && !mod->reserved ) + if ( boot_info->mods[0].headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < boot_info->nr_mods; ++i ) { @@ -2077,7 +2081,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(mod, modules_headroom, + dom0 = create_dom0(mod, boot_info->mods[0].headroom, initrdidx < boot_info->nr_mods ? mod + initrdidx : NULL, kextra, boot_info->boot_loader_name); if ( !dom0 ) From patchwork Fri Aug 30 21:46:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785594 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 2B296CA101A for ; Fri, 30 Aug 2024 21:48:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786680.1196324 (Exim 4.92) (envelope-from ) id 1sk9U7-0007mk-DW; Fri, 30 Aug 2024 21:48:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786680.1196324; Fri, 30 Aug 2024 21:48:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9U7-0007mX-9J; Fri, 30 Aug 2024 21:48:47 +0000 Received: by outflank-mailman (input) for mailman id 786680; Fri, 30 Aug 2024 21:48:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9U5-00065G-RD for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:45 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a038ab1a-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:48:44 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505446851348.39122552142521; Fri, 30 Aug 2024 14:47:48 -0700 (PDT) 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: a038ab1a-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054470; cv=none; d=zohomail.com; s=zohoarc; b=ETp14un5/oRlpw59XDSha+sLCsPX7dzvMDm6v/B7GqUW/ai3XLcyLu9VlqpQz0FLlPwTAMuR31saMVgpnMG7tGcTffPRfVYvbl0HdiqMRONVF3bViygDQjaiS5UkH6VGz3EaAbBz42ueYxMvhbD8EnY1GSK1/FBJjZ/Wf0X4Giw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054470; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=bHmAH7Z09uDCvq9Lv4ibJKqcWjY/D6qrWQ62O+CCfoc=; b=hy/WDeoEtxLbSTVg1Y/K8RabOYXbLJTQs5snF3J8mwJtPiQrZYi85HgcKfyqJVQzEY80BD03AbuFnKxVozodPxvEDhSWeDf1jVFW1eo4erv4sBYU7tM3TlLHqjqaQ0Ymk8XTrng8ZPln9aLN8FUbB7rKZUYf0BZVVn0r1HK3IMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054470; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=bHmAH7Z09uDCvq9Lv4ibJKqcWjY/D6qrWQ62O+CCfoc=; b=vWIFzzwO5EKR5BbYzso1Z775SxcdDEpJVFG4Jllb+38PeR2RIWaO8nofWBvRSmQV LXeJL5myJc/YX+175AdpzdModS4G4fpDYGvAon/4d9gClKDo/bxCWd8QhoevMIuYYJi 4ZnIM2bZg8v5wfOHJtX31khvPjxBKqUasTk7ZzhE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 08/44] x86/boot: convert setup.c mod refs to early_mod Date: Fri, 30 Aug 2024 17:46:53 -0400 Message-Id: <20240830214730.1621-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External To allow a slow conversion of x86 over to struct boot_module, start with replacing all references to struct mod to the early_mod element of struct boot_module. These serves twofold, first to allow the incremental transition from struct mod fields to struct boot_module fields. The second is to allow the conversion of function definitions from taking struct mod parameters to accepting struct boot_module as needed when a transitioned field will be accessed. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 61 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index fd6cc7fac907..82a4375683d2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1360,15 +1360,15 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - initial_images = mod; + initial_images = boot_info->mods[0].early_mod; for ( i = 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++ ) { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( boot_info->mods[i].early_mod->mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - mod[i].mod_end -= mod[i].mod_start; - mod[i].mod_start >>= PAGE_SHIFT; - mod[i].reserved = 0; + boot_info->mods[i].early_mod->mod_end -= boot_info->mods[i].early_mod->mod_start; + boot_info->mods[i].early_mod->mod_start >>= PAGE_SHIFT; + boot_info->mods[i].early_mod->reserved = 0; } /* @@ -1379,6 +1379,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( xen_phys_start ) { + int idx = boot_info->nr_mods; relocated = true; /* @@ -1386,8 +1387,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[boot_info->nr_mods].mod_start = virt_to_mfn(_stext); - mod[boot_info->nr_mods].mod_end = __2M_rwdata_end - _stext; + boot_info->mods[idx].early_mod->mod_start = virt_to_mfn(_stext); + boot_info->mods[idx].early_mod->mod_end = __2M_rwdata_end - _stext; } boot_info->mods[0].headroom = bzimage_headroom( @@ -1480,9 +1481,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &boot_info->mods[j]; unsigned long size; - size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); + size = PAGE_ALIGN(bm->headroom + bm->early_mod->mod_end); - if ( mod[j].reserved ) + if ( boot_info->mods[j].early_mod->reserved ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1494,14 +1495,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( s < end && (bm->headroom || - ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) + ((end - size) >> PAGE_SHIFT) > bm->early_mod->mod_start) ) { move_memory(end - size + bm->headroom, - (uint64_t)mod[j].mod_start << PAGE_SHIFT, - mod[j].mod_end); - mod[j].mod_start = (end - size) >> PAGE_SHIFT; - mod[j].mod_end += bm->headroom; - mod[j].reserved = 1; + (uint64_t)bm->early_mod->mod_start << PAGE_SHIFT, + bm->early_mod->mod_end); + bm->early_mod->mod_start = (end - size) >> PAGE_SHIFT; + bm->early_mod->mod_end += bm->headroom; + bm->early_mod->reserved = 1; } } @@ -1527,13 +1528,15 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( boot_info->mods[0].headroom && !mod->reserved ) + if ( boot_info->mods[0].headroom && !boot_info->mods[0].early_mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < boot_info->nr_mods; ++i ) { - uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s = (uint64_t)boot_info->mods[i].early_mod->mod_start + << PAGE_SHIFT; - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end)); + reserve_e820_ram(&boot_e820, s, + s + PAGE_ALIGN(boot_info->mods[i].early_mod->mod_end)); } if ( !xen_phys_start ) @@ -1611,8 +1614,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < boot_info->nr_mods; ++j ) { - uint64_t end = pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end = pfn_to_paddr( + boot_info->mods[j].early_mod->mod_start) + + boot_info->mods[j].early_mod->mod_end; if ( map_e < end ) map_e = end; @@ -1686,11 +1690,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < boot_info->nr_mods; ++i ) { - set_pdx_range(mod[i].mod_start, - mod[i].mod_start + PFN_UP(mod[i].mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(mod[i].mod_start), - _mfn(mod[i].mod_start), - PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR); + set_pdx_range(boot_info->mods[i].early_mod->mod_start, + boot_info->mods[i].early_mod->mod_start + + PFN_UP(boot_info->mods[i].early_mod->mod_end)); + map_pages_to_xen( + (unsigned long)mfn_to_virt(boot_info->mods[i].early_mod->mod_start), + _mfn(boot_info->mods[i].early_mod->mod_start), + PFN_UP(boot_info->mods[i].early_mod->mod_end), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC @@ -2081,8 +2087,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(mod, boot_info->mods[0].headroom, - initrdidx < boot_info->nr_mods ? mod + initrdidx : NULL, + dom0 = create_dom0(boot_info->mods[0].early_mod, boot_info->mods[0].headroom, + initrdidx < boot_info->nr_mods ? + boot_info->mods[initrdidx].early_mod : NULL, kextra, boot_info->boot_loader_name); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Fri Aug 30 21:46:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785627 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 10C05CA101A for ; Fri, 30 Aug 2024 21:57:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786836.1196644 (Exim 4.92) (envelope-from ) id 1sk9bx-0001vn-TH; Fri, 30 Aug 2024 21:56:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786836.1196644; Fri, 30 Aug 2024 21:56:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bx-0001v6-NO; Fri, 30 Aug 2024 21:56:53 +0000 Received: by outflank-mailman (input) for mailman id 786836; Fri, 30 Aug 2024 21:56:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9UE-00065G-M1 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:48:54 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a554d6ac-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:48:53 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505446971316.97653174204663; Fri, 30 Aug 2024 14:47:49 -0700 (PDT) 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: a554d6ac-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054471; cv=none; d=zohomail.com; s=zohoarc; b=hHj7CnoyPUwHL2we26yrGRBkLa+C6Tfl+J2xTIeFDxw04Gh5hyGvL8FtkCH0ii1VirKxvnOEd43qMLBka8KNihEdeVAgldD/Vp2yN6/w6EW2O6Tumu/oh7iM9TBaa9q6PqrPzJLE2YydT/ydXLdtkBgT7kkb6Xwyn2PGRzX/PeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054471; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rr9hHCtWc2lrRTZc+Cw5XDkXel6MHlg11c0GsYwyIeY=; b=mJKWP48CQM2TVPXSnpmc6D6RvEmbtJbe/V8AePBbOwTgu5+yBMyl7JC6v6KUqFrTyR3/mUwgO9cZnYus0RHlIje0xZ17e5ew5YOCPybBBmmY/Z+XmnliPkkJvJ2J4OEqBLPd3P/xxzGDrcxgPx/SNVpLrlTjpMbedOmUss0+I7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054471; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Rr9hHCtWc2lrRTZc+Cw5XDkXel6MHlg11c0GsYwyIeY=; b=DzIWdZhCLOVB5scc2EYji95CnsXAZG5GMStqp6sZ5SQqgiHzPD19Pnf8WqC2dXL6 VTmNJqTQfYCb+eb+O0/QC3qrfVzo3r4xxpfDntVkWBTBojXyYItS3nU34BtCQxEIbRi Ul7nGtap4QYWs/4eM6QZ8KVicBxP8FT9R3YvO00w= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , jason.andryuk@amd.com, christopher.w.clark@gmail.com, "Daniel P . Smith" , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 09/44] x86/boot: split bootstrap_map_addr() out of bootstrap_map() Date: Fri, 30 Aug 2024 17:46:54 -0400 Message-Id: <20240830214730.1621-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External From: Andrew Cooper Using an interface based on addresses directly, not modules. No functional change. Signed-off-by: Andrew Cooper Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/setup.h | 1 + xen/arch/x86/setup.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index d75589178b91..15dcb62cb5ac 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -34,6 +34,7 @@ void setup_io_bitmap(struct domain *d); unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); +void *bootstrap_map_addr(uint64_t start, uint64_t end); void *bootstrap_map(const module_t *mod); int remove_xen_ranges(struct rangeset *r); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 82a4375683d2..d4f557b4c50d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -436,24 +436,22 @@ static void __init normalise_cpu_order(void) * Ensure a given physical memory range is present in the bootstrap mappings. * Use superpage mappings to ensure that pagetable memory needn't be allocated. */ -void *__init bootstrap_map(const module_t *mod) +void *__init bootstrap_map_addr(uint64_t start, uint64_t end) { static unsigned long __initdata map_cur = BOOTSTRAP_MAP_BASE; - uint64_t start, end, mask = (1L << L2_PAGETABLE_SHIFT) - 1; + uint64_t mask = (1L << L2_PAGETABLE_SHIFT) - 1; void *ret; if ( system_state != SYS_STATE_early_boot ) - return mod ? mfn_to_virt(mod->mod_start) : NULL; + return end ? maddr_to_virt(start) : NULL; - if ( !mod ) + if ( !end ) { destroy_xen_mappings(BOOTSTRAP_MAP_BASE, BOOTSTRAP_MAP_LIMIT); map_cur = BOOTSTRAP_MAP_BASE; return NULL; } - start = (uint64_t)mod->mod_start << PAGE_SHIFT; - end = start + mod->mod_end; if ( start >= end ) return NULL; @@ -469,6 +467,15 @@ void *__init bootstrap_map(const module_t *mod) return ret; } +void *__init bootstrap_map(const module_t *mod) +{ + if ( !mod ) + return bootstrap_map_addr(0, 0); + + return bootstrap_map_addr(pfn_to_paddr(mod->mod_start), + pfn_to_paddr(mod->mod_start) + mod->mod_end); +} + static void __init move_memory( uint64_t dst, uint64_t src, unsigned int size) { From patchwork Fri Aug 30 21:46:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785615 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 49123CA101B for ; Fri, 30 Aug 2024 21:56:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786759.1196515 (Exim 4.92) (envelope-from ) id 1sk9bS-0002nK-M0; Fri, 30 Aug 2024 21:56:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786759.1196515; Fri, 30 Aug 2024 21:56:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bS-0002kK-CL; Fri, 30 Aug 2024 21:56:22 +0000 Received: by outflank-mailman (input) for mailman id 786759; Fri, 30 Aug 2024 21:56:21 +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 1sk9UM-00065G-PO for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:02 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aa3bf009-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:01 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505447081714.54061475318008; Fri, 30 Aug 2024 14:47:50 -0700 (PDT) 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: aa3bf009-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054472; cv=none; d=zohomail.com; s=zohoarc; b=W+sWhKs2BNLPpb3UGBqNNQ3s/h+I85dvSqj/MVRDT2a5B2IcR6G/dUXEvuH598i1uSjBYpDqoak4a8XnMdVnH33X01k6etUA+eOsvpi92Ye9NyD/uhOrS78rt52nzgJ1guNzH3SDCBUW/KXVVvP4WKpPKt11maAxQQEePsZTXqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054472; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q0pSe2RfpDMnhePm+Qzlz8IPsCD571W7svuapogeYRE=; b=Dr2m674YWJRHRI16wy+9BAmDVULJAzf01TaxRpWrAH+JuvG1KmL3xIPpogks/IgFqgCAojJ17pKTJEhPCZR/GNF9wj/JrS+Ffyoo/SIvsi28vFJPmWULj8MsIT+DpZHSHWVdtBZscxTWlJLre0cRKBTwAOWH3WVjCTIJPe18aQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054472; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Q0pSe2RfpDMnhePm+Qzlz8IPsCD571W7svuapogeYRE=; b=eWCZwr2S5GiGAD7qVm/FCN7HABPeVPVJae/4sfYLd200e0RqIwEMjN1MDQ1mVm3g /K+37OG7ZRnaXJBtMaIHTgK2PhWMFZ9yDctGj4zbjOed6BcJeRcG1VYYbhq1rQJuiHf iQX5dj6JmgNPB4MNOwpOdcOVUvVKOdxqzRsjW6tI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 10/44] x86/boot: introduce boot module types Date: Fri, 30 Aug 2024 17:46:55 -0400 Message-Id: <20240830214730.1621-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This commit introduces module types of xen, kernel, and ramdisk to allow boot module detect code to tag the purpose of a boot module. This reduces the need for hard coded order assumptions and global variables to be used by consumers of boot modules, such as domain construction. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 9 +++++++++ xen/arch/x86/setup.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 3e0e36df096b..1b1b640f83f7 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -11,9 +11,18 @@ #include #include +/* Boot module binary type / purpose */ +enum bootmod_type { + BOOTMOD_UNKNOWN, + BOOTMOD_XEN, + BOOTMOD_KERNEL, + BOOTMOD_RAMDISK, +}; + struct boot_module { module_t *early_mod; unsigned long headroom; + enum bootmod_type type; }; struct boot_info { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d4f557b4c50d..8d5450c981a8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -314,6 +314,7 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) boot_mods[i].early_mod = &mods[i]; /* map the last mb module for xen entry */ + boot_mods[info.nr_mods].type = BOOTMOD_XEN; boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods]; boot_info = &info; @@ -1197,6 +1198,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bitmap_fill(module_map, boot_info->nr_mods); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + boot_info->mods[0].type = BOOTMOD_KERNEL; if ( pvh_boot ) { @@ -2085,6 +2087,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? "" : "not "); initrdidx = find_first_bit(module_map, boot_info->nr_mods); + boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK; if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Fri Aug 30 21:46:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785622 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 CCB46CA101A for ; Fri, 30 Aug 2024 21:56:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786794.1196584 (Exim 4.92) (envelope-from ) id 1sk9bh-0006QF-Q3; Fri, 30 Aug 2024 21:56:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786794.1196584; Fri, 30 Aug 2024 21:56:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bh-0006PL-J6; Fri, 30 Aug 2024 21:56:37 +0000 Received: by outflank-mailman (input) for mailman id 786794; Fri, 30 Aug 2024 21:56:37 +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 1sk9UU-00065G-P4 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:10 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id af0b5679-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:09 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054471893456.85203276225536; Fri, 30 Aug 2024 14:47:51 -0700 (PDT) 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: af0b5679-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054474; cv=none; d=zohomail.com; s=zohoarc; b=lasNya4BFw/XtdtSGjwfRiCwlJ2VNmaP/DFwPqwMxuNlpnFaYBJBhFgki3cfogDxU9wZYf3sUP2yDsT6xSYk7Efsvn+j0zHp59BdR6GcpVpgSjjETUkRpT0qWonoxJ/5mPk6bV0H/C25eSmuy0/Im70MrNAskpaEUf5ZHQ6PKQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054474; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=5tRW/AonFx6PkMudQZ5UfviW7yOCGUwEDitNjDx5cYw=; b=P2RZyBCBWzg0mXe89rpIkcQ59rMsls/HXUJftpwSGUiGPS0zBhrAevJorYsL+HSroAlas1NIBhfkBtsXAvV5LSEo9zqvPkEltsIp1t1HTaDRy/DRO7VaOwsE3LSi+VgN3NW7Z3ESgpgAE0e5L6ObQQSqIaONU0ZjLGzrEvCBtEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054474; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=5tRW/AonFx6PkMudQZ5UfviW7yOCGUwEDitNjDx5cYw=; b=BNiO0Zw2VJ1gTey+LPtH+bszYg/zKQgmqw12d7w3C7FDRgty38trREA9D0XrAzVf e9ushTYSMZsYQnQMMAeh8QBW4teIaKM+qgiPA9Jyp9CLFMc0RFnEVC4Zw/u5nldabKy SUysyMO272fQbZGub475DGGOCmYI4IeMOsVcrA28= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 11/44] x86/boot: introduce boot module flags Date: Fri, 30 Aug 2024 17:46:56 -0400 Message-Id: <20240830214730.1621-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The existing startup code employs various ad-hoc state tracking about certain boot module types by each area of the code. A boot module flags is added to enable tracking these different states. The first state to be transition by this commit is module relocation. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 4 ++++ xen/arch/x86/setup.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 1b1b640f83f7..baf6d74db754 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -23,6 +23,10 @@ struct boot_module { module_t *early_mod; unsigned long headroom; enum bootmod_type type; + + uint32_t flags; +#define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) + }; struct boot_info { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8d5450c981a8..47e4fcc2a8ce 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1377,7 +1377,6 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("Bootloader didn't honor module alignment request\n"); boot_info->mods[i].early_mod->mod_end -= boot_info->mods[i].early_mod->mod_start; boot_info->mods[i].early_mod->mod_start >>= PAGE_SHIFT; - boot_info->mods[i].early_mod->reserved = 0; } /* @@ -1492,7 +1491,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) size = PAGE_ALIGN(bm->headroom + bm->early_mod->mod_end); - if ( boot_info->mods[j].early_mod->reserved ) + if ( boot_info->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1511,7 +1510,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bm->early_mod->mod_end); bm->early_mod->mod_start = (end - size) >> PAGE_SHIFT; bm->early_mod->mod_end += bm->headroom; - bm->early_mod->reserved = 1; + bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1537,7 +1536,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( boot_info->mods[0].headroom && !boot_info->mods[0].early_mod->reserved ) + if ( boot_info->mods[0].headroom && + !(boot_info->mods[0].flags & BOOTMOD_FLAG_X86_RELOCATED) ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < boot_info->nr_mods; ++i ) { From patchwork Fri Aug 30 21:46:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785621 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 EB564CA0EF3 for ; Fri, 30 Aug 2024 21:56:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786796.1196593 (Exim 4.92) (envelope-from ) id 1sk9bj-0006nI-4T; Fri, 30 Aug 2024 21:56:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786796.1196593; Fri, 30 Aug 2024 21:56:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bi-0006lv-V6; Fri, 30 Aug 2024 21:56:38 +0000 Received: by outflank-mailman (input) for mailman id 786796; Fri, 30 Aug 2024 21:56:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Ub-00065G-HM for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:17 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b30bd153-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:16 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054472969909.2016091326745; Fri, 30 Aug 2024 14:47:52 -0700 (PDT) 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: b30bd153-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054475; cv=none; d=zohomail.com; s=zohoarc; b=KUfmCtxNnGmntY9ieNlaQabAEenLPhdpW++jT/YEBx4k5VZcX7A7kJ+4Up2Xell391zbwyXvHuHDIcVKKMHsocxEeo/tzJSvO7PvW6Vx6pVjCq8nFZxjppUoznhZAfzHNVIJCRmz1e6pmDGCrDBDA8JyijGA/By6udcoDG3Wgfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054475; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=hMDag8iJyDBnao+fi0n8bnFwJVAPf0gtfWYWCLly+Do=; b=FulD+ajNsq2Sratk39+2vvEScHrSK04+ijZU34RHXjflMYw4eMszCASSZy3Aren4gYfyXQfxck3QWmKGiGQycaLf6d7cebuWbXv14WPaSoCMwhh3l7PcU1JhPmcMPX1alQO18CeJ/2g1uPDo0/rLdhUSbBlN775TSIXRN063loQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054475; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=hMDag8iJyDBnao+fi0n8bnFwJVAPf0gtfWYWCLly+Do=; b=UsCkLTR/qZ20iBtGI+FDIwx165HevcceSuvREt9dKW8qc097SFWGR8Brzw/EOc8p 20fcveaBonum0QXiLuLdo2CM0bJqUcg2SoxLEc3/kjxyakCcQlT0mx7YPWMdovCKe4C TVO5hh40fPtHPOFqps2fgPL53scx3c/Ak37cn55M= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 12/44] x86/boot: add start and size fields to struct boot_module Date: Fri, 30 Aug 2024 17:46:57 -0400 Message-Id: <20240830214730.1621-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This commit introduces the start and size fields to struct boot_module and adds a corresponding bootstrap mapping function, bootstrap_map_bm. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/include/asm/setup.h | 2 ++ xen/arch/x86/setup.c | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index baf6d74db754..37132afb4e6a 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -27,6 +27,8 @@ struct boot_module { uint32_t flags; #define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) + paddr_t start; + size_t size; }; struct boot_info { diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 15dcb62cb5ac..165ca744ba34 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -2,6 +2,7 @@ #define __X86_SETUP_H_ #include +#include #include extern const char __2M_text_start[], __2M_text_end[]; @@ -36,6 +37,7 @@ unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); void *bootstrap_map_addr(uint64_t start, uint64_t end); void *bootstrap_map(const module_t *mod); +void *bootstrap_map_bm(const struct boot_module *bm); int remove_xen_ranges(struct rangeset *r); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 47e4fcc2a8ce..021c5699f86c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -311,8 +311,13 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) info.mods = boot_mods; for ( i=0; i < info.nr_mods; i++ ) + { boot_mods[i].early_mod = &mods[i]; + boot_mods[i].start = (paddr_t)mods[i].mod_start; + boot_mods[i].size = mods[i].mod_end - mods[i].mod_start; + } + /* map the last mb module for xen entry */ boot_mods[info.nr_mods].type = BOOTMOD_XEN; boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods]; @@ -477,6 +482,14 @@ void *__init bootstrap_map(const module_t *mod) pfn_to_paddr(mod->mod_start) + mod->mod_end); } +void *__init bootstrap_map_bm(const struct boot_module *bm) +{ + if ( !bm ) + return bootstrap_map_addr(0, 0); + + return bootstrap_map_addr(bm->start, bm->start + bm->size); +} + static void __init move_memory( uint64_t dst, uint64_t src, unsigned int size) { From patchwork Fri Aug 30 21:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785626 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 27645CA0EF3 for ; Fri, 30 Aug 2024 21:56:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786823.1196634 (Exim 4.92) (envelope-from ) id 1sk9bs-0000p6-Ky; Fri, 30 Aug 2024 21:56:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786823.1196634; Fri, 30 Aug 2024 21:56:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bs-0000nT-Bf; Fri, 30 Aug 2024 21:56:48 +0000 Received: by outflank-mailman (input) for mailman id 786823; Fri, 30 Aug 2024 21:56:47 +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 1sk9Uh-00065G-SA for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:23 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b6d802c6-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054474029613.6614984690195; Fri, 30 Aug 2024 14:47:54 -0700 (PDT) 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: b6d802c6-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054476; cv=none; d=zohomail.com; s=zohoarc; b=OqXVWMl7VaK78DNscKnrvJshV2lLeRxJIRCTAN5X0CgXklka61qAYSml/8DkGzuOxyD9BvlGER25Ai10Uol2gbB1DsirSLX9l7oCeq9X1wcuYsPJG0mRR106kwAMqpyD6k7vfcFjg0r/mqBJHYOfMEiXIR4ISuVIj/JG6Jb1qYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054476; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=vMlkGiuGcxaWfLc66KQ7uFjoPq32SrNVLlk/N0KOM60=; b=NGq0XhVOBECsmQ6LU85OvMFXVEPB9xNZ1U9G0ZnqmUu7ncfoN53tMnfbcwekmMhp5i08d9AoQkcl3J4IVdlQnkLF5nLqEuy+VrMg8XgEyD1eSfUtfC48BUcGRqDB7Q64hZBOIoZ/wPEPrC4DYrjwso+lM0Ya7t0fOCATB3MwTBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054476; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=vMlkGiuGcxaWfLc66KQ7uFjoPq32SrNVLlk/N0KOM60=; b=Q7/nsgQyLuK3bygbmw0vF7wqJhUdup2FoXX66y36jqPe03uVNLFpT1+U6DdIADwy AlXAp227+zkOpIJHGZc5iqJNQlWpzYH378zrS8RA3hOFL00XsUf1443Pgwh6nyiDl47 mobJUlJlHT9l1yKrNKpCHE7dC6msK/PvbqzkUEcM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 13/44] x86/boot: update struct boot_module on module relocation Date: Fri, 30 Aug 2024 17:46:58 -0400 Message-Id: <20240830214730.1621-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External When a boot module is relocated, ensure struct boot_module start and size fields are updated along with early_mod. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 021c5699f86c..27517d24b2ea 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1408,8 +1408,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - boot_info->mods[idx].early_mod->mod_start = virt_to_mfn(_stext); - boot_info->mods[idx].early_mod->mod_end = __2M_rwdata_end - _stext; + boot_info->mods[idx].start = boot_info->mods[idx].early_mod->mod_start + = virt_to_mfn(_stext); + boot_info->mods[idx].size = boot_info->mods[idx].early_mod->mod_end + = __2M_rwdata_end - _stext; } boot_info->mods[0].headroom = bzimage_headroom( From patchwork Fri Aug 30 21:46:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785617 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 CBEDBCA0EF3 for ; Fri, 30 Aug 2024 21:56:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786760.1196534 (Exim 4.92) (envelope-from ) id 1sk9bW-0003h4-19; Fri, 30 Aug 2024 21:56:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786760.1196534; Fri, 30 Aug 2024 21:56: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 1sk9bV-0003gn-TW; Fri, 30 Aug 2024 21:56:25 +0000 Received: by outflank-mailman (input) for mailman id 786760; Fri, 30 Aug 2024 21:56: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 1sk9Up-00065G-Iu for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:31 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bb685fb0-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054475097108.05435664404672; Fri, 30 Aug 2024 14:47:55 -0700 (PDT) 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: bb685fb0-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054477; cv=none; d=zohomail.com; s=zohoarc; b=d6e5Wiun1gTE7j1u305GpLy+PnGIYCDEeqFN7m+gLdij3t0rEtBwcb3OiCVckj8DTOWRO8qK5H3w0yPnohT1XbpZ28Nj2hA+U6Jn1lP85AtWl8JeuzgXR6vXvqwzx3L23fi75b2hWZevYeThQtaJQvfoHmygabe2rM1PsLFA8Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054477; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=NPlHbwKF+a8HLFZ7J6H7myDoAP2mw8XIrCc9sG0+8Xw=; b=drgHp7d0UZBIxKvtKXmu5vBs1jw/dBMIELB7R0JMq5GXeohFfAp6EVjmTZtGO5ajvoCmaGr0ngBlMMUcR9uiFMwpD3Ob/hMKrwY2XZTe2u+0ABkf6NVu0EeIdyHsbPO899lLcKcDWEFJsPfUGm+W8fF89KDXkM/Q+sFA8Qkf0xw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054477; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=NPlHbwKF+a8HLFZ7J6H7myDoAP2mw8XIrCc9sG0+8Xw=; b=ZrHpK9XluX96/QQzpIf4M+PhnWfXDiEKHA0xQyvs2MQ/jR+FbgSPkKfdyw+YExhC U49/hNB7GSPsEhI9EdfRNwr5hQjSs9TN7gYC5kKmB357anBhPjZpF0dH40sDduEdarY MwRtC/UxlQPO6ASsQzl7jXJGntqeflL2/IYAM4Ek= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 14/44] x86/boot: transition relocation calculations to struct boot_module Date: Fri, 30 Aug 2024 17:46:59 -0400 Message-Id: <20240830214730.1621-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Use struct boot_module fields, start and size, when calculating the relocation address and size. It also ensures that early_mod references are kept in sync. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 27517d24b2ea..0b6bde9ce7e3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1504,7 +1504,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &boot_info->mods[j]; unsigned long size; - size = PAGE_ALIGN(bm->headroom + bm->early_mod->mod_end); + size = PAGE_ALIGN(bm->headroom + bm->size); if ( boot_info->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; @@ -1518,13 +1518,12 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( s < end && (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->early_mod->mod_start) ) + paddr_to_pfn(end - size) > paddr_to_pfn(bm->start)) ) { - move_memory(end - size + bm->headroom, - (uint64_t)bm->early_mod->mod_start << PAGE_SHIFT, - bm->early_mod->mod_end); - bm->early_mod->mod_start = (end - size) >> PAGE_SHIFT; - bm->early_mod->mod_end += bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size); + bm->start = (end - size); + bm->early_mod->mod_start = paddr_to_pfn(bm->start); + bm->size = bm->early_mod->mod_end += bm->headroom; bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1556,11 +1555,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < boot_info->nr_mods; ++i ) { - uint64_t s = (uint64_t)boot_info->mods[i].early_mod->mod_start - << PAGE_SHIFT; + uint64_t s = (uint64_t)boot_info->mods[i].start; reserve_e820_ram(&boot_e820, s, - s + PAGE_ALIGN(boot_info->mods[i].early_mod->mod_end)); + s + PAGE_ALIGN(boot_info->mods[i].size)); } if ( !xen_phys_start ) @@ -1638,9 +1636,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < boot_info->nr_mods; ++j ) { - uint64_t end = pfn_to_paddr( - boot_info->mods[j].early_mod->mod_start) + - boot_info->mods[j].early_mod->mod_end; + uint64_t end = boot_info->mods[j].start + + boot_info->mods[j].size; if ( map_e < end ) map_e = end; @@ -1714,13 +1711,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < boot_info->nr_mods; ++i ) { - set_pdx_range(boot_info->mods[i].early_mod->mod_start, - boot_info->mods[i].early_mod->mod_start + + set_pdx_range(paddr_to_pfn(boot_info->mods[i].start), + paddr_to_pfn(boot_info->mods[i].start) + PFN_UP(boot_info->mods[i].early_mod->mod_end)); map_pages_to_xen( - (unsigned long)mfn_to_virt(boot_info->mods[i].early_mod->mod_start), - _mfn(boot_info->mods[i].early_mod->mod_start), - PFN_UP(boot_info->mods[i].early_mod->mod_end), PAGE_HYPERVISOR); + (unsigned long)maddr_to_virt(boot_info->mods[i].start), + maddr_to_mfn(boot_info->mods[i].start), + PFN_UP(boot_info->mods[i].size), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC From patchwork Fri Aug 30 21:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785611 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 0BC10CA101B for ; Fri, 30 Aug 2024 21:56:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786749.1196494 (Exim 4.92) (envelope-from ) id 1sk9bK-0001Nh-Ie; Fri, 30 Aug 2024 21:56:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786749.1196494; Fri, 30 Aug 2024 21:56:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bK-0001Mg-Ey; Fri, 30 Aug 2024 21:56:14 +0000 Received: by outflank-mailman (input) for mailman id 786749; Fri, 30 Aug 2024 21:56:12 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Ux-00065G-IL for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:39 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c03a5813-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505447615751.84400849252813; Fri, 30 Aug 2024 14:47:56 -0700 (PDT) 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: c03a5813-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054478; cv=none; d=zohomail.com; s=zohoarc; b=RIu98M/WjNAwh4rLsJQmTFkd35kOFhff7JsaX/iK85SOqYY06ORXt/xFUWNEvlfh6B33v14uU7wQz6RwFPxR+TsHQfMFpJzQERPfT+dHhWetGnaeZBYtDa4GupoykX4+Z/XHdvHyIE2bhywkPHXlc/eUGyXH7KxA8h5CnwqrVsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054478; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=GvFaYALw+a+2+o8Vrk1YWy2xkmV+m8u1BbaORy59Yw0=; b=J5g2d2wowLdc3DYvH5cYpHNrxOw4dfexDFJ4GFVcWQZtEIdFwfxKhnrUKUeVvwP44Z7wcgwkdz8JCg31zLLK9Iya309wWL+KiLhsgBsmfxzt2xmkTwo+FKdHFQdcREsn/2tkBUFU9szTVCyK1dM9FX9F3RJPpx5N7VHDrIaSuCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054478; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=GvFaYALw+a+2+o8Vrk1YWy2xkmV+m8u1BbaORy59Yw0=; b=lVdd8f1HD9/Y6RqiitV5mlXw/b1xDdSLSvKtBcHfn9Mb3XIf3q1E6nW3TZ7OYd8G VEchoyyGW9DgTYbXTT9g4gLSzIvt+Xw3ojzCKmH635rsyuJCPj796vDkYYUxRCKVr3B xKcMW/AU/AYNtK5HB6JTcisTFAfDuYjONcwbzWhQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 15/44] x86/boot: introduce boot module interator Date: Fri, 30 Aug 2024 17:47:00 -0400 Message-Id: <20240830214730.1621-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Provide an iterator to go through boot module array searching based on type. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 37132afb4e6a..99f8c9b83b25 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -42,8 +42,24 @@ struct boot_info { uint32_t mmap_length; }; -#endif +static inline int __init next_boot_module_index( + const struct boot_info *bi, enum bootmod_type t, int offset) +{ + int i; + + for ( i = offset; i < bi->nr_mods; i++ ) + { + if ( bi->mods[i].type == t ) + return i; + } + + return -1; +} +#define first_boot_module_index(bi, t) \ + next_boot_module_index(bi, t, 0) + +#endif /* * Local variables: * mode: C From patchwork Fri Aug 30 21:47:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785618 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 E7B8ACA101A for ; Fri, 30 Aug 2024 21:56:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786770.1196554 (Exim 4.92) (envelope-from ) id 1sk9bZ-0004WM-34; Fri, 30 Aug 2024 21:56:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786770.1196554; Fri, 30 Aug 2024 21:56: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 1sk9bY-0004Vz-SQ; Fri, 30 Aug 2024 21:56:28 +0000 Received: by outflank-mailman (input) for mailman id 786770; Fri, 30 Aug 2024 21:56:27 +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 1sk9V4-00065G-Cw for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:46 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c4583564-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:45 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054477221407.77333741442715; Fri, 30 Aug 2024 14:47:57 -0700 (PDT) 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: c4583564-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054479; cv=none; d=zohomail.com; s=zohoarc; b=Ru3p5X5v6TlDJEMWI+9LyYX324Xjv8m84ceJlv3IYp+7xQzTqB/gdRUrXVNf6MFRUQok2KtkRl0zCj0kzNQJuhfKPwvXF9dOMLPtrz0oAy+QeIbYkSPshMJoxPWxAKM9HKF1/rLZlGV2SMRDdZo+RYyEP9ECLLymkgau2zf6bAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054479; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=bVRjWgn0rJXMNoedI0B0emnthNEBUMt5tP4JhrqFCck=; b=PoQmeXORo1oDLnmlw1vnvJyFufOxxOybxKsklwFZN730rSXEQ6rEE98TEymWkStYuD+Cl/wgsTAFFX3eP5c94pZuY+VhSS2vWYeF9KVEjsE/F2fIzVhutZ5JIdzbjkiNApzQTzgVDcrxvMyP8EmLhLHE9a44cqO+si9ILezEWi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054479; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=bVRjWgn0rJXMNoedI0B0emnthNEBUMt5tP4JhrqFCck=; b=d75Ha3abZDe4oPlyicA6qJ2en6+xikcXvyGnaiCzezvMag0Y8fSQyflJRJesYTxd qOLkUE2Fukh2HCjJMkHpl/XybwFizBZuF8AGBv7IrqEsDIhizSCz0i28Amfo4Zgwdn5 7yF4NBqr5n1v+OSjEbaRc9/chi1Oy2h/7iqCZtoE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 16/44] x86/boot: introduce consumed flag for struct boot_module Date: Fri, 30 Aug 2024 17:47:01 -0400 Message-Id: <20240830214730.1621-17-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Allow the tracking of when a boot module has been consumed by a handler in the hypervisor independent of when it is claimed. The instances where the hypervisor does nothing beyond claiming, the dom0 kernel, dom0 ramdisk, and a placeholder for itself, are updated as being consumed at the time of being claimed. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 99f8c9b83b25..740308693629 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -26,6 +26,7 @@ struct boot_module { uint32_t flags; #define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) +#define BOOTMOD_FLAG_X86_CONSUMED (1U << 1) paddr_t start; size_t size; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0b6bde9ce7e3..da75dfce083d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -320,6 +320,7 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) /* map the last mb module for xen entry */ boot_mods[info.nr_mods].type = BOOTMOD_XEN; + boot_mods[info.nr_mods].flags |= BOOTMOD_FLAG_X86_CONSUMED; boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods]; boot_info = &info; @@ -1212,6 +1213,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bitmap_fill(module_map, boot_info->nr_mods); __clear_bit(0, module_map); /* Dom0 kernel is always first */ boot_info->mods[0].type = BOOTMOD_KERNEL; + boot_info->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; if ( pvh_boot ) { @@ -2100,6 +2102,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) initrdidx = find_first_bit(module_map, boot_info->nr_mods); boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK; + boot_info->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Fri Aug 30 21:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785620 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 D5D32CA101A for ; Fri, 30 Aug 2024 21:56:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786778.1196574 (Exim 4.92) (envelope-from ) id 1sk9bd-0005SW-09; Fri, 30 Aug 2024 21:56:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786778.1196574; Fri, 30 Aug 2024 21:56: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 1sk9bc-0005SC-Q0; Fri, 30 Aug 2024 21:56:32 +0000 Received: by outflank-mailman (input) for mailman id 786778; Fri, 30 Aug 2024 21:56:31 +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 1sk9VB-00065G-Hn for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:49:53 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c894741f-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:49:52 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054478301324.8472500488509; Fri, 30 Aug 2024 14:47:58 -0700 (PDT) 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: c894741f-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054480; cv=none; d=zohomail.com; s=zohoarc; b=aHPpeIVNL0p7qiPf3/PYT+YdR6pGnPsfotpzxAxe9GUrjvMnDEtSTs4Dk7hTqj5wy3JyImccl2jqZR1xratTWf8HWFUK+p8kdn8bt6PapBN9+LUIF0dzdjZ5D8plYKrSzXWUwRnbjgOp9UvYGyUzJbjaWvoJyDiCqhCVXOb17uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054480; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=kpui6t02X83Vt5ycf0OvPFAWFtuSlnhdgDe57IspVC4=; b=OCoZcvqymaIice8IHgu574wZY7TeKr1nbbVPrk7vxy4EqMBByu+A6/LA19hgJkc9F4KrZyOAMpSR/VYLlGNWe6X6UJnEtIMWJ122jphDwZR90nyrXwb0RB1KqeRWvO1mJueAZdT3ZKUaWNWw76O4ipQWjZobTMYNy14SXtvSS00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054480; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=kpui6t02X83Vt5ycf0OvPFAWFtuSlnhdgDe57IspVC4=; b=asyp2iG7GLWIyAHoBvsqrdEJxpqLGDn8v/EQGypHao6+NgVAPgY9HEf/WtRcea/A La6bCLcPWupK4OAoTQKQ5isgBTlaNw5y9Mtjx8N6n6ngvm17DlAWKtw7K2W6ux5SqB7 4HSImcYDn9PusSujYjI4tl2gg/TdPeVZ/2vacvPg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 17/44] x86/boot: convert microcode loading to consume struct boot_info Date: Fri, 30 Aug 2024 17:47:02 -0400 Message-Id: <20240830214730.1621-18-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Convert the microcode loading functions to take struct boot_info, and then using struct boot_module to map and check for microcode. To keep the changes focused, continue using the struct mod to hold the reference to the microcode that is used by the late microcode logic. Signed-off-by: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 37 +++++++++++++--------------- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/include/asm/microcode.h | 14 ++++++----- xen/arch/x86/setup.c | 4 +-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 8a9e744489b9..653a725173ba 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -152,10 +153,8 @@ static int __init cf_check parse_ucode(const char *s) custom_param("ucode", parse_ucode); static void __init microcode_scan_module( - unsigned long *module_map, - const multiboot_info_t *mbi) + unsigned long *module_map, const struct boot_info *bi) { - module_t *mod = (module_t *)__va(mbi->mods_addr); uint64_t *_blob_start; unsigned long _blob_size; struct cpio_data cd; @@ -177,16 +176,16 @@ static void __init microcode_scan_module( /* * Try all modules and see whichever could be the microcode blob. */ - for ( i = 1 /* Ignore dom0 kernel */; i < mbi->mods_count; i++ ) + for ( i = 1 /* Ignore dom0 kernel */; i < bi->nr_mods; i++ ) { if ( !test_bit(i, module_map) ) continue; - _blob_start = bootstrap_map(&mod[i]); - _blob_size = mod[i].mod_end; + _blob_start = bootstrap_map_bm(&bi->mods[i]); + _blob_size = bi->mods[i].size; if ( !_blob_start ) { - printk("Could not map multiboot module #%d (size: %ld)\n", + printk("Could not map boot module #%d (size: %ld)\n", i, _blob_size); continue; } @@ -204,20 +203,18 @@ static void __init microcode_scan_module( } static void __init microcode_grab_module( - unsigned long *module_map, - const multiboot_info_t *mbi) + unsigned long *module_map, const struct boot_info *bi) { - module_t *mod = (module_t *)__va(mbi->mods_addr); - if ( ucode_mod_idx < 0 ) - ucode_mod_idx += mbi->mods_count; - if ( ucode_mod_idx <= 0 || ucode_mod_idx >= mbi->mods_count || + ucode_mod_idx += bi->nr_mods; + if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_mods || !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; - ucode_mod = mod[ucode_mod_idx]; + bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; + ucode_mod = *bi->mods[ucode_mod_idx].early_mod; scan: if ( ucode_scan ) - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); } static struct microcode_ops __ro_after_init ucode_ops; @@ -805,8 +802,8 @@ static int __init early_update_cache(const void *data, size_t len) return rc; } -int __init microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init microcode_init_cache( + unsigned long *module_map, const struct boot_info *bi) { int rc = 0; @@ -815,7 +812,7 @@ int __init microcode_init_cache(unsigned long *module_map, if ( ucode_scan ) /* Need to rescan the modules because they might have been relocated */ - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); if ( ucode_mod.mod_end ) rc = early_update_cache(bootstrap_map(&ucode_mod), @@ -862,7 +859,7 @@ static int __init early_microcode_update_cpu(void) } int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) + const struct boot_info *bi) { const struct cpuinfo_x86 *c = &boot_cpu_data; int rc = 0; @@ -905,7 +902,7 @@ int __init early_microcode_init(unsigned long *module_map, return -ENODEV; } - microcode_grab_module(module_map, mbi); + microcode_grab_module(module_map, bi); if ( ucode_mod.mod_end || ucode_blob.size ) rc = early_microcode_update_cpu(); diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 740308693629..1cef48457c66 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -17,6 +17,7 @@ enum bootmod_type { BOOTMOD_XEN, BOOTMOD_KERNEL, BOOTMOD_RAMDISK, + BOOTMOD_MICROCODE, }; struct boot_module { diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/asm/microcode.h index 57c08205d475..02fdb56bb82b 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -4,6 +4,8 @@ #include #include +#include + #include struct multiboot_info; @@ -22,12 +24,12 @@ struct cpu_signature { DECLARE_PER_CPU(struct cpu_signature, cpu_sig); void microcode_set_module(unsigned int idx); -int microcode_update(XEN_GUEST_HANDLE(const_void) buf, - unsigned long len, unsigned int flags); -int early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi); -int microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi); +int microcode_update( + XEN_GUEST_HANDLE(const_void) buf, unsigned long len, unsigned int flags); +int early_microcode_init( + unsigned long *module_map, const struct boot_info *bi); +int microcode_init_cache( + unsigned long *module_map, const struct boot_info *bi); int microcode_update_one(void); #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index da75dfce083d..6495ab393576 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1398,7 +1398,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * TODO: load ucode earlier once multiboot modules become accessible * at an earlier stage. */ - early_microcode_init(module_map, mbi); + early_microcode_init(module_map, boot_info); if ( xen_phys_start ) { @@ -1952,7 +1952,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) timer_init(); - microcode_init_cache(module_map, mbi); /* Needs xmalloc() */ + microcode_init_cache(module_map, boot_info); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Fri Aug 30 21:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785595 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 5D0EECA101A for ; Fri, 30 Aug 2024 21:50:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786687.1196335 (Exim 4.92) (envelope-from ) id 1sk9VM-0000tj-0D; Fri, 30 Aug 2024 21:50:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786687.1196335; Fri, 30 Aug 2024 21:50:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9VL-0000t8-QH; Fri, 30 Aug 2024 21:50:03 +0000 Received: by outflank-mailman (input) for mailman id 786687; Fri, 30 Aug 2024 21:50:02 +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 1sk9VK-0000Zf-8u for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:02 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cd2154f2-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:50:00 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054479373585.778896678308; Fri, 30 Aug 2024 14:47:59 -0700 (PDT) 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: cd2154f2-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054481; cv=none; d=zohomail.com; s=zohoarc; b=FEGmLK6fu+9wYmYqWZCJ3D208mCbv5w+ovSDVze+c93yVuEgwNzEFii9v59Wx5bpIEEMGUgbHjCAdvfj7aNsUmqk2mOtCqz97RxBYjVJmYp09LSaPwrUzP9kJ3xhNB6cS8sJxCePDWzNOQhqaJ0di9OUGRr3dUsi0tg8FaKN3Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054481; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=x7EA1HjwHFmnd4GnZ7Gub2RJOomQt0q62OXf51BcXpM=; b=VTWhRAdCMXgT8oyOCjAtvVXa52eqKZG3JRjIxN7XwVgt7uj7MIzsvWHQpT26VvERP+105AzH6hlMz+/vDnTZO/x1BqPi//6ndjGHYzLmzswtQbWPzlnXocPsG+uKw8NLffuyZBnHLfAQ/0Qdex4AZeMhpaw7GPRK8OAxdCz8fIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054481; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=x7EA1HjwHFmnd4GnZ7Gub2RJOomQt0q62OXf51BcXpM=; b=pSth6LFRIXPSZKfgsmM1u9uCXbxqB+1eHdVwKjkXPw+NDTySyaXzTiji8PL5zIyr vro1JEqgTsOTLFlxGB0xBSEvQQsdASY1ErOql689Syj+lq3sch1gJ2Aim2iZy47/eCZ BuzKKeWDSuwqp02/CvQHW4cdaGGTaVthiIpWXFBo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 18/44] x86/boot: convert late microcode loading to struct boot_module Date: Fri, 30 Aug 2024 17:47:03 -0400 Message-Id: <20240830214730.1621-19-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Remove the use of struct mod to hold the reference for the microcode, converting the code to work with a struct boot_module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 653a725173ba..cedb03beea54 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +58,7 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 -static module_t __initdata ucode_mod; +static struct boot_module __initdata ucode_mod; static signed int __initdata ucode_mod_idx; static bool __initdata ucode_mod_forced; static unsigned int nr_cores; @@ -93,7 +92,7 @@ struct ucode_mod_blob { static struct ucode_mod_blob __initdata ucode_blob; /* - * By default we will NOT parse the multiboot modules to see if there is + * By default we will NOT parse the boot modules to see if there is * cpio image with the microcode images. */ static bool __initdata ucode_scan; @@ -198,7 +197,7 @@ static void __init microcode_scan_module( ucode_blob.data = cd.data; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } } @@ -211,7 +210,7 @@ static void __init microcode_grab_module( !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; - ucode_mod = *bi->mods[ucode_mod_idx].early_mod; + ucode_mod = bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) microcode_scan_module(module_map, bi); @@ -749,14 +748,14 @@ static int __init cf_check microcode_init(void) */ if ( ucode_blob.size ) { - bootstrap_map(NULL); + bootstrap_map_bm(NULL); ucode_blob.size = 0; ucode_blob.data = NULL; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - bootstrap_map(NULL); - ucode_mod.mod_end = 0; + bootstrap_map_bm(NULL); + ucode_mod.size = 0; } return 0; @@ -814,9 +813,9 @@ int __init microcode_init_cache( /* Need to rescan the modules because they might have been relocated */ microcode_scan_module(module_map, bi); - if ( ucode_mod.mod_end ) - rc = early_update_cache(bootstrap_map(&ucode_mod), - ucode_mod.mod_end); + if ( ucode_mod.size ) + rc = early_update_cache(bootstrap_map_bm(&ucode_mod), + ucode_mod.size); else if ( ucode_blob.size ) rc = early_update_cache(ucode_blob.data, ucode_blob.size); @@ -835,10 +834,10 @@ static int __init early_microcode_update_cpu(void) len = ucode_blob.size; data = ucode_blob.data; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - len = ucode_mod.mod_end; - data = bootstrap_map(&ucode_mod); + len = ucode_mod.size; + data = bootstrap_map_bm(&ucode_mod); } if ( !data ) @@ -904,7 +903,7 @@ int __init early_microcode_init(unsigned long *module_map, microcode_grab_module(module_map, bi); - if ( ucode_mod.mod_end || ucode_blob.size ) + if ( ucode_mod.size || ucode_blob.size ) rc = early_microcode_update_cpu(); /* From patchwork Fri Aug 30 21:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785596 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 47C8BCA101A for ; Fri, 30 Aug 2024 21:50:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786688.1196344 (Exim 4.92) (envelope-from ) id 1sk9VS-0001bx-5C; Fri, 30 Aug 2024 21:50:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786688.1196344; Fri, 30 Aug 2024 21:50:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9VS-0001bq-2Y; Fri, 30 Aug 2024 21:50:10 +0000 Received: by outflank-mailman (input) for mailman id 786688; Fri, 30 Aug 2024 21:50:09 +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 1sk9VR-0000Zf-FW for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:09 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d1d1e673-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:50:07 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505448043769.83491652747614; Fri, 30 Aug 2024 14:48:00 -0700 (PDT) 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: d1d1e673-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054482; cv=none; d=zohomail.com; s=zohoarc; b=XTnfnMMm4v6l8bgXkrImzcmzW4zs0WOeye4Wvyn/3qtPDFmtYslJfbzmsHztcRJrBrXcUdp8HkyNIxuXbyT6L6h5ZRs80F8cn2GJBR1F/wlCulfd042UqUvOqfSMaIt3jtqczW34RQ0BpB+IcoVlZ6k9S8z5j9tjtdAsa92owW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054482; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=LvQN4/ZeUGHQXB1oFQeKAxyDBFEc9pZ1Jq2e0h2a0EA=; b=PwZwn/ShaCUjoquhIDwC/pWauonn6EskybZSDF0kJECtc4ykfm8siRTP2Hu7yuBVPejf15P6bJKNFHopZdLQZiiTrUjFaUij77/nGSR2yjIKVgj5uh0iMmucnKSUfJVZGdnQycXXReNKz+e8i6sBiu8gvAvTIxYDuTqdoxV4xzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054482; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=LvQN4/ZeUGHQXB1oFQeKAxyDBFEc9pZ1Jq2e0h2a0EA=; b=W/Gl4cgwewEQRRVLEyJntP9FHXJtsY8Bg50wNRAiItjTUSUQ4QV4d/aJmgozlJdt 2pUEavy2UhYy5r/kroq/mqALqBSw4r2+wFArYhplNMjL4QjZWsNJRWSEuwexTL3ESRe fGvhnScPUX3CVOece3XxRKakOQrReni3BC+MSiB0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 19/44] x86/boot: use consumed boot module flag for microcode Date: Fri, 30 Aug 2024 17:47:04 -0400 Message-Id: <20240830214730.1621-20-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External To track if the microcode boot module was loaded, a copy of the boot module is kept. The size element of this copy is set to zero as the indicator that the microcode was loaded. A side effect is that the modules have to be rescanned to find the boot module post-relocation, so the cache copy can be created. Use the consumed boot module flag to track the loading of the microcode boot module. This removes the need to manipulate the boot module size element, no longer requiring the copy, thus allowing it to be replaced by a reference. As a result it is no longer necessary to rescan the boot modules after relocation has occurred. Signed-off-by: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index cedb03beea54..83dd8bbe9fb1 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -58,7 +58,7 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 -static struct boot_module __initdata ucode_mod; +static struct boot_module __initdata *ucode_mod; static signed int __initdata ucode_mod_idx; static bool __initdata ucode_mod_forced; static unsigned int nr_cores; @@ -210,7 +210,7 @@ static void __init microcode_grab_module( !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; - ucode_mod = bi->mods[ucode_mod_idx]; + ucode_mod = &bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) microcode_scan_module(module_map, bi); @@ -752,10 +752,10 @@ static int __init cf_check microcode_init(void) ucode_blob.size = 0; ucode_blob.data = NULL; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED) ) { bootstrap_map_bm(NULL); - ucode_mod.size = 0; + ucode_mod->flags |= BOOTMOD_FLAG_X86_CONSUMED; } return 0; @@ -809,14 +809,14 @@ int __init microcode_init_cache( if ( !ucode_ops.apply_microcode ) return -ENODEV; - if ( ucode_scan ) - /* Need to rescan the modules because they might have been relocated */ + /* Scan if microcode was not detected earlier */ + if ( !ucode_mod ) microcode_scan_module(module_map, bi); - if ( ucode_mod.size ) - rc = early_update_cache(bootstrap_map_bm(&ucode_mod), - ucode_mod.size); - else if ( ucode_blob.size ) + if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED) ) + rc = early_update_cache(bootstrap_map_bm(ucode_mod), + ucode_mod->size); + else if ( ucode_mod && ucode_blob.size ) rc = early_update_cache(ucode_blob.data, ucode_blob.size); return rc; @@ -834,10 +834,10 @@ static int __init early_microcode_update_cpu(void) len = ucode_blob.size; data = ucode_blob.data; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED) ) { - len = ucode_mod.size; - data = bootstrap_map_bm(&ucode_mod); + len = ucode_mod->size; + data = bootstrap_map_bm(ucode_mod); } if ( !data ) @@ -903,7 +903,7 @@ int __init early_microcode_init(unsigned long *module_map, microcode_grab_module(module_map, bi); - if ( ucode_mod.size || ucode_blob.size ) + if ( ucode_mod || ucode_blob.size ) rc = early_microcode_update_cpu(); /* From patchwork Fri Aug 30 21:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785597 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 EEC03CA101A for ; Fri, 30 Aug 2024 21:50:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786690.1196354 (Exim 4.92) (envelope-from ) id 1sk9Va-00022c-Bu; Fri, 30 Aug 2024 21:50:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786690.1196354; Fri, 30 Aug 2024 21:50:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Va-00022U-8f; Fri, 30 Aug 2024 21:50:18 +0000 Received: by outflank-mailman (input) for mailman id 786690; Fri, 30 Aug 2024 21:50:17 +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 1sk9VZ-0000Zf-3p for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:17 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d62f24fe-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:50:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054481581187.92876924816562; Fri, 30 Aug 2024 14:48:01 -0700 (PDT) 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: d62f24fe-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054483; cv=none; d=zohomail.com; s=zohoarc; b=MImAxhfwNPeS3w8pWcKg4XRtc6oggkouWyA+B/FXA+UfZHI5QNwG88fQIgbAVE4DgNVLQGltY3LuT4QqILVlht22rkpTdj6mMO4jhPzdVSaXjs+qKhsuGVhW+KC5tqCbwR0+gzwwb21AqlKClpkSY/4easU3xmNdiN0oIOrSPXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054483; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=HBuvBxLu0927SlqbG8RcjS/3s6UZxSTS/pkLGNBX224=; b=Q7BjRw5S14bOAYEyGSFlzxeebkGQJecgUnPtlDQuIOluyU6LMt+UJM51CsScplaQZLcxl17Ya3N+qBBe9VFmzZoB4mgCQ/maSLrSZ9ywYYPpFBY2nf8jbmA3yJeNRqxEQOOHKUrzkTpxzkZU0g33j2lnPHAFsBuR47VUxHtR0NM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054483; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=HBuvBxLu0927SlqbG8RcjS/3s6UZxSTS/pkLGNBX224=; b=aVD2dDfuU1kn0SnndaUHLfFEXQNIof6L+lN7Z97oJQI1DViGz+HiERFQ3I5JoPXv JYUUKI0v6VU1/YITg0yn/n5Fqlo+BqGOK4ooymMWQoY5vsk/uLeXavzfzuIJydYk7U9 XzTy9BZo+dlFeId/fJGhZH89euiM0sZyJTzasB8g= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 20/44] x86/boot: convert xsm policy loading to struct boot_module Date: Fri, 30 Aug 2024 17:47:05 -0400 Message-Id: <20240830214730.1621-21-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Iterate through the unclaimed struct boot_module to see if any are an XSM FLASK policy. If one is located, mark it as an xsm policy. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 11 +++++++---- xen/xsm/xsm_core.c | 13 +++++++++++-- xen/xsm/xsm_policy.c | 15 ++++++++------- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 1cef48457c66..1a325f66b3ba 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -18,6 +18,7 @@ enum bootmod_type { BOOTMOD_KERNEL, BOOTMOD_RAMDISK, BOOTMOD_MICROCODE, + BOOTMOD_XSM_POLICY, }; struct boot_module { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6495ab393576..28b39d23f644 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1878,7 +1878,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges = rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); - xsm_multiboot_init(module_map, mbi); + xsm_multiboot_init(module_map, boot_info); /* * IOMMU-related ACPI table parsing may require some of the system domains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 627c0d2731af..9e511ef8878c 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -17,7 +17,10 @@ #include #include -#include + +#ifdef CONFIG_MULTIBOOT +#include +#endif /* policy magic number (defined by XSM_MAGIC) */ typedef uint32_t xsm_magic_t; @@ -779,9 +782,9 @@ static inline int xsm_argo_send(const struct domain *d, const struct domain *t) #ifdef CONFIG_MULTIBOOT int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi); + unsigned long *module_map, const struct boot_info *bi); int xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, + unsigned long *module_map, const struct boot_info *bi, void **policy_buffer, size_t *policy_size); #endif @@ -829,7 +832,7 @@ static const inline struct xsm_ops *silo_init(void) #ifdef CONFIG_MULTIBOOT static inline int xsm_multiboot_init ( - unsigned long *module_map, const multiboot_info_t *mbi) + unsigned long *module_map, const struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index eaa028109bde..9f87ec4f6754 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -21,6 +21,7 @@ #ifdef CONFIG_XSM #ifdef CONFIG_MULTIBOOT +#include #include #endif @@ -140,7 +141,7 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi) + unsigned long *module_map, const struct boot_info *bi) { int ret = 0; void *policy_buffer = NULL; @@ -150,7 +151,7 @@ int __init xsm_multiboot_init( if ( XSM_MAGIC ) { - ret = xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, + ret = xsm_multiboot_policy_init(module_map, bi, &policy_buffer, &policy_size); if ( ret ) { @@ -161,6 +162,14 @@ int __init xsm_multiboot_init( } ret = xsm_core_init(policy_buffer, policy_size); + if ( ret == 0 ) + { + int idx = first_boot_module_index(bi, BOOTMOD_XSM_POLICY); + + /* If the policy was loaded from a boot module, mark it consumed */ + if ( idx >= 0 ) + bi->mods[idx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + } bootstrap_map(NULL); return 0; diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc93810f..e4c94afd108d 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -21,6 +21,7 @@ #include #ifdef CONFIG_MULTIBOOT #include +#include #include #endif #include @@ -31,11 +32,10 @@ #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, + unsigned long *module_map, const struct boot_info *bi, void **policy_buffer, size_t *policy_size) { int i; - module_t *mod = (module_t *)__va(mbi->mods_addr); int rc = 0; u32 *_policy_start; unsigned long _policy_len; @@ -44,13 +44,13 @@ int __init xsm_multiboot_policy_init( * Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. */ - for ( i = mbi->mods_count-1; i >= 1; i-- ) + for ( i = bi->nr_mods-1; i >= 1; i-- ) { - if ( !test_bit(i, module_map) ) + if ( bi->mods[i].type != BOOTMOD_UNKNOWN ) continue; - _policy_start = bootstrap_map(mod + i); - _policy_len = mod[i].mod_end; + _policy_start = bootstrap_map_bm(&bi->mods[i]); + _policy_len = bi->mods[i].size; if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC ) { @@ -61,11 +61,12 @@ int __init xsm_multiboot_policy_init( _policy_len,_policy_start); __clear_bit(i, module_map); + bi->mods[i].type = BOOTMOD_XSM_POLICY; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } return rc; From patchwork Fri Aug 30 21:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785598 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 32162CA101A for ; Fri, 30 Aug 2024 21:50:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786695.1196363 (Exim 4.92) (envelope-from ) id 1sk9Vi-0002Ta-Kv; Fri, 30 Aug 2024 21:50:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786695.1196363; Fri, 30 Aug 2024 21:50: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 1sk9Vi-0002Sx-HO; Fri, 30 Aug 2024 21:50:26 +0000 Received: by outflank-mailman (input) for mailman id 786695; Fri, 30 Aug 2024 21:50:25 +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 1sk9Vh-0000Zf-8P for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:25 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id db15f88e-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:50:23 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054482625863.6026282912172; Fri, 30 Aug 2024 14:48:02 -0700 (PDT) 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: db15f88e-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054484; cv=none; d=zohomail.com; s=zohoarc; b=ZpQugvle45rdXeAfWV4kID5LyxhjVsZlWkEtcWbbKHNTJ6+e9VOPH12tT2oLZN5emnI68vHZva7ndgNSiupWfe4RHjHJzhnNkfGgXFTXr3Fiqyq6rOWIOl3zQ26SbwSixa9Ba4ih70XLObXQ/rN4tIKy9GBpoV06Yg1kkOyJy+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054484; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=eet/JYMlrz1AXMqNeYAuxYWhlWnTzhzkBPRDYkxgQbw=; b=Q0HBGubFwAyK2Z2xulPWBWP9X2bwB3YDmZvqXYGhleo6vL37DEs3hAKcMmC8HNLWKnOHtddDHsGFwHW1Xtpyb7O8Dr8kjaZlFj1hzSVOIRnwcAjbLC2/jgYX7cDRyS7dLYw0hKJCQQDQ6jok50SS5VfHX/+aNOKEvMOmxqbn9mo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054484; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=eet/JYMlrz1AXMqNeYAuxYWhlWnTzhzkBPRDYkxgQbw=; b=oIpDnyve5SvNNVceia88lUtSdHiR3zWs3MlNAlJ+EVtl/HShQfvig0ZsXlY3SPCd 8Ad13IouLhb+4CmMKSFYzxW7pVpLXfCF2f3X8uL88S815QfP8e851eH4OWRSme1KFlv BdTnjPqR76Ke5Q8+3Pkz+FTujWmLJoKZFHEW0Kt4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 21/44] x86/boot: convert ramdisk locating to struct boot_module Date: Fri, 30 Aug 2024 17:47:06 -0400 Message-Id: <20240830214730.1621-22-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Locate the first unclaimed struct boot_module and mark it as ramdisk. If there are any remaining unclaimed struct boot_module instances, report to the console. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 28b39d23f644..189c45302fab 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2100,20 +2100,30 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); - initrdidx = find_first_bit(module_map, boot_info->nr_mods); - boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK; - boot_info->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; - if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) - printk(XENLOG_WARNING - "Multiple initrd candidates, picking module #%u\n", - initrdidx); + /* + * 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 + * candidates. + */ + initrdidx = first_boot_module_index(boot_info, BOOTMOD_UNKNOWN); + if ( initrdidx >= 0 ) + { + boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK; + boot_info->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + if ( first_boot_module_index(boot_info, BOOTMOD_UNKNOWN) >= 0 ) + printk(XENLOG_WARNING + "Multiple initrd candidates, picking module #%u\n", + initrdidx); + } /* * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ dom0 = create_dom0(boot_info->mods[0].early_mod, boot_info->mods[0].headroom, - initrdidx < boot_info->nr_mods ? + (initrdidx >= 0 && initrdidx < boot_info->nr_mods) ? boot_info->mods[initrdidx].early_mod : NULL, kextra, boot_info->boot_loader_name); if ( !dom0 ) From patchwork Fri Aug 30 21:47:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785599 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 0B31CCA0EF3 for ; Fri, 30 Aug 2024 21:50:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786701.1196374 (Exim 4.92) (envelope-from ) id 1sk9Vq-0002ua-TW; Fri, 30 Aug 2024 21:50:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786701.1196374; Fri, 30 Aug 2024 21:50: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 1sk9Vq-0002uT-Qj; Fri, 30 Aug 2024 21:50:34 +0000 Received: by outflank-mailman (input) for mailman id 786701; Fri, 30 Aug 2024 21:50:33 +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 1sk9Vp-0002pb-Q4 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:33 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dffef035-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:50:31 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054483861421.2034253922176; Fri, 30 Aug 2024 14:48:03 -0700 (PDT) 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: dffef035-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054485; cv=none; d=zohomail.com; s=zohoarc; b=ia6wGt9t5HuBaQqNQZ55WRnAQOdNnd9zqfY1qg9OixdfEMmT1wNje3s6Q/q5BhgBMfDWXZTTN4LYwoEoAigRMgQt275/Gv6+yHbGe1kTnb9GPV7fCOc1+V5D8M+xbfuYC6yAnytFTD+oPN0G6yLo3CQUpsVq7CGSXcqVueFbjNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054485; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=9VY/wyQt4O/me1dGYDFEc+UYgABFvTmTG94v1OX5tlk=; b=KLZYeWk/gNdHKm7R1TsLTdZnnfd8Pqld01RmdseUqYSB4176FVTlWN1YBPRka9dlzAc+cAJ6V2NEl9QZKTnwPuY4m59HUJ57JjTZ3n/feNlfemlOeYXz9GfxWYCtnvzMYcajOzov85JazR5b/M+sB/LFajIHJywr5S6tfrqhVGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054485; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=9VY/wyQt4O/me1dGYDFEc+UYgABFvTmTG94v1OX5tlk=; b=dF8UFFgbdH1r41iLKSnyhdODKsMso2k76i9ie9JTslPQtsE3jMsvPBNpVZj4g+uK uqEJTlaujfMdz+wn+o2J0xj5U6TskKUwhWHmUWqWk937G3c0SPd8vfbHjyWwhrjdblf TX7n9XXtYAoQbM4TLZq9EYdpQ2vNTrNF7GkEbBPk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 22/44] x86/boot: remove module_map usage from microcode loading Date: Fri, 30 Aug 2024 17:47:07 -0400 Message-Id: <20240830214730.1621-23-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External With all consumers of module_map converted, remove usage of it by the microcode loading logic. Signed-off-by: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 22 +++++++++------------- xen/arch/x86/include/asm/microcode.h | 6 ++---- xen/arch/x86/setup.c | 4 ++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index 83dd8bbe9fb1..a465a676d176 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -151,8 +151,7 @@ static int __init cf_check parse_ucode(const char *s) } custom_param("ucode", parse_ucode); -static void __init microcode_scan_module( - unsigned long *module_map, const struct boot_info *bi) +static void __init microcode_scan_module(const struct boot_info *bi) { uint64_t *_blob_start; unsigned long _blob_size; @@ -177,7 +176,7 @@ static void __init microcode_scan_module( */ for ( i = 1 /* Ignore dom0 kernel */; i < bi->nr_mods; i++ ) { - if ( !test_bit(i, module_map) ) + if ( bi->mods[i].type != BOOTMOD_UNKNOWN ) continue; _blob_start = bootstrap_map_bm(&bi->mods[i]); @@ -201,19 +200,18 @@ static void __init microcode_scan_module( } } -static void __init microcode_grab_module( - unsigned long *module_map, const struct boot_info *bi) +static void __init microcode_grab_module(const struct boot_info *bi) { if ( ucode_mod_idx < 0 ) ucode_mod_idx += bi->nr_mods; if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_mods || - !__test_and_clear_bit(ucode_mod_idx, module_map) ) + (bi->mods[ucode_mod_idx].type != BOOTMOD_UNKNOWN) ) goto scan; bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; ucode_mod = &bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); } static struct microcode_ops __ro_after_init ucode_ops; @@ -801,8 +799,7 @@ static int __init early_update_cache(const void *data, size_t len) return rc; } -int __init microcode_init_cache( - unsigned long *module_map, const struct boot_info *bi) +int __init microcode_init_cache(const struct boot_info *bi) { int rc = 0; @@ -811,7 +808,7 @@ int __init microcode_init_cache( /* Scan if microcode was not detected earlier */ if ( !ucode_mod ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED) ) rc = early_update_cache(bootstrap_map_bm(ucode_mod), @@ -857,8 +854,7 @@ static int __init early_microcode_update_cpu(void) return microcode_update_cpu(patch); } -int __init early_microcode_init(unsigned long *module_map, - const struct boot_info *bi) +int __init early_microcode_init(const struct boot_info *bi) { const struct cpuinfo_x86 *c = &boot_cpu_data; int rc = 0; @@ -901,7 +897,7 @@ int __init early_microcode_init(unsigned long *module_map, return -ENODEV; } - microcode_grab_module(module_map, bi); + microcode_grab_module(bi); if ( ucode_mod || ucode_blob.size ) rc = early_microcode_update_cpu(); diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/asm/microcode.h index 02fdb56bb82b..6abd6c1ff510 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -26,10 +26,8 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig); void microcode_set_module(unsigned int idx); int microcode_update( XEN_GUEST_HANDLE(const_void) buf, unsigned long len, unsigned int flags); -int early_microcode_init( - unsigned long *module_map, const struct boot_info *bi); -int microcode_init_cache( - unsigned long *module_map, const struct boot_info *bi); +int early_microcode_init(const struct boot_info *bi); +int microcode_init_cache(const struct boot_info *bi); int microcode_update_one(void); #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 189c45302fab..541a956923d3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1398,7 +1398,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * TODO: load ucode earlier once multiboot modules become accessible * at an earlier stage. */ - early_microcode_init(module_map, boot_info); + early_microcode_init(boot_info); if ( xen_phys_start ) { @@ -1952,7 +1952,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) timer_init(); - microcode_init_cache(module_map, boot_info); /* Needs xmalloc() */ + microcode_init_cache(boot_info); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Fri Aug 30 21:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785600 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 E5E7ECA101A for ; Fri, 30 Aug 2024 21:50:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786705.1196384 (Exim 4.92) (envelope-from ) id 1sk9Vx-0003Mf-AZ; Fri, 30 Aug 2024 21:50:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786705.1196384; Fri, 30 Aug 2024 21:50:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Vx-0003MY-7h; Fri, 30 Aug 2024 21:50:41 +0000 Received: by outflank-mailman (input) for mailman id 786705; Fri, 30 Aug 2024 21:50:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Vw-0002pb-GT for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:40 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e4722501-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:50:39 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054484953288.2781406902028; Fri, 30 Aug 2024 14:48:04 -0700 (PDT) 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: e4722501-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054486; cv=none; d=zohomail.com; s=zohoarc; b=fMBteAsI13MSUK4JhY2EasizYgJhcij4MN1c+5n7gd7nE0l0SsZ39qCofDWdb6+oc1ziSm+bhYHl7Tqhpp1jAWILiIsY4EJl5Iqzl+vFt1coeIA01Glqcj88pXe4SAZ6HMDk6EOg71np5el8QBgH6VBeFZYcdCWHCWNBiRRNPZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054486; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=CWEMixDJY7x4MLnQ/ZkZHLIFrIhvLWgtbDqN9QKbuu4=; b=QolIQEHusFGH/1c7zyLjewOEij4pwbIQ/uWsxESAEJNd6uDb3Lc9h36BVXidVBERvSGb8c2HLTynoBN+5KUbTUCjSPdhbZZjeKO/YTJhXY3Xuc+rqXejjtuLRYpCH9f4j2RhNRJ+IJ5W4d6a+/8JK0HC/9yzY6j199exdjt/Ups= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054486; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=CWEMixDJY7x4MLnQ/ZkZHLIFrIhvLWgtbDqN9QKbuu4=; b=gsUanQnsMQJRxhBKO4nK+31N6TJynts15cxFfqcmbWbFQv7dk50npWV3qnrlwqzs NVnQ+aBuuQU01qZX3glUcgQrcVwcvxaFnOqXRv602/idE0jzHlt0ER55B0y6X15ruBw jBhn8VggWGLyLrrlGqgRSlJ/3dLAq8PQHscyZxBI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 23/44] x86/boot: remove module_map usage from xsm policy loading Date: Fri, 30 Aug 2024 17:47:08 -0400 Message-Id: <20240830214730.1621-24-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 9 +++------ xen/xsm/xsm_core.c | 6 ++---- xen/xsm/xsm_policy.c | 5 +---- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 541a956923d3..90c2ddb3728a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1878,7 +1878,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges = rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); - xsm_multiboot_init(module_map, boot_info); + xsm_multiboot_init(boot_info); /* * IOMMU-related ACPI table parsing may require some of the system domains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 9e511ef8878c..3f05d09880d8 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -781,11 +781,9 @@ static inline int xsm_argo_send(const struct domain *d, const struct domain *t) #endif /* XSM_NO_WRAPPERS */ #ifdef CONFIG_MULTIBOOT -int xsm_multiboot_init( - unsigned long *module_map, const struct boot_info *bi); +int xsm_multiboot_init(const struct boot_info *bi); int xsm_multiboot_policy_init( - unsigned long *module_map, const struct boot_info *bi, - void **policy_buffer, size_t *policy_size); + const struct boot_info *bi, void **policy_buffer, size_t *policy_size); #endif #ifdef CONFIG_HAS_DEVICE_TREE @@ -831,8 +829,7 @@ static const inline struct xsm_ops *silo_init(void) #include #ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init ( - unsigned long *module_map, const struct boot_info *bi) +static inline int xsm_multiboot_init(const struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 9f87ec4f6754..f816c94fb5aa 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -140,8 +140,7 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) } #ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_init( - unsigned long *module_map, const struct boot_info *bi) +int __init xsm_multiboot_init(const struct boot_info *bi) { int ret = 0; void *policy_buffer = NULL; @@ -151,8 +150,7 @@ int __init xsm_multiboot_init( if ( XSM_MAGIC ) { - ret = xsm_multiboot_policy_init(module_map, bi, &policy_buffer, - &policy_size); + ret = xsm_multiboot_policy_init(bi, &policy_buffer, &policy_size); if ( ret ) { bootstrap_map(NULL); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index e4c94afd108d..ac09dd808b27 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -32,8 +32,7 @@ #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_policy_init( - unsigned long *module_map, const struct boot_info *bi, - void **policy_buffer, size_t *policy_size) + const struct boot_info *bi, void **policy_buffer, size_t *policy_size) { int i; int rc = 0; @@ -42,7 +41,6 @@ int __init xsm_multiboot_policy_init( /* * Try all modules and see whichever could be the binary policy. - * Adjust module_map for the module that is the binary policy. */ for ( i = bi->nr_mods-1; i >= 1; i-- ) { @@ -60,7 +58,6 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); - __clear_bit(i, module_map); bi->mods[i].type = BOOTMOD_XSM_POLICY; break; From patchwork Fri Aug 30 21:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785601 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 A7B12CA101A for ; Fri, 30 Aug 2024 21:50:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786709.1196394 (Exim 4.92) (envelope-from ) id 1sk9W4-0003ry-Hp; Fri, 30 Aug 2024 21:50:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786709.1196394; Fri, 30 Aug 2024 21:50:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9W4-0003rr-Ex; Fri, 30 Aug 2024 21:50:48 +0000 Received: by outflank-mailman (input) for mailman id 786709; Fri, 30 Aug 2024 21:50:47 +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 1sk9W3-0002pb-7I for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:47 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e88aa22b-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:50:46 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054486005884.6684138233145; Fri, 30 Aug 2024 14:48:06 -0700 (PDT) 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: e88aa22b-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054488; cv=none; d=zohomail.com; s=zohoarc; b=SNkhcUTb5ljjl2N4k5YOyU3+oI1ILjCxlFunEQS+985K2oo1Yu+xBrLdrDkBJDxLmc2f8rW0DkVOn31d/xaGFBsjtN+u5FJLip4P+ik3GQIxhVbI41HHWntYWnMTBDrw35GjtavGKlfZ8nbhxngiDGjH4VbgJS1m3Yma82oQxLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054488; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=4r8bmG5H6VttNyjMx0aG3Heh83MSlb/U7U7R6jqNGbY=; b=VMKWkebmIugSeqsy1YB478K5MVEVqELvz/mT7v+uKnvardBgLfOvaUxAZE4aN0UuqN0tXWortoPkUyoixYwwC94fYrC6CVesl0q5oj68SR9VrU0XdsprkOBSPcGsoXvaF36d0ClD849xYdLug6saTybJXLie4/lQYcSSEllzVco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054488; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=4r8bmG5H6VttNyjMx0aG3Heh83MSlb/U7U7R6jqNGbY=; b=j63f/8kEFjZLnJwXnEwaZ/+r476pw2tLC0WHdxn5Qz5P9y7hHGmfP3qA+hpNyKde nuSZy3mzccLVOIEdnGTaKXemyOWhoJc2r20EWT3fLiceMuUvnhoE9/aZTzcNCQUiCd3 FjUZTGwcsQWeUS2/ou7R3tUVBdmJJxdh+pvDBqlM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 24/44] x86/boot: remove module_map usage by ramdisk loading Date: Fri, 30 Aug 2024 17:47:09 -0400 Message-Id: <20240830214730.1621-25-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The ramdisk loading is the last user of module_map, remove its usage and any remaining remnants of module_map. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 90c2ddb3728a..5f42d1049110 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1053,7 +1053,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked = 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, module_map[1]; + unsigned long nr_pages, raw_max_page; int i, j, e820_warn = 0, bytes = 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done = false, relocated = false; @@ -1203,15 +1203,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("dom0 kernel not specified. Check bootloader configuration\n"); /* Check that we don't have a silly number of modules. */ - if ( boot_info->nr_mods > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > MAX_NR_BOOTMODS + 1 ) { - boot_info->nr_mods = sizeof(module_map) * 8; + boot_info->nr_mods = MAX_NR_BOOTMODS + 1; printk("Excessive multiboot modules - using the first %u only\n", boot_info->nr_mods); } - bitmap_fill(module_map, boot_info->nr_mods); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ + /* Dom0 kernel is always first */ boot_info->mods[0].type = BOOTMOD_KERNEL; boot_info->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; From patchwork Fri Aug 30 21:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785602 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 14C19CA0EF3 for ; Fri, 30 Aug 2024 21:51:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786715.1196405 (Exim 4.92) (envelope-from ) id 1sk9WC-0004QN-Ro; Fri, 30 Aug 2024 21:50:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786715.1196405; Fri, 30 Aug 2024 21:50:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9WC-0004Q9-MC; Fri, 30 Aug 2024 21:50:56 +0000 Received: by outflank-mailman (input) for mailman id 786715; Fri, 30 Aug 2024 21:50:55 +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 1sk9WB-0002pb-5E for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:50:55 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ed3756ba-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:50:53 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054487065771.3540805061515; Fri, 30 Aug 2024 14:48:07 -0700 (PDT) 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: ed3756ba-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054489; cv=none; d=zohomail.com; s=zohoarc; b=RwM36eY5ndlANJvGlJ0eLycvYhep4L+JHBT2OQ10GwM4BWVcyagKcezER0btgNhQqDCTixPnC90sk7zXQqs1Rl0gKC0vgvB8lMKGEd5M7G+sdFxHm8/7yPsjMc+Pr6uAp+TdkYCMcHFHDzUxJwZsxugaCHIdx7Dz4S09miNu/GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054489; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ys18ftsSkLmnP3FGqbLMZshx9Vb7hKAbenYbX5oGr+w=; b=FrdO7+lXLw8G6ysgq0pzXR020mdz7cIsmcyHkAwq7dfUfTDcMTxNu+6dtIX5W+6TgmlqE0uTmI87IgZOvs2dZv4SMDWcHvLn5Jrr/iV336Fl9KLnP10lBGtuHJkz9Lq7FID/fCW9vZrdfheqefj4QkFrTob2Nw0PBDPcOADgHns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054489; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=ys18ftsSkLmnP3FGqbLMZshx9Vb7hKAbenYbX5oGr+w=; b=DHLyREtRAhlEVRDnPbdhTi+PYXcBI8/qPzw9pewwZ7lTVdEJbGuayFw7jjdPLqB7 eBUUAEdpbCQ8gCHvfZpJnFo3XBeGJqkqfCz7Uoqt5j77z+jj5BbIjttDqb2OJqnDNYv vaRKqhSPaLfFYSCz2GBCMQlV2XZnh43a/i6muMbk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 25/44] x86/boot: convert create_dom0 to use boot info Date: Fri, 30 Aug 2024 17:47:10 -0400 Message-Id: <20240830214730.1621-26-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This commit changes create_dom0 to no longer take the individual components and take struct boot_info instead. Internally, it is changed to locate the kernel and ramdisk details from struct boot_info. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5f42d1049110..6a613c4847b0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -946,10 +946,8 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li return n; } -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kextra, - const char *loader) +static struct domain *__init create_dom0(const struct boot_info *bi, + const char *kextra) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -964,9 +962,21 @@ static struct domain *__init create_dom0(const module_t *image, .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + int headroom, mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); + module_t *image, *initrd; struct domain *d; domid_t domid; + /* Map boot_module to mb1 module for dom0 */ + image = bi->mods[0].early_mod; + headroom = bi->mods[0].headroom; + + /* Map boot_module to mb1 module for initrd */ + if ( mod_idx < 0 ) + initrd = NULL; + else + initrd = bi->mods[mod_idx].early_mod; + if ( opt_dom0_pvh ) { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | @@ -995,7 +1005,8 @@ static struct domain *__init create_dom0(const module_t *image, if ( image->string || kextra ) { if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), loader)); + safe_strcpy(cmdline, cmdline_cook(__va(image->string), + bi->boot_loader_name)); if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -2121,10 +2132,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(boot_info->mods[0].early_mod, boot_info->mods[0].headroom, - (initrdidx >= 0 && initrdidx < boot_info->nr_mods) ? - boot_info->mods[initrdidx].early_mod : NULL, - kextra, boot_info->boot_loader_name); + dom0 = create_dom0(boot_info, kextra); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Fri Aug 30 21:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785624 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 BADB6CA101A for ; Fri, 30 Aug 2024 21:56:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786798.1196608 (Exim 4.92) (envelope-from ) id 1sk9bl-0007KO-KE; Fri, 30 Aug 2024 21:56:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786798.1196608; Fri, 30 Aug 2024 21:56:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bk-0007Gp-QY; Fri, 30 Aug 2024 21:56:40 +0000 Received: by outflank-mailman (input) for mailman id 786798; Fri, 30 Aug 2024 21:56:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9WI-0002pb-3U for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:02 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f162e06d-6719-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:51:01 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054488141373.37797061577385; Fri, 30 Aug 2024 14:48:08 -0700 (PDT) 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: f162e06d-6719-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054490; cv=none; d=zohomail.com; s=zohoarc; b=S4WCJwe9XVjYfg9SYILGNDE2sLz+Fy8ozFBIUpBe/WlTznKzyhhLGYtS1b3CKgmLNjAKvugxhxjndWMhapjUB5Bb50EmtTMHaPAQwjnDRLmeI/92Cp0Y9UcE/uQkJoMveQzWlpVFAT7xXJPOq9mPOTaoTsfUfUrDzTjVLHQuApM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054490; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=L5tz0lT7C2k6e608u4s5wJilake7jMdmn/z/xN+eCro=; b=exqOAKBMLEALMZSYZhdyG09tTYe0Ugv/3VBzCdFP4j1oYhvKROwZd3KKWCk7q26nxqVCYQjV928oYzAkwZVJeQpZHNzR6QaZvvz79AEb1PGCodQdgyq3dc4fAkuelA1uX6R1SEYyKNBD1SEXtPGW6uKXcDQzpZE1OIFBW3yblWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054490; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=L5tz0lT7C2k6e608u4s5wJilake7jMdmn/z/xN+eCro=; b=nrRFsyM5UInTlstUVsEl0V9mKlmIzQ5GB7oNPvl0tI8pA2iD0DVY1ZkM87bXUrRl qB92yUjPt9ufulSH/3sN+PrzkkTfbUoXzp/bYdXD5eXa5vbgEtgHX1O/DshJ82qL6Ib /ekXHXojlFbeIrRCyHvvDDZdgsspcCyoXrOw+Wa4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 26/44] x86/boot: convert construct_dom0 to use struct boot_module Date: Fri, 30 Aug 2024 17:47:11 -0400 Message-Id: <20240830214730.1621-27-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The construct_dom0 function is converted to consume struct boot_module instances for the kernel and ramdisk. With this change, it is no longer necessary for the internal use of struct mod by create_dom0, so they are changed to struct boot_module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 10 +++++----- xen/arch/x86/include/asm/setup.h | 6 ++---- xen/arch/x86/setup.c | 17 ++++++++--------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8d56705a0861..fb1b7e5d11cf 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -596,9 +597,8 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } -int __init construct_dom0(struct domain *d, const module_t *image, - unsigned long image_headroom, module_t *initrd, - const char *cmdline) +int __init construct_dom0(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline) { int rc; @@ -610,9 +610,9 @@ int __init construct_dom0(struct domain *d, const module_t *image, process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct_pvh(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct_pv(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 165ca744ba34..19e2ad95b523 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -27,10 +27,8 @@ void subarch_init_memory(void); void init_IRQ(void); int construct_dom0( - struct domain *d, - const module_t *image, unsigned long image_headroom, - module_t *initrd, - const char *cmdline); + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline); void setup_io_bitmap(struct domain *d); unsigned long initial_images_nrpages(nodeid_t node); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6a613c4847b0..f58eb21d00d7 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -962,20 +962,19 @@ static struct domain *__init create_dom0(const struct boot_info *bi, .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - int headroom, mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - module_t *image, *initrd; + int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); + struct boot_module *image, *initrd; struct domain *d; domid_t domid; /* Map boot_module to mb1 module for dom0 */ - image = bi->mods[0].early_mod; - headroom = bi->mods[0].headroom; + image = &bi->mods[0]; /* Map boot_module to mb1 module for initrd */ if ( mod_idx < 0 ) initrd = NULL; else - initrd = bi->mods[mod_idx].early_mod; + initrd = &bi->mods[mod_idx]; if ( opt_dom0_pvh ) { @@ -1002,10 +1001,10 @@ static struct domain *__init create_dom0(const struct boot_info *bi, panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->string || kextra ) + if ( image->early_mod->string || kextra ) { - if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), + if ( image->early_mod->string ) + safe_strcpy(cmdline, cmdline_cook(__va(image->early_mod->string), bi->boot_loader_name)); if ( kextra ) @@ -1040,7 +1039,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi, write_cr4(read_cr4() & ~X86_CR4_SMAP); } - if ( construct_dom0(d, image, headroom, initrd, cmdline) != 0 ) + if ( construct_dom0(d, image, initrd, cmdline) != 0 ) panic("Could not construct domain 0\n"); if ( cpu_has_smap ) From patchwork Fri Aug 30 21:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785614 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 3EA7FCA0EF3 for ; Fri, 30 Aug 2024 21:56:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786758.1196509 (Exim 4.92) (envelope-from ) id 1sk9bS-0002iF-B2; Fri, 30 Aug 2024 21:56:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786758.1196509; Fri, 30 Aug 2024 21:56:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bS-0002gq-2C; Fri, 30 Aug 2024 21:56:22 +0000 Received: by outflank-mailman (input) for mailman id 786758; Fri, 30 Aug 2024 21:56:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9WQ-0000Zf-1T for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:10 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f5ba0d87-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:08 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054489185157.27284103749457; Fri, 30 Aug 2024 14:48:09 -0700 (PDT) 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: f5ba0d87-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054491; cv=none; d=zohomail.com; s=zohoarc; b=EuGnOBmt9m/VVYVXJTTFa3ILqf+v+luBtSr/jYRWgoh8BFZkKOBZ0ap57WAC/aNKuOurd30kGqdZ9EuYnseqMH7rKzOzhUeL4idjUxaTYSk3eafIe80ACX1b8QZBIWyjzu28oVLNviDbftLcjVUe1btwkij8OWUhxRFiwYzOAuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054491; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=1CoQkH+lHv+L/z16JNTEDasfAHp/vM4gE3D+btk1VDg=; b=ApXX6ZRn8dM9UjlWhKXCgfsNkuikD8zlP76mpYsNvozKvLthiyTMcfz0mNwV/BIhlh0rdCe2rk4WflwHK2xFQYw2gnuEPP2ELZpjxvNEJ4yi9hIvsp5hq1Vy+CWNO5eptrw6z7V+WBuvLFczIUUNUyel6zROCk2eM6ujy3xnBHA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054491; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=1CoQkH+lHv+L/z16JNTEDasfAHp/vM4gE3D+btk1VDg=; b=Qe5pJZwkJOmCZy2ZS+NXw1udAcRDK9I0V59Rpd1tHSvGIgVlTExzNueQMF45/t47 qzV9GFdiVg4+b0tzqP1/yRCL/qtu+x4fr+R4zKASf03pC0KKyk1rWEPwa88KBQyN3Q8 vcDIrEN7oM075KBPt9/0a6/G71m6l3ThlhMTeC/0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 27/44] x86/boot: relocate kextra into boot info Date: Fri, 30 Aug 2024 17:47:12 -0400 Message-Id: <20240830214730.1621-28-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Move kextra into struct boot_info, thus no longer needed to be passed as a parameter to create_dom0. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 1a325f66b3ba..06b3ecaf7bec 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -41,6 +41,8 @@ struct boot_info { const char *boot_loader_name; const char *cmdline; + const char *kextra; + paddr_t mmap_addr; uint32_t mmap_length; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f58eb21d00d7..76f25e9d620c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -946,8 +946,7 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li return n; } -static struct domain *__init create_dom0(const struct boot_info *bi, - const char *kextra) +static struct domain *__init create_dom0(const struct boot_info *bi) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -1001,15 +1000,15 @@ static struct domain *__init create_dom0(const struct boot_info *bi, panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->early_mod->string || kextra ) + if ( image->early_mod->string || bi->kextra ) { if ( image->early_mod->string ) safe_strcpy(cmdline, cmdline_cook(__va(image->early_mod->string), bi->boot_loader_name)); - if ( kextra ) + if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, kextra); + safe_strcat(cmdline, bi->kextra); /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) @@ -1119,6 +1118,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) *kextra = '\0'; kextra += 3; while ( kextra[1] == ' ' ) kextra++; + boot_info->kextra = kextra; } cmdline_parse(boot_info->cmdline); @@ -2131,7 +2131,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(boot_info, kextra); + dom0 = create_dom0(boot_info); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Fri Aug 30 21:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785630 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 66391CA0EF3 for ; Fri, 30 Aug 2024 21:57:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786848.1196674 (Exim 4.92) (envelope-from ) id 1sk9c4-0003iI-Ak; Fri, 30 Aug 2024 21:57:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786848.1196674; Fri, 30 Aug 2024 21:57:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9c4-0003g7-4M; Fri, 30 Aug 2024 21:57:00 +0000 Received: by outflank-mailman (input) for mailman id 786848; Fri, 30 Aug 2024 21:56:58 +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 1sk9WX-0000Zf-8B for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:17 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fa2e6891-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054490245563.5309767248942; Fri, 30 Aug 2024 14:48:10 -0700 (PDT) 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: fa2e6891-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054492; cv=none; d=zohomail.com; s=zohoarc; b=ghvdmCfKW1U3wg9sVOKivTQYdsa4a+eHSWZbKhe1gp+AXBzi0edi04NBOH3kYlmAri4dAD5BPM0ldjJ8uripVNYruJja0N/j8dff+YEZ4nPSAj5x5YxvD3Gdeu07RMiRMJkuUIOp6b/RedOvoRDGWOdXRDkwIIuW+6+cS9X6s4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054492; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=hWh29eRgG/vTUY/4IatoM48RmM3sftffSEOld+XbhDI=; b=Tr+i9P/YXYznZyn71L/95qgtkaHyFBTrLY5OPGGgqsgCjPWE42b96OHPGF88kO3q0fejsa4/Xep2LeNDBkARAUzTee+22PZ+BawUKpYDCdERtsAP0OH0mqzkqkiQFsfIPthO5Jf1Y+/JfqU/u07zo2sCy2LWgsdoAtOr7Fn90Zo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054492; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=hWh29eRgG/vTUY/4IatoM48RmM3sftffSEOld+XbhDI=; b=Yd1s04nq0GCD9bo1FakYxpkA6AFbm7mrguZ6tktaABvdGIbhO2M/s1BdhdPhy8Jl aFciKfh2G7AQ9SkyDMPbHCvtLxxEwst0oBOIDVSjf39ouV78sQw3BITvniN9iRJ23pL 2Wf6q5yomLNCQlbmtzdoBWP58apA1yxQ+8LS9PIo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 28/44] x86/boot: add cmdline to struct boot_module Date: Fri, 30 Aug 2024 17:47:13 -0400 Message-Id: <20240830214730.1621-29-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Add a char pointer field, cmdline, to struct boot_module to hold the address pointed to by the string field of struct mod. This removes the need to use the early_mod field to get to the dom0 kernel command line. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 06b3ecaf7bec..edd5c435d032 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -30,6 +30,8 @@ struct boot_module { #define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) #define BOOTMOD_FLAG_X86_CONSUMED (1U << 1) + const char *cmdline; + paddr_t start; size_t size; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 76f25e9d620c..8ba32c6b6bfa 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -314,6 +314,8 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) { boot_mods[i].early_mod = &mods[i]; + boot_mods[i].cmdline = (char *)(paddr_t)mods[i].string; + boot_mods[i].start = (paddr_t)mods[i].mod_start; boot_mods[i].size = mods[i].mod_end - mods[i].mod_start; } @@ -1000,10 +1002,11 @@ static struct domain *__init create_dom0(const struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->early_mod->string || bi->kextra ) + if ( image->cmdline || bi->kextra ) { - if ( image->early_mod->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->early_mod->string), + if ( image->cmdline ) + safe_strcpy(cmdline, + cmdline_cook(__va((unsigned long)image->cmdline), bi->boot_loader_name)); if ( bi->kextra ) From patchwork Fri Aug 30 21:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785612 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 0F523CA0EF3 for ; Fri, 30 Aug 2024 21:56:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786748.1196479 (Exim 4.92) (envelope-from ) id 1sk9bJ-0000n1-Az; Fri, 30 Aug 2024 21:56:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786748.1196479; Fri, 30 Aug 2024 21:56:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bJ-0000ke-5g; Fri, 30 Aug 2024 21:56:13 +0000 Received: by outflank-mailman (input) for mailman id 786748; Fri, 30 Aug 2024 21:56:12 +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 1sk9We-0000Zf-T1 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:24 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fe975f19-6719-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:23 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054491309423.19157704731253; Fri, 30 Aug 2024 14:48:11 -0700 (PDT) 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: fe975f19-6719-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054493; cv=none; d=zohomail.com; s=zohoarc; b=Em5k1TM7/Bv3Y5RLflF8f0Tgx8xEUzNyQoJtPqZK8r8Xuh9OX4NnuyiVSzUd+2ZyqZuxSiLiC2iNI/mEV8ihfRua029wqL5VrzUrsd8vVSjRIuE3t0tLtqUBV+vKONvQzL6SWHyW1F+Zd6ypTvEI+RhgvPS5WBoek7faJphj+QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054493; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=MquSQeaVrCWxsat0mhr5L62hgcjXnVV+6k/kWhQHcXY=; b=ReWpnUmzkfOtjl723Hc4Ke1Xm9ED7AJw3Q1GvRaCZBGRsIdZ1JSEkvHT5NbNI+y9aWKgaMSyTy2ABECAk003a6HLTjmMv6686E9wEnNnXm0YylMsO0IVH+bDo52/+SzabFbv3Ubvaph66VrGVvIdpY11LE3Y6ypyF/B7miH8QMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054493; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=MquSQeaVrCWxsat0mhr5L62hgcjXnVV+6k/kWhQHcXY=; b=DtYQqFa9eEHPKSuvN8LbUWAdOUrEtAFwYQFxiTFu6R1hfxHjNiwlHKyXjSJNKxPR T3P3KvazzeiZ3dFpJQIdlTqtM4cUXoKno8uYlx0aBFUPn3EHHFMvRckonP7+hK/eeC1 WkjwWUteZiAWE9wteux2wb/T4aCeJr8Qjoo9QVGs= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 29/44] x86/boot: convert dom0_construct_pv image param to struct boot_module Date: Fri, 30 Aug 2024 17:47:14 -0400 Message-Id: <20240830214730.1621-30-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This changes the type for the image parameter of dom0_construct_pv to be struct boot_module. Removing the usage of early_mod field for kernel module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 7 +++---- xen/arch/x86/pv/dom0_build.c | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index fb1b7e5d11cf..42043230faff 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -612,7 +612,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, if ( is_hvm_domain(d) ) rc = dom0_construct_pvh(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); + rc = dom0_construct_pv(d, image, initrd->early_mod, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index 107c1ff98367..a1f36f7d360d 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,10 +13,9 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); -int dom0_construct_pv(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline); +int dom0_construct_pv( + struct domain *d, const struct boot_module *image, + module_t *initrd, const char *cmdline); int dom0_construct_pvh(struct domain *d, const module_t *image, unsigned long image_headroom, diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 57e58a02e707..db908ddb78b5 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -355,8 +355,7 @@ static struct page_info * __init alloc_chunk(struct domain *d, } int __init dom0_construct_pv(struct domain *d, - const module_t *image, - unsigned long image_headroom, + const struct boot_module *image, module_t *initrd, const char *cmdline) { @@ -374,9 +373,9 @@ int __init dom0_construct_pv(struct domain *d, unsigned int flush_flags = 0; start_info_t *si; struct vcpu *v = d->vcpu[0]; - void *image_base = bootstrap_map(image); - unsigned long image_len = image->mod_end; - void *image_start = image_base + image_headroom; + void *image_base = bootstrap_map_bm(image); + unsigned long image_len = image->size; + void *image_start = image_base + image->headroom; unsigned long initrd_len = initrd ? initrd->mod_end : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; From patchwork Fri Aug 30 21:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785629 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 94252CA101B for ; Fri, 30 Aug 2024 21:57:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786847.1196658 (Exim 4.92) (envelope-from ) id 1sk9c1-0002uA-Pu; Fri, 30 Aug 2024 21:56:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786847.1196658; Fri, 30 Aug 2024 21:56:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9c1-0002sW-JU; Fri, 30 Aug 2024 21:56:57 +0000 Received: by outflank-mailman (input) for mailman id 786847; Fri, 30 Aug 2024 21:56:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Wm-0000Zf-CF for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:32 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 032ce5b5-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054492373987.601800935306; Fri, 30 Aug 2024 14:48:12 -0700 (PDT) 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: 032ce5b5-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054494; cv=none; d=zohomail.com; s=zohoarc; b=JuHcrUfitLx/+Erxf4iWnnj0eub3kVaT0caTtDwSooGvJGSdrl7DdCq8KuCW+Nl8oum3LT10RfhomYGH1UD7iMEW9MO9mmYFaN5RxzgqV6OSVGLMLh3w1uX7JW4gcj1cf2XkcyEoAouyx5E7V9bKgQhYAXwB7HdIwmhJPJWFV6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054494; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Uco3P2nZt+b7+Lgo/+TlzWVF3igUfsGLOahtS9BrSXY=; b=C/4A7iLKTQX1xnrQLTHGlBwd4vTHtIHOSz3isZVxXR09a+sH61okdKgPQUI4AQ8oRZRThtE7KsowLlQG+T7rPvIhVN3g+avuUsbl/+TGD2KlZ28eGT3OlpjTKG/2G78eakoaGvGR72Fm9jfVtwhZCYyAlj5EoScKTSYu2vHJT/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054494; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Uco3P2nZt+b7+Lgo/+TlzWVF3igUfsGLOahtS9BrSXY=; b=AD9sgbWVjCjLa0y/0Oa6d5wKkUO6C8X54qDNS/S4/j8bmT42MipbVvTaTgQQHSNL 5mlFsdxRAYabaOJUhKO8XABaqmym0bRVa/y4m86HBEQC8PCNjIN8lBQO9WpRxAFG1gM ws+1Z5mjj2c6r57Y6RVfDad8G4WbHmAWYKE8If+s= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 30/44] x86/boot: convert dom0_construct_pv initrd param to struct boot_module Date: Fri, 30 Aug 2024 17:47:15 -0400 Message-Id: <20240830214730.1621-31-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This changes the type for the initrd parameter of dom0_construct_pv to be struct boot_module. This conversion requires several adjustments throughout dom0_construct_pv to account for the type change. Removes the usage of early_mod field for ramdisk module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 2 +- xen/arch/x86/pv/dom0_build.c | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 42043230faff..c39588b346b0 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -612,7 +612,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, if ( is_hvm_domain(d) ) rc = dom0_construct_pvh(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd->early_mod, cmdline); + rc = dom0_construct_pv(d, image, initrd, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index a1f36f7d360d..2ce5ea3851af 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -15,7 +15,7 @@ int dom0_setup_permissions(struct domain *d); int dom0_construct_pv( struct domain *d, const struct boot_module *image, - module_t *initrd, const char *cmdline); + struct boot_module *initrd, const char *cmdline); int dom0_construct_pvh(struct domain *d, const module_t *image, unsigned long image_headroom, diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index db908ddb78b5..dce62d76e41e 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -356,7 +356,7 @@ static struct page_info * __init alloc_chunk(struct domain *d, int __init dom0_construct_pv(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline) { int i, rc, order, machine; @@ -376,7 +376,7 @@ int __init dom0_construct_pv(struct domain *d, void *image_base = bootstrap_map_bm(image); unsigned long image_len = image->size; void *image_start = image_base + image->headroom; - unsigned long initrd_len = initrd ? initrd->mod_end : 0; + unsigned long initrd_len = initrd ? initrd->size : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; l2_pgentry_t *l2tab = NULL, *l2start = NULL; @@ -612,7 +612,7 @@ int __init dom0_construct_pv(struct domain *d, initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn = mfn = initrd->mod_start; + initrd_mfn = mfn = initrd->start >> PAGE_SHIFT; count = PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) ) @@ -627,12 +627,13 @@ int __init dom0_construct_pv(struct domain *d, free_domheap_pages(page, order); page += 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), + memcpy(page_to_virt(page), maddr_to_virt(initrd->start), initrd_len); - mpt_alloc = (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc = initrd->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); - initrd->mod_start = initrd_mfn = mfn_x(page_to_mfn(page)); + initrd_mfn = mfn_x(page_to_mfn(page)); + initrd->start = initrd_mfn << PAGE_SHIFT; } else { @@ -640,7 +641,7 @@ int __init dom0_construct_pv(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->mod_end = 0; + initrd->size = initrd->early_mod->mod_end = 0; iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); @@ -654,7 +655,7 @@ int __init dom0_construct_pv(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc = (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc = initrd->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -882,7 +883,7 @@ int __init dom0_construct_pv(struct domain *d, if ( pfn >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = initrd->mod_start + (pfn - initrd_pfn); + mfn = (initrd->start >> PAGE_SHIFT) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } From patchwork Fri Aug 30 21:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785628 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 33F4BCA0EF3 for ; Fri, 30 Aug 2024 21:57:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786843.1196654 (Exim 4.92) (envelope-from ) id 1sk9c1-0002ky-8U; Fri, 30 Aug 2024 21:56:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786843.1196654; Fri, 30 Aug 2024 21:56:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9c1-0002jz-3u; Fri, 30 Aug 2024 21:56:57 +0000 Received: by outflank-mailman (input) for mailman id 786843; Fri, 30 Aug 2024 21:56:55 +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 1sk9Wt-0000Zf-HG for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:39 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0776c7e4-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:37 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054493481659.7029863364719; Fri, 30 Aug 2024 14:48:13 -0700 (PDT) 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: 0776c7e4-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054495; cv=none; d=zohomail.com; s=zohoarc; b=BUNATfUWScvd3LlCBz3oxWB4klY/a/ZFb0WrEEDkSF1GeZbYQ4cx7aKlbgUepwKpLrjCafVTI3ekJXbpJ8NMG4L8Aci498e7XlzGhrGpy4vhnpkkMOV4W1zNMwcu+9ApTU2BPuTbieZo3wytTXmmtAt5eP4ndwqAXkM77MEg1vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054495; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=eI2uOeGg/sx1MKwSvVvpZfm5vXW9RsarhqsgbbBK1us=; b=SuKImHLz4umEcAcUr/53zbcU+rZYyhC59Ls2qWQlTDMotkWNlUjgsRg2cc43J6+Cr2OtYrl3qBPR6k/NE+7fL/mQax7RhPy7pS7Q3SsI64nioQ4XQbFEq1tkAg900G6jnlyYWlqH3jHvZX4OPrsg5OlbJacurXIZXnC0gNU5Ytw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054495; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=eI2uOeGg/sx1MKwSvVvpZfm5vXW9RsarhqsgbbBK1us=; b=uqc1l1dU+Rth/KAcN0NmNpMZpz42q7mguQYej0hai0CntRWZ1sIUhkcFCLPOgKrN AU+xWY0U7N3P2x9d8iPIWU4WzF5UCe33b7lbt1mNuukzkq6WTsPR9gTKMRa0O9tFnND h5TiCNPIIFMfJgxVBoGpDJYsIVOkVyg+p+ivSwyw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 31/44] x86/boot: convert dom0_construct_pvh to struct boot_module Date: Fri, 30 Aug 2024 17:47:16 -0400 Message-Id: <20240830214730.1621-32-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This changes both the kernel and ramdisk parameters over to struct boot_module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 11 +++++------ xen/arch/x86/include/asm/dom0_build.h | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index c39588b346b0..71b2e3afc1a1 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -610,7 +610,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image->early_mod, image->headroom, initrd->early_mod, cmdline); + rc = dom0_construct_pvh(d, image, initrd, cmdline); else if ( is_pv_domain(d) ) rc = dom0_construct_pv(d, image, initrd, cmdline); else diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index f3eddb684686..1579034ebfc0 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1285,10 +1285,9 @@ static void __hwdom_init pvh_setup_mmcfg(struct domain *d) } } -int __init dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline) +int __init dom0_construct_pvh( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline) { paddr_t entry, start_info; int rc; @@ -1332,8 +1331,8 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image, return rc; } - rc = pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map(image), - cmdline, &entry, &start_info); + rc = pvh_load_kernel(d, image->early_mod, image->headroom, initrd->early_mod, + bootstrap_map_bm(image), cmdline, &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index 2ce5ea3851af..8f7b37f3d308 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -17,10 +17,9 @@ int dom0_construct_pv( struct domain *d, const struct boot_module *image, struct boot_module *initrd, const char *cmdline); -int dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline); +int dom0_construct_pvh( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline); unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); From patchwork Fri Aug 30 21:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785613 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 19676CA101A for ; Fri, 30 Aug 2024 21:56:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786756.1196505 (Exim 4.92) (envelope-from ) id 1sk9bR-0002cj-TR; Fri, 30 Aug 2024 21:56:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786756.1196505; Fri, 30 Aug 2024 21:56: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 1sk9bR-0002cX-NJ; Fri, 30 Aug 2024 21:56:21 +0000 Received: by outflank-mailman (input) for mailman id 786756; Fri, 30 Aug 2024 21:56:19 +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 1sk9X0-0000Zf-W1 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:46 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0bea60a2-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:45 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172505449453355.86826546005; Fri, 30 Aug 2024 14:48:14 -0700 (PDT) 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: 0bea60a2-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054496; cv=none; d=zohomail.com; s=zohoarc; b=kRWghNc2F5sPVQ5+qzb7H8DQVUJNT8NJBljwX7Z9CzrlbUmFyh2Ft/QvGKXqbknxOISJ8sZJg1gJnjO7Qwnh+h1K7VA7T+/3Bp5WCjsDUatXkZsTzgpIP1GatTBH6+wP2NniEcRcOnD0Tis0INikyeG49vQL+IW04EzQjLfTRMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054496; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=e/jZPWMKnu3Xz391hq0lPvFpid72gh7AyHIhBUi4faY=; b=OZyFK80p65oqo4Ii7KoSnlpeiyCNDLvCwT9u9C/+ylHjTtpK/oQicRPRJArPOhPIQ+BhXPQ39sw0WlV9JESlqB3k9r6odG+PSk8x84pwgxZH/EvHQ36go5l6JaLyOYkzF3O/bgTKmn5MkBTNcmv5ccRmvB+T4PNNQKqR1sIXN/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054496; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=e/jZPWMKnu3Xz391hq0lPvFpid72gh7AyHIhBUi4faY=; b=AKjnzuNyRb3yNdo7f2glmUqBQS3oQghijs1A4zbpenqkwz9M8x5GmABZOqvwt5mT Oo7af5neTsiQ3hK9+4kkmVcM1TYto19tNM5ixt2u5rsLgYnfbItVuC8oC+GkKyiW7h2 8FzcAuPbbFcsYr3wD8r/N8YeGYJDM+Ikid6RsYLc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 32/44] x86/boot: convert pvh_load_kernel to struct boot_module Date: Fri, 30 Aug 2024 17:47:17 -0400 Message-Id: <20240830214730.1621-33-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This changes both the kernel and ramdisk parameters over to struct boot_module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/hvm/dom0_build.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 1579034ebfc0..b359f3d98376 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -642,15 +642,14 @@ static bool __init check_and_adjust_load_address( return true; } -static int __init pvh_load_kernel(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, void *image_base, - const char *cmdline, paddr_t *entry, - paddr_t *start_info_addr) +static int __init pvh_load_kernel( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, void *image_base, + const char *cmdline, paddr_t *entry, paddr_t *start_info_addr) { - void *image_start = image_base + image_headroom; - unsigned long image_len = image->mod_end; - unsigned long initrd_len = initrd ? initrd->mod_end : 0; + void *image_start = image_base + image->headroom; + unsigned long image_len = image->size; + unsigned long initrd_len = initrd ? initrd->size : 0; struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -725,7 +724,7 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, if ( initrd != NULL ) { - rc = hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_start), + rc = hvm_copy_to_guest_phys(last_addr, maddr_to_virt(initrd->start), initrd_len, v); if ( rc ) { @@ -736,9 +735,9 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, mod.paddr = last_addr; mod.size = initrd_len; last_addr += ROUNDUP(initrd_len, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + if ( initrd->cmdline ) { - char *str = __va(initrd->string); + char *str = __va((unsigned long)initrd->cmdline); size_t len = strlen(str) + 1; rc = hvm_copy_to_guest_phys(last_addr, str, len, v); @@ -1331,8 +1330,8 @@ int __init dom0_construct_pvh( return rc; } - rc = pvh_load_kernel(d, image->early_mod, image->headroom, initrd->early_mod, - bootstrap_map_bm(image), cmdline, &entry, &start_info); + rc = pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdline, + &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); From patchwork Fri Aug 30 21:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785631 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 663D1CA101C for ; Fri, 30 Aug 2024 21:57:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786849.1196680 (Exim 4.92) (envelope-from ) id 1sk9c4-0003n8-RM; Fri, 30 Aug 2024 21:57:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786849.1196680; Fri, 30 Aug 2024 21:57:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9c4-0003ml-Jz; Fri, 30 Aug 2024 21:57:00 +0000 Received: by outflank-mailman (input) for mailman id 786849; Fri, 30 Aug 2024 21:56:58 +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 1sk9X8-0000Zf-E8 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:51:54 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 105c3a69-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:52 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054495605114.11610584368918; Fri, 30 Aug 2024 14:48:15 -0700 (PDT) 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: 105c3a69-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054497; cv=none; d=zohomail.com; s=zohoarc; b=Gcr2dQXwBERTqwQcwuFqX+lzCerzO8XkQcP00CFR8FHA7WkZsU5OZl/tSbJ6xokX8yIQaqPwbKPnnKSFU3+FDmPYrroMmTT7EIbRSB1hCj1B2F7Dqdp6jIvuHC+d1QeaBg3Wg3PbaQgGy6VBirYlHZG+6LOLWAGblN6I4dvpv+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054497; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=mt1dRXz36GBmL3hIsTAQ0JnOmkyCwzbvQkCGLSUmMkc=; b=FJ8YmX0BEzPNKHpNrYWufWrkbbnWhojfiAR5cey0btEdiFOHYip0W0ffEuvAY174ypyu2eOCRDns8f6ZAfNj3oLNotBXqL0kwk3GA5ts+k1c4PfDBkejJF2nJSZff5K5FHNqp8fEXbmnhLDygJa+DA0p+3oB4EXKiyQwHbTQzfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054497; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=mt1dRXz36GBmL3hIsTAQ0JnOmkyCwzbvQkCGLSUmMkc=; b=udtZAvomEEfPM104ld7VCW2/Vcvybqvg17RTZGeXlJUmmEtv78yAg9+YoYmY5I0b nFjPqtKy6uhuyaFQdP8t+XcumC4aBwlLf+vkU9uSeeMaiY7Y7YAGuCN7JJODmzftQRb uRl3pd0TEkpUAx1nw1gvZZVORxrF6uJCXzpTx3qY= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 33/44] x86/boot: convert initial_images to struct boot_module Date: Fri, 30 Aug 2024 17:47:18 -0400 Message-Id: <20240830214730.1621-34-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The variable initial_images is used for tracking the boot modules passed in by the boot loader. Convert to a struct boot_module and adjust the code that uses it accordingly. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8ba32c6b6bfa..77c0833dd441 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -281,7 +281,7 @@ static const char *cmdline_cook(const char *p, const char *loader_name); /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 -static const module_t *__initdata initial_images; +static const struct boot_module *__initdata initial_images; static struct boot_info __initdata *boot_info; static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) @@ -337,8 +337,9 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < boot_info->nr_mods; ++i ) { - unsigned long start = initial_images[i].mod_start; - unsigned long end = start + PFN_UP(initial_images[i].mod_end); + unsigned long start = initial_images[i].early_mod->mod_start; + unsigned long end = start + + PFN_UP(initial_images[i].early_mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -353,10 +354,12 @@ void __init discard_initial_images(void) for ( i = 0; i < boot_info->nr_mods; ++i ) { - uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; + uint64_t start = + (uint64_t)initial_images[i].early_mod->mod_start << PAGE_SHIFT; init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + + PAGE_ALIGN(initial_images[i].early_mod->mod_end)); } boot_info->nr_mods = 0; @@ -1396,7 +1399,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - initial_images = boot_info->mods[0].early_mod; + initial_images = boot_info->mods; for ( i = 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++ ) { From patchwork Fri Aug 30 21:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785623 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 94BD9CA101B for ; Fri, 30 Aug 2024 21:56:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786797.1196601 (Exim 4.92) (envelope-from ) id 1sk9bk-0007E2-KR; Fri, 30 Aug 2024 21:56:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786797.1196601; Fri, 30 Aug 2024 21:56:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bk-0007DG-Ad; Fri, 30 Aug 2024 21:56:40 +0000 Received: by outflank-mailman (input) for mailman id 786797; Fri, 30 Aug 2024 21:56:38 +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 1sk9XF-0000Zf-FX for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:01 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1499de74-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:51:59 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054496865249.05797085453992; Fri, 30 Aug 2024 14:48:16 -0700 (PDT) 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: 1499de74-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054498; cv=none; d=zohomail.com; s=zohoarc; b=aGjcaSKDQL6x6+3QXUmV2Efhk+Exo2aZVhqZKyiTLSvnpZoEV1d7orOqC+I/1CHv3YTpdq/AFhRB+xnYdPzoHTUjCLqe7t6bLZ/WGGgY6KSbSrrxUxjiySvnldRwfLvngOGKiFyQxJgj/goM6cVMlWPBjqW26UKsvLgdbHyeABg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054498; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=p5o3cV7jLCbs9cI7Hw5PLo3huoAejKeUL5qr3Pk5iyM=; b=SHVdUAjdxF3eFlZ44wPBx//nBDmPRuqv3dIURtO5dEgYYIVGTA4e0Zs6Xg5/KfwtqXyXvGWrgZTnBq1fVI44JCeFqHkFrN4T1st/7Y5YCJJ/HPCDYJx6u98d3ykVfVHTdkJZKnKkbzHZ2zVQMkj14VgbDI3VjY1vHR2INhr00Uc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054498; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=p5o3cV7jLCbs9cI7Hw5PLo3huoAejKeUL5qr3Pk5iyM=; b=rT6h3CC64FDRJJ0kWqC7zOjjBZg+0sL5owrewS3VPHxPEazX5lxfySujcSw5+Zzs xi8P1bRN4n+QH+8Kw2Up/BZzdGSqRAoF2G6k/0D684i5BurXgnV19f/jwbaNGDuSuCR NbhBYLJccCfj7AaVYZVLwdqz9ieuDDLM2nHL1cXQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 34/44] x86/boot: drop the use of initial_images unit global Date: Fri, 30 Aug 2024 17:47:19 -0400 Message-Id: <20240830214730.1621-35-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 77c0833dd441..977b68098694 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -281,7 +281,6 @@ static const char *cmdline_cook(const char *p, const char *loader_name); /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 -static const struct boot_module *__initdata initial_images; static struct boot_info __initdata *boot_info; static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) @@ -337,9 +336,9 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < boot_info->nr_mods; ++i ) { - unsigned long start = initial_images[i].early_mod->mod_start; + unsigned long start = boot_info->mods[i].early_mod->mod_start; unsigned long end = start + - PFN_UP(initial_images[i].early_mod->mod_end); + PFN_UP(boot_info->mods[i].early_mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -355,15 +354,14 @@ void __init discard_initial_images(void) for ( i = 0; i < boot_info->nr_mods; ++i ) { uint64_t start = - (uint64_t)initial_images[i].early_mod->mod_start << PAGE_SHIFT; + (uint64_t)boot_info->mods[i].early_mod->mod_start << PAGE_SHIFT; init_domheap_pages(start, start + - PAGE_ALIGN(initial_images[i].early_mod->mod_end)); + PAGE_ALIGN(boot_info->mods[i].early_mod->mod_end)); } boot_info->nr_mods = 0; - initial_images = NULL; } static void __init init_idle_domain(void) @@ -1399,8 +1397,6 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - initial_images = boot_info->mods; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++ ) { if ( boot_info->mods[i].early_mod->mod_start & (PAGE_SIZE - 1) ) From patchwork Fri Aug 30 21:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785616 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 350EDCA101A for ; Fri, 30 Aug 2024 21:56:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786761.1196540 (Exim 4.92) (envelope-from ) id 1sk9bW-0003lO-Ha; Fri, 30 Aug 2024 21:56:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786761.1196540; Fri, 30 Aug 2024 21:56: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 1sk9bW-0003ky-AR; Fri, 30 Aug 2024 21:56:26 +0000 Received: by outflank-mailman (input) for mailman id 786761; Fri, 30 Aug 2024 21:56:24 +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 1sk9XN-0000Zf-48 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:09 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 18fa953c-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:52:07 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054497909399.3572608288832; Fri, 30 Aug 2024 14:48:17 -0700 (PDT) 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: 18fa953c-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054499; cv=none; d=zohomail.com; s=zohoarc; b=m7eOzt8e/yus21ggPibpZzLMVSol6XKNBAqGEyVU1ABNF0K5G9G4lBcnEogjFP14uw0yjxqrzoIihXX0KCh6ANS/wdwQN+2myufcSVASeuwdDTYzFGRN9WsNYSGLgC25XXSKOGFbxMjSuXFkIlvvc+PNCQfu+Cg1Ig4HNWiRubc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054499; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ngbbLEQwLIwlBq1EHKDN2ggSsuXtMR1Wvlwl95KPSyQ=; b=XKV/qK1n4YfpLRcHQzZYUkTt5NaWQZcBqEzuZuKQ6WVZOI/c1C2xDrbZRFFa+tga0jnKwSLlDcobePPXggqY0UwWFh2J6swvAeJqQORz7Eb2P87c3qpVphDOAJIf70ZhI50vtibv0N9i8OvurNTc8755ui8oVJiu6X5dr3DNkD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054499; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=ngbbLEQwLIwlBq1EHKDN2ggSsuXtMR1Wvlwl95KPSyQ=; b=NfDR64LYuwiTPYpAKJN0PClsPjMmpP07k/DIX03CUM/rZHxpk4WobGSqVAmK/dxI U2TruI3vHDcvGmlGo10h0lFlqe2CCb6LlpjAkEEtdPxCLyylnl8qXOiTspmMQ+ZNIrc wfA0C1dpD98odlW4In2Xbod84kEq+SdPk/VwdWUo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 35/44] x86/boot: remove usage of mod_end by discard_initial_images Date: Fri, 30 Aug 2024 17:47:20 -0400 Message-Id: <20240830214730.1621-36-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This eliminates usage of early_mod by discard_initial_images Signed-off-by: Daniel P. Smith --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/arch/x86/setup.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index dce62d76e41e..a403e23b2f93 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -641,7 +641,7 @@ int __init dom0_construct_pv(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->size = initrd->early_mod->mod_end = 0; + initrd->size = 0; iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 977b68098694..81610405a53c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -353,12 +353,10 @@ void __init discard_initial_images(void) for ( i = 0; i < boot_info->nr_mods; ++i ) { - uint64_t start = - (uint64_t)boot_info->mods[i].early_mod->mod_start << PAGE_SHIFT; + uint64_t start = boot_info->mods[i].start; init_domheap_pages(start, - start + - PAGE_ALIGN(boot_info->mods[i].early_mod->mod_end)); + start + PAGE_ALIGN(boot_info->mods[i].size)); } boot_info->nr_mods = 0; From patchwork Fri Aug 30 21:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785625 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 C658ACA101C for ; Fri, 30 Aug 2024 21:56:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786799.1196612 (Exim 4.92) (envelope-from ) id 1sk9bm-0007ZX-Cj; Fri, 30 Aug 2024 21:56:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786799.1196612; Fri, 30 Aug 2024 21:56:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bl-0007UK-OU; Fri, 30 Aug 2024 21:56:41 +0000 Received: by outflank-mailman (input) for mailman id 786799; Fri, 30 Aug 2024 21:56:39 +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 1sk9XU-0000Zf-OQ for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:16 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1dadde6a-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:52:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054498973975.9857328919481; Fri, 30 Aug 2024 14:48:18 -0700 (PDT) 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: 1dadde6a-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054500; cv=none; d=zohomail.com; s=zohoarc; b=GDSKvUqHJ5BLAS627Did2xnWccmZLTtAIspbKcJn4SGe+PXR7jf2bbK4RBHkXgpJyXMoXgbW+AcpY8RE4NjMdMt+h7Z6mVNP8nu7ZQjSfY0883AJlZaXBARkIuxBJSo35yuf7NxczM08AhMjwtPp/bNdbAQG8pK30GuB5Sstszk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054500; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=3IESuTbSEXt1kpS4QxXRhBwnK5tj42QFRgJSLR4gL7g=; b=AWuOdAeM3rEUAZclJJdARbz6aWQFvv4+gbaGqZ6ZV6q5e3kqzSURm7l6Z175lOkRgYF9U/szQc/TPZ+oKE5jErAV5wLzfpWFF41NtY1pEBiiwZKblJim9nR/keQReqgoqt7OjcFL04XAwaRixaQvHtmW2i80o3ZW0zzbfitd0Dc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054500; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=3IESuTbSEXt1kpS4QxXRhBwnK5tj42QFRgJSLR4gL7g=; b=brTGisH6Dp8rEw9sOTjel49uha73GTWa+U+PshwLRspU68ej6q2ytrr5AMqt2SNZ Hy4OXwg5ZRCE1oPWC9SljIAjBbZ2C1wUTjsTGR3VmwOg7KFP32Ci3swK0uHJzadS7XA orHHrnnbRu4jgznCPGNPv9vWNJzbmk8N3P8wOur8= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 36/44] x86/boot: remove remaining early_mod references Date: Fri, 30 Aug 2024 17:47:21 -0400 Message-Id: <20240830214730.1621-37-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Any direct usages of struct mod have been transitioned, remove the remaining references to early_mod fields. Signed-off-by: Daniel P. Smith --- xen/arch/x86/setup.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 81610405a53c..46f6bf82fe63 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -336,9 +336,8 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < boot_info->nr_mods; ++i ) { - unsigned long start = boot_info->mods[i].early_mod->mod_start; - unsigned long end = start + - PFN_UP(boot_info->mods[i].early_mod->mod_end); + unsigned long start = boot_info->mods[i].start; + unsigned long end = start + PFN_UP(boot_info->mods[i].size); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -665,8 +664,8 @@ static uint64_t __init consider_modules( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = (uint64_t)mods[i].early_mod->mod_start << PAGE_SHIFT; - uint64_t end = start + PAGE_ALIGN(mods[i].early_mod->mod_end); + uint64_t start = (uint64_t)mods[i].start; + uint64_t end = start + PAGE_ALIGN(mods[i].size); if ( i == this_mod ) continue; @@ -1397,10 +1396,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++ ) { - if ( boot_info->mods[i].early_mod->mod_start & (PAGE_SIZE - 1) ) + if ( boot_info->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - boot_info->mods[i].early_mod->mod_end -= boot_info->mods[i].early_mod->mod_start; - boot_info->mods[i].early_mod->mod_start >>= PAGE_SHIFT; } /* @@ -1419,15 +1416,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - boot_info->mods[idx].start = boot_info->mods[idx].early_mod->mod_start - = virt_to_mfn(_stext); - boot_info->mods[idx].size = boot_info->mods[idx].early_mod->mod_end - = __2M_rwdata_end - _stext; + boot_info->mods[idx].start = virt_to_maddr(_stext); + boot_info->mods[idx].size = __2M_rwdata_end - _stext; } boot_info->mods[0].headroom = bzimage_headroom( - bootstrap_map(boot_info->mods[0].early_mod), - boot_info->mods[0].early_mod->mod_end); + bootstrap_map_bm(&boot_info->mods[0]), + boot_info->mods[0].size); bootstrap_map(NULL); #ifndef highmem_start @@ -1533,8 +1528,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { move_memory(end - size + bm->headroom, bm->start, bm->size); bm->start = (end - size); - bm->early_mod->mod_start = paddr_to_pfn(bm->start); - bm->size = bm->early_mod->mod_end += bm->headroom; + bm->size += bm->headroom; bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1724,7 +1718,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { set_pdx_range(paddr_to_pfn(boot_info->mods[i].start), paddr_to_pfn(boot_info->mods[i].start) + - PFN_UP(boot_info->mods[i].early_mod->mod_end)); + PFN_UP(boot_info->mods[i].size)); map_pages_to_xen( (unsigned long)maddr_to_virt(boot_info->mods[i].start), maddr_to_mfn(boot_info->mods[i].start), From patchwork Fri Aug 30 21:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785619 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 02259CA101C for ; Fri, 30 Aug 2024 21:56:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786771.1196559 (Exim 4.92) (envelope-from ) id 1sk9bZ-0004bZ-L9; Fri, 30 Aug 2024 21:56:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786771.1196559; Fri, 30 Aug 2024 21:56: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 1sk9bZ-0004a5-CK; Fri, 30 Aug 2024 21:56:29 +0000 Received: by outflank-mailman (input) for mailman id 786771; Fri, 30 Aug 2024 21:56:27 +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 1sk9Xe-0000Zf-2K for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:26 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 230e677c-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:52:24 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054500033634.5246086156144; Fri, 30 Aug 2024 14:48:20 -0700 (PDT) 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: 230e677c-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054502; cv=none; d=zohomail.com; s=zohoarc; b=Cn+G1qZky79yw/9hC9HKgKVZ45rI70UfgV6bSQszYWRKkXYJS+n7rUyXGKAg2S04DaXfEOBp+vhvvKhuaAp68kajkYA8KdnS9lThNTCR9JgK8q2UyREJ2JhZNeqeTy2URaIuUk34tH/M9n7lnCVB9R/8YHXPTbfqRmA7/7hDLHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054502; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=HBxvAb1ltpAXzL9WPBIkhD8Kd9b/CO8vDcvLfbJPxj0=; b=NyK2nyr1cr4+N2IXgM9Yf24qblL/EEcV4TKqcAuRuvryjSY29ISWJsD8GAoSbZt56VUNMyvzBKtdHR8s6H4XW/+RvPbLKKeL/RFlWFfj0pnm9Z+hk6yLvadUhEsc3/sqig33WELaZq5AI9yoUTOXOoFnuoboDQy7VPzAcoUoiPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054502; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=HBxvAb1ltpAXzL9WPBIkhD8Kd9b/CO8vDcvLfbJPxj0=; b=cvoUht3bbrWsoWvlmhjW+xzwaNFHpd2V3oFWssLldYyD06/GXvJTdPTgHCRLSGhb Ct9SZN5YqudaQCtv31nY7Gad2C7AvK0BuFfCNzchQgqGMsHbtkfOC+dQD6/ECIgQRT5 j5IChvDDZ2ZLRh0bPyJ9nxjzbzpstW/NHNciv9pw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 37/44] x86/boot: remove early_mod from struct boot_module Date: Fri, 30 Aug 2024 17:47:22 -0400 Message-Id: <20240830214730.1621-38-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External With all references to early_mod fields removed, remove the early_mod field from struct boot_module. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 2 -- xen/arch/x86/setup.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index edd5c435d032..59755ef42e53 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,7 +8,6 @@ #ifndef __XEN_X86_BOOTINFO_H__ #define __XEN_X86_BOOTINFO_H__ -#include #include /* Boot module binary type / purpose */ @@ -22,7 +21,6 @@ enum bootmod_type { }; struct boot_module { - module_t *early_mod; unsigned long headroom; enum bootmod_type type; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 46f6bf82fe63..a6fbaecee9ed 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -311,8 +311,6 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) for ( i=0; i < info.nr_mods; i++ ) { - boot_mods[i].early_mod = &mods[i]; - boot_mods[i].cmdline = (char *)(paddr_t)mods[i].string; boot_mods[i].start = (paddr_t)mods[i].mod_start; @@ -322,7 +320,6 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) /* map the last mb module for xen entry */ boot_mods[info.nr_mods].type = BOOTMOD_XEN; boot_mods[info.nr_mods].flags |= BOOTMOD_FLAG_X86_CONSUMED; - boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods]; boot_info = &info; } From patchwork Fri Aug 30 21:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785610 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 EF4EBCA101A for ; Fri, 30 Aug 2024 21:56:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786747.1196475 (Exim 4.92) (envelope-from ) id 1sk9bJ-0000hs-3d; Fri, 30 Aug 2024 21:56:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786747.1196475; Fri, 30 Aug 2024 21:56:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9bI-0000hE-Uj; Fri, 30 Aug 2024 21:56:12 +0000 Received: by outflank-mailman (input) for mailman id 786747; Fri, 30 Aug 2024 21:56:12 +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 1sk9Xm-0000Zf-Fv for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:34 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2836cd3a-671a-11ef-99a1-01e77a169b0f; Fri, 30 Aug 2024 23:52:32 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054501101460.90423645474493; Fri, 30 Aug 2024 14:48:21 -0700 (PDT) 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: 2836cd3a-671a-11ef-99a1-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1725054503; cv=none; d=zohomail.com; s=zohoarc; b=lMGZs8SIDtJtI131S+0ymMPmMbm9ZrRmIfMPtzovliVyRoavvu25Qd+y+OFcQ0d2D3/m4cBHKYWobvDQ1UUqSWgDS5S/va6mEdgjq4urQuiSO3BAdXLkyHaWQy26CDvUIfcVS4+wrJ7uxFGH5NQ3VOpLQC9wJA9M+IBJUvXUygQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054503; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=R/MzkWoN4ISAq+3iGJhqemI2sorOj7/J8EPT75xG/08=; b=JNgYY8qoj7tkrn2MgvM4Qp2r8jm/4q+yUnjOdVb6gTLYpEZ9b9nRs5455sStAqo4AkvwBvxw1yy0yyyR2yzsF6BK5ByL3CSR3lxppX29hzZIIft0JT9jqCdrVn0dcemP1u0Z7VR5+g8kUoHk9B3L7HUuAa9TgzYkJ6t4hcZYmqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054503; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=R/MzkWoN4ISAq+3iGJhqemI2sorOj7/J8EPT75xG/08=; b=TwTSDY3tQjVwTmmgBSrXGW7hpH82mM7D7QOwNJU3BO2zmz87+6jWWN/bDP0NiZxQ +MCTnu4tbq8KehJzvjegdmtakDUDr/oxw3ux6ugKVTegxKeaRbrdQOfLTCFtD0kGvvM 88mHGE1ZkNxFWHxDAiEvBxDOMb3kHgICmFO1QRic= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 38/44] x86/boot: introduce boot domain Date: Fri, 30 Aug 2024 17:47:23 -0400 Message-Id: <20240830214730.1621-39-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External To begin moving toward allowing the hypervisor to construct more than one domain at boot, a container is needed for a domain's build information. Introduce a new header, , that contains the initial struct boot_domain that encapsulate the build information for a domain. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 28 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 7 +++++++ xen/arch/x86/setup.c | 27 +++++++++++--------------- 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootdomain.h diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/bootdomain.h new file mode 100644 index 000000000000..4285223ac5ab --- /dev/null +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Apertus Solutions, LLC + * Author: Daniel P. Smith + * Copyright (c) 2024 Christopher Clark + */ + +#ifndef __XEN_X86_BOOTDOMAIN_H__ +#define __XEN_X86_BOOTDOMAIN_H__ + +struct boot_module; + +struct boot_domain { + struct boot_module *kernel; + struct boot_module *ramdisk; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 59755ef42e53..b135aaebd25e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -10,6 +10,11 @@ #include +#include + +/* Max number of boot domains that Xen can construct */ +#define MAX_NR_BOOTDOMS 1 + /* Boot module binary type / purpose */ enum bootmod_type { BOOTMOD_UNKNOWN, @@ -45,6 +50,8 @@ struct boot_info { paddr_t mmap_addr; uint32_t mmap_length; + + struct boot_domain *domains; }; static inline int __init next_boot_module_index( diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a6fbaecee9ed..77abed637ff2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -287,6 +287,7 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) { static struct boot_info __initdata info; static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1]; + static struct boot_domain __initdata boot_doms[MAX_NR_BOOTDOMS]; unsigned int i; info.nr_mods = mbi->mods_count; @@ -321,6 +322,8 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) boot_mods[info.nr_mods].type = BOOTMOD_XEN; boot_mods[info.nr_mods].flags |= BOOTMOD_FLAG_X86_CONSUMED; + info.domains = boot_doms; + boot_info = &info; } @@ -958,20 +961,10 @@ static struct domain *__init create_dom0(const struct boot_info *bi) .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - struct boot_module *image, *initrd; + struct boot_domain *bd = &bi->domains[0]; struct domain *d; domid_t domid; - /* Map boot_module to mb1 module for dom0 */ - image = &bi->mods[0]; - - /* Map boot_module to mb1 module for initrd */ - if ( mod_idx < 0 ) - initrd = NULL; - else - initrd = &bi->mods[mod_idx]; - if ( opt_dom0_pvh ) { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | @@ -997,11 +990,11 @@ static struct domain *__init create_dom0(const struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->cmdline || bi->kextra ) + if ( bd->kernel->cmdline || bi->kextra ) { - if ( image->cmdline ) - safe_strcpy(cmdline, - cmdline_cook(__va((unsigned long)image->cmdline), + if ( bd->kernel->cmdline ) + safe_strcpy(cmdline, cmdline_cook( + __va((unsigned long)bd->kernel->cmdline), bi->boot_loader_name)); if ( bi->kextra ) @@ -1036,7 +1029,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi) write_cr4(read_cr4() & ~X86_CR4_SMAP); } - if ( construct_dom0(d, image, initrd, cmdline) != 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) != 0 ) panic("Could not construct domain 0\n"); if ( cpu_has_smap ) @@ -1221,6 +1214,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) /* Dom0 kernel is always first */ boot_info->mods[0].type = BOOTMOD_KERNEL; boot_info->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; + boot_info->domains[0].kernel = &boot_info->mods[0]; if ( pvh_boot ) { @@ -2112,6 +2106,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK; boot_info->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + boot_info->domains[0].ramdisk = &boot_info->mods[initrdidx]; if ( first_boot_module_index(boot_info, BOOTMOD_UNKNOWN) >= 0 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Fri Aug 30 21:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785604 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 6D88CCA101A for ; Fri, 30 Aug 2024 21:52:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786723.1196414 (Exim 4.92) (envelope-from ) id 1sk9Xw-0005ab-4P; Fri, 30 Aug 2024 21:52:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786723.1196414; Fri, 30 Aug 2024 21:52:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Xw-0005aU-1Z; Fri, 30 Aug 2024 21:52:44 +0000 Received: by outflank-mailman (input) for mailman id 786723; Fri, 30 Aug 2024 21:52:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Xu-0005aM-So for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:42 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2d0ecb87-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:52:41 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054502153808.9241274770283; Fri, 30 Aug 2024 14:48:22 -0700 (PDT) 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: 2d0ecb87-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054504; cv=none; d=zohomail.com; s=zohoarc; b=HQc/8Mpes7nky1IqTnmc7WcSNsdXEdetXZNaGZMrV3ObGjL9HzhgtIDvnmOp0jZqs55UI4JZf4dO/NSgiLBX2P0CIWRYauWHowYmeNO6rXIBBPrwoCUivc5qBxeEYb6j9uW3nL+q9ct3+pqm8LZVA5fyB0EFIFA10NGe09Rw0as= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054504; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=feqDlwU7EGLLtvhfulZ1x0mRALgPHN///oYnW4IFKWA=; b=a2pxoqUMt5aHGMs71XhzBzZq7qxLsNQYRpN8qfLkTQ4fy6OqBeJ1kItKz/3oP2fx5pz/HL8Xtmq3EspRq0t38yLYlqrDbCO1d8ICw/V0/P/uzKFbpZNXSxKzEswcoAThQJw4885YODAYop6k8RhAXQvG5hiz7dEsTkfBiu4PWEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054504; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=feqDlwU7EGLLtvhfulZ1x0mRALgPHN///oYnW4IFKWA=; b=P7jsgqlg6tmxb9gsrZXaupZa0AdgOxCLm/Cmg3KqyoABo6g2PbcZyShtGec57SSr ZtO5rJLvQi1ZXd4nesUHE/lhkUzJ6vELNpBoEqd1vLRugqzBZ9wRyyMTsCx4gKdz3Tw UfHQ2WTWo5VHV9UySk4SRuZMmnVZcoCl1Bxim+Jo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 39/44] x86/boot: introduce domid field to struct boot_domain Date: Fri, 30 Aug 2024 17:47:24 -0400 Message-Id: <20240830214730.1621-40-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Add a domid field to struct boot_domain to hold the assigned domain id for the domain. During initialization, ensure all instances of struct boot_domain have the invalid domid to ensure that the domid must be set either by convention or configuration. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 2 ++ xen/arch/x86/setup.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/bootdomain.h index 4285223ac5ab..d6264d554dba 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -11,6 +11,8 @@ struct boot_module; struct boot_domain { + domid_t domid; + struct boot_module *kernel; struct boot_module *ramdisk; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 77abed637ff2..43b588d4d105 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -322,6 +322,9 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods) boot_mods[info.nr_mods].type = BOOTMOD_XEN; boot_mods[info.nr_mods].flags |= BOOTMOD_FLAG_X86_CONSUMED; + for ( i=0; i < MAX_NR_BOOTDOMS; i++ ) + boot_doms[i].domid = DOMID_INVALID; + info.domains = boot_doms; boot_info = &info; @@ -963,7 +966,6 @@ static struct domain *__init create_dom0(const struct boot_info *bi) }; struct boot_domain *bd = &bi->domains[0]; struct domain *d; - domid_t domid; if ( opt_dom0_pvh ) { @@ -979,15 +981,15 @@ static struct domain *__init create_dom0(const struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid = get_initial_domain_id(); + d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); init_dom0_cpuid_policy(d); if ( alloc_dom0_vcpu0(d) == NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline || bi->kextra ) From patchwork Fri Aug 30 21:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785605 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 52594CA101A for ; Fri, 30 Aug 2024 21:52:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786725.1196424 (Exim 4.92) (envelope-from ) id 1sk9Y5-0005sr-Ab; Fri, 30 Aug 2024 21:52:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786725.1196424; Fri, 30 Aug 2024 21:52:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Y5-0005sk-7O; Fri, 30 Aug 2024 21:52:53 +0000 Received: by outflank-mailman (input) for mailman id 786725; Fri, 30 Aug 2024 21:52:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9Y4-0005aM-45 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:52 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 329b11bb-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:52:50 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17250545032331016.3890116274274; Fri, 30 Aug 2024 14:48:23 -0700 (PDT) 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: 329b11bb-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054505; cv=none; d=zohomail.com; s=zohoarc; b=GA7Yp4LFWXcUTCQ+tcxx7puOdH0pa01EM+OSB1scExt/54hyvetQ5OqApsaTg5bhieRGq8CZ0TEH2EqR42b/fkKU4deFvS7a8D7/kKY0YDcnGpp5QWB1fqAwaVrGvyJPwbEbdNOYu0gx1caNmkUjh31mqbfTmMJDnmcTeuYqy5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054505; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Sd7QQyOHQcpE3M4m4u6Ct3Fw13iRggCCs6j9qnmZOMk=; b=f3kuXxbWhnh9K89+FrbWk50c5gQwEw+vXn0kUXi/q5VA2cOUs548oAm7or7+iH6nl+hxLwKQWmVFVWU87+uhxnvKh399OkS/oA7B7aAx0AQsfYZTGGDdXDchqyGILSWZonIb42lnDXEZvGjhpsdRkbmqiwzyw6B1sXkeIEQ4Cc8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054505; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Sd7QQyOHQcpE3M4m4u6Ct3Fw13iRggCCs6j9qnmZOMk=; b=bbvsH87qot8P5OwLFLsH9YynUee1DpqXrTjvDagCWBZuBKHREwoSy3evHF+Fehwm WcdP0l7LFQzr4f1EX1TA4q/YRh8tW0TQkg4voUpF/6vIBTmNrk8NMKENe8A9HXPVPCY p7KZgRCe+XHpDWOXzG/OfJhzNA4hWDhLl/vgqFZ8= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 40/44] x86/boot: add cmdline to struct boot_domain Date: Fri, 30 Aug 2024 17:47:25 -0400 Message-Id: <20240830214730.1621-41-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Add a container for the "cooked" command line for a domain. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 18 ++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/bootdomain.h index d6264d554dba..00f7d9267965 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -8,9 +8,13 @@ #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ +#include + struct boot_module; struct boot_domain { + char cmdline[MAX_GUEST_CMDLINE]; + domid_t domid; struct boot_module *kernel; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 43b588d4d105..2c1aa1475c4e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -951,8 +951,6 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li static struct domain *__init create_dom0(const struct boot_info *bi) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; - struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, @@ -995,17 +993,17 @@ static struct domain *__init create_dom0(const struct boot_info *bi) if ( bd->kernel->cmdline || bi->kextra ) { if ( bd->kernel->cmdline ) - safe_strcpy(cmdline, cmdline_cook( + safe_strcpy(bd->cmdline, cmdline_cook( __va((unsigned long)bd->kernel->cmdline), bi->boot_loader_name)); if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + safe_strcat(bd->cmdline, bi->kextra); /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + if ( skip_ioapic_setup && !strstr(bd->cmdline, "noapic") ) + safe_strcat(bd->cmdline, " noapic"); if ( (strlen(acpi_param) == 0) && acpi_disabled ) { @@ -1013,10 +1011,10 @@ static struct domain *__init create_dom0(const struct boot_info *bi) safe_strcpy(acpi_param, "off"); } - if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") ) + if ( (strlen(acpi_param) != 0) && !strstr(bd->cmdline, "acpi=") ) { - safe_strcat(cmdline, " acpi="); - safe_strcat(cmdline, acpi_param); + safe_strcat(bd->cmdline, " acpi="); + safe_strcat(bd->cmdline, acpi_param); } } @@ -1031,7 +1029,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi) write_cr4(read_cr4() & ~X86_CR4_SMAP); } - if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) != 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) panic("Could not construct domain 0\n"); if ( cpu_has_smap ) From patchwork Fri Aug 30 21:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785606 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 DBF3ACA0EF3 for ; Fri, 30 Aug 2024 21:53:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786726.1196434 (Exim 4.92) (envelope-from ) id 1sk9YB-0006D6-Lq; Fri, 30 Aug 2024 21:52:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786726.1196434; Fri, 30 Aug 2024 21:52:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9YB-0006Ct-IV; Fri, 30 Aug 2024 21:52:59 +0000 Received: by outflank-mailman (input) for mailman id 786726; Fri, 30 Aug 2024 21:52:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9YA-0005aM-PN for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:52:58 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36efc773-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:52:57 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054505001907.1045928467133; Fri, 30 Aug 2024 14:48:25 -0700 (PDT) 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: 36efc773-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054506; cv=none; d=zohomail.com; s=zohoarc; b=XomcCrLeVpW08ad/3v70oAvP5emB5KRDdrW2/JPT5js1srnSkvp5X6aWhc50ZSnK+Dgd9WlAs1rfoIQv4ZcARJCh4HbdQA1TXcmUiSifX8m1+A0u40XkCkqtoR2AaDrWX1T5DcxTor1bB+seMX5fZuVqhQEvJXv1/NXM/G5Nr+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054506; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=FMMyV/u+IcJlzna8xPedLWbpzcFdbye2wRnqCcAWCr4=; b=dhIu1CJp6gv0Pj5rDEeAgXcnLINWMqbKLQRH/zJRnMBT+AZVgLlseL1+Xt76s8ZLO+4hq9mIzDsFpLD+B8EOD8cBMx9XlECxWJ0mM/C6aG0Oic/a5HxAS0Oj2K2iXzlTqrBlhL8fM6TmAYWjuOZPxnOKnCQCtfyPxot7mwilYJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054506; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=FMMyV/u+IcJlzna8xPedLWbpzcFdbye2wRnqCcAWCr4=; b=Q9ecpxi+qWrHVcOUKwjYqwtCFh7Q4MQWgNZ2569OoDPGnO24NUa3yN2MWX7hktiJ RF1atkVKx107UYLFz36EdEebw7DZdb148q24qP/aamrV1AoNJw9q61mnv56N3FBixyw aS8IEBLtWN/3JHJmU8D1NLRTKBbxp4+cZUbLckPQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 41/44] x86/boot: add struct domain to struct boot_domain Date: Fri, 30 Aug 2024 17:47:26 -0400 Message-Id: <20240830214730.1621-42-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Store a reference to the created domain in struct boot_domain. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 3 +++ xen/arch/x86/setup.c | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/bootdomain.h index 00f7d9267965..2322c459e36a 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -10,6 +10,7 @@ #include +struct domain; struct boot_module; struct boot_domain { @@ -19,6 +20,8 @@ struct boot_domain { struct boot_module *kernel; struct boot_module *ramdisk; + + struct domain *d; }; #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2c1aa1475c4e..872d51310628 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -963,7 +963,6 @@ static struct domain *__init create_dom0(const struct boot_info *bi) }, }; struct boot_domain *bd = &bi->domains[0]; - struct domain *d; if ( opt_dom0_pvh ) { @@ -980,13 +979,13 @@ static struct domain *__init create_dom0(const struct boot_info *bi) /* 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)); + bd->d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + if ( IS_ERR(bd->d) ) + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(bd->d)); - init_dom0_cpuid_policy(d); + init_dom0_cpuid_policy(bd->d); - if ( alloc_dom0_vcpu0(d) == NULL ) + if ( alloc_dom0_vcpu0(bd->d) == NULL ) panic("Error creating d%uv0\n", bd->domid); /* Grab the DOM0 command line. */ @@ -1029,7 +1028,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi) write_cr4(read_cr4() & ~X86_CR4_SMAP); } - if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) + if ( construct_dom0(bd->d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) panic("Could not construct domain 0\n"); if ( cpu_has_smap ) @@ -1038,7 +1037,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi) cr4_pv32_mask |= X86_CR4_SMAP; } - return d; + return bd->d; } /* How much of the directmap is prebuilt at compile time. */ From patchwork Fri Aug 30 21:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785607 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 2A6FFCA101A for ; Fri, 30 Aug 2024 21:53:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786728.1196445 (Exim 4.92) (envelope-from ) id 1sk9YJ-0006hW-V2; Fri, 30 Aug 2024 21:53:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786728.1196445; Fri, 30 Aug 2024 21:53:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9YJ-0006hP-PX; Fri, 30 Aug 2024 21:53:07 +0000 Received: by outflank-mailman (input) for mailman id 786728; Fri, 30 Aug 2024 21:53:07 +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 1sk9YJ-0005aM-6M for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:53:07 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3bea8550-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:53:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054506125987.9398819733996; Fri, 30 Aug 2024 14:48:26 -0700 (PDT) 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: 3bea8550-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054508; cv=none; d=zohomail.com; s=zohoarc; b=O8TRKyhf8CV/yw/RfoC5zy4TtPHUtc8LB3MP+K0p/PkWrMwUrePhHVrH/IYTbujWy/+m9lNOYC2n4/z6q7hCrRRhGXwu+BKcqcNBhLaWde10CTgCPniDi3loDLtduY+9kQql5mWtMSJcIxlRLcy+0acfMIlTuUhMcSJ5VXdAxV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054508; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=CRDjJu35KX6V+P191+8yBK+MBAuPjEumeiizl3mdu7o=; b=QFYXEIHnY1ez+yY/vX+3OTTkR5DKVe46LUbPe3xcjyUNthHTXSHNz2Ju3vkekhvFklCLoPF5ddBV2qjUNbH5ft3SjBqNGrkHsLgYHPQg4LL+vMkxTP4ZILXAryhlO6sVW3Pq9vEl7WXnO5EGHpf0D/CQTzUYxNAqPUG6hcRxUlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054508; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=CRDjJu35KX6V+P191+8yBK+MBAuPjEumeiizl3mdu7o=; b=ANHjI/3uMXWw5dgDKD0wrBI5ouad1BHyIwR0ocGzQEwsaFGPxDaGuD2RSj6M/1F7 g60NIYcLWlnbJTPhI+rQY9lSEiOj5B3oVZLOsdkdCkXdpfwkco3nrhMaEyc68WKQtBg 6herQMuzvN2pR68iFQTvhNMKqtQQ4w6Wmkzkoop8= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 42/44] x86/boot: convert construct_dom0 to struct boot_domain Date: Fri, 30 Aug 2024 17:47:27 -0400 Message-Id: <20240830214730.1621-43-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External A struct boot_domain now encapsulates the domain reference, kernel, ramdisk, and command line for the domain being constructed. As a result of this encapsulation, construct_dom0 can now take a single struct boot_domain instead of these four parameters. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 19 +++++++++---------- xen/arch/x86/include/asm/setup.h | 4 +--- xen/arch/x86/setup.c | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 71b2e3afc1a1..e552f2e9abef 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -597,22 +597,21 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } -int __init construct_dom0(struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline) +int __init construct_dom0(struct boot_domain *bd) { int rc; /* Sanity! */ - BUG_ON(!pv_shim && d->domain_id != 0); - BUG_ON(d->vcpu[0] == NULL); - BUG_ON(d->vcpu[0]->is_initialised); + BUG_ON(!pv_shim && bd->d->domain_id != 0); + BUG_ON(bd->d->vcpu[0] == NULL); + BUG_ON(bd->d->vcpu[0]->is_initialised); process_pending_softirqs(); - if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image, initrd, cmdline); - else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd, cmdline); + if ( is_hvm_domain(bd->d) ) + rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + else if ( is_pv_domain(bd->d) ) + rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); @@ -620,7 +619,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, return rc; /* Sanity! */ - BUG_ON(!d->vcpu[0]->is_initialised); + BUG_ON(!bd->d->vcpu[0]->is_initialised); return 0; } diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 19e2ad95b523..8f54b429b954 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,9 +26,7 @@ void subarch_init_memory(void); void init_IRQ(void); -int construct_dom0( - struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline); +int construct_dom0(struct boot_domain *d); void setup_io_bitmap(struct domain *d); unsigned long initial_images_nrpages(nodeid_t node); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 872d51310628..5d48ebea51d5 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1028,7 +1028,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi) write_cr4(read_cr4() & ~X86_CR4_SMAP); } - if ( construct_dom0(bd->d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) + if ( construct_dom0(bd) != 0 ) panic("Could not construct domain 0\n"); if ( cpu_has_smap ) From patchwork Fri Aug 30 21:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785608 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 89EE2CA101A for ; Fri, 30 Aug 2024 21:53:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786734.1196454 (Exim 4.92) (envelope-from ) id 1sk9YR-0007EF-5H; Fri, 30 Aug 2024 21:53:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786734.1196454; Fri, 30 Aug 2024 21:53:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9YR-0007E6-1n; Fri, 30 Aug 2024 21:53:15 +0000 Received: by outflank-mailman (input) for mailman id 786734; Fri, 30 Aug 2024 21:53:14 +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 1sk9YQ-0005aM-5r for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:53:14 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 402f402e-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:53:13 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054507201417.3403256954641; Fri, 30 Aug 2024 14:48:27 -0700 (PDT) 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: 402f402e-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054509; cv=none; d=zohomail.com; s=zohoarc; b=nYIvBOw7bKH/+LTjSG8e20u+CSkjctNMf9HleaCaqR6l2qNThdczixIpcUgA/XfkJ3GuEIAyCqdi/KODOQZ3aIe1jS7/FbKRIADjLdNH49Nwo8ezRIaEWLjsl69pmVsLeMI1tUmLLe6TxVDYuRZip3cihISNHkQa24UAeMX5c70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054509; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=om7y5y0WMnQkQrCTabtNb0cenhPENJfwq9EcVkz9EkM=; b=koMQ8ITrLNawDlvka1CS5H4GERurOgdHGfKt0qJCmkR2uBoC7e3Z2Nz5T6K3EDgbQN9BgSQHJOhidJGM0+OyNVthBIGnBwywVUwe7dbkY968H0NIUAOMPy2aYxAOm3b4braEt//Ea2R7n/+E9qpfDbQ9Msq01o+xC+XrlkujOvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054509; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=om7y5y0WMnQkQrCTabtNb0cenhPENJfwq9EcVkz9EkM=; b=rUJdJuo9pANssvynRbE4/1h9ESWuAPhuE46FQPQzjN5tiwXjHgUalWu0LOgaWODW uqtZfApEHBqMIl5ceBXVbDGLCiCR5IixqUYLZEwmy3/CEyQ2XOjeMHmmGaYEpJ5DlOO qZ178oei70C03G1GS86eIboiIHi/YUAmtWDs5L+s= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 43/44] x86/boot: convert dom0_construct_pv to struct boot_domain Date: Fri, 30 Aug 2024 17:47:28 -0400 Message-Id: <20240830214730.1621-44-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External With construct_dom0 consuming struct boot_domain, continue passing the structure down to dom0_construct_pv. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 5 ++-- xen/arch/x86/pv/dom0_build.c | 36 +++++++++++++-------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index e552f2e9abef..8beb33032940 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -611,7 +611,7 @@ int __init construct_dom0(struct boot_domain *bd) if ( is_hvm_domain(bd->d) ) rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else if ( is_pv_domain(bd->d) ) - rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + rc = dom0_construct_pv(bd); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index 8f7b37f3d308..60e9cb21f14d 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -4,6 +4,7 @@ #include #include +#include #include extern unsigned int dom0_memflags; @@ -13,9 +14,7 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); -int dom0_construct_pv( - struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline); +int dom0_construct_pv(struct boot_domain *bd); int dom0_construct_pvh( struct domain *d, const struct boot_module *image, diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index a403e23b2f93..82dc0c379f27 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -354,10 +354,7 @@ static struct page_info * __init alloc_chunk(struct domain *d, return page; } -int __init dom0_construct_pv(struct domain *d, - const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline) +int __init dom0_construct_pv(struct boot_domain *bd) { int i, rc, order, machine; bool compatible, compat; @@ -372,11 +369,12 @@ int __init dom0_construct_pv(struct domain *d, struct page_info *page = NULL; unsigned int flush_flags = 0; start_info_t *si; - struct vcpu *v = d->vcpu[0]; - void *image_base = bootstrap_map_bm(image); - unsigned long image_len = image->size; - void *image_start = image_base + image->headroom; - unsigned long initrd_len = initrd ? initrd->size : 0; + struct domain *d = bd->d; + struct vcpu *v = bd->d->vcpu[0]; + void *image_base = bootstrap_map_bm(bd->kernel); + unsigned long image_len = bd->kernel->size; + void *image_start = image_base + bd->kernel->headroom; + unsigned long initrd_len = bd->ramdisk ? bd->ramdisk->size : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; l2_pgentry_t *l2tab = NULL, *l2start = NULL; @@ -612,7 +610,7 @@ int __init dom0_construct_pv(struct domain *d, initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn = mfn = initrd->start >> PAGE_SHIFT; + initrd_mfn = mfn = bd->ramdisk->start >> PAGE_SHIFT; count = PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) ) @@ -627,13 +625,13 @@ int __init dom0_construct_pv(struct domain *d, free_domheap_pages(page, order); page += 1UL << order; } - memcpy(page_to_virt(page), maddr_to_virt(initrd->start), + memcpy(page_to_virt(page), maddr_to_virt(bd->ramdisk->start), initrd_len); - mpt_alloc = initrd->start; + mpt_alloc = bd->ramdisk->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); initrd_mfn = mfn_x(page_to_mfn(page)); - initrd->start = initrd_mfn << PAGE_SHIFT; + bd->ramdisk->start = initrd_mfn << PAGE_SHIFT; } else { @@ -641,7 +639,7 @@ int __init dom0_construct_pv(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->size = 0; + bd->ramdisk->size = 0; iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); @@ -653,9 +651,9 @@ int __init dom0_construct_pv(struct domain *d, if ( domain_tot_pages(d) < nr_pages ) printk(" (%lu pages to be allocated)", nr_pages - domain_tot_pages(d)); - if ( initrd ) + if ( bd->ramdisk ) { - mpt_alloc = initrd->start; + mpt_alloc = bd->ramdisk->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -883,7 +881,7 @@ int __init dom0_construct_pv(struct domain *d, if ( pfn >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = (initrd->start >> PAGE_SHIFT) + (pfn - initrd_pfn); + mfn = (bd->ramdisk->start >> PAGE_SHIFT) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } @@ -953,8 +951,8 @@ int __init dom0_construct_pv(struct domain *d, } memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( cmdline != NULL ) - strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)); + if ( bd->cmdline[0] != '\0' ) + strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line)); #ifdef CONFIG_VIDEO if ( !pv_shim && fill_console_start_info((void *)(si + 1)) ) From patchwork Fri Aug 30 21:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13785609 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 284C6CA0EF3 for ; Fri, 30 Aug 2024 21:53:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.786736.1196463 (Exim 4.92) (envelope-from ) id 1sk9YY-0007gy-DA; Fri, 30 Aug 2024 21:53:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 786736.1196463; Fri, 30 Aug 2024 21:53:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sk9YY-0007gn-AL; Fri, 30 Aug 2024 21:53:22 +0000 Received: by outflank-mailman (input) for mailman id 786736; Fri, 30 Aug 2024 21:53: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 1sk9YW-0005aM-N4 for xen-devel@lists.xenproject.org; Fri, 30 Aug 2024 21:53:20 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 43f67f7e-671a-11ef-a0b1-8be0dac302b0; Fri, 30 Aug 2024 23:53:19 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1725054508269777.6559146284596; Fri, 30 Aug 2024 14:48:28 -0700 (PDT) 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: 43f67f7e-671a-11ef-a0b1-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1725054510; cv=none; d=zohomail.com; s=zohoarc; b=F8GDSqvtfe8sJGYcYxWphnjze9dEx9bE/zadr8JX5NVSXkAQhinY0XWCWka4Ek15zQDVUuMX6EUN9/HQqtDyfomKjBeGlFQJt4oE+IYPNqDfaT+5ObFh7MRoDtvjARGEA46ihAa31MELBPSzOl3c9TD+/pIzFaD/0tCU1RInw94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725054510; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=KS82AUYRZGk7W9Pk3CIfd4vp+4qfK/g7l4LYGblZ46w=; b=N0RFq2bGoZ/6Tp7lh2CY6T6WanyroSB87ZR1BvHqh5PcluVV5ZgIiGvWp9jfmAWa35mNXyVLiCLfvk8j4pjZB04YmopVUB1xheHGlcT3YSYmQCzMrvrroytJUd34EEuGbMCHpQapW1ufx22t58AiWWNLg59lHeVj+Y1QBvUm1Mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725054510; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=KS82AUYRZGk7W9Pk3CIfd4vp+4qfK/g7l4LYGblZ46w=; b=ei25+HbYtoU4V9y9fHjO2Jal2Ep9aNv4ViQcn5+wcA9OrxyDi/LplUmi16AjAN+E TNV6bNnFASva7Ak/4eC6BxaCLNRYT8H9wRekpIn2VSSkAwknPVfgtbR1NjY77Ds9dU7 ImpxIBcpsghkPP7WYjwIfj4VTfx9HbbAXiD4sF/Y= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 44/44] x86/boot: convert dom0_construct_pvh to struct boot_domain Date: Fri, 30 Aug 2024 17:47:29 -0400 Message-Id: <20240830214730.1621-45-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240830214730.1621-1-dpsmith@apertussolutions.com> References: <20240830214730.1621-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External With construct_dom0 consuming struct boot_domain, continue passing the structure down to dom0_construct_pvh. Signed-off-by: Daniel P. Smith --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 31 +++++++++++++-------------- xen/arch/x86/include/asm/dom0_build.h | 4 +--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8beb33032940..6a21fd46d5a3 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -609,7 +609,7 @@ int __init construct_dom0(struct boot_domain *bd) process_pending_softirqs(); if ( is_hvm_domain(bd->d) ) - rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + rc = dom0_construct_pvh(bd); else if ( is_pv_domain(bd->d) ) rc = dom0_construct_pv(bd); else diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index b359f3d98376..13e17550efa5 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1284,25 +1284,23 @@ static void __hwdom_init pvh_setup_mmcfg(struct domain *d) } } -int __init dom0_construct_pvh( - struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline) +int __init dom0_construct_pvh(const struct boot_domain *bd) { paddr_t entry, start_info; int rc; - printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); + printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", bd->domid); - if ( is_hardware_domain(d) ) + if ( is_hardware_domain(bd->d) ) { /* * Setup permissions early so that calls to add MMIO regions to the * p2m as part of vPCI setup don't fail due to permission checks. */ - rc = dom0_setup_permissions(d); + rc = dom0_setup_permissions(bd->d); if ( rc ) { - printk("%pd unable to setup permissions: %d\n", d, rc); + printk("%pd unable to setup permissions: %d\n", bd->d, rc); return rc; } } @@ -1312,25 +1310,26 @@ int __init dom0_construct_pvh( * initialization so the iommu code can fetch the MMCFG regions used by the * domain. */ - pvh_setup_mmcfg(d); + pvh_setup_mmcfg(bd->d); /* * Craft dom0 physical memory map and set the paging allocation. This must * be done before the iommu initializion, since iommu initialization code * will likely add mappings required by devices to the p2m (ie: RMRRs). */ - pvh_init_p2m(d); + pvh_init_p2m(bd->d); - iommu_hwdom_init(d); + iommu_hwdom_init(bd->d); - rc = pvh_populate_p2m(d); + rc = pvh_populate_p2m(bd->d); if ( rc ) { printk("Failed to setup Dom0 physical memory map\n"); return rc; } - rc = pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdline, + rc = pvh_load_kernel(bd->d, bd->kernel, bd->ramdisk, + bootstrap_map_bm(bd->kernel), bd->cmdline, &entry, &start_info); if ( rc ) { @@ -1338,14 +1337,14 @@ int __init dom0_construct_pvh( return rc; } - rc = pvh_setup_cpus(d, entry, start_info); + rc = pvh_setup_cpus(bd->d, entry, start_info); if ( rc ) { printk("Failed to setup Dom0 CPUs: %d\n", rc); return rc; } - rc = pvh_setup_acpi(d, start_info); + rc = pvh_setup_acpi(bd->d, start_info); if ( rc ) { printk("Failed to setup Dom0 ACPI tables: %d\n", rc); @@ -1354,8 +1353,8 @@ int __init dom0_construct_pvh( if ( opt_dom0_verbose ) { - printk("Dom%u memory map:\n", d->domain_id); - print_e820_memory_map(d->arch.e820, d->arch.nr_e820); + printk("Dom%u memory map:\n", bd->domid); + print_e820_memory_map(bd->d->arch.e820, bd->d->arch.nr_e820); } return 0; diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h index 60e9cb21f14d..adbe90bfd034 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -16,9 +16,7 @@ int dom0_setup_permissions(struct domain *d); int dom0_construct_pv(struct boot_domain *bd); -int dom0_construct_pvh( - struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline); +int dom0_construct_pvh(const struct boot_domain *bd); unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages);