From patchwork Sun Oct 6 21:49: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: 13823875 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 85731CFB43F for ; Sun, 6 Oct 2024 21:50:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811318.1223877 (Exim 4.92) (envelope-from ) id 1sxZ8w-0005G2-1u; Sun, 06 Oct 2024 21:50:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811318.1223877; Sun, 06 Oct 2024 21:50: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 1sxZ8v-0005Fv-VT; Sun, 06 Oct 2024 21:50:21 +0000 Received: by outflank-mailman (input) for mailman id 811318; Sun, 06 Oct 2024 21:50:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZ8u-00051E-J4 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:50:20 +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 f9951dd3-842c-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:50:18 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17282514052498.635198092673818; Sun, 6 Oct 2024 14:50:05 -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: f9951dd3-842c-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251408; cv=none; d=zohomail.com; s=zohoarc; b=ihZbQCud266+NDUZz2Tb/rukXT5+D9DC8M1a/qEZipprStrdI2AHKPJdnMFZVgs+nvC2S3KgblZsic6TZbhaG3HmfGdW2TMsaoeQMfMct7sLxNSJGaRwQxGct7krLILYqp4z4u5PvI4HYBHT4XtO0n5Q5z35hkOFkuaUb6jcEjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251408; 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=mR5FDOsbmFDquT3lrYY8U7kNVFC0meHVwZwznJGSBOs=; b=QPkEm0FNYGl5Ed01FczVBht0VCsONZJDTzm8Tu70R8WQnd6yyqdhcPRl0moS7LKsdbAAuJsgoA9q9YPWR+51tA/XXk8iE3hxUhjfVckVe+nDeqt/i/2OrvAqXSUuyENOmGTyfvrL/Zuja2FaB5UFWFoCHyOofgRvE4WQof+uAFE= 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=1728251408; 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=mR5FDOsbmFDquT3lrYY8U7kNVFC0meHVwZwznJGSBOs=; b=mKYOERorUmP3k1v8c443KDu4vtZA9h9TZxKLEqeoL8SKmDr+5neBKJOiCMvDRHVc gzFGNyVePiuEVriUFxzy1gTYguQFlOwDKOMUZ5FLIhi/v25hHXJEvgPfW2+7ilqjJZE uewvKoYSwLt6jjeHx+O9CbzRZrVe+KBXgvkaI7uc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: Christopher Clark , jason.andryuk@amd.com, stefano.stabellini@amd.com, "Daniel P . Smith" , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 01/44] x86/boot: move x86 boot module counting into a new boot_info struct Date: Sun, 6 Oct 2024 17:49:12 -0400 Message-Id: <20241006214956.24339-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk Acked-by: Jan Beulich --- xen/arch/x86/include/asm/bootinfo.h | 29 +++++++++++++ xen/arch/x86/include/asm/setup.h | 2 + xen/arch/x86/setup.c | 64 ++++++++++++++++++----------- 3 files changed, 71 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..a649500ee3a2 --- /dev/null +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -0,0 +1,29 @@ +/* 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__ + +/* + * Xen internal representation of information provided by the + * bootloader/environment, or derived from the information. + */ +struct boot_info { + unsigned int nr_modules; +}; + +#endif /* __XEN_X86_BOOTINFO_H__ */ + +/* + * 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/setup.h b/xen/arch/x86/include/asm/setup.h index d75589178b91..3d189521189d 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -32,6 +32,8 @@ int construct_dom0( const char *cmdline); void setup_io_bitmap(struct domain *d); +extern struct boot_info xen_boot_info; + unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); void *bootstrap_map(const module_t *mod); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a6e77c9ed9fc..b75deb4fe4ee 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include #include @@ -274,16 +275,28 @@ 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; + +struct boot_info __initdata xen_boot_info; + +static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) +{ + struct boot_info *bi = &xen_boot_info; + const multiboot_info_t *mbi = __va(mbi_p); + + bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0; + + return bi; +} unsigned long __init initial_images_nrpages(nodeid_t node) { + struct boot_info *bi = &xen_boot_info; unsigned long node_start = node_start_pfn(node); unsigned long node_end = node_end_pfn(node); unsigned long nr; unsigned int i; - for ( nr = i = 0; i < nr_initial_images; ++i ) + for ( nr = i = 0; i < bi->nr_modules; ++i ) { unsigned long start = initial_images[i].mod_start; unsigned long end = start + PFN_UP(initial_images[i].mod_end); @@ -297,9 +310,10 @@ unsigned long __init initial_images_nrpages(nodeid_t node) void __init discard_initial_images(void) { + struct boot_info *bi = &xen_boot_info; unsigned int i; - for ( i = 0; i < nr_initial_images; ++i ) + for ( i = 0; i < bi->nr_modules; ++i ) { uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; @@ -307,7 +321,7 @@ void __init discard_initial_images(void) start + PAGE_ALIGN(initial_images[i].mod_end)); } - nr_initial_images = 0; + bi->nr_modules = 0; initial_images = NULL; } @@ -969,6 +983,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) void *bsp_stack; struct cpu_info *info = get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked = 0; + struct boot_info *bi; multiboot_info_t *mbi; module_t *mod; unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; @@ -1015,6 +1030,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod = __va(mbi->mods_addr); } + bi = multiboot_fill_boot_info(mbi_p); + loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name) : "unknown"; @@ -1122,18 +1139,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 ( !bi->nr_modules ) 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 ( bi->nr_modules > sizeof(module_map) * 8 ) { - mbi->mods_count = sizeof(module_map) * 8; - printk("Excessive multiboot modules - using the first %u only\n", - mbi->mods_count); + bi->nr_modules = sizeof(module_map) * 8; + printk("Excessive boot modules - using the first %u only\n", + bi->nr_modules); } - bitmap_fill(module_map, mbi->mods_count); + bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ if ( pvh_boot ) @@ -1306,9 +1323,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 < bi->nr_modules; i++ ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); @@ -1332,8 +1348,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[bi->nr_modules].mod_start = virt_to_mfn(_stext); + mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; } modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); @@ -1393,7 +1409,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, bi->nr_modules, -1); end &= ~mask; } else @@ -1414,7 +1430,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 = bi->nr_modules - 1; j >= 0; j-- ) { /* * 'headroom' is a guess for the decompressed size and @@ -1429,7 +1445,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); + bi->nr_modules + relocated, j); if ( highmem_start && end > highmem_start ) continue; @@ -1456,7 +1472,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); + bi->nr_modules + relocated, -1); if ( s >= e ) break; if ( e > kexec_crash_area_limit ) @@ -1471,7 +1487,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 < bi->nr_modules; ++i ) { uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; @@ -1551,7 +1567,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 < bi->nr_modules; ++j ) { uint64_t end = pfn_to_paddr(mod[j].mod_start) + mod[j].mod_end; @@ -1626,7 +1642,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) } } - for ( i = 0; i < mbi->mods_count; ++i ) + for ( i = 0; i < bi->nr_modules; ++i ) { set_pdx_range(mod[i].mod_start, mod[i].mod_start + PFN_UP(mod[i].mod_end)); @@ -2011,8 +2027,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, bi->nr_modules); + if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2022,7 +2038,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 < bi->nr_modules ? mod + initrdidx : NULL, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Sun Oct 6 21:49: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: 13823874 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 A6B19CFB424 for ; Sun, 6 Oct 2024 21:50:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811319.1223887 (Exim 4.92) (envelope-from ) id 1sxZ95-0005b4-Dh; Sun, 06 Oct 2024 21:50:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811319.1223887; Sun, 06 Oct 2024 21:50:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZ95-0005ax-Ac; Sun, 06 Oct 2024 21:50:31 +0000 Received: by outflank-mailman (input) for mailman id 811319; Sun, 06 Oct 2024 21:50:29 +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 1sxZ93-00051E-Ht for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:50:29 +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 feeb7867-842c-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:50:27 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251406432355.42805100974965; Sun, 6 Oct 2024 14:50: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: feeb7867-842c-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251409; cv=none; d=zohomail.com; s=zohoarc; b=Z5eFUjW7jP8wwgsV5ZT66v2d02ulH4JHOIdGYfusS0AMzh6SexOCLgcw6Gt0nxRNup0GnNpBXHr3BAr8KWpFpQWnvezKvHqPtZL1j6B3RnhR3Y4SrVwU1CA3bywMJkUOOVwTkXHjYsd1nw3/spwcMlW6vw7aIyzq6mbGVi7Z4lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251409; 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=+VxBmPLfHuhGyVCN3XNQywHt4j+f3k80ai+3ymBT5Xk=; b=iz1LYKgAHhL+kGFzqgQn7zcroJXLw5t6A7ZyZwXc3Fc5p1oKotMk1TzL8YlftbAOPaCzhQn0EQLbzggEMAFxQuSUKyIz9tple0kPqnHvBNO2aqYSXLEG2EVJyFyGtZE73sFhTbWlZ9JWo/bUbjZ2z+JZVgSogMuHoP3ZbNaAnIk= 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=1728251409; 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=+VxBmPLfHuhGyVCN3XNQywHt4j+f3k80ai+3ymBT5Xk=; b=GiytQE2yWSs7sVb5k/vmzNXoN6PZM9lutLD9azcp0zBG6lgdb2Yuz5GaPOUqA0iT zO+SYJnGEnqnjkgoulzTtEaKO+yIwlZaKJb1WBPYfaqKqvEMk7KXWZxX5Ec81wrd8hw BYP6EkYx6UmNbnbUxN+/+680Sz46LbTCTIqHJDY8= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 02/44] x86/boot: move boot loader name to boot info Date: Sun, 6 Oct 2024 17:49:13 -0400 Message-Id: <20241006214956.24339-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index a649500ee3a2..98ba773c9bc5 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -14,6 +14,8 @@ */ struct boot_info { unsigned int nr_modules; + + const char *loader; }; #endif /* __XEN_X86_BOOTINFO_H__ */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b75deb4fe4ee..aafc098ca268 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -285,6 +285,9 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0; + bi->loader = (mbi->flags & MBI_LOADERNAME) ? + __va(mbi->boot_loader_name) : "unknown"; + return bi; } @@ -978,7 +981,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; @@ -1032,12 +1035,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bi = multiboot_fill_boot_info(mbi_p); - 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), bi->loader); if ( (kextra = strstr(cmdline, " -- ")) != NULL ) { @@ -1078,7 +1078,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", bi->loader); printk("Command line: %s\n", cmdline); @@ -1171,7 +1171,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 = bi->loader; } else if ( efi_enabled(EFI_BOOT) ) memmap_type = "EFI"; @@ -2039,7 +2039,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ dom0 = create_dom0(mod, modules_headroom, initrdidx < bi->nr_modules ? mod + initrdidx : NULL, - kextra, loader); + kextra, bi->loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Sun Oct 6 21:49: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: 13823877 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 1AE54CFB43F for ; Sun, 6 Oct 2024 21:50:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811320.1223897 (Exim 4.92) (envelope-from ) id 1sxZ9C-00064T-Kq; Sun, 06 Oct 2024 21:50:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811320.1223897; Sun, 06 Oct 2024 21:50:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZ9C-00063l-IE; Sun, 06 Oct 2024 21:50:38 +0000 Received: by outflank-mailman (input) for mailman id 811320; Sun, 06 Oct 2024 21:50:37 +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 1sxZ9B-00051E-8F for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:50:37 +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 0382eaac-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:50:35 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251407684824.8538448252724; Sun, 6 Oct 2024 14:50: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: 0382eaac-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251409; cv=none; d=zohomail.com; s=zohoarc; b=bOooYAtv2R0jfUAshkSHKN1r2PAwmPs8odeWp3OFUyDh98JANeF6ugToKDwEE/QnhUpB4FC0CdqQaP4khQWGpPgz01fda3w/2dZjr63veCoelVsyTB6N1AxgnrHYrW3Jo15LwR/aIwKNZW5nSGzeXdf2j84uRY3K7coX2RlmLqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251409; 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=+uni2D8IzNXNtxODgaLcie6Ece0kX1I6Od5Z1lNdP44=; b=S+dOKMAUdFcxC2R6e1yGaWjCp3neuHSv008sJGOrbmyCnW7v5Ba6HaIckmNXETuSi2aQzckNmL2vMXkA/XtP4V8cTJFOayBBfhmetKWCtEqg86fTT+Ykc88Z/BtPsKsCZIA/jeeOyU2JErbBLfTTjK4RbbDFusEcZtbyQy+8DfE= 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=1728251409; 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=+uni2D8IzNXNtxODgaLcie6Ece0kX1I6Od5Z1lNdP44=; b=DJomWE9EHMgMJMnzE9RJE79vg3sH1zN2t6bw5z4mHPYXC+luiDPwvTV3RTkSQmWO wQdP8EPTAtAb+TFl82XCyEVr0MnZ7hFt8DF73tokzlzA6hx5bFGJInERtMMdE7EIJoU oVJlz2x91kxRx8F8NvnlzhiKsuQDkHJSQz3dHbLc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 03/44] x86/boot: move cmdline to boot info Date: Sun, 6 Oct 2024 17:49:14 -0400 Message-Id: <20241006214956.24339-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 98ba773c9bc5..327038465a44 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -16,6 +16,7 @@ struct boot_info { unsigned int nr_modules; const char *loader; + const char *cmdline; }; #endif /* __XEN_X86_BOOTINFO_H__ */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index aafc098ca268..0921f296075f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -274,6 +274,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; struct boot_info __initdata xen_boot_info; @@ -288,6 +290,12 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) bi->loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name) : "unknown"; + /* Parse the command-line options. */ + if ( mbi->flags & MBI_CMDLINE ) + bi->cmdline = cmdline_cook(__va(mbi->cmdline), bi->loader); + else + bi->cmdline = ""; + return bi; } @@ -981,7 +989,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; @@ -1035,11 +1043,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bi = multiboot_fill_boot_info(mbi_p); - /* Parse the command-line options. */ - if ( mbi->flags & MBI_CMDLINE ) - cmdline = cmdline_cook(__va(mbi->cmdline), bi->loader); - - if ( (kextra = strstr(cmdline, " -- ")) != NULL ) + if ( (kextra = strstr(bi->cmdline, " -- ")) != NULL ) { /* * Options after ' -- ' separator belong to dom0. @@ -1050,7 +1054,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) kextra += 3; while ( kextra[1] == ' ' ) kextra++; } - cmdline_parse(cmdline); + cmdline_parse(bi->cmdline); /* Must be after command line argument parsing and before * allocing any xenheap structures wanted in lower memory. */ @@ -1080,7 +1084,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) printk("Bootloader: %s\n", bi->loader); - printk("Command line: %s\n", cmdline); + printk("Command line: %s\n", bi->cmdline); printk("Xen image load base address: %#lx\n", xen_phys_start); if ( hypervisor_name ) From patchwork Sun Oct 6 21:49: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: 13823878 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 ACD93CFB43F for ; Sun, 6 Oct 2024 21:51:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811326.1223907 (Exim 4.92) (envelope-from ) id 1sxZ9K-0006V2-UD; Sun, 06 Oct 2024 21:50:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811326.1223907; Sun, 06 Oct 2024 21:50:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZ9K-0006UD-P3; Sun, 06 Oct 2024 21:50:46 +0000 Received: by outflank-mailman (input) for mailman id 811326; Sun, 06 Oct 2024 21:50:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZ9K-0006RM-1H for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:50:46 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 08be64d6-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:50:44 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251408844260.4452650836515; Sun, 6 Oct 2024 14:50: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: 08be64d6-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251410; cv=none; d=zohomail.com; s=zohoarc; b=RhoqR4I4q0pWLan9GBidh4YJmbywSpEZ/OScVBmithodruAlVI/SmieboFk950hhpG+XLWTTagdaWQAmdbE183lINDyjni7VLNZVFVrXuTlCBI+Yda64bskKs3QrLqzTbbmtZM7oX9c0kJC5l6/9vm6mdUGzqzJc7vfTfZ8PnIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251410; 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=im/29rNxqImDLCcMDPqpn9SU0pgWzyuA70lRR35s2/Q=; b=G8Dmt+bTfgEYHN5+vTUyB76SQUBETIEnqrR9qJnxL24Z+N8LUs0IpJ38ydaTjzy238w+dzJcN0aC+Y/ilXKYOUwpho+gRqIMTIgvOf7vmdY2XjKxXuaZuDm4al/U5ztU3T3OFxykQFHtw2ZC3uGkJth5xnTUhrZDt6E9JWs6/3k= 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=1728251410; 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=im/29rNxqImDLCcMDPqpn9SU0pgWzyuA70lRR35s2/Q=; b=RF0elIhVwAv7b9mP7rI2DCkiGAyXl/yLiFfWROi/3QYR4WGYFCiqVjBNcxAJ0Dq4 4IsGQNA2yzzDb7Ftz11tf51EhpLMyWPOoEO+Kbscu3SlN53w4NrDuHU+0+NKKSfu8Yi io/n48eNUjGgEc/kuBJ9tCmhGjudDRTxjNbfWnlw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 04/44] x86/boot: move mmap info to boot info Date: Sun, 6 Oct 2024 17:49:15 -0400 Message-Id: <20241006214956.24339-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 327038465a44..87d311ac1399 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,6 +8,8 @@ #ifndef __XEN_X86_BOOTINFO_H__ #define __XEN_X86_BOOTINFO_H__ +#include + /* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. @@ -17,6 +19,9 @@ struct boot_info { const char *loader; const char *cmdline; + + paddr_t memmap_addr; + size_t memmap_length; }; #endif /* __XEN_X86_BOOTINFO_H__ */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0921f296075f..f0482ca8cc55 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -296,6 +296,12 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) else bi->cmdline = ""; + if ( mbi->flags & MBI_MEMMAP ) + { + bi->memmap_addr = mbi->mmap_addr; + bi->memmap_length = mbi->mmap_length; + } + return bi; } @@ -1185,13 +1191,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { memmap_type = "Xen-e820"; } - else if ( mbi->flags & MBI_MEMMAP ) + else if ( bi->memmap_addr ) { memmap_type = "Multiboot-e820"; - while ( bytes < mbi->mmap_length && + while ( bytes < bi->memmap_length && e820_raw.nr_map < ARRAY_SIZE(e820_raw.map) ) { - memory_map_t *map = __va(mbi->mmap_addr + bytes); + memory_map_t *map = __va(bi->memmap_addr + bytes); /* * This is a gross workaround for a BIOS bug. Some bootloaders do From patchwork Sun Oct 6 21:49: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: 13823905 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 DC650CFB43F for ; Sun, 6 Oct 2024 21:57:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811403.1224177 (Exim 4.92) (envelope-from ) id 1sxZFU-0002uz-Rc; Sun, 06 Oct 2024 21:57:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811403.1224177; Sun, 06 Oct 2024 21:57:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFU-0002ud-M5; Sun, 06 Oct 2024 21:57:08 +0000 Received: by outflank-mailman (input) for mailman id 811403; Sun, 06 Oct 2024 21:57: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 1sxZ9U-0006RM-VL for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:50:56 +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 0e969338-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:50:54 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251410008152.1502674267898; Sun, 6 Oct 2024 14:50: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: 0e969338-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251412; cv=none; d=zohomail.com; s=zohoarc; b=VTL42CyW2Td8CIuc8CEiCsM7s42uJYyrxQuZwcET4dOSm2LMiogBUUrD/mYhwRTPSHdD9ew9s0MigvGLbLu8+rMSinr578ZaiWjjJRR60yHcnpy9GP8UxuUpg4eQEWKvnzBOrVvsxMOiSjd3JaF/Jrmd3YfKWFHFE16GJYv5EmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251412; 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=x/0pbSRKvsD7gGf1XEw1gxRP4YoiCChfwLPAVJ7btAM=; b=K29Tpnma1Y/rrhq2MO2DDBPuSBvMxy+s18+q9EFUD8UCqxJlEhg4Z3ZQUH4WdQF8DIeOGtzSHKYTrGbkzoK36IM5KB98KfMe30/P14pUgbXozOpi3Xv6ZqKeDCy9ZYUU50u4Kt2y4aTA97ipRCP+ZrJ+vRvgrGujdpReo/dxFqU= 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=1728251412; 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=x/0pbSRKvsD7gGf1XEw1gxRP4YoiCChfwLPAVJ7btAM=; b=srtDDtbUkOrvDVA12dRaCHk/xDFPGWM4XYGwGQKn4yQY84azTqhzog5sOGUhT9SU ShyNKLmxyCyliVtn2WYt73Q7xcS4/lqjcNUjOGLWjv8VA83cB2qu4w3vuL77y0s12cH QDDhnUyjkZMcxj9aChka9jB0sDOEJcyOKANgFv6U= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 05/44] x86/boot: introduce struct boot_module Date: Sun, 6 Oct 2024 17:49:16 -0400 Message-Id: <20241006214956.24339-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 `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 Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 14 ++++++++++++-- xen/arch/x86/setup.c | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 87d311ac1399..d19473d8941e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,20 +8,30 @@ #ifndef __XEN_X86_BOOTINFO_H__ #define __XEN_X86_BOOTINFO_H__ +#include #include +/* Max number of boot modules a bootloader can provide in addition to Xen */ +#define MAX_NR_BOOTMODS 63 + +struct boot_module { + /* Transitionary only */ + module_t *mod; +}; + /* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. */ struct boot_info { - unsigned int nr_modules; - const char *loader; const char *cmdline; paddr_t memmap_addr; size_t memmap_length; + + unsigned int nr_modules; + struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; #endif /* __XEN_X86_BOOTINFO_H__ */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f0482ca8cc55..68eb4c848ae8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -284,6 +284,8 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) { struct boot_info *bi = &xen_boot_info; const multiboot_info_t *mbi = __va(mbi_p); + module_t *mods = __va(mbi->mods_addr); + unsigned int i; bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0; @@ -302,6 +304,13 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) bi->memmap_length = mbi->mmap_length; } + /* + * This will iterate over all modules to include an extra mb module, which + * should have been reserved to hold an entry for Xen. + */ + for ( i = 0; i <= bi->nr_modules; i++ ) + bi->mods[i].mod = &mods[i]; + return bi; } From patchwork Sun Oct 6 21:49: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: 13823910 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 6FCFFCFB424 for ; Sun, 6 Oct 2024 21:57:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811431.1224293 (Exim 4.92) (envelope-from ) id 1sxZG9-0001Sb-AU; Sun, 06 Oct 2024 21:57:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811431.1224293; Sun, 06 Oct 2024 21:57:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZG9-0001Q6-0H; Sun, 06 Oct 2024 21:57:49 +0000 Received: by outflank-mailman (input) for mailman id 811431; Sun, 06 Oct 2024 21:57: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 1sxZ9c-0006RM-Oj for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:04 +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 14032359-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:51:03 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17282514112724.126986125020153; Sun, 6 Oct 2024 14:50: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: 14032359-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251413; cv=none; d=zohomail.com; s=zohoarc; b=l+kcipkQHwlLBxkls/w+F07A6/TNidxopflU4/XNpdjLLfIemUDQzJdxXC56L/QZ1IpHnnsYvBNBTCvYQvX1bFxUpLt0+kTHrllOm5CQgvs0nSInWU4awJkYTPt4p2NRGC0CkdRV6S7ftEGt/SP6BMO4+bDiYqeCs/0fAAs27aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251413; 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=BE8TyVW42746XaPgeBDvj85Fi23Wy8nFIdm1DUR4nhI=; b=TQUQ1Zh9+7T4eZ1apxvDhqiKVcRwagwqe9Q9aLgN85rY/XMpPirX/QyNKeX64Dmt1quHueWRSeowfV8+LwtI3ApgSTJKldPF6w+Ji5T1xoNW2XHao+7fPTGhOh048fqzwHZZ8KIx7SyZm+P4aqiOwRzGK15oWU78HZNQuYyTwck= 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=1728251413; 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=BE8TyVW42746XaPgeBDvj85Fi23Wy8nFIdm1DUR4nhI=; b=ERdnp+ChYfN0FQoigzs12OEgJLEXohNlZFsiZEgqcXjipzCuiWaSEMecjuBbXqKS wKgyue6cHU81yvA7jL7SLKxOE2vAsDGD/SPaiW89I+HekUm6uhw1Sa9ba9nFPFM6siZ iHp31iEcEBXHyX5pV7Fp8C5VCH/DSKv3zyla8iOc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 06/44] x86/boot: convert consider_modules to struct boot_module Date: Sun, 6 Oct 2024 17:49:17 -0400 Message-Id: <20241006214956.24339-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 mod. No functional change intended. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- 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 68eb4c848ae8..ba9f110d98c6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -629,7 +629,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; @@ -639,20 +639,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)pfn_to_paddr(mods[i].mod->mod_start); + uint64_t end = start + PAGE_ALIGN(mods[i].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); } } @@ -1428,7 +1428,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, bi->nr_modules, -1); + bi->mods, bi->nr_modules, -1); end &= ~mask; } else @@ -1463,7 +1463,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, bi->mods, bi->nr_modules + relocated, j); if ( highmem_start && end > highmem_start ) @@ -1490,7 +1490,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), bi->mods, bi->nr_modules + relocated, -1); if ( s >= e ) break; From patchwork Sun Oct 6 21:49: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: 13823901 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 E4F35CFB424 for ; Sun, 6 Oct 2024 21:57:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811401.1224165 (Exim 4.92) (envelope-from ) id 1sxZFR-0002DG-Ai; Sun, 06 Oct 2024 21:57:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811401.1224165; Sun, 06 Oct 2024 21:57:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFR-0002Br-4Q; Sun, 06 Oct 2024 21:57:05 +0000 Received: by outflank-mailman (input) for mailman id 811401; Sun, 06 Oct 2024 21:57:03 +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 1sxZ9j-0006RM-FG for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:11 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 186e355f-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:51:10 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172825141245318.856694027254207; Sun, 6 Oct 2024 14:50: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: 186e355f-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251414; cv=none; d=zohomail.com; s=zohoarc; b=cm4ml96E4fcgfoUNWfSuPxDqelAqZ0lePU0r5/3SZRmqTO12TvlSGFYClPWgYy+WQ7uM7hyTJP3rYuWzue6Tu+NWlSmrsHSTAlvEBQeXLGkvn1LyyT5gP8FjiMWsMMywmf9GqD5qO4WSt96sIKoUmlmVQkfT9WGHFBlWYlwFQDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251414; 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=wmEpNJvCOY3XSQWugWw1bHFHppHVSJwVFmalxOGZtqI=; b=lW0W2zWt6MbfSfzIZ+4Hj2h6xbhXlff8VC6AA+CfeA6Jd+axN2tDlzRMPCNKW8C0cxm54bd4EnYLXlTLhzFYbvSKj8Y7dbG9WDS+ciEqrkVPHIRlA5XaE0voU1Ma+z79opQii3qlv12/E7/K1H9dXNmjU8Cy38AhuSpOCZ2A+mg= 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=1728251414; 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=wmEpNJvCOY3XSQWugWw1bHFHppHVSJwVFmalxOGZtqI=; b=RUb41T8+0zFUMaqXfWuc0g5LkaRAHrNm3PhTsiZ36dzwgTlQiwvXpmtJ9q2hsqZ2 Hf4CotJkX/vKJIaANtlwk78//gI9foC1SiWvBcBwvE0GPmbGuaCNFb+oe28tuhjUFpf DeH7576HCakcDhkvC4IGyeVo1gXVhBAr3x9rVNic= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 07/44] x86/boot: move headroom to boot modules Date: Sun, 6 Oct 2024 17:49:18 -0400 Message-Id: <20241006214956.24339-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External The purpose of struct boot_module is to encapsulate the state of boot module as it is processed by Xen. Locating boot module state struct boot_module reduces the number of global variables as well as the number of state variables that must be passed around. It also lays the groundwork for hyperlaunch mult-domain construction, where multiple instances of state variables like headroom will be needed. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/setup.c | 23 ++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index d19473d8941e..c7e6b4ebf0da 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -17,6 +17,11 @@ struct boot_module { /* Transitionary only */ module_t *mod; + /* + * A boot module may contain a compressed kernel that Xen will need space + * reserved, into which it will be decompressed. + */ + unsigned long headroom; }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ba9f110d98c6..dd82ca3d43e2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1012,7 +1012,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_info *bi; 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; @@ -1371,7 +1371,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; } - modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); + bi->mods[0].headroom = + bzimage_headroom(bootstrap_map(bi->mods[0].mod), + bi->mods[0].mod->mod_end); + bootstrap_map(NULL); #ifndef highmem_start @@ -1456,8 +1459,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 = &bi->mods[j]; + unsigned long size; + + size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); if ( mod[j].reserved ) continue; @@ -1470,14 +1475,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; } } @@ -1504,7 +1509,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( modules_headroom && !mod->reserved ) + if ( bi->mods[0].headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { @@ -2056,7 +2061,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, bi->mods[0].headroom, initrdidx < bi->nr_modules ? mod + initrdidx : NULL, kextra, bi->loader); if ( !dom0 ) From patchwork Sun Oct 6 21:49: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: 13823893 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 3DF11CFB440 for ; Sun, 6 Oct 2024 21:56:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811367.1224023 (Exim 4.92) (envelope-from ) id 1sxZEr-0003xB-6I; Sun, 06 Oct 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 811367.1224023; Sun, 06 Oct 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 1sxZEq-0003u9-Tj; Sun, 06 Oct 2024 21:56:28 +0000 Received: by outflank-mailman (input) for mailman id 811367; Sun, 06 Oct 2024 21:56:28 +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 1sxZ9s-00051E-35 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:20 +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 1d3ccea8-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:18 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251413620237.5379180699381; Sun, 6 Oct 2024 14:50: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: 1d3ccea8-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251415; cv=none; d=zohomail.com; s=zohoarc; b=LiTgnBWASsbRJ8trdYADGK6vgq6juSZECEm8QjL9CDCtsvxz3LF86FQ8sUdvGT3bffF6845ZEo6iQiSQF9G5g8e9a+i7jzo7aIDtWH5uZOxXfU3Pg2by6fxL7CZfnsaxyW5E5jhI74mct83KbwE0mTZINsh2FuXxfMgj/h6TtYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251415; 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=o7PLHsPZ6nr6p3qDw0hUE5j4XeSnSAA6iUDaBG5Wocg=; b=MrrEi9TDekN30wVsKVzFUkfCSsekkzZpdQ4bQZB4WSxsTIrRqBlAcG1K+ASmSKn85Au1EE+5EyhhVyBtQIVaovvB+gdGH3emmGUrW3n9XaLzIwwIkQZgWmR/p1+qbe5Kp4NDKW2S1Oh/Oxmcp/tP0Jaeo0UO0jQDkChqGTunFzE= 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=1728251415; 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=o7PLHsPZ6nr6p3qDw0hUE5j4XeSnSAA6iUDaBG5Wocg=; b=GAcHTe3bsDi165kmB/hCP67EykYZBMdvJn5U7gNPgSZvkhsgO6U+QQ+565c6FhCv 5O871ak0iktwez3LxxlfDP2JRd2HAyfnshVeovv8qB1NZ6wKS7DGxzHBCw/fhya1bl/ hscw1eI5f2aYZGxPiH3cmlQvWIkeao7BN+4fC4fo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 08/44] x86/boot: convert setup.c mod refs to early_mod Date: Sun, 6 Oct 2024 17:49:19 -0400 Message-Id: <20241006214956.24339-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 dd82ca3d43e2..ba4bee6b93af 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1341,15 +1341,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 = bi->mods[0].mod; for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( bi->mods[i].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; + bi->mods[i].mod->mod_end -= bi->mods[i].mod->mod_start; + bi->mods[i].mod->mod_start >>= PAGE_SHIFT; + bi->mods[i].mod->reserved = 0; } /* @@ -1360,6 +1360,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( xen_phys_start ) { + unsigned int xen = bi->nr_modules; relocated = true; /* @@ -1367,8 +1368,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[bi->nr_modules].mod_start = virt_to_mfn(_stext); - mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; + bi->mods[xen].mod->mod_start = virt_to_mfn(_stext); + bi->mods[xen].mod->mod_end = __2M_rwdata_end - _stext; } bi->mods[0].headroom = @@ -1462,9 +1463,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &bi->mods[j]; unsigned long size; - size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); + size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); - if ( mod[j].reserved ) + if ( bi->mods[j].mod->reserved ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1476,14 +1477,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->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->mod->mod_start << PAGE_SHIFT, + bm->mod->mod_end); + bm->mod->mod_start = (end - size) >> PAGE_SHIFT; + bm->mod->mod_end += bm->headroom; + bm->mod->reserved = 1; } } @@ -1509,13 +1510,15 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( bi->mods[0].headroom && !mod->reserved ) + if ( bi->mods[0].headroom && !bi->mods[0].mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s = (uint64_t)bi->mods[i].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(bi->mods[i].mod->mod_end)); } if ( !xen_phys_start ) @@ -1593,8 +1596,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 < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end = pfn_to_paddr( + bi->mods[j].mod->mod_start) + + bi->mods[j].mod->mod_end; if ( map_e < end ) map_e = end; @@ -1668,11 +1672,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < bi->nr_modules; ++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(bi->mods[i].mod->mod_start, + bi->mods[i].mod->mod_start + + PFN_UP(bi->mods[i].mod->mod_end)); + map_pages_to_xen( + (unsigned long)mfn_to_virt(bi->mods[i].mod->mod_start), + _mfn(bi->mods[i].mod->mod_start), + PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC @@ -2061,8 +2067,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, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? mod + initrdidx : NULL, + dom0 = create_dom0(bi->mods[0].mod, bi->mods[0].headroom, + initrdidx < bi->nr_modules ? + bi->mods[initrdidx].mod : NULL, kextra, bi->loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Sun Oct 6 21:49: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: 13823890 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 5F223CFB440 for ; Sun, 6 Oct 2024 21:56:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811366.1224014 (Exim 4.92) (envelope-from ) id 1sxZEq-0003l6-JR; Sun, 06 Oct 2024 21:56:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811366.1224014; Sun, 06 Oct 2024 21:56:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZEq-0003jr-AR; Sun, 06 Oct 2024 21:56:28 +0000 Received: by outflank-mailman (input) for mailman id 811366; Sun, 06 Oct 2024 21:56:26 +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 1sxZA0-00051E-4H for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:28 +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 21f21c74-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:26 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251414777363.47999883098566; Sun, 6 Oct 2024 14:50: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: 21f21c74-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251416; cv=none; d=zohomail.com; s=zohoarc; b=QtOx3JlBaNesHvtITNP5YdRA+QcUMh2LxsUf3cj2vO/0om4McBZnVdDzDJo7ix84ZnOVa8gtjpIUqNUJRwgOjndW3ABNf1gfu049YbPDaValK/gARz2aqLkp4Mf4p5mQx6Ggkw1hOh2bDiuOFhCwjy5RFnllZbaGSYfBYRZavKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251416; 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=Y+YFqvG91BoEhUMPMtE6Kyra9a+npi8misIshir3lQ0=; b=KP/ngO2WXnRS7rSVzcQGsIZkJlVfYbWj11XuBL3az1C3GbomlReQV5LdQaMo0q6l+DAIym2kkOu3dC9nlkvqxJaOlIW2tBu1kCxZDk9S6i0HqcyjSdy2LQHe4QRXBqviaoHW8GXKAz6Ty3OGfAED/JqsGPQWcxrMzFaecb5lI94= 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=1728251416; 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=Y+YFqvG91BoEhUMPMtE6Kyra9a+npi8misIshir3lQ0=; b=ZQ8AWXZXqMbNDwrC12Vd851S24nqi8Cb1cvihhO9cxwofGqvpjLZjf98juAkzc84 69d4bIwTUpNyI7ksM9x1vAmTM9SAC2QrQpUCJv8zywK1MDZMWvt3R8jz+ZffnzgXyTg IRv4RqmSYV2pnVc6XbHWI8YA9MSOu0WAdmbO6VUQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 09/44] x86/boot: introduce boot module types Date: Sun, 6 Oct 2024 17:49:20 -0400 Message-Id: <20241006214956.24339-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index c7e6b4ebf0da..6941a8975ea6 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -14,6 +14,14 @@ /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 +/* Boot module binary type / purpose */ +enum bootmod_type { + BOOTMOD_UNKNOWN, + BOOTMOD_XEN, + BOOTMOD_KERNEL, + BOOTMOD_RAMDISK, +}; + struct boot_module { /* Transitionary only */ module_t *mod; @@ -22,6 +30,7 @@ struct boot_module { * reserved, into which it will be decompressed. */ unsigned long headroom; + enum bootmod_type type; }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ba4bee6b93af..69c45f115523 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -311,6 +311,10 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) for ( i = 0; i <= bi->nr_modules; i++ ) bi->mods[i].mod = &mods[i]; + /* map the last mb module for xen entry */ + bi->mods[bi->nr_modules].type = BOOTMOD_XEN; + bi->mods[bi->nr_modules].mod = &mods[bi->nr_modules]; + return bi; } @@ -1171,6 +1175,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + bi->mods[0].type = BOOTMOD_KERNEL; if ( pvh_boot ) { @@ -2058,6 +2063,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? "" : "not "); initrdidx = find_first_bit(module_map, bi->nr_modules); + bi->mods[initrdidx].type = BOOTMOD_RAMDISK; if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Sun Oct 6 21:49: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: 13823898 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 40FC8CFB424 for ; Sun, 6 Oct 2024 21:57:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811378.1224087 (Exim 4.92) (envelope-from ) id 1sxZFA-00076m-5h; Sun, 06 Oct 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 811378.1224087; Sun, 06 Oct 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 1sxZFA-00076U-1L; Sun, 06 Oct 2024 21:56:48 +0000 Received: by outflank-mailman (input) for mailman id 811378; Sun, 06 Oct 2024 21:56:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZA8-00051E-6z for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:36 +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 26c117ce-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:34 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172825141593795.75148855391808; Sun, 6 Oct 2024 14:50: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: 26c117ce-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251418; cv=none; d=zohomail.com; s=zohoarc; b=VyLnwAqb497h0jJeT27j0q1Yat7Xzb8keCeAJTth3TBPQxTDXAvYDpzDYOKZ8bQ/KoNYcMEA4RFc7E+LK2+UzqospI2GJterGyuBLiwuZd1pIAhCFqSi+ehlJ/TbQPtKvyYkun94tGktUFyR9r3S8K3M8gbGJta9wDDtu0IecPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251418; 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=LLrOReDmzknWCbN9N+hIkJRPFFBTEgW6Ul0tsXA+CWE=; b=e0kwamlqbiuM9scBH+TRRfT+uWH6AHfbLsmJ5gSg33fgjR/wS0NoZGmFfzEGFEodFOdFcn1tL+KulhnW4pWxxMxUJEO1hiVHIfXeDCmEzJW+EJZHOELAeLnX27Kijvoge/H/2mbtyOKh5+kLjXBiDOu/aZ6VYOGLTlMhSoOkjCs= 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=1728251418; 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=LLrOReDmzknWCbN9N+hIkJRPFFBTEgW6Ul0tsXA+CWE=; b=rBN8lRutmggRr/zlKN4avoLiM5bxkeFnquIdN8NtgvLXT7jZzuDxs4yxEkHTheJU CjQv+n5LMJCpT07tKRIh058llxRJvEaj2BC1IwWioA9lKv9/uxDvLb6Rs5AGyX9OMi2 YbU7/kkvVuvQK2N3zqdtbk2j4zEijEZUJYUmEYP0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 10/44] x86/boot: introduce boot module flags Date: Sun, 6 Oct 2024 17:49:21 -0400 Message-Id: <20241006214956.24339-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk Acked-by: Jan Beulich --- 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 6941a8975ea6..021ff0d93643 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -31,6 +31,10 @@ struct boot_module { */ unsigned long headroom; enum bootmod_type type; + + uint32_t flags; +#define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) + }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 69c45f115523..161415a8e667 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1354,7 +1354,6 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("Bootloader didn't honor module alignment request\n"); bi->mods[i].mod->mod_end -= bi->mods[i].mod->mod_start; bi->mods[i].mod->mod_start >>= PAGE_SHIFT; - bi->mods[i].mod->reserved = 0; } /* @@ -1470,7 +1469,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); - if ( bi->mods[j].mod->reserved ) + if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1489,7 +1488,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bm->mod->mod_end); bm->mod->mod_start = (end - size) >> PAGE_SHIFT; bm->mod->mod_end += bm->headroom; - bm->mod->reserved = 1; + bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1515,7 +1514,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - if ( bi->mods[0].headroom && !bi->mods[0].mod->reserved ) + if ( bi->mods[0].headroom && + !(bi->mods[0].flags & BOOTMOD_FLAG_X86_RELOCATED) ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { From patchwork Sun Oct 6 21:49: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: 13823909 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 F1932CFB43F for ; Sun, 6 Oct 2024 21:57:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811428.1224287 (Exim 4.92) (envelope-from ) id 1sxZG8-0001Gq-Dx; Sun, 06 Oct 2024 21:57:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811428.1224287; Sun, 06 Oct 2024 21:57:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZG8-0001G6-9W; Sun, 06 Oct 2024 21:57:48 +0000 Received: by outflank-mailman (input) for mailman id 811428; Sun, 06 Oct 2024 21:57:47 +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 1sxZAF-00051E-TO for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:43 +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 2b57ecc8-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:42 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251417197888.0299636437695; Sun, 6 Oct 2024 14:50: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: 2b57ecc8-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251419; cv=none; d=zohomail.com; s=zohoarc; b=GB7ur/A9gXUq6rSTAzMhKxVJF6A9DsXJJ5AdLjSQo8OURi5mONX1ZgtDoAN30rLyKp2exHjYKuOWvtpuukY2A7z3QpRXLrW6o1FIQtXwJ8ob1352C2TwK9cAtD5Iv1GEHbn4LpY0yik5oYS+RoKj2MFGTWD6EDYQzXdri8/thJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251419; 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=AiMno3h27u/8NtsH+f5BaBaPNWe2g2HvJaNYtgBk2CY=; b=VevxLj/VLygHMlZMlU1AJ2r/9FZ+JGNgYWxkrbFqBCtnBX7msrfZLKgs7LNA6nbYWAjE7dXaFvzi7GkNXI043hy4m5ltiQHiTsAjEymx3OxDlfYPG2oVJzwu6QYh+ce2lhEG2bOxbEP+VXUv9i4nhlHsCqg/phCp4ZNaMDnCxQA= 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=1728251419; 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=AiMno3h27u/8NtsH+f5BaBaPNWe2g2HvJaNYtgBk2CY=; b=QykZQC2TMTw0xS7zAsnTr+kV/cTI/WUHGySBVl1kr6GCWFwGDA/vhycqzJhLzt7h jJA4CD6YDu1Pr/nZ6ctxBGfWYy3REEJNyQtDKxr2F3tCuVaxiiyWg1NpM+DpB095M22 Zeg/kjycUuoGFlSZwX1F5CR48eTWfULwIzcgJJLA= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, "Daniel P . Smith" , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 11/44] x86/boot: split bootstrap_map_addr() out of bootstrap_map() Date: Sun, 6 Oct 2024 17:49:22 -0400 Message-Id: <20241006214956.24339-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 3d189521189d..213584b05fb2 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -36,6 +36,7 @@ extern struct boot_info xen_boot_info; unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); +void *bootstrap_map_addr(paddr_t start, paddr_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 161415a8e667..1cc7fcba094b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -437,24 +437,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(paddr_t start, paddr_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; @@ -470,6 +468,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 Sun Oct 6 21:49: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: 13823897 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 E274CCFB43F for ; Sun, 6 Oct 2024 21:57:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811390.1224133 (Exim 4.92) (envelope-from ) id 1sxZFK-0000iM-5F; Sun, 06 Oct 2024 21:56:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811390.1224133; Sun, 06 Oct 2024 21:56:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFJ-0000hK-Q2; Sun, 06 Oct 2024 21:56:57 +0000 Received: by outflank-mailman (input) for mailman id 811390; Sun, 06 Oct 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 1sxZAO-00051E-AM for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:51:52 +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 3039b3c7-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:50 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251418372861.7563899223412; Sun, 6 Oct 2024 14:50: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: 3039b3c7-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251420; cv=none; d=zohomail.com; s=zohoarc; b=I4jJR9a2EHCuDsSvc8luUnOJetc4IHL1G9aidlEdyl6Wf6TAhPZ/MMEVdENH5fLb88H9KkyeKP1RGsRr5yGHFUSs1Wcq6+zfE1mEpFQC0SPVcJw+ur0HGpd5kndTujZWqpBfVP+hKYJWJ1Md4IibIIkYSxl+kJFHMTBDhRULblo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251420; 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=RcV1PHBeCLrZ2Ul5KaCez/ZJJqAAL9qH6Sb79p3LNdQ=; b=mAiyY4SN353oPkWOzYkw6jI6Xux4ausBMrn44iPlxeVCdclSCvn00V81mFSHvMRgF5deWWbqWVyq9H5IfyZtPqBHv0D2Hvm16USNXDgnHmatp2HpD/rfhdzz6Xt274VwEjfNxOD/p8uXpyKFFhOY1aj9Kjhnj1kehU/y7uBt0N8= 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=1728251420; 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=RcV1PHBeCLrZ2Ul5KaCez/ZJJqAAL9qH6Sb79p3LNdQ=; b=OFRdUUu86PgsTQnySZnQ0V86SOkirQmUTbS0tV1xjDxC+vuwLVIwmu9Pz3P6Pauj BVdawHpqPVuo4ohL8IbFGbTLEH2uqTF1CWF34DwugX4mfMwUCwA5pT97W2o15Lg/MoS stQTTX1sdOFWEuV2RdzdPAqJwxl8kLkjmR01Tqpk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 12/44] x86/boot: add start and size fields to struct boot_module Date: Sun, 6 Oct 2024 17:49:23 -0400 Message-Id: <20241006214956.24339-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 021ff0d93643..2ee0d5ad6d72 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -35,6 +35,8 @@ struct boot_module { uint32_t flags; #define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) + paddr_t start; + size_t size; }; /* diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 213584b05fb2..bb7e73258a21 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[]; @@ -38,6 +39,7 @@ unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); void *bootstrap_map_addr(paddr_t start, paddr_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 1cc7fcba094b..093a4f5380d1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -309,8 +309,13 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) * should have been reserved to hold an entry for Xen. */ for ( i = 0; i <= bi->nr_modules; i++ ) + { bi->mods[i].mod = &mods[i]; + bi->mods[i].start = (paddr_t)mods[i].mod_start; + bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; + } + /* map the last mb module for xen entry */ bi->mods[bi->nr_modules].type = BOOTMOD_XEN; bi->mods[bi->nr_modules].mod = &mods[bi->nr_modules]; @@ -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 Sun Oct 6 21:49: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: 13823911 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 E54F9CFB440 for ; Sun, 6 Oct 2024 21:57:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811406.1224187 (Exim 4.92) (envelope-from ) id 1sxZFd-00048Q-71; Sun, 06 Oct 2024 21:57:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811406.1224187; Sun, 06 Oct 2024 21:57: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 1sxZFd-000487-15; Sun, 06 Oct 2024 21:57:17 +0000 Received: by outflank-mailman (input) for mailman id 811406; Sun, 06 Oct 2024 21:57:15 +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 1sxZAW-00051E-7s for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:00 +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 34f9efea-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:51:58 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251419620923.5885886254096; Sun, 6 Oct 2024 14:50:19 -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: 34f9efea-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251421; cv=none; d=zohomail.com; s=zohoarc; b=C7bfeo+iZKVTYaWJ5X97pyAu2kDVxcsiEi+xMdkpWZ0++YhzLoZKWU1Ef+5ToV5uGnLUK5ORBfUWDr0PyfBoba7TxiKio+tM96X2Y72MDVqqc7eCj2b04l4my8cNQaYLV2x/j5QSMVd1rdEDeR/IfkvNr6WrIlkjE7GXlxUaKz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251421; 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=NxzxsjEAulp7wEAc20NZOtDa3Lo4GRSs8lW4ILTmQAc=; b=CSOpj5Dxfy9GmEWtV8S9F1lXQZu2+TZvRd9ylYeJPMuarO9zARlX3WG0x/V3cxX6RgNRB2hYmhT5IzUlBlaOUQc9iBj31JsR6sgQ6gLwZVEyBfaxHmV2RHRGoWbsJW7R1m8imQV8sYtvzHFw+AHeUE+aas1RreUot1mYiBeepow= 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=1728251421; 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=NxzxsjEAulp7wEAc20NZOtDa3Lo4GRSs8lW4ILTmQAc=; b=H4X0VdXYKTpFyTzY6KNrY/d+o15qsn73YN+x6tCM7wDI/BAuaZtuMoZwEajxOEHA v8E2yEM7HYHxTu9TWx6kSWghcwUteA4xJS0/xGuTlTMAfZeB3HdY7NjBS62stOv8Ox5 1dULuYPuT/XnQmLqDb6q3sQCynRU34E1vINJ+LZU= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 13/44] x86/boot: update struct boot_module on module relocation Date: Sun, 6 Oct 2024 17:49:24 -0400 Message-Id: <20241006214956.24339-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 093a4f5380d1..f968758048ed 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1392,8 +1392,11 @@ 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. */ - bi->mods[xen].mod->mod_start = virt_to_mfn(_stext); - bi->mods[xen].mod->mod_end = __2M_rwdata_end - _stext; + bi->mods[xen].start = virt_to_mfn(_stext); + bi->mods[xen].size = __2M_rwdata_end - _stext; + + bi->mods[xen].mod->mod_start = bi->mods[xen].start; + bi->mods[xen].mod->mod_end = bi->mods[xen].size; } bi->mods[0].headroom = From patchwork Sun Oct 6 21:49: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: 13823903 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 95E51CFB440 for ; Sun, 6 Oct 2024 21:57:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811396.1224147 (Exim 4.92) (envelope-from ) id 1sxZFP-0001gr-AV; Sun, 06 Oct 2024 21:57:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811396.1224147; Sun, 06 Oct 2024 21:57: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 1sxZFP-0001gT-5x; Sun, 06 Oct 2024 21:57:03 +0000 Received: by outflank-mailman (input) for mailman id 811396; Sun, 06 Oct 2024 21:57:01 +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 1sxZAd-00051E-Qz for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:07 +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 3997bac1-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:52:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251420772766.2057968943333; Sun, 6 Oct 2024 14:50: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: 3997bac1-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251422; cv=none; d=zohomail.com; s=zohoarc; b=AA3iZP6P+/NUmlrLARfVjAVSfA4n8YTISN1RtKfkhmPGFZfgw1dfU/vc1o/gQQqzPIR6AKHja8lt0YN1Pynje8lV9AxuNf4vfl63bayjF6IlJKuFCAW8G89Gy04C7ipNXzNddISVaG6hwB3bt3BpzJClUEVH3Zu1/8RMoDbGtRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251422; 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=V9QgKtPNRLsg8Bm0GHM4LvcFu8fucGZu4abX1YQ8tHQ=; b=GMcYDSMT3wMGi/MRLcETsRy78RyZdQfkBsc/0w1meeY6F7iCCWCZ+fyiNi0ZbrKNpXbX+4awIq7X/wJU0PYG3U1xT3otc3bWaf4xAPpErm43Qf7kzf+vJQLHr4tgmqalcfjF7/cCbpsc8xAYv9hU1YJzI6kc3TGUrmKJpZINWXU= 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=1728251422; 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=V9QgKtPNRLsg8Bm0GHM4LvcFu8fucGZu4abX1YQ8tHQ=; b=L5/Z9p0oIL7mN5wsjEH3OoaCUdM6ct9EwaNfjjCh8LEkk/2ryoQMeOoQn+Es+Xeq p+7SQ26WwSaB0xokIJVP2oF90xkSINQlpFVbs2u5IYPSJ2S+Clnb9sPiYBqhDcHDMg8 frBR+IBD2Yf9FTtjOG1u7as1Y+TEvi2D/7RuePvY= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 14/44] x86/boot: transition relocation calculations to struct boot_module Date: Sun, 6 Oct 2024 17:49:25 -0400 Message-Id: <20241006214956.24339-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f968758048ed..4f540c461b26 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1490,7 +1490,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &bi->mods[j]; unsigned long size; - size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); + size = PAGE_ALIGN(bm->headroom + bm->size); if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; @@ -1504,13 +1504,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( s < end && (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) + paddr_to_pfn(end - size) > paddr_to_pfn(bm->start)) ) { - move_memory(end - size + bm->headroom, - (uint64_t)bm->mod->mod_start << PAGE_SHIFT, - bm->mod->mod_end); - bm->mod->mod_start = (end - size) >> PAGE_SHIFT; - bm->mod->mod_end += bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size); + bm->start = (end - size); + bm->mod->mod_start = paddr_to_pfn(bm->start); + bm->size += bm->headroom; + bm->mod->mod_end = bm->size; bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1542,11 +1542,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 < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)bi->mods[i].mod->mod_start - << PAGE_SHIFT; + uint64_t s = (uint64_t)bi->mods[i].start; reserve_e820_ram(&boot_e820, s, - s + PAGE_ALIGN(bi->mods[i].mod->mod_end)); + s + PAGE_ALIGN(bi->mods[i].size)); } if ( !xen_phys_start ) @@ -1624,9 +1623,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 < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr( - bi->mods[j].mod->mod_start) + - bi->mods[j].mod->mod_end; + uint64_t end = bi->mods[j].start + + bi->mods[j].size; if ( map_e < end ) map_e = end; @@ -1700,13 +1698,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < bi->nr_modules; ++i ) { - set_pdx_range(bi->mods[i].mod->mod_start, - bi->mods[i].mod->mod_start + - PFN_UP(bi->mods[i].mod->mod_end)); + set_pdx_range(paddr_to_pfn(bi->mods[i].mod->mod_start), + paddr_to_pfn(bi->mods[i].mod->mod_start) + + PFN_UP(bi->mods[i].size)); map_pages_to_xen( - (unsigned long)mfn_to_virt(bi->mods[i].mod->mod_start), - _mfn(bi->mods[i].mod->mod_start), - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); + (unsigned long)maddr_to_virt(bi->mods[i].start), + maddr_to_mfn(bi->mods[i].start), + PFN_UP(bi->mods[i].size), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC From patchwork Sun Oct 6 21:49: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: 13823908 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 073B7CFB424 for ; Sun, 6 Oct 2024 21:57:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811421.1224267 (Exim 4.92) (envelope-from ) id 1sxZG1-0000EF-Kl; Sun, 06 Oct 2024 21:57:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811421.1224267; Sun, 06 Oct 2024 21:57:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZG1-0000Do-Fv; Sun, 06 Oct 2024 21:57:41 +0000 Received: by outflank-mailman (input) for mailman id 811421; Sun, 06 Oct 2024 21:57: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 1sxZAm-00051E-OF for xen-devel@lists.xenproject.org; Sun, 06 Oct 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 3ed2f10f-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:52:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172825142194853.559157816554375; Sun, 6 Oct 2024 14:50: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: 3ed2f10f-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251423; cv=none; d=zohomail.com; s=zohoarc; b=LLNk/4S0TYK3SgAjpsFQ+SoXPGn8bPocbqUn0KdQ/34RNWeoCb4cuQZZQk3qYZP9Gn6VonaXCa4nR+3iK8+CxB4pazWS3u+KBKyk+EEMAD3/p31VKkLTlIqlGLxjuERDg5Dge3GCykX4eGxOyMAbdlOpdVgl955fbsRA3T7huKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251423; 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=QE3lxVGKOuPftRvukhIadN4V91ghc85ZfnuZPHZLmIo=; b=mJQz/cqEutJwHL/MYnPx7lLsDxEhaxyxVRNA28L/jPuxwF3Cl4ns0gSWJ/MOfU0QWCKjignlnA0sJoI0j/JYXzBewbqLiSf70UYG8PPDee7DZeUB5kUGOlblPIt5sxmPOwKPdCRR4WVy5hmD76FDhNCefC3asj5Ck9kLWXVwGHM= 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=1728251423; 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=QE3lxVGKOuPftRvukhIadN4V91ghc85ZfnuZPHZLmIo=; b=qUUxBvfdPWSDGtnAhWNDYtp4F90sB0unDG/87/VgH/qrEyInYs/+VYtBc+m1yags OPXcMhoLhrz9CoPmrTmcl3KIJQT1Fdi74ikWcFdJ5ma/xz1WVXJy0oEMd1CS0SRXLEf oVi6qucOarqEGVOzO1smJCuXSCJO0iLbzl3p0Gzg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 15/44] x86/boot: introduce boot module interator Date: Sun, 6 Oct 2024 17:49:26 -0400 Message-Id: <20241006214956.24339-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 2ee0d5ad6d72..c79678840d31 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -54,8 +54,24 @@ struct boot_info { struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; -#endif /* __XEN_X86_BOOTINFO_H__ */ +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_modules; 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 /* __XEN_X86_BOOTINFO_H__ */ /* * Local variables: * mode: C From patchwork Sun Oct 6 21:49: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: 13823879 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 68312CFB43F for ; Sun, 6 Oct 2024 21:52:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811338.1223917 (Exim 4.92) (envelope-from ) id 1sxZAv-0007a5-81; Sun, 06 Oct 2024 21:52:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811338.1223917; Sun, 06 Oct 2024 21:52: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 1sxZAv-0007Zy-4J; Sun, 06 Oct 2024 21:52:25 +0000 Received: by outflank-mailman (input) for mailman id 811338; Sun, 06 Oct 2024 21:52:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZAt-0007Zk-OC for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:23 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 43674cee-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251423076361.4005991604132; Sun, 6 Oct 2024 14:50: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: 43674cee-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251424; cv=none; d=zohomail.com; s=zohoarc; b=Cm2yfDgYKVhiWdiJpNXBaqZCh9/wTnSqO8SGzK4i6Z2mEkoDfvn7ZaQtEFd37N1xSBjAiKfMd1b2p5Mg7D1JS9mdth0ESL+yyaBCW3jOP8Rlpf6bBk5DzLR6spYt1rzNg2USfy1EbmK2LdMywHEO220c6vuV/DuOWCPGpocKtt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251424; 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=rsjinz7BtJ8PUF4bqFrjiANBKB2lhUkIggv9H9Y5wr0=; b=kXenxq/25XZNg6VAiDUYU2cr/yZp0s512PCAb+K53nXBh0byxnHgyNBSahYP1ZH+fH5WMkNHamDAX08LtWSR84NS9N/DjD7q9bFxFaxE8gzNSVdSQksmsrDMUOJBqYIRn4Wx0EkxSLSgkfrCEdXskCqytUbMroS/n5w0BIrztuM= 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=1728251424; 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=rsjinz7BtJ8PUF4bqFrjiANBKB2lhUkIggv9H9Y5wr0=; b=ehzm01XGqWInV9duJeZ9tiR0stjjoz0zfGP6K3UYKwH/3lybb1s+SnrcF+W59Guc fxTfJVR6HrLql3mNUYSPYUIvPAW9JD3Q9cpRB/sDPeYfoChjjfZkxhNRJlk7lIcrlCN 95eZReM0hPWsK8zd0gsPWMPLoTkf1ojisL2432SE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 16/44] x86/boot: introduce consumed flag for struct boot_module Date: Sun, 6 Oct 2024 17:49:27 -0400 Message-Id: <20241006214956.24339-17-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 c79678840d31..7833b065eff1 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -34,6 +34,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 4f540c461b26..235b4e41f653 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -318,6 +318,7 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) /* map the last mb module for xen entry */ bi->mods[bi->nr_modules].type = BOOTMOD_XEN; + bi->mods[bi->nr_modules].flags |= BOOTMOD_FLAG_X86_CONSUMED; bi->mods[bi->nr_modules].mod = &mods[bi->nr_modules]; return bi; @@ -1196,6 +1197,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ bi->mods[0].type = BOOTMOD_KERNEL; + bi->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; if ( pvh_boot ) { @@ -2085,6 +2087,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) initrdidx = find_first_bit(module_map, bi->nr_modules); bi->mods[initrdidx].type = BOOTMOD_RAMDISK; + bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Sun Oct 6 21:49: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: 13823881 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 543C1CFB424 for ; Sun, 6 Oct 2024 21:52:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811339.1223927 (Exim 4.92) (envelope-from ) id 1sxZB2-0007rn-Ds; Sun, 06 Oct 2024 21:52:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811339.1223927; Sun, 06 Oct 2024 21:52: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 1sxZB2-0007rg-Al; Sun, 06 Oct 2024 21:52:32 +0000 Received: by outflank-mailman (input) for mailman id 811339; Sun, 06 Oct 2024 21:52:30 +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 1sxZB0-0007Zk-N2 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:30 +0000 Received: from sender3-of-o59.zoho.com (sender3-of-o59.zoho.com [136.143.184.59]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 47b2d596-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:29 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251424241362.33263729658347; Sun, 6 Oct 2024 14:50:24 -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: 47b2d596-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251426; cv=none; d=zohomail.com; s=zohoarc; b=Dj3EA8If0G5yMwKqaTp3FThzMtbUDefDpjUIs0gY1Jf2Qa/BGak3dAZk5/HG3TKYRZajafvTlz1e9aqQnGR7Noom6ODChTxju1n4YuKgcucbdbiIsoo1RuaNBWdYpwdZCiru3u/93GthrtAT0DRt4EhYwuR9bKB9dROapyAFvCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251426; 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=HEqo8d6ZIFv5zBQXXADComdO+6rAups1e2Re1r6sRig=; b=WEzs8n0cuOpxJcvDVmDkrXvbVBzRownzeqaChiAo5YUQF/XnUvrFE5BRdi1O0aGj79QDYK4S0u1QZdhAXCZbuq5Xps3/qt5gJEE1KHckC8e3zwckB3UrvoSR1g8xZKn71UDMJyqWyqDQzqOI7Xbj4EkdU7jxvFROlArt3GlDP7I= 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=1728251426; 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=HEqo8d6ZIFv5zBQXXADComdO+6rAups1e2Re1r6sRig=; b=SPTLkQK7xclopGcA5Q0I2EftBiP9yT7m6KmGKxBTxb7NoG/y4DlSJfWd8PFuTgyS odp0LsCDIwHxY6syyR7Tm/ktYZHSx2J3ZfeyzQxjSGQWrXQIXINIMnllnQqTmqRBRqm VboEVnRN+okPH4L9y3BpwPqVaJJVSBk5F4v4JKoc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 17/44] x86/boot: convert microcode loading to consume struct boot_info Date: Sun, 6 Oct 2024 17:49:28 -0400 Message-Id: <20241006214956.24339-18-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 8564e4d2c94c..22fea80bc97e 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 @@ -153,10 +154,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; @@ -178,16 +177,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_modules; 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; } @@ -205,20 +204,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, 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_modules; + if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_modules || !__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].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; @@ -822,8 +819,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; @@ -832,7 +829,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), @@ -879,7 +876,7 @@ static int __init early_microcode_update_cpu(void) } int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) + struct boot_info *bi) { const struct cpuinfo_x86 *c = &boot_cpu_data; int rc = 0; @@ -922,7 +919,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 7833b065eff1..1ec29a423061 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -20,6 +20,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..495c8f7a7cc5 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, 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 235b4e41f653..48c509b62a4c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1382,7 +1382,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, bi); if ( xen_phys_start ) { @@ -1939,7 +1939,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, bi); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Sun Oct 6 21:49: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: 13823882 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 22645CFB43F for ; Sun, 6 Oct 2024 21:53:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811340.1223937 (Exim 4.92) (envelope-from ) id 1sxZB8-0008EH-Pm; Sun, 06 Oct 2024 21:52:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811340.1223937; Sun, 06 Oct 2024 21:52:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZB8-0008EA-Lz; Sun, 06 Oct 2024 21:52:38 +0000 Received: by outflank-mailman (input) for mailman id 811340; Sun, 06 Oct 2024 21:52: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 1sxZB7-0007Zk-GS for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:37 +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 4bd39301-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:36 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251425417792.9443259328399; Sun, 6 Oct 2024 14:50: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: 4bd39301-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251427; cv=none; d=zohomail.com; s=zohoarc; b=h/mY93XEW60nPUsutwR7iWiZgS7zET21cJ4yQTyDysiruHKRm8t7wivLjV7959M4/sdkL/q8SnA9U5T8bX9WRgc6YhSh6f/Q/pR3Esq/hlvIkQ21CMpHROlW5AakscV4z3HMXWInpNlfgjPjQ3Y70XuoITs9Yk4jajNMF6gRd5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251427; 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=8SJ3l6W5Fjze1fW/V5fSHZb+ng2bvJdWFKLTG0JGAVw=; b=g/IbNRwL6A8CwnPXgVAQ/ECGSjSlk7PEmuMGs43D739olVVzdOPJjtWS7ruodofg0LKNKgvp4CJ3MokkwHYuU9Qs/NcSqEWcU8kRCRIOcx4LpQ/YLBTFu7Gydm2XJ8bQ7Mk7l4atB0csRDgz9iKZcRbq+3RezNwyELYlbexvaaE= 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=1728251427; 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=8SJ3l6W5Fjze1fW/V5fSHZb+ng2bvJdWFKLTG0JGAVw=; b=aza6s0qGlurg7cBUEJca7VCER1+nInKzjWvx1cPrFUF8NGpDHDVaWhVHogNDw7D3 j/V78wUDLrhpr1tcTDfdNpFduw4iQ1koUcd1R3BBRYq8X5ueELxfSVqqzF97rtipF18 LLVOqO/s6r6HLjkaZRpoidDe938Hl9dLeYQPExzU= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 18/44] x86/boot: convert late microcode loading to struct boot_module Date: Sun, 6 Oct 2024 17:49:29 -0400 Message-Id: <20241006214956.24339-19-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 22fea80bc97e..7bcc17e0ab2f 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; @@ -98,7 +97,7 @@ struct patch_with_flags { 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; @@ -199,7 +198,7 @@ static void __init microcode_scan_module( ucode_blob.data = cd.data; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } } @@ -212,7 +211,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].mod; + ucode_mod = bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) microcode_scan_module(module_map, bi); @@ -766,14 +765,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; @@ -831,9 +830,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); @@ -852,10 +851,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 ) @@ -921,7 +920,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 Sun Oct 6 21:49:30 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: 13823880 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 9F88CCFB424 for ; Sun, 6 Oct 2024 21:52:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811341.1223947 (Exim 4.92) (envelope-from ) id 1sxZBF-0000B3-1q; Sun, 06 Oct 2024 21:52:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811341.1223947; Sun, 06 Oct 2024 21:52:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZBE-0000Aw-U5; Sun, 06 Oct 2024 21:52:44 +0000 Received: by outflank-mailman (input) for mailman id 811341; Sun, 06 Oct 2024 21:52:44 +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 1sxZBE-0007Zk-1r for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:44 +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 4fbdc0bc-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:43 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251426576325.80828550922445; Sun, 6 Oct 2024 14:50: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: 4fbdc0bc-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251428; cv=none; d=zohomail.com; s=zohoarc; b=N7iKppSVcfv0jDz46c/BvD4cZCGDru5iTva3GFu9FHVTvhmUf9lpTML2p4EIi9k9MUBmUIVXeQLPiuly8CG8ML123LKGsAA7mgAGjaNgrsNZbJwPFfvWMkJHyEwumFJnR+tGPSBZsAY9dLD1Zi9FbuW8Uvc76GXeuTD/Wed0ays= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251428; 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=VF4eHm6uxrTpSrtxk8vxbuolB5VgBKHNdcHv6nx9QeQ=; b=LJLNm2vN3suBgycEWjxJ09CR8EDgehILREXuI8TxjaGY2KRT56AuEoWTJjQ5scv3IPvg+44rj0AjobqOJcSh1vsnOX5jJ1Q0X74bZpEnxUKS+5pZyKu3ifk2VcybGsVfaSdiJlA9Hi/bIaJ6XtY+A7lhhnl4FWR85dQbiT0QYsE= 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=1728251428; 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=VF4eHm6uxrTpSrtxk8vxbuolB5VgBKHNdcHv6nx9QeQ=; b=jdwto2rbWK+65sAyB9UAyAZfy1cVxDbiBOPoToPpI6P7OBGsR3QtrR05OhORT9cT I9VVlY4HKGk8CqJ+ShLQn5YhCdW/3s0s09AUO4ZLTuYPJNrp7aLsS/JbNWlp+lLcMXZ hngLz9gRcYCJmjyAKs2gHJNOrO8hH6vCSqhyQgH4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 19/44] x86/boot: use consumed boot module flag for microcode Date: Sun, 6 Oct 2024 17:49:30 -0400 Message-Id: <20241006214956.24339-20-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 7bcc17e0ab2f..5b42aad2fdd0 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; @@ -211,7 +211,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); @@ -769,10 +769,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; @@ -826,14 +826,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; @@ -851,10 +851,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 ) @@ -920,7 +920,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 Sun Oct 6 21:49:31 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: 13823883 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 9426ACFB43F for ; Sun, 6 Oct 2024 21:53:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811343.1223956 (Exim 4.92) (envelope-from ) id 1sxZBN-0000nl-8d; Sun, 06 Oct 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 811343.1223956; Sun, 06 Oct 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 1sxZBN-0000ne-5t; Sun, 06 Oct 2024 21:52:53 +0000 Received: by outflank-mailman (input) for mailman id 811343; Sun, 06 Oct 2024 21:52:51 +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 1sxZBL-0007Zk-Gy for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:51 +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 53ea6be1-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:50 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251427757545.6494291742589; Sun, 6 Oct 2024 14:50: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: 53ea6be1-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251429; cv=none; d=zohomail.com; s=zohoarc; b=ee4crEVc8qe5BMK4juKcdNkqFWSezFP+nVQmV2l+x51NKld5jKi/PW8BKxf+XLdZfAI1QDm61wdIkTmakyhjd1UMIO2I0R4BKfuhDUXIpH77l76fIMFYQnj/enyoVxqqLpJ6G0yI4aZO3gT6O8LSBRxjR+ZdC7/gWOwLJhg8VLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251429; 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=JIn7xG+4jabXsP0NV21SdZNlGU9vp4JgVyXNn06XG5c=; b=NByntYxYIG50tIZNv7RX5QKKvQlcYz9fRdREQSIGv24G3G+zUsrzawhwkBC2lvvHStMu7QVkHGXNZBSZz8MucfmkGxzraRL+c5TL6V19awXieAgQgY1RkTo27FwpayvMMpo3FAsUUyypLsz3m6Y5PEdpK6mS7nD25LZ33WRXNSA= 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=1728251429; 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=JIn7xG+4jabXsP0NV21SdZNlGU9vp4JgVyXNn06XG5c=; b=B7wx8YJy3b4x4ZoojtzxmqPKOhK8Fp0alkuYI75q4PlTATgMlXNBlkePA4nOPjwP /TVZ+/bb79Y5S1pLAqnBighPCC6fveZVEu+3LVLkzVGxyNuKM09V+FUBGGsK6KZEvLX Ri89Yvs+KuvwZ7W2K5QvygtQ7Laz6+VvcrZAZ29k= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 20/44] x86/boot: convert xsm policy loading to struct boot_module Date: Sun, 6 Oct 2024 17:49:31 -0400 Message-Id: <20241006214956.24339-21-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 1ec29a423061..5cbd1cbbbccd 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -21,6 +21,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 48c509b62a4c..e560fa798d71 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1865,7 +1865,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, bi); /* * 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..69d3800d4c39 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, 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..921bb254b9d1 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, 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_modules-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 Sun Oct 6 21:49:32 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: 13823916 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 11DD1CFB440 for ; Sun, 6 Oct 2024 21:58:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811415.1224237 (Exim 4.92) (envelope-from ) id 1sxZFs-0006rA-6d; Sun, 06 Oct 2024 21:57:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811415.1224237; Sun, 06 Oct 2024 21:57: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 1sxZFs-0006qS-0r; Sun, 06 Oct 2024 21:57:32 +0000 Received: by outflank-mailman (input) for mailman id 811415; Sun, 06 Oct 2024 21:57:30 +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 1sxZBS-00051E-TN for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:58 +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 580a8eea-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:52:57 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172825142887696.29494057344664; Sun, 6 Oct 2024 14:50: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: 580a8eea-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251430; cv=none; d=zohomail.com; s=zohoarc; b=jJzy7FhjHrKYYkfDzW82tNVzizfhfrM5oeOLo+W/ef03H2uzWQZE1RMJbmomBzr7yuJ5tRm/lTK3cOS7peDUVExqmeZw/GAPey/qiSyJQkNF6+vRm/XnQ0mcf0xSpDvbhzv+UjxmSAp99qVwmxY3y16CbU6jZIBv7l1Uz3Bh5Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251430; 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=KVTUDBf5itHqMtcxsfp0xgFE01OmBqCDzmFITv9nlQc=; b=BiV8zUzkA4pwde/ZeTvSzmQl7S/0z/w+sZ7jozKPUjtXQfPtdAC7H3xaMaiKMqnqFRuO8IK5+giXdmkzGi85VagWERViZd98Wshh57ttmNuz4EqRDM+ZiPGGHPeLXzIRNGGN+6T8y/v4gfhCqm84doieY3/7gkwVNyQbWkGuSL4= 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=1728251430; 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=KVTUDBf5itHqMtcxsfp0xgFE01OmBqCDzmFITv9nlQc=; b=hcqnVXJQx58AauJ0JQOQSP0iuHt8lDEUGUih0+X07oDBmnqq2BmGKe+JI3LAB11N jcslhyy5N3fSTEIIjJl/Mzx3f4FLRWirPE2lGpL6KFjc1aY+7aVwZ8oived+ZCvFTUp uyZ3CcimJ5K1VafiL4Jwf5+ZjxZYcn+2zH0tU6qM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 21/44] x86/boot: convert ramdisk locating to struct boot_module Date: Sun, 6 Oct 2024 17:49:32 -0400 Message-Id: <20241006214956.24339-22-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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. In the change, the new boot module iterator is used to find the initrd index, which returns a signed int. Switch initrdidx from unsigned to signed. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/setup.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e560fa798d71..e42afb0c30cb 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1033,7 +1033,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) char *kextra; void *bsp_stack; struct cpu_info *info = get_cpu_info(), *bsp_info; - unsigned int initrdidx, num_parked = 0; + unsigned int num_parked = 0; struct boot_info *bi; multiboot_info_t *mbi; module_t *mod; @@ -1042,7 +1042,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) unsigned long eb_start, eb_end; bool acpi_boot_table_init_done = false, relocated = false; bool vm_init_done = false; - int ret; + int initrdidx, ret; struct ns16550_defaults ns16550 = { .data_bits = 8, .parity = 'n', @@ -2085,20 +2085,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, bi->nr_modules); - bi->mods[initrdidx].type = BOOTMOD_RAMDISK; - bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; - if ( bitmap_weight(module_map, bi->nr_modules) > 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(bi, BOOTMOD_UNKNOWN); + if ( initrdidx >= 0 ) + { + bi->mods[initrdidx].type = BOOTMOD_RAMDISK; + bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + if ( first_boot_module_index(bi, 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(bi->mods[0].mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? + (initrdidx >= 0 && initrdidx < bi->nr_modules) ? bi->mods[initrdidx].mod : NULL, kextra, bi->loader); if ( !dom0 ) From patchwork Sun Oct 6 21:49:33 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: 13823891 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 EC38DCFB43F for ; Sun, 6 Oct 2024 21:56:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811365.1224007 (Exim 4.92) (envelope-from ) id 1sxZEq-0003ch-2k; Sun, 06 Oct 2024 21:56:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811365.1224007; Sun, 06 Oct 2024 21:56:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZEp-0003al-Tf; Sun, 06 Oct 2024 21:56:27 +0000 Received: by outflank-mailman (input) for mailman id 811365; Sun, 06 Oct 2024 21:56:26 +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 1sxZBa-00051E-1o for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:06 +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 5c4c2da6-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:53:04 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251430044946.1779583169215; Sun, 6 Oct 2024 14:50:30 -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: 5c4c2da6-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251432; cv=none; d=zohomail.com; s=zohoarc; b=fi3792AYUyNhvg31Zl86HKd8400o5iQihGwm9Cawmxrkq1DIcmW8ZuLXYrAVZSeRn1jz5fPpWoQ45ue9lgEn2wg3EvixOV2pJqHOU++dozBp5LEgsbSsZ/UqdmWTq+lq3J6jmNH7SzUF0hHaNg/KmDHEqzGzQhikyXhs/BWkykY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251432; 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=bxPxcsxpPK9+pHqiZxrW+JILNThIMZMh2pWKm97OWhk=; b=hcCFcLK+IScnUaCr0rxu4ESp73E3Qh6EJW8tlC/Dd4ywrcVu4evVPAMItudQeVpb84GfE95DqWZSk2/bxm/oa9AwzqK185DqSX9MFV8+qa9DhGyyv5+ZbHmKYabFZ3QjL5gY1Yi2cst2VB3TV/w5TlXD9qE1657Ih0lEnlHIlsE= 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=1728251432; 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=bxPxcsxpPK9+pHqiZxrW+JILNThIMZMh2pWKm97OWhk=; b=M00QmXCBVaGP+mHgTK8ZT73wNfUDOvY1+XY1G5HHQKI24oyqb5aJhsEBvy7rVHQW eMUb6TFl4WReUFm/wTIYhwTj626FOlXe6duBu3IDX5horwjcIWTK577wxLKEl6piORp Gl7VJCBlkqpo9DhMPcJuCrMPL9nR6EXdLb+2e72I= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 22/44] x86/boot: remove module_map usage from microcode loading Date: Sun, 6 Oct 2024 17:49:33 -0400 Message-Id: <20241006214956.24339-23-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 5b42aad2fdd0..f7ce2247a33e 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -152,8 +152,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; @@ -178,7 +177,7 @@ static void __init microcode_scan_module( */ for ( i = 1 /* Ignore dom0 kernel */; i < bi->nr_modules; i++ ) { - if ( !test_bit(i, module_map) ) + if ( bi->mods[i].type != BOOTMOD_UNKNOWN ) continue; _blob_start = bootstrap_map_bm(&bi->mods[i]); @@ -202,19 +201,18 @@ static void __init microcode_scan_module( } } -static void __init microcode_grab_module( - unsigned long *module_map, struct boot_info *bi) +static void __init microcode_grab_module(struct boot_info *bi) { if ( ucode_mod_idx < 0 ) ucode_mod_idx += bi->nr_modules; if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_modules || - !__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; @@ -818,8 +816,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; @@ -828,7 +825,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), @@ -874,8 +871,7 @@ static int __init early_microcode_update_cpu(void) return microcode_update_cpu(patch, 0); } -int __init early_microcode_init(unsigned long *module_map, - struct boot_info *bi) +int __init early_microcode_init(struct boot_info *bi) { const struct cpuinfo_x86 *c = &boot_cpu_data; int rc = 0; @@ -918,7 +914,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 495c8f7a7cc5..84e0eb487244 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, struct boot_info *bi); -int microcode_init_cache( - unsigned long *module_map, const struct boot_info *bi); +int early_microcode_init(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 e42afb0c30cb..90acd4180441 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1382,7 +1382,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, bi); + early_microcode_init(bi); if ( xen_phys_start ) { @@ -1939,7 +1939,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) timer_init(); - microcode_init_cache(module_map, bi); /* Needs xmalloc() */ + microcode_init_cache(bi); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Sun Oct 6 21:49:34 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: 13823913 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 74A7ACFB424 for ; Sun, 6 Oct 2024 21:58:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811417.1224257 (Exim 4.92) (envelope-from ) id 1sxZFw-0007oE-82; Sun, 06 Oct 2024 21:57:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811417.1224257; Sun, 06 Oct 2024 21:57:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFw-0007nL-4B; Sun, 06 Oct 2024 21:57:36 +0000 Received: by outflank-mailman (input) for mailman id 811417; Sun, 06 Oct 2024 21:57:35 +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 1sxZBh-00051E-1d for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:13 +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 6090b9fa-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:53:11 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251431236817.04787703317; Sun, 6 Oct 2024 14:50:31 -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: 6090b9fa-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251433; cv=none; d=zohomail.com; s=zohoarc; b=lh3KVpki89otWeudeeH6H/BP6+EEsTgz29UixmIvZK3bmD+A6DB8m3RwBdWQBfD0FQuvqxhv1FwG0ltWi2p72FXxgFj+KLlvTplusBSft0Gc/7sGjYpY4nd4oYXabOEHYR0mNcyW2zB0VcFcF/apDbg7H4wEot5txFDJJlHqOS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251433; 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=+2Ke8GYb62UIWjB0JwnvDHRLpWBMoxBl4a1CfrQFltM=; b=ZJx3+cenL9JK8a0gyApg0qIYO++s67R+A6jg2cO3jLc43JiFQc42ILx2UIzB/3gz2/zgwCZb7uHA+dcOO22i/Bz5v62BLnQiiAwG3cG9VMTG1IrBICEFaLXiC+cBlUiNoQbC86YO1SAe8OZ6VvxBOadWrCOk53p4Kq8KKnU8idU= 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=1728251433; 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=+2Ke8GYb62UIWjB0JwnvDHRLpWBMoxBl4a1CfrQFltM=; b=dXz6sbI74T6TmjMqwbyo0edtylcAQ1m5W7glp/4Ut07IYu/gKqsVxbwiqH8fMTh+ QXmApr0nQCL3juUMcSxtbxKBL4dQ9p0REa7JEd4M6uMPM+qg0ZISkrgbq9pFlMaxdKE GdjJ6EIN3bmi56XcgKrEFTX2nYUCk/vSeds20n2g= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 23/44] x86/boot: remove module_map usage from xsm policy loading Date: Sun, 6 Oct 2024 17:49:34 -0400 Message-Id: <20241006214956.24339-24-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- 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 90acd4180441..b0946216ea3f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1865,7 +1865,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, bi); + xsm_multiboot_init(bi); /* * 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..791936e5285b 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(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); + 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(struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 69d3800d4c39..0e74b96a4cc7 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, struct boot_info *bi) +int __init xsm_multiboot_init(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 921bb254b9d1..a22367a62e93 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, struct boot_info *bi, - void **policy_buffer, size_t *policy_size) + 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_modules-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 Sun Oct 6 21:49:35 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: 13823894 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 8EDF7CFB43F for ; Sun, 6 Oct 2024 21:56:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811370.1224057 (Exim 4.92) (envelope-from ) id 1sxZEw-0005Aj-V0; Sun, 06 Oct 2024 21:56:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811370.1224057; Sun, 06 Oct 2024 21:56: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 1sxZEw-0005AI-QM; Sun, 06 Oct 2024 21:56:34 +0000 Received: by outflank-mailman (input) for mailman id 811370; Sun, 06 Oct 2024 21:56:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZBo-00051E-MH for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:20 +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 650a9e33-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:53:18 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251432400543.0775612505048; Sun, 6 Oct 2024 14:50:32 -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: 650a9e33-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251434; cv=none; d=zohomail.com; s=zohoarc; b=Wo8l/iqs0v+YfsaZggX/JdItZU2EmCAUgfcamMKYsfid1EJDnECFn4sKQJAHUyxaeNoJZx77kzctPUMAiCEE3FPuZJdTVYq0mFoyNv0deqgNymhsgE2nZKxOE8hkqMDpgCj2do7bb8kxhFRMjFGTanGN0yBThnxHXBEsiXGyjeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251434; 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=DcuCOm6F9wLbL6EWI6TTjiee10KbQ7Dlc1P2+oEs++8=; b=OEG2q/wo8v1TSZnurKIcogeSRcN0SIJHJx4/3DPCCD5dqepJNRwK+THd/e1lBr9Fjz95vclJfhzCdHw4Qi9lyPxJ0hGvQBSbX3tnTV70N8A0IR8fPs+4Rs4QzRf7RaCpu3r8JSWmnuhFMpDEru3w0YeMjId5cKDEdDw2C7rIrew= 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=1728251434; 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=DcuCOm6F9wLbL6EWI6TTjiee10KbQ7Dlc1P2+oEs++8=; b=B0mBQ53ebkIPVGD6KF5U3rj4y012k0er12okRIsoW5dXagXZ1xAP9ZPE0hVUyqSG pbI6CLMhIRbcSQ8luiw7Y9dsHjrhQ4Wvhp7L7JmywDTwNcT/DU5vU4HTBzFVTwDPpu+ iZlCeOz+MOBnbtu++fqPqfxiZwc68GtGri85uFhg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 24/44] x86/boot: remove module_map usage by ramdisk loading Date: Sun, 6 Oct 2024 17:49:35 -0400 Message-Id: <20241006214956.24339-25-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b0946216ea3f..0d2ee19998aa 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1037,7 +1037,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_info *bi; 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; @@ -1187,15 +1187,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 ( bi->nr_modules > sizeof(module_map) * 8 ) + if ( bi->nr_modules > MAX_NR_BOOTMODS + 1 ) { - bi->nr_modules = sizeof(module_map) * 8; - printk("Excessive boot modules - using the first %u only\n", + bi->nr_modules = MAX_NR_BOOTMODS + 1; + printk("Excessive multiboot modules - using the first %u only\n", bi->nr_modules); } - bitmap_fill(module_map, bi->nr_modules); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ + /* Dom0 kernel is always first */ bi->mods[0].type = BOOTMOD_KERNEL; bi->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; From patchwork Sun Oct 6 21:49:36 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: 13823904 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 8B132CFB424 for ; Sun, 6 Oct 2024 21:57:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811400.1224151 (Exim 4.92) (envelope-from ) id 1sxZFP-0001l6-MC; Sun, 06 Oct 2024 21:57:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811400.1224151; Sun, 06 Oct 2024 21:57: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 1sxZFP-0001kR-IB; Sun, 06 Oct 2024 21:57:03 +0000 Received: by outflank-mailman (input) for mailman id 811400; Sun, 06 Oct 2024 21:57:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZBx-0007Zk-GA for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:29 +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 6ab2c9e8-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:53:28 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251433564220.8251256642435; Sun, 6 Oct 2024 14:50:33 -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: 6ab2c9e8-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251435; cv=none; d=zohomail.com; s=zohoarc; b=R7MHXd/ljkarvCOOawrZJvHqwLEN6qXibQo25E8vRWWTvGcMktXzk/FiWCfCVumdrbXZ6MlAZ7FW7qeEjGGgRt88e3BZTidR6zscT1XZ8+DCp+hD1m8ethNd5YMalhbK5/JOiBs55/bPxS8Q6ruNMneiPuZObqEMWE+kdPWEZiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251435; 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=zja2KfbtQhgM7evcwk5V6CujBNK+2yO+oACiE8xCgoo=; b=AjEgxvRqeUbeUw3EX5IDrUd2AlGGyVhk7JJgfAIqh6ky4LVswxRHCBtAYvw4x2bpgk3004DLWmBOXQBH5WIGjSBRyIxK6I8vjnu1fSMdHaxwy7lPuTGHPxbmizkcCAvYWb68Is6fQCrR6b8ORE8UFMVY4vMfKEMoFoMyGNGTe3M= 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=1728251435; 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=zja2KfbtQhgM7evcwk5V6CujBNK+2yO+oACiE8xCgoo=; b=aJC5SQJjPj2UiKQ5rMjoqsPbNa8Rq9bLZ/zJzlWjZ9Rbd65oCD3Gee5lDuQvBQVi IZJArVQjbtNEtmU3zOc+dxhdMQ0wCArin+jWhy2RQYV6fAU2clVOxTdIMsW6oEzthqU qJ2uKVU7q3Pa9Z0w/lxFw1lLGBpC06hApMeaUGmg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 25/44] x86/boot: convert create_dom0 to use boot info Date: Sun, 6 Oct 2024 17:49:36 -0400 Message-Id: <20241006214956.24339-26-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/setup.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0d2ee19998aa..c2bcddc50990 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].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].mod; + if ( opt_dom0_pvh ) { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | @@ -995,7 +1005,7 @@ 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->loader)); if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -2106,10 +2116,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(bi->mods[0].mod, bi->mods[0].headroom, - (initrdidx >= 0 && initrdidx < bi->nr_modules) ? - bi->mods[initrdidx].mod : NULL, - kextra, bi->loader); + dom0 = create_dom0(bi, kextra); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Sun Oct 6 21:49:37 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: 13823899 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 88B16CFB440 for ; Sun, 6 Oct 2024 21:57:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811380.1224097 (Exim 4.92) (envelope-from ) id 1sxZFC-0007f7-FC; Sun, 06 Oct 2024 21:56:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811380.1224097; Sun, 06 Oct 2024 21:56:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFC-0007eu-BD; Sun, 06 Oct 2024 21:56:50 +0000 Received: by outflank-mailman (input) for mailman id 811380; Sun, 06 Oct 2024 21:56:48 +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 1sxZC5-0007Zk-Qe for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:37 +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 6f9ffeb2-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:53:36 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251434720804.0768514812222; Sun, 6 Oct 2024 14:50:34 -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: 6f9ffeb2-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251436; cv=none; d=zohomail.com; s=zohoarc; b=PgH7ljePXJDX6yRCAQJ5ykvq0yKj/RcIvXU0s5wZv82YnJIe1FQ1MwopCsv5YJ9KtnxzmnGaRvVTtotAK53YNtZ868u1JqLVjue2un/lwmAqI36Me5BUY1N/d5gKcCWQ4IUpUdHSTxf+xwL6s4ip0dN2QFFx0dLyWANSeGurFjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251436; 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=P7Tt0KAWI4oKC0YCkQ5SKG8TalzAPVfW3Oq4Jt8xlzs=; b=DwX05JsgYdMxmuRkMn6FGusCgpEr7XJsrJQrSDOd88vSqVuqA0CSEJGmsTPUQSOQRFOW5if42xiJpzPLfAiQkC7j+Y/RBBUBhhcpRlHAYzSQQjB4Q/m5GywhmitPchz4MfWaETcLCn5AfHf870aOxy1JC/t4afM9ZZ7wvQvs0SA= 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=1728251436; 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=P7Tt0KAWI4oKC0YCkQ5SKG8TalzAPVfW3Oq4Jt8xlzs=; b=LgOUUKwYM6UajOFMaKTSHOOK702H6yvJ2P0KNJNNAxD4dESa1iPC2lqJBOKm1fH0 8v6X+7Grb7AY5/IrF5MapPTT2LWY8oYJN4sJvRmfLCJGkYFU/nzTx71x99MbJL2Mk8x I7pIDNZ+0edNmc3JYNK2QvoQREKq+zlX49r7bbOM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 26/44] x86/boot: convert construct_dom0 to use struct boot_module Date: Sun, 6 Oct 2024 17:49:37 -0400 Message-Id: <20241006214956.24339-27-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 12 +++++++----- xen/arch/x86/include/asm/setup.h | 6 ++---- xen/arch/x86/setup.c | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8d56705a0861..1eff3192f72d 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,11 @@ 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->mod, image->headroom, initrd->mod, + cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct_pv(d, image->mod, image->headroom, initrd->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 bb7e73258a21..04bf0e62a9d7 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); extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c2bcddc50990..135bd6591c1c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -946,7 +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, +static struct domain *__init create_dom0(struct boot_info *bi, const char *kextra) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -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].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].mod; + initrd = &bi->mods[mod_idx]; if ( opt_dom0_pvh ) { @@ -1002,10 +1001,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->string || kextra ) + if ( image->mod->string || kextra ) { - if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), bi->loader)); + if ( image->mod->string ) + safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), + bi->loader)); if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -1028,7 +1028,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi, } } - if ( construct_dom0(d, image, headroom, initrd, cmdline) != 0 ) + if ( construct_dom0(d, image, initrd, cmdline) != 0 ) panic("Could not construct domain 0\n"); return d; From patchwork Sun Oct 6 21:49:38 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: 13823888 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 BD88CCFB43F for ; Sun, 6 Oct 2024 21:56:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811368.1224047 (Exim 4.92) (envelope-from ) id 1sxZEv-0004rx-Cq; Sun, 06 Oct 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 811368.1224047; Sun, 06 Oct 2024 21:56:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZEv-0004ri-9C; Sun, 06 Oct 2024 21:56:33 +0000 Received: by outflank-mailman (input) for mailman id 811368; Sun, 06 Oct 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 1sxZCD-0007Zk-7f for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53:45 +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 74144c94-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:53:44 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251435852741.2371065758415; Sun, 6 Oct 2024 14:50:35 -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: 74144c94-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251437; cv=none; d=zohomail.com; s=zohoarc; b=fpE4iWnG7MRWvMIXDZu0+C/SbbBTjIpEDh1IDmCnGPkCU1sscwmqpb/64Ekm2yrqwMxSqr/360Fp0v+xyuE+/teI3DEHSCLnGmd5tQ/VbXVo+L99LaX/zot6gBuOJg4s9yIhOVeDBd3TmD05LB+Fq7+WU5Fstg+wXH2KbZoWmuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251437; 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=U0epSQBbEatFgMV9a6wGUqA/KCfapTC+zhJG3oyewHg=; b=BEd3jpvoPde7X5zkhKaKripcFM27MfHK29nhrsTBtrPQhNAD+NQTMpoKpNgdrq8/0BDihi5WpBlPhKNmomFOtMGw+NsA3C7ruzO6/hAt1WLQL8/6i2khX0sxpxbGgmlv7gcqjHGWViNwmzIRhf44dUzq22mPM8D26EccMDVL6vk= 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=1728251437; 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=U0epSQBbEatFgMV9a6wGUqA/KCfapTC+zhJG3oyewHg=; b=Nk22mfqK65/2UbA74b+aYyxLns0LP+Keh6/mmfHzt40FKiDNJt05syTMzhtgXYZV gItpS95yeFBYQjLHo6PKBj42MlsLV8IupcYSGSygaq83JJ4Avhd97orqhQgbwjGpbzb sjV2k4LXuRkKvkk8Q60Bv+VuAaXta9oWpVfC0ZiI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 27/44] x86/boot: relocate kextra into boot info Date: Sun, 6 Oct 2024 17:49:38 -0400 Message-Id: <20241006214956.24339-28-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 5cbd1cbbbccd..9ed260629012 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -49,6 +49,7 @@ struct boot_module { struct boot_info { const char *loader; const char *cmdline; + const char *kextra; paddr_t memmap_addr; size_t memmap_length; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 135bd6591c1c..aed0837902c4 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(struct boot_info *bi, - const char *kextra) +static struct domain *__init create_dom0(struct boot_info *bi) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -1001,15 +1000,15 @@ static struct domain *__init create_dom0(struct boot_info *bi, panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->mod->string || kextra ) + if ( image->mod->string || bi->kextra ) { if ( image->mod->string ) safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), bi->loader)); - 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") ) @@ -1103,6 +1102,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) *kextra = '\0'; kextra += 3; while ( kextra[1] == ' ' ) kextra++; + bi->kextra = kextra; } cmdline_parse(bi->cmdline); @@ -2116,7 +2116,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(bi, kextra); + dom0 = create_dom0(bi); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Sun Oct 6 21:49:39 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: 13823906 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 E1C06CFB440 for ; Sun, 6 Oct 2024 21:57:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811407.1224197 (Exim 4.92) (envelope-from ) id 1sxZFf-0004Z5-Fg; Sun, 06 Oct 2024 21:57:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811407.1224197; Sun, 06 Oct 2024 21:57:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFf-0004Yt-B6; Sun, 06 Oct 2024 21:57:19 +0000 Received: by outflank-mailman (input) for mailman id 811407; Sun, 06 Oct 2024 21:57:17 +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 1sxZCL-0007Zk-1e for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:53: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 78bbd94c-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:53:52 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251436997842.3804635331212; Sun, 6 Oct 2024 14:50:36 -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: 78bbd94c-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251438; cv=none; d=zohomail.com; s=zohoarc; b=DCFg2UlgJ9kxRpCSZac3bnSsQF7cc+mSGMixX1sZr+ZC/cGGZE3sti2n8RfT/cZabwNepzEcI0lms13FaiugCtR/6dZdw0UZMsJoqktPhuGqEh+eRhVW+l3YAB5kUQNc+Tw5gFRPZ+QDDh442a6S1nmS22AH4nliZl8edtWbKqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251438; 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=k6RMuxzCGNIwefwYfLaAQQdjZurM3hL6dfBBxSvt0dY=; b=aoH+7sZUt2pnpMOF40B+oNADdALUkO7nH+Nln5XTjDXVYrwGTh6iDso7AiFrSBfOb+RTujKwIUgvFSnz67V+J2bpaSEXy5lvuDYl0lWh7Mlg7kWJasulye/ApEdb+rd21CP6rQp+gX7LiRpzV10l8VWSjpExEppJZBb/jzd1qLk= 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=1728251438; 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=k6RMuxzCGNIwefwYfLaAQQdjZurM3hL6dfBBxSvt0dY=; b=Aom7nRvQi3CsVAyVj3cLtDsCAbXj8WW9Y5CFYlM9nDNiuSWvv4HrloHl2a/Dh2BK OikVEyu1zTCDioZ7EGMmaV/Xrl0knMjqT+wX2SJ4HfDesB7YaN9aaRYNa4kf+H3Y3Wo W4dzKo1IymEzocC5TnfxO8x9rlyU0kxTiQcYdsP4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 28/44] x86/boot: add cmdline to struct boot_module Date: Sun, 6 Oct 2024 17:49:39 -0400 Message-Id: <20241006214956.24339-29-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 9ed260629012..3b6bfbe88770 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -38,6 +38,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 aed0837902c4..d5916e85f68e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -312,6 +312,8 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) { bi->mods[i].mod = &mods[i]; + bi->mods[i].cmdline = (char *)(paddr_t)mods[i].string; + bi->mods[i].start = (paddr_t)mods[i].mod_start; bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; } @@ -1000,10 +1002,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->mod->string || bi->kextra ) + if ( image->cmdline || bi->kextra ) { - if ( image->mod->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), + if ( image->cmdline ) + safe_strcpy(cmdline, + cmdline_cook(__va((unsigned long)image->cmdline), bi->loader)); if ( bi->kextra ) From patchwork Sun Oct 6 21:49:40 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: 13823907 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 9226FCFB424 for ; Sun, 6 Oct 2024 21:57:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811413.1224223 (Exim 4.92) (envelope-from ) id 1sxZFk-0005q4-TW; Sun, 06 Oct 2024 21:57:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811413.1224223; Sun, 06 Oct 2024 21:57:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFk-0005n2-JH; Sun, 06 Oct 2024 21:57:24 +0000 Received: by outflank-mailman (input) for mailman id 811413; Sun, 06 Oct 2024 21:57: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 1sxZCS-0007Zk-93 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54:00 +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 7d297a9e-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:53:59 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251438140394.0842588354635; Sun, 6 Oct 2024 14:50:38 -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: 7d297a9e-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251440; cv=none; d=zohomail.com; s=zohoarc; b=GA8nJhzzWC/DSUASsPXxy+TDlmruTa7NuHPxxtbBHUHVWqDDhsoEAzW/9qpVTrGdRlV57dr01UmNYN9SuBw0EbyGJpOvAdm0PX4MjDA/d3mimfPqPv0vT90ZCqpCeLbd4M313Godt0fIFOpdvwaVug9U8EekJISc0fF5+u3hLPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251440; 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=Fh/7Uk3Vw+tb0Y+Dui/MHmomzSneFUYlu0DymL9u5VQ=; b=Z/nNqAxRmVxwXoVkrDpkjmB5zZAn1jQlykm5+Ah2gWfVg/Yeuz8mUIi0H9kZhy+mCO7F3BZhQbCaBshxbfd5FXbMcmsjXGPiWLk4R2mr61Wx6+zcUl/68h8n8WBc80cTM+ZEj7mfAZUjABE43oNbTCbUDsi4X+Wwm3JybT4c0kM= 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=1728251440; 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=Fh/7Uk3Vw+tb0Y+Dui/MHmomzSneFUYlu0DymL9u5VQ=; b=DZ871kCoeXOh6seUZdQULPWGkZLcXmSqefp2kAVtO/YRAwoH6FJZRCWH5HhYggc2 YxnHzObonYO6S0gIL5jSJBv4iHnZyl6MuCIhmz4Ik6SZfPNHQGI2BkO8/YvszkSJIkq jVOcIxrGSI+tyA5q7nAOrBQSuAugCw8XaFfn8e+o= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 29/44] x86/boot: convert dom0_construct_pv image param to struct boot_module Date: Sun, 6 Oct 2024 17:49:40 -0400 Message-Id: <20241006214956.24339-30-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 3 +-- xen/arch/x86/include/asm/dom0_build.h | 7 +++---- xen/arch/x86/pv/dom0_build.c | 14 ++++++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 1eff3192f72d..54db578dd29f 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -613,8 +613,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image->mod, image->headroom, initrd->mod, - cmdline); + rc = dom0_construct_pv(d, image, initrd->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 262edb6bf2f0..7b6afe64d799 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, } static int __init dom0_construct(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 @@ static int __init dom0_construct(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; @@ -1052,8 +1051,7 @@ out: } 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) { @@ -1072,7 +1070,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(read_cr4() & ~X86_CR4_SMAP); } - rc = dom0_construct(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct(d, image, initrd, cmdline); if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) ) { From patchwork Sun Oct 6 21:49:41 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: 13823914 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 9C8DDCFB440 for ; Sun, 6 Oct 2024 21:58:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811411.1224217 (Exim 4.92) (envelope-from ) id 1sxZFk-0005kC-EG; Sun, 06 Oct 2024 21:57:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811411.1224217; Sun, 06 Oct 2024 21:57:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFk-0005jw-9k; Sun, 06 Oct 2024 21:57:24 +0000 Received: by outflank-mailman (input) for mailman id 811411; Sun, 06 Oct 2024 21:57:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZCa-0007Zk-7R for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54:08 +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 81de1d2d-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:07 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251439293836.8451746381855; Sun, 6 Oct 2024 14:50:39 -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: 81de1d2d-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251441; cv=none; d=zohomail.com; s=zohoarc; b=f7uPFxnNxNSwS5iGpHo5I392MgLtFiItLuV6jVa9yt/nZ98gGC97UyCPtoKwXqUtY9B2nqS7Fr+EhFdut2+kgbL/weoMWMeAsPDAdDkvMEgmDwPdyMsbmRUZjjUDaC0j836VJrc/Hh8DSPc49+DGlXb+aZRuiLWT22Sqy9eML2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251441; 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=xkaiW9OjgWPFU0BNzVKSQC1ectLOUlTK2xVwSMDZnWo=; b=GX8CLeUxgYtdzfLIdTRoQNixNxpkzINuW8Zh3oIegqvqbrybiFwY346I1QZ7otYvIvGO39pL9ZkBr5K6ilu/jE4iKpfhM/8QgEy/KjZC3dlDGwsVw7/ieAuCygyHIcpW64FqkZUR5W41zdcjlV1Kg4fTEhxB6oFgBo56KthT5Eg= 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=1728251441; 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=xkaiW9OjgWPFU0BNzVKSQC1ectLOUlTK2xVwSMDZnWo=; b=XcRbXHzbJsjP4VxUjD09sKr0MASD6YuZNtPsTEOsl6uGp6P3qBN4xjeTmvatswo8 NLfZg84GZwqSsf7gLmpQ8WSet1KgN6CV2chNzZmw9kYyM8D0zE/3ZBznQfEcAF7a7Kl nBzuh1QsH8DL5OWxn9p4ajju2PnVASO5doAPmnAw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 30/44] x86/boot: convert dom0_construct_pv initrd param to struct boot_module Date: Sun, 6 Oct 2024 17:49:41 -0400 Message-Id: <20241006214956.24339-31-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 2 +- xen/arch/x86/pv/dom0_build.c | 29 +++++++++++++++------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 54db578dd29f..1d05ee53a6d8 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -613,7 +613,7 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd->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 7b6afe64d799..16b8c1e40998 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, static int __init dom0_construct(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline) { int i, rc, order, machine; @@ -367,7 +367,8 @@ static int __init dom0_construct(struct domain *d, unsigned long nr_pt_pages; unsigned long alloc_spfn; unsigned long alloc_epfn; - unsigned long initrd_pfn = -1, initrd_mfn = 0; + unsigned long initrd_pfn = -1; + mfn_t initrd_mfn = { 0 }; unsigned long count; struct page_info *page = NULL; unsigned int flush_flags = 0; @@ -376,7 +377,7 @@ static int __init dom0_construct(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 +613,8 @@ static int __init dom0_construct(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 = maddr_to_mfn(initrd->start); + mfn = mfn_x(initrd_mfn); count = PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) ) @@ -627,12 +629,13 @@ static int __init dom0_construct(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 = page_to_mfn(page); + initrd->start = mfn_to_maddr(initrd_mfn); } else { @@ -640,9 +643,9 @@ static int __init dom0_construct(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->mod_end = 0; + initrd->size = 0; - iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), + iommu_memory_setup(d, "initrd", mfn_to_page(initrd_mfn), PFN_UP(initrd_len), &flush_flags); } @@ -654,7 +657,7 @@ static int __init dom0_construct(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); } @@ -763,7 +766,7 @@ static int __init dom0_construct(struct domain *d, if ( count < initrd_pfn || count >= initrd_pfn + PFN_UP(initrd_len) ) mfn = pfn++; else - mfn = initrd_mfn++; + mfn = mfn_x(initrd_mfn) + 1; *l1tab = l1e_from_pfn(mfn, compat ? COMPAT_L1_PROT : L1_PROT); l1tab++; @@ -882,7 +885,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = initrd->mod_start + (pfn - initrd_pfn); + mfn = paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } @@ -1052,7 +1055,7 @@ out: int __init dom0_construct_pv(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline) { int rc; From patchwork Sun Oct 6 21:49:42 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: 13823887 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 A7DB4CFB424 for ; Sun, 6 Oct 2024 21:56:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811363.1224003 (Exim 4.92) (envelope-from ) id 1sxZEp-0003Yp-Sf; Sun, 06 Oct 2024 21:56:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811363.1224003; Sun, 06 Oct 2024 21:56: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 1sxZEp-0003YT-Lw; Sun, 06 Oct 2024 21:56:27 +0000 Received: by outflank-mailman (input) for mailman id 811363; Sun, 06 Oct 2024 21:56: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 1sxZCh-0007Zk-W6 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54:15 +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 86674351-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172825144047617.705943069105388; Sun, 6 Oct 2024 14:50: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: 86674351-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251442; cv=none; d=zohomail.com; s=zohoarc; b=e0rup5qfj8UW7i/iFGXqfPAnnPEy3E+3TfdmtqTQrdbEm5IkkHATQLHqFEN7CM8dPPO0zF6whz0yK3Wa+hz8A+wy6AvAZieBtXpz9ow4oK+ayqZaQPX6+58WG7K7RWfyNszYSTFOcF6ueT/lwWvwQBIxgPmELeN813NPLSzDpUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251442; 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=BmGSuaBaKd3qtvehAz6QI6DFDtdVzluTKF7yLA1UKrY=; b=kkNQdQizSQsesked0oWY82g0FUM7tIdvouhlyEJ5KqKd7zarFB4eydo9erBXe0V8+GdZdNB38GqoHNolfptRPiogD6BkycLnAT68vjOGWBW0SXyyrPwa95vVLKBHi/rc/9UPkkOSxKyOjajuFPxknAk+MbH5qv6GrDqN3Y+fCiY= 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=1728251442; 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=BmGSuaBaKd3qtvehAz6QI6DFDtdVzluTKF7yLA1UKrY=; b=gVvarlnL2il/njaqrQD9NyndLOgMrI4ZUEKa6vlMFO/QAh/PrOe7tnQjame1K+Ju IAEWZxL1jlYKYxWaJ0M3/cRFKT7lvstpNAp/nqMrSEQPqZVmoz6RMiuqwFw6QRfviIq hklX0CL/hOXcvn+J9vye2DHC9zhTCEp7tVNJSltg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 31/44] x86/boot: convert dom0_construct_pvh to struct boot_module Date: Sun, 6 Oct 2024 17:49:42 -0400 Message-Id: <20241006214956.24339-32-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 3 +-- xen/arch/x86/hvm/dom0_build.c | 11 +++++------ xen/arch/x86/include/asm/dom0_build.h | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 1d05ee53a6d8..71b2e3afc1a1 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -610,8 +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->mod, image->headroom, initrd->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 3dd913bdb029..beaa1d492077 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1300,10 +1300,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; @@ -1347,8 +1346,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->mod, image->headroom, initrd->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 Sun Oct 6 21:49:43 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: 13823912 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 ED921CFB43F for ; Sun, 6 Oct 2024 21:57:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811422.1224273 (Exim 4.92) (envelope-from ) id 1sxZG2-0000K3-7u; Sun, 06 Oct 2024 21:57:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811422.1224273; Sun, 06 Oct 2024 21:57: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 1sxZG1-0000Hd-Sm; Sun, 06 Oct 2024 21:57:41 +0000 Received: by outflank-mailman (input) for mailman id 811422; Sun, 06 Oct 2024 21:57: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 1sxZCp-0007Zk-Iq for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54: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 8aee2ea4-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251441612580.1270707109736; Sun, 6 Oct 2024 14:50: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: 8aee2ea4-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251443; cv=none; d=zohomail.com; s=zohoarc; b=fW3nCxrVxlJAABUPr8tk4DgH1UHsa2p7CIHqc/1BqtpXFFQ45MwsKwQI0vZWERsaZtCiuPOHaQoPh5DqU3zNyooPca61OCGwe+i/A5kxpEGmvs8m4XddwXEDu48c9R1OwyH06vOchMBKoDk0Cyuq7ZRXUMDm0pkmP7tqBfN4tTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251443; 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=8fXOlbbmg64oLi+2VKa9EtSyLufW2pfIFApT44ZRUyU=; b=EftjvZP3TkSYHLBi5Uz7Kx//7SDTVvcOMvepmT1CFwiBZaiKIdZvmoaQEfH1jPEWpMEaa5T1FkK5qjst9wD6ySjzALCny+KovUxQP13BDXSWqsir2y4c5Z7RFqHg4MvKFPYvseqtqyFLsHQD9PKxhr9w4eT/ILIVlpvrJw1HEQo= 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=1728251443; 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=8fXOlbbmg64oLi+2VKa9EtSyLufW2pfIFApT44ZRUyU=; b=ncgvaws9KT3pnIYEjMeB2+66d8tCjs7I3FWF3/6UNZ5/hASim5W0wXAl+u2JjzwN XEMQ3aVeUGHeAOzd/x/2fKKg5J4vIh86TvWXzRdtBjWZGm6HgcZ0AwbsbMVVGDaGnEv FHkeOcZQBSgKAOn/z9/LPQQZrlZzG1TcdTCwYhP0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 32/44] x86/boot: convert pvh_load_kernel to struct boot_module Date: Sun, 6 Oct 2024 17:49:43 -0400 Message-Id: <20241006214956.24339-33-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 beaa1d492077..a3fd5e762dc4 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); @@ -1346,8 +1345,8 @@ int __init dom0_construct_pvh( return rc; } - rc = pvh_load_kernel(d, image->mod, image->headroom, initrd->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 Sun Oct 6 21:49:44 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: 13823917 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 9189DCFB424 for ; Sun, 6 Oct 2024 21:58:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811416.1224242 (Exim 4.92) (envelope-from ) id 1sxZFs-0006wF-LH; Sun, 06 Oct 2024 21:57:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811416.1224242; Sun, 06 Oct 2024 21:57: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 1sxZFs-0006tS-Bp; Sun, 06 Oct 2024 21:57:32 +0000 Received: by outflank-mailman (input) for mailman id 811416; Sun, 06 Oct 2024 21:57: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 1sxZCx-0007Zk-N8 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54: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 8fca659b-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251442732849.6483430442723; Sun, 6 Oct 2024 14:50:42 -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: 8fca659b-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251444; cv=none; d=zohomail.com; s=zohoarc; b=UA0l215/6O/n3czwu2u4fUwznFePhivW8NOOszpzyp4vrhUg86OtZumlLWWz6MzCrR+yZhjHdWc8A+Tpfr1fvLimCrfdjeqrkXwJKck6r3/IiU6Th7s6WxR8kAH6nULeY7UOQxWq04X70a1OOIGmE7KrrOge6c82iUKgVjfryHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251444; 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=lFv35bSZ+DTHV5Gr3NY0x1keGRZxgvnnRPUaSaXb4uA=; b=IHNicosX7CZxHz6jj1IcGGLGyY1mZ+5NyFsMxI2yFdrCxhcMAaqPUW1kbx3ItDc8Vdi5fpSAMRZEEJ/dBgiTtQ6MHe6/YnX5miHRbbSfp5habcBDwZLGep52CBX/UU4ju/3lmrj43RyHU+X/DDKSnwekM/B7PZ+5oark8SALcLY= 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=1728251444; 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=lFv35bSZ+DTHV5Gr3NY0x1keGRZxgvnnRPUaSaXb4uA=; b=RjG7c1OpcwWYakPT+LpzpGsbDcH1m1JUpb+dMY+37++R+XNTJ8NJTCmKPvW+Ntgh J1D77WAqkdq/lF/GFcAbhfCX8BxKjJHEeghnWiAY2PKDDs0PvJaf8gx+zNDuFAiT/i6 i3oV4jccSgD/OAWvQtmFjJp7GZI3J0m05Gqo+ehI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 33/44] x86/boot: convert initial_images to struct boot_module Date: Sun, 6 Oct 2024 17:49:44 -0400 Message-Id: <20241006214956.24339-34-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 d5916e85f68e..30a139074833 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,7 +276,7 @@ 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 const struct boot_module *__initdata initial_images; struct boot_info __initdata xen_boot_info; @@ -336,8 +336,9 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++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].mod->mod_start; + unsigned long end = start + + PFN_UP(initial_images[i].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 < bi->nr_modules; ++i ) { - uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; + uint64_t start = + (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + + PAGE_ALIGN(initial_images[i].mod->mod_end)); } bi->nr_modules = 0; @@ -1380,7 +1383,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 = bi->mods[0].mod; + initial_images = bi->mods; for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { From patchwork Sun Oct 6 21:49:45 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: 13823918 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 89F70CFB43F for ; Sun, 6 Oct 2024 21:58:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811434.1224307 (Exim 4.92) (envelope-from ) id 1sxZGF-0002Mh-Gz; Sun, 06 Oct 2024 21:57:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811434.1224307; Sun, 06 Oct 2024 21:57: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 1sxZGF-0002MO-Ao; Sun, 06 Oct 2024 21:57:55 +0000 Received: by outflank-mailman (input) for mailman id 811434; Sun, 06 Oct 2024 21:57:54 +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 1sxZD4-0007Zk-PS for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54:38 +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 9404fcf2-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:37 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251443868264.5790216144809; Sun, 6 Oct 2024 14:50: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: 9404fcf2-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251445; cv=none; d=zohomail.com; s=zohoarc; b=YjFRi6RSin7RS7URyzfSCUHHkzSAXGNAIvBhq+4Or4YqrRVxOycfoVFRNq3BKrhYyLVo4MlNsBlrzKRlGFzyGpl8ct2UugN2RAsiJ6R2mBFXHt31L6mXHI7iqVSPmwHdNf+YBtNE2+Fy78DWd9LrvxSPGObXu9MOgB9ZHt64Qh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251445; 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=3hkZxM5JKY193qyhBp7nRAR8syZAmf01uqr3bX0ldPM=; b=XDmtwOkTJPGnIVDuA1acDUu0BT/5MWFW8n4jhUznqfIGiSZEx0JNOftK7hI0KkeOrVIKFHuecDpWY4qMEC+pnDzh0KM70LW9n6s9tV0Dyup/0Ij7MnWNVEE5ziPjDuhgbTttwNFHOOc6WZHIV4ZGEiG5iBrHWDUATL33c/HnsWo= 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=1728251445; 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=3hkZxM5JKY193qyhBp7nRAR8syZAmf01uqr3bX0ldPM=; b=CDdRbygm93UaItfWJV6ST87dwiZxBwGRrW/2tTQAH5J+D9lyHW1xGEcZc9w4Q+7u Nb1lA8vaX58bvTFb32cnIX8CwLxBMccLi/3KAW6rYmd34BIwM+TjnvjfP9W4PEpZbVs gnSZU58pkDzQdlouA5pnyU/pgE96Z0x17nrVfdME= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 34/44] x86/boot: drop the use of initial_images unit global Date: Sun, 6 Oct 2024 17:49:45 -0400 Message-Id: <20241006214956.24339-35-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/setup.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 30a139074833..b3b6e6f38622 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,8 +276,6 @@ custom_param("acpi", parse_acpi_param); static const char *cmdline_cook(const char *p, const char *loader_name); -static const struct boot_module *__initdata initial_images; - struct boot_info __initdata xen_boot_info; static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) @@ -336,9 +334,9 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = initial_images[i].mod->mod_start; + unsigned long start = bi->mods[i].mod->mod_start; unsigned long end = start + - PFN_UP(initial_images[i].mod->mod_end); + PFN_UP(bi->mods[i].mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -355,15 +353,14 @@ void __init discard_initial_images(void) for ( i = 0; i < bi->nr_modules; ++i ) { uint64_t start = - (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; + (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; init_domheap_pages(start, start + - PAGE_ALIGN(initial_images[i].mod->mod_end)); + PAGE_ALIGN(bi->mods[i].mod->mod_end)); } bi->nr_modules = 0; - initial_images = NULL; } static void __init init_idle_domain(void) @@ -1383,8 +1380,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 = bi->mods; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) From patchwork Sun Oct 6 21:49: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: 13823895 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 820E8CFB424 for ; Sun, 6 Oct 2024 21:56:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811372.1224067 (Exim 4.92) (envelope-from ) id 1sxZF2-0005iB-7x; Sun, 06 Oct 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 811372.1224067; Sun, 06 Oct 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 1sxZF2-0005hs-2w; Sun, 06 Oct 2024 21:56:40 +0000 Received: by outflank-mailman (input) for mailman id 811372; Sun, 06 Oct 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 1sxZDC-0007Zk-4F for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54:46 +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 9866d10b-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:45 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251445000314.8393630433128; Sun, 6 Oct 2024 14:50: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: 9866d10b-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251446; cv=none; d=zohomail.com; s=zohoarc; b=dOhYo29x6tMVT8LnKdGrCGuKX9X0hPFgXgg7nC98keqFG91efzoRmoIIC8MaaBqQIY+yRX2FCN78P5iVZwKq5VaZjZvtrkfoU6SSgIdnyL7fqCf4XCxB8RrLkzMGRP6Ajb2+WZdmTTUJHX7zhj+rRhdQglQDa/Bnsg2cxbpAZs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251446; 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=My1BwYQikiMj2XVbz63ltqTkowzAIebw6oWPH/8M3ao=; b=Umb/9jG0SJ+w4FKBK4BmVF0D0iTgCz+JYO0GbZ0FH8AE9B75HMWqlrPIGY9bTAmUxLWQYoIPjrHMhnXBvmucFYCE2NSJOmXUuyY9TgtuK4vpDlFGDudE3hhYwlPtZ7pkmF++CKD3jqXSId6RdGCtyXacJTbmbbudlTZEm8+6RyY= 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=1728251446; 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=My1BwYQikiMj2XVbz63ltqTkowzAIebw6oWPH/8M3ao=; b=PRFaYn/TOdu/iACALsvxTGZRO/zqOHcAOffHIkxdNWAsaoDAnXjeKM+h6yNEid/Y xU1PUPiZyeOwkf2wwK2e9BPlMKrK6gBSvlfJzSwO+IqWBWa6g/cQy1RuLS/alLK1zR1 Gpmg9Ax1/yFjXb0LthR6e2InoYkL9+fDUOhTmf00= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 35/44] x86/boot: remove usage of mod_end by discard_initial_images Date: Sun, 6 Oct 2024 17:49:46 -0400 Message-Id: <20241006214956.24339-36-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/setup.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b3b6e6f38622..e9e3da3204f1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -352,12 +352,10 @@ void __init discard_initial_images(void) for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t start = - (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; + uint64_t start = bi->mods[i].start; init_domheap_pages(start, - start + - PAGE_ALIGN(bi->mods[i].mod->mod_end)); + start + PAGE_ALIGN(bi->mods[i].size)); } bi->nr_modules = 0; From patchwork Sun Oct 6 21:49: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: 13823915 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 B4371CFB424 for ; Sun, 6 Oct 2024 21:58:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811408.1224201 (Exim 4.92) (envelope-from ) id 1sxZFf-0004dX-UN; Sun, 06 Oct 2024 21:57:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811408.1224201; Sun, 06 Oct 2024 21:57:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFf-0004cu-L6; Sun, 06 Oct 2024 21:57:19 +0000 Received: by outflank-mailman (input) for mailman id 811408; Sun, 06 Oct 2024 21:57:17 +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 1sxZDJ-0007Zk-44 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:54: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 9ca37c2f-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:54:52 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251446148991.8497668397073; Sun, 6 Oct 2024 14:50: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: 9ca37c2f-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251448; cv=none; d=zohomail.com; s=zohoarc; b=bNsgLn464aZeuv+ZYClJOH6gMVQinmTHfCyGViv40l3gEDafLIMtfgqdqgN/DawipepLWEFW0FV2lgaxh8FeuAKm+VGGeBCMD65VnDQ5vcj8CApG2kJgyd1G9ifizG0/DQkNQT6yJql8pYZbShWisn0kMO6t5WJCa1Htf0qgMJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251448; 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=Jb2nZ+7HGkVeAJRXjrn8aAVl9GUxbiL1jFANEJYgSG0=; b=g6cY5WkxXGcd7j5EbuC/Rlr5LpL7EXLdZ32PbuOjleyn1VHGQXGiKJ962CO9TaCho37OxeK1LdPmHdmNFxCMQ787sTW+96480Oset+KOxyH9XYnx7SoGXmqcVNQzSf9qY5EosmDlzFqCO4kQeEhilO1W9DSfPHpAGHM3RkK2+gY= 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=1728251448; 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=Jb2nZ+7HGkVeAJRXjrn8aAVl9GUxbiL1jFANEJYgSG0=; b=fOWMkwhJlAAN6/oEmr96AMyxsKJnAOW0ssiGpmOniLF4SUUL7I7YWecBA0qtujvi ZYjxTlbSw5GAkOCigotOE1Wo2JggQD5V2X8ERk5CP5w2m0FJgjgy6eY386EUGnR7Ch+ M31SmCeXKYz9cBd83tuM/1b+MxcALz+xKk6+dqqk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 36/44] x86/boot: remove remaining early_mod references Date: Sun, 6 Oct 2024 17:49:47 -0400 Message-Id: <20241006214956.24339-37-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e9e3da3204f1..0ffe8d3ff8dd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -334,9 +334,8 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = bi->mods[i].mod->mod_start; - unsigned long end = start + - PFN_UP(bi->mods[i].mod->mod_end); + unsigned long start = bi->mods[i].start; + unsigned long end = start + PFN_UP(bi->mods[i].size); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -664,8 +663,8 @@ static uint64_t __init consider_modules( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = (uint64_t)pfn_to_paddr(mods[i].mod->mod_start); - uint64_t end = start + PAGE_ALIGN(mods[i].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; @@ -1380,10 +1379,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { - if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) + if ( bi->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - bi->mods[i].mod->mod_end -= bi->mods[i].mod->mod_start; - bi->mods[i].mod->mod_start >>= PAGE_SHIFT; } /* @@ -1404,16 +1401,12 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ bi->mods[xen].start = virt_to_mfn(_stext); bi->mods[xen].size = __2M_rwdata_end - _stext; - - bi->mods[xen].mod->mod_start = bi->mods[xen].start; - bi->mods[xen].mod->mod_end = bi->mods[xen].size; } - bi->mods[0].headroom = - bzimage_headroom(bootstrap_map(bi->mods[0].mod), - bi->mods[0].mod->mod_end); - - bootstrap_map(NULL); + bi->mods[0].headroom = bzimage_headroom( + bootstrap_map_bm(&bi->mods[0]), + bi->mods[0].size); + bootstrap_map_bm(NULL); #ifndef highmem_start /* Don't allow split below 4Gb. */ @@ -1518,9 +1511,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->mod->mod_start = paddr_to_pfn(bm->start); bm->size += bm->headroom; - bm->mod->mod_end = bm->size; bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1708,8 +1699,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < bi->nr_modules; ++i ) { - set_pdx_range(paddr_to_pfn(bi->mods[i].mod->mod_start), - paddr_to_pfn(bi->mods[i].mod->mod_start) + + set_pdx_range(paddr_to_pfn(bi->mods[i].start), + paddr_to_pfn(bi->mods[i].start) + PFN_UP(bi->mods[i].size)); map_pages_to_xen( (unsigned long)maddr_to_virt(bi->mods[i].start), From patchwork Sun Oct 6 21:49: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: 13823902 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 0044BCFB440 for ; Sun, 6 Oct 2024 21:57:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811389.1224127 (Exim 4.92) (envelope-from ) id 1sxZFJ-0000bg-Ke; Sun, 06 Oct 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 811389.1224127; Sun, 06 Oct 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 1sxZFJ-0000bL-En; Sun, 06 Oct 2024 21:56:57 +0000 Received: by outflank-mailman (input) for mailman id 811389; Sun, 06 Oct 2024 21:56: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 1sxZDQ-0007Zk-VL for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:00 +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 a12a7fa3-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:55:00 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17282514472961014.7196473903033; Sun, 6 Oct 2024 14:50: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: a12a7fa3-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251449; cv=none; d=zohomail.com; s=zohoarc; b=Tsr6VNSaivJn2RLAfxpVSkPx/nM5xLWUJFWjCrYQTTA4BI6Jau0ib6xyH2CBI4qDtAqbHA+WdEaSQPAbP/AKNOOtgpGc56uFguoezQIPvivjyxpa0pgZB3UUZMDoOzET+SJBu0s+o1dcyLcHULR9fJN9wpNbl1lRYvDd9NK/vco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251449; 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=I5+jMetwK1mnjWjlCDImNyJTFTfOMPbGyVjb5LEAn64=; b=CNE0X4BFUE8QnHnQyqlJmbbSZcDymhMnhDNqq4HQyIu4/BN6NSx201islFhmH7ILwh+BGkDeZi8KI0sMilDzXHB0FzEXzso8vWPFRK9ShXG2hM5/OMsaB1N6RatzMgl9EkncAtX0bd/ISxpKSb/yWEGBLIVq/u3jpCEOcepz93A= 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=1728251449; 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=I5+jMetwK1mnjWjlCDImNyJTFTfOMPbGyVjb5LEAn64=; b=WNKRC8v2MtqnWGSRRDumROkzc92d0lE+p6b77ZCKnZ5gij9wVdLWTVkpLbWW6mDC YB3qOsF1g3mMUgwNDSTE+RB+lXCFeHUTlrZ212xgsKB9EqlNohHjt6VF3rheFPn4jbB wtv+gZeslGCg3UkGVjtypudDCc5R5kfn8iddhxCE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 37/44] x86/boot: remove mod from struct boot_module Date: Sun, 6 Oct 2024 17:49:48 -0400 Message-Id: <20241006214956.24339-38-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External With all references to mod field removed, remove the mod field from struct boot_module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 3 --- xen/arch/x86/setup.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 3b6bfbe88770..4cb722e8ba0a 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 /* Max number of boot modules a bootloader can provide in addition to Xen */ @@ -25,8 +24,6 @@ enum bootmod_type { }; struct boot_module { - /* Transitionary only */ - module_t *mod; /* * A boot module may contain a compressed kernel that Xen will need space * reserved, into which it will be decompressed. diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0ffe8d3ff8dd..3604c8fbe40a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -308,8 +308,6 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) */ for ( i = 0; i <= bi->nr_modules; i++ ) { - bi->mods[i].mod = &mods[i]; - bi->mods[i].cmdline = (char *)(paddr_t)mods[i].string; bi->mods[i].start = (paddr_t)mods[i].mod_start; @@ -319,7 +317,6 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) /* map the last mb module for xen entry */ bi->mods[bi->nr_modules].type = BOOTMOD_XEN; bi->mods[bi->nr_modules].flags |= BOOTMOD_FLAG_X86_CONSUMED; - bi->mods[bi->nr_modules].mod = &mods[bi->nr_modules]; return bi; } From patchwork Sun Oct 6 21:49: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: 13823896 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 9BA7ECFB43F for ; Sun, 6 Oct 2024 21:56:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811381.1224101 (Exim 4.92) (envelope-from ) id 1sxZFC-0007il-QI; Sun, 06 Oct 2024 21:56:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811381.1224101; Sun, 06 Oct 2024 21:56:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZFC-0007hO-KR; Sun, 06 Oct 2024 21:56:50 +0000 Received: by outflank-mailman (input) for mailman id 811381; Sun, 06 Oct 2024 21:56:48 +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 1sxZDY-0007Zk-GC for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:08 +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 a5a8e301-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:55:07 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251448469735.6475877847893; Sun, 6 Oct 2024 14:50: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: a5a8e301-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251450; cv=none; d=zohomail.com; s=zohoarc; b=gL3W7KzlRXxTJffwsk5aUT1mZJiaQOy+27svywuNui7Msx45qb1ydF/8MrWILaQK296Zzb6yZktx5uGQNQYm+WH99916dHe4ggfQxgZMQvfIVn0L9/z7oD8BzKUFWpExlc94vDm6XVNajPTpEDRvTgXxQ1HGCUvJCIIM0ID2phQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251450; 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=srKA70GY5IBQBR1ovY/FSrdYLsXQmvS6Ni95eTseTPk=; b=Wk/94XUtubHsB8+OtKx7lKH+caJptOQiZwofJuER0tR0oFHQRm+zoZE7DnTM8tOpXYf4ulSWbLqzTh1ojRVIrzCXjB5CLz+US0dYZ0+/O3G4KGzLJTaCNpSIUNzq//FLMM5JQ1btEdPUMu1j9fnYb7TVYnMsyq8bveGITenttbs= 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=1728251450; 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=srKA70GY5IBQBR1ovY/FSrdYLsXQmvS6Ni95eTseTPk=; b=jk8ebFGcT01SYbHPY7n0feqNp3UUotJB+3HK4wecuh25SdZewHgX6QRPqvIYn2EV aAHr4DL3Qtaa5MiwRQcxTxEGm0Q4ZDAUP1J5J62T3M9h43oLqJz+CMQm80VZsk+74sN 0dHPICoumzrVfA/Cyt2A/PDkl2FcHg3sPqVDMbDc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 38/44] x86/boot: introduce boot domain Date: Sun, 6 Oct 2024 17:49:49 -0400 Message-Id: <20241006214956.24339-39-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootdomain.h | 28 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/setup.c | 24 ++++++++--------------- 3 files changed, 41 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 4cb722e8ba0a..7b4da6cad1ed 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -9,10 +9,14 @@ #define __XEN_X86_BOOTINFO_H__ #include +#include /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 +/* Max number of boot domains that Xen can construct */ +#define MAX_NR_BOOTDOMS 1 + /* Boot module binary type / purpose */ enum bootmod_type { BOOTMOD_UNKNOWN, @@ -55,6 +59,7 @@ struct boot_info { unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; static inline int __init next_boot_module_index( diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3604c8fbe40a..ad4a1f473f6d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -957,20 +957,10 @@ static struct domain *__init create_dom0(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 | @@ -996,11 +986,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - if ( image->cmdline || 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->loader)); if ( bi->kextra ) @@ -1024,7 +1014,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) } } - 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"); return d; @@ -1204,6 +1194,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) /* Dom0 kernel is always first */ bi->mods[0].type = BOOTMOD_KERNEL; bi->mods[0].flags |= BOOTMOD_FLAG_X86_CONSUMED; + bi->domains[0].kernel = &bi->mods[0]; if ( pvh_boot ) { @@ -2093,6 +2084,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + bi->domains[0].ramdisk = &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) >= 0 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Sun Oct 6 21:49: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: 13823892 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 3F936CFB424 for ; Sun, 6 Oct 2024 21:56:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811373.1224073 (Exim 4.92) (envelope-from ) id 1sxZF2-0005mu-PV; Sun, 06 Oct 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 811373.1224073; Sun, 06 Oct 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 1sxZF2-0005lg-F9; Sun, 06 Oct 2024 21:56:40 +0000 Received: by outflank-mailman (input) for mailman id 811373; Sun, 06 Oct 2024 21:56: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 1sxZDf-0007Zk-SN for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:15 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aa2c19d8-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:55:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251449609589.5889422713361; Sun, 6 Oct 2024 14:50: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: aa2c19d8-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251451; cv=none; d=zohomail.com; s=zohoarc; b=JlJUmd0TOekQy0zfycMfgmBcPBdofA2dqliJymIVQFL4guAVAhMwdknmlbB5pQFcGubRX2o1mtocpOSuZavS7KMhdjQDcYp0T/wyR6oIUJsxC29I+gG9nDqKLRxMFE5/ihFvvOqN+8nFGxsgcEMZI6CqyV2DhoH/hV44zkHE9nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251451; 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=sVdP9gq2A9htJd3rJlMgvzdj4EwJQkEQZWlBQ/0O9Lc=; b=Fsw7UTLm80y0oFSb8nqGBJxXqxI5UIhHEatx3rbFUx+xw0UD7UuCf0V8g8YEORL+bDEnPTfqsqMEKnCp8cBehSc49+gr2QApxMiWF8HGu+8bp5uMKzEwUDpYHVjryQW1II7ucjZOyjThWlJNQ+vXRCJHwjJEXjXbpF95+iBCfLc= 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=1728251451; 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=sVdP9gq2A9htJd3rJlMgvzdj4EwJQkEQZWlBQ/0O9Lc=; b=g+kwgIWsDoyxniQekARXJ3vbglybUrJHSapjlxf9/RclvFxM/JnH0NAs9oGnS7Ru KCHC64QE3x7O1CDPrPcUvVVydjEo4WzyGwT7pxS9Y2Nmbt0yboHEIfUgakeBsA4T+9X 8/jZhdsc64Pa8U1kHA/6gvmtxFMFx/9Vqh2092Hg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 39/44] x86/boot: introduce domid field to struct boot_domain Date: Sun, 6 Oct 2024 17:49:50 -0400 Message-Id: <20241006214956.24339-40-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- 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 ad4a1f473f6d..a1204b2bd594 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -318,6 +318,9 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p) bi->mods[bi->nr_modules].type = BOOTMOD_XEN; bi->mods[bi->nr_modules].flags |= BOOTMOD_FLAG_X86_CONSUMED; + for ( i = 0; i < MAX_NR_BOOTDOMS; i++ ) + bi->domains[i].domid = DOMID_INVALID; + return bi; } @@ -959,7 +962,6 @@ static struct domain *__init create_dom0(struct boot_info *bi) }; struct boot_domain *bd = &bi->domains[0]; struct domain *d; - domid_t domid; if ( opt_dom0_pvh ) { @@ -975,15 +977,15 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid = get_initial_domain_id(); + d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); init_dom0_cpuid_policy(d); if ( alloc_dom0_vcpu0(d) == NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline || bi->kextra ) From patchwork Sun Oct 6 21:49: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: 13823889 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 A352DCFB424 for ; Sun, 6 Oct 2024 21:56:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811362.1223997 (Exim 4.92) (envelope-from ) id 1sxZEp-0003VY-HE; Sun, 06 Oct 2024 21:56:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811362.1223997; Sun, 06 Oct 2024 21:56: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 1sxZEp-0003VP-DI; Sun, 06 Oct 2024 21:56:27 +0000 Received: by outflank-mailman (input) for mailman id 811362; Sun, 06 Oct 2024 21:56: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 1sxZDn-0007Zk-9J for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55: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 ae7c2e88-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:55:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251450737717.4255628801843; Sun, 6 Oct 2024 14:50: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: ae7c2e88-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251452; cv=none; d=zohomail.com; s=zohoarc; b=NLJZZt8iLCBbP+PTbQCQWc7wQ1SEbPaQRy9xJqJxU31rpAs2CyCTyzQJe3dBDpRUP1xPdxb+fCnkLN2OhBSLYhpKoOaHS9PYKC6YWF8S0buMfR79M2ymTBU1wErQaoVoFnzFPY9CWAi7I/l1zpKMaUKlrtqACyuQ/ygUrT2FtF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251452; 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=2zXTHeuS1u+eZ5P26JBIt9WYBNMZWbOEM+pEnQhRDE0=; b=JWxo7XQLpm6Od5El5kRl5Ag7Tj5WNh2S7jnkvBDZDIS6RUWGWWGB803inS1wLmvbUccbAaMRmzeSdEx+bzMmsNWvu6/zWCHoA+ZfWp7gD8w/XSIToFrYST9x9ARHjvHriJcfJ1oxrEF9GmOnhDQcyCWhrJcNNVWDssLo1EPvnXg= 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=1728251452; 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=2zXTHeuS1u+eZ5P26JBIt9WYBNMZWbOEM+pEnQhRDE0=; b=a/Ge/JGD8wIdnD4U3qE61PdlSvjY1BVgo906gaI2/aS05HQQIuANSi8XEa1Bm9mP 0FhYjseq9Jk9wk7TyQPKOi9oghNSB8eowPvlVPB9envySOGIWcqaXtZ4D8O1Y7JlugT kq+dxCpO9MVuu9SgIeiEKLAQEpGbOsPMI1X7Jsx4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 40/44] x86/boot: add cmdline to struct boot_domain Date: Sun, 6 Oct 2024 17:49:51 -0400 Message-Id: <20241006214956.24339-41-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 a1204b2bd594..f250638edf09 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -947,8 +947,6 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li static struct domain *__init create_dom0(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, @@ -991,17 +989,17 @@ static struct domain *__init create_dom0(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->loader)); 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 ) { @@ -1009,14 +1007,14 @@ static struct domain *__init create_dom0(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); } } - 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"); return d; From patchwork Sun Oct 6 21:49: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: 13823900 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 263BCCFB43F for ; Sun, 6 Oct 2024 21:57:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811388.1224117 (Exim 4.92) (envelope-from ) id 1sxZFI-0000EY-8P; Sun, 06 Oct 2024 21:56:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811388.1224117; Sun, 06 Oct 2024 21:56: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 1sxZFI-0000EM-4Y; Sun, 06 Oct 2024 21:56:56 +0000 Received: by outflank-mailman (input) for mailman id 811388; Sun, 06 Oct 2024 21:56: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 1sxZDu-0007Zk-Pc for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:30 +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 b2fff737-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:55:29 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251451864396.89237154171735; Sun, 6 Oct 2024 14:50: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: b2fff737-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251453; cv=none; d=zohomail.com; s=zohoarc; b=gUr1ufUEBitU+nDM0BWSLW+Xx/Hmfr4uUJ7xlx+234sllpYdyGknA5gSMWCbMau/MquWwq5RD4ijUNdSSaoBEBdSgBtoy8PEggI+4xEzhoLp7uArk1S8GaOPno/D7z+lKTfS0gMznOXRVjkw7dlLVd6H9e1oY15Bnn8G/9ErF58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251453; 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=lUf8dRXsSe31nIQ8ru6siZ++csVBXQ/vKqr++5VfORM=; b=hScijmFEh7BrkJmujyCZTUJJAkAs2+95VGStCtgi8B8kR9cEHpkjAW+yj0P3AffqXOFmo7BXqn1e41v4L+pnkx+O3S3mFdtj3XqDZ7erSwQtPbZ0j3smOidZuj1UWb8nCeMz+LQiflcVkO1a68NssK+I2Fj01LF4EAqcWcw+nPQ= 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=1728251453; 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=lUf8dRXsSe31nIQ8ru6siZ++csVBXQ/vKqr++5VfORM=; b=AgfTJL4QRtO6aQOjgJCvE70ZYtT2E7QXd8EQrvu+iy4V1bNFe8HdsAeQv3razu2I 3HSiC/o56QZbRySI9kZNljZaqWp/9legmkv3yVR+jgYozRKL0m+Ui1Iya8RMN7QxsnA tj8cTyYW/deTCRBhwznDeieOp2fFJ0vkEwR4Iko0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 41/44] x86/boot: add struct domain to struct boot_domain Date: Sun, 6 Oct 2024 17:49:52 -0400 Message-Id: <20241006214956.24339-42-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 f250638edf09..e6a231bd2d42 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -959,7 +959,6 @@ static struct domain *__init create_dom0(struct boot_info *bi) }, }; struct boot_domain *bd = &bi->domains[0]; - struct domain *d; if ( opt_dom0_pvh ) { @@ -976,13 +975,13 @@ static struct domain *__init create_dom0(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. */ @@ -1014,10 +1013,10 @@ static struct domain *__init create_dom0(struct boot_info *bi) } } - 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"); - return d; + return bd->d; } /* How much of the directmap is prebuilt at compile time. */ From patchwork Sun Oct 6 21:49: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: 13823884 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 0B4BFCFB424 for ; Sun, 6 Oct 2024 21:56:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811350.1223967 (Exim 4.92) (envelope-from ) id 1sxZE6-0001v2-MB; Sun, 06 Oct 2024 21:55:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811350.1223967; Sun, 06 Oct 2024 21:55: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 1sxZE6-0001uv-JQ; Sun, 06 Oct 2024 21:55:42 +0000 Received: by outflank-mailman (input) for mailman id 811350; Sun, 06 Oct 2024 21:55:40 +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 1sxZE4-0001uL-Uc for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:40 +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 b8661ecd-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:55:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251453021201.06087713384034; Sun, 6 Oct 2024 14:50:53 -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: b8661ecd-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251454; cv=none; d=zohomail.com; s=zohoarc; b=dOZopKojpuUEaMeIzR4cTDvLB32F4XuRU38OeKgMrGsk0EP3vccZK5qQVMoBnf2ReIHrI+Nv5QACJIoQsIomdVRObVZeGEWwkr+1CZG5+pYi1dBSm8WqLCzLqNz8cpfyVcJOJEA18a4xRj4nmSkwrXsl68cH+sFd5j8FV+EN910= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251454; 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=7Q7gPOcTOOjpreqScRGkoQBD1OTSB+7KpnKBZPYI7Vk=; b=MynRpxQF4nFVFgXCYoNdqz5jUW1TPLk1/qRCAoHrylXqVur0YP+igkswiBl1nzrFtaZvlZ/uVkZtzdo0d3VrRgcJvbq2Qq5fOqkgQI9uMh3/anlYuQkxCcKSqD1mfefIcdmA0htD23K1vi6kB6YA5L1E8LB9PfgpD8dzG3JUYFA= 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=1728251454; 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=7Q7gPOcTOOjpreqScRGkoQBD1OTSB+7KpnKBZPYI7Vk=; b=NGrYi0QQ/eIh0p1DkUfWvt/gg7u6JcMxuV8C1MdQDhWnvVc6fS+arIVZ/zrwJCN+ CwtT8HnIIDP7Bpf061wiRdGCCXOVSpDGUtWrjuqglxLPfAzZ8QkBb0SNEb3fECLLeqG sGPPbsfr4EbW5wBaX7bA242Wpa9h4ZpEjYFszMXg= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 42/44] x86/boot: convert construct_dom0 to struct boot_domain Date: Sun, 6 Oct 2024 17:49:53 -0400 Message-Id: <20241006214956.24339-43-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 04bf0e62a9d7..6fdb392432ad 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); extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e6a231bd2d42..6ea825b64541 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1013,7 +1013,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) } } - if ( construct_dom0(bd->d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) + if ( construct_dom0(bd) != 0 ) panic("Could not construct domain 0\n"); return bd->d; From patchwork Sun Oct 6 21:49: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: 13823885 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 D1E4ECFB424 for ; Sun, 6 Oct 2024 21:56:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811351.1223976 (Exim 4.92) (envelope-from ) id 1sxZEG-0002Fj-0f; Sun, 06 Oct 2024 21:55:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811351.1223976; Sun, 06 Oct 2024 21:55:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZEF-0002Fa-UE; Sun, 06 Oct 2024 21:55:51 +0000 Received: by outflank-mailman (input) for mailman id 811351; Sun, 06 Oct 2024 21:55:49 +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 1sxZED-0001uL-T4 for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:49 +0000 Received: from sender3-of-o59.zoho.com (sender3-of-o59.zoho.com [136.143.184.59]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bdd229f3-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:55:48 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251454189590.8322273235076; Sun, 6 Oct 2024 14:50: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: bdd229f3-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251456; cv=none; d=zohomail.com; s=zohoarc; b=iwd0CdCex8OMj6fuI4MpWjGosCNOred3h3IdfvLsLK/ip7dh9IQTuYBhR8Pz1dxOkrgIYrrRFfJvLszaOvtOPiz3siqHK9Ho2G/tShcC5WsDYo4y+mV9wvxzeKONdKj+5xquRQjglft5rqHkAmKtLOZGBsKZoK0OSHO2ne/+Wc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251456; 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=7/WzvHNkS1n2F3LfpTPfjCeWeMxPp7gP5SpizVRz19A=; b=jITOlgra8dGn0VUihCRHh/gDs4NPoDFNbecK1fztPQQesso6+3Uf2wpXhZ+IRHCAyrGGJbTm0z4+9Gb9YDNk72bCkCdFCF/1eLkKpubXHkruxTbSRR6W87o3lottHxuZjUdmCFwjSCAN6KXJOTqkTJ30C5+T5ABVSLajDdhTVf0= 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=1728251456; 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=7/WzvHNkS1n2F3LfpTPfjCeWeMxPp7gP5SpizVRz19A=; b=ecaPOL/RvfVza2iBUz1GnLixrF33xu+KJS/H0aQCSSmr3iImOZGaKAd/AJNITxTW +/JQb70qLTL20LYefiGooT3WdtX10i9Id1Wgxw/kzUqk+fZYHzTGuQs3SwnPZdAMT8m HrvhJRYyNejxhAPGUbUKZWKvgUvjoSjBoHex1+zc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 43/44] x86/boot: convert dom0_construct_pv to struct boot_domain Date: Sun, 6 Oct 2024 17:49:54 -0400 Message-Id: <20241006214956.24339-44-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 5 ++-- xen/arch/x86/pv/dom0_build.c | 43 ++++++++++++--------------- 3 files changed, 22 insertions(+), 28 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 16b8c1e40998..34974aa7cd56 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; } -static int __init dom0_construct(struct domain *d, - const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline) +static int __init dom0_construct(struct boot_domain *bd) { int i, rc, order, machine; bool compatible, compat; @@ -373,11 +370,12 @@ static int __init dom0_construct(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; @@ -613,7 +611,7 @@ static int __init dom0_construct(struct domain *d, initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn = maddr_to_mfn(initrd->start); + initrd_mfn = maddr_to_mfn(bd->ramdisk->start); mfn = mfn_x(initrd_mfn); count = PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && @@ -629,13 +627,13 @@ static int __init dom0_construct(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 = page_to_mfn(page); - initrd->start = mfn_to_maddr(initrd_mfn); + bd->ramdisk->start = mfn_to_maddr(initrd_mfn); } else { @@ -643,7 +641,7 @@ static int __init dom0_construct(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(initrd_mfn), PFN_UP(initrd_len), &flush_flags); @@ -655,9 +653,9 @@ static int __init dom0_construct(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); } @@ -885,7 +883,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); + mfn = paddr_to_pfn(bd->ramdisk->start) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } @@ -955,8 +953,8 @@ static int __init dom0_construct(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)) ) @@ -1053,10 +1051,7 @@ out: return rc; } -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 rc; @@ -1073,7 +1068,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(read_cr4() & ~X86_CR4_SMAP); } - rc = dom0_construct(d, image, initrd, cmdline); + rc = dom0_construct(bd); if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) ) { From patchwork Sun Oct 6 21:49: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: 13823886 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 5FFEDCFB43F for ; Sun, 6 Oct 2024 21:56:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.811352.1223987 (Exim 4.92) (envelope-from ) id 1sxZEN-0002d2-89; Sun, 06 Oct 2024 21:55:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 811352.1223987; Sun, 06 Oct 2024 21:55: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 1sxZEN-0002cr-5L; Sun, 06 Oct 2024 21:55:59 +0000 Received: by outflank-mailman (input) for mailman id 811352; Sun, 06 Oct 2024 21:55: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 1sxZEM-0001uL-Ax for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:55:58 +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 c31471e7-842d-11ef-99a2-01e77a169b0f; Sun, 06 Oct 2024 23:55:56 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251455348935.8420153270763; Sun, 6 Oct 2024 14:50: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: c31471e7-842d-11ef-99a2-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1728251457; cv=none; d=zohomail.com; s=zohoarc; b=Ea3qNjfJ6VJKlg3Ct6BMonRnbgQZ2gCmLC2W4BCbI6xD3EnXqMufu7dotc5sgpf7FfsWbmSWeF6ehwnrkuxmZU/kZDQjd4lwcDNTHCS6oDwfWPOmI1fGxrupgyj+IdVgEQfLT1/POAT8lBkxrPIDPCi5pR+nGs9AFZnIIDZrh3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251457; 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=k02giGfjUf1KH01cwomZDl95HUxwWx+LCdIDh2PrA48=; b=EUgPSyAMFgpRqKLFztzW6V3BrQAhYsHLVpVyMk+/dqWkNE99rYsYMPbAHinD7/kvKGtu9eiBqHkZmRTszRCMOysf4t4t1eHs/+GAHmEd9qfFcGDtRoDFd+DNBn7qEuMzjrGV/JBk57ZFvwnugo/GK0XoS1UiBWgegTljmw+/aIs= 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=1728251457; 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=k02giGfjUf1KH01cwomZDl95HUxwWx+LCdIDh2PrA48=; b=inA3bTYPVuAvnEBdHUJyGaREVDHlGTWrC+XAd1FTV1aMhEFOK4hQIC1Nqy6kt5sE Wu9slOkOyTHGzBLWgfHzQWUGp4yHdRsUil7P37mXHYwOAEfF++8Uur6BxUmiDh38Per WVIEP1WgwdMExj4xnfGOj6kgLLfVZBdOrFRkDZ3g= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v5 44/44] x86/boot: convert dom0_construct_pvh to struct boot_domain Date: Sun, 6 Oct 2024 17:49:55 -0400 Message-Id: <20241006214956.24339-45-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-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 a3fd5e762dc4..755e257cdf30 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1299,25 +1299,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; } } @@ -1327,25 +1325,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 ) { @@ -1353,14 +1352,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); @@ -1369,8 +1368,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);