From patchwork Thu Oct 17 17:02: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: 13840468 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 38A9DD3C525 for ; Thu, 17 Oct 2024 17:04:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820830.1234459 (Exim 4.92) (envelope-from ) id 1t1Tuf-000700-Ts; Thu, 17 Oct 2024 17:03:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820830.1234459; Thu, 17 Oct 2024 17:03: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 1t1Tuf-0006zr-QP; Thu, 17 Oct 2024 17:03:49 +0000 Received: by outflank-mailman (input) for mailman id 820830; Thu, 17 Oct 2024 17:03:48 +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 1t1Tue-0006TN-KO for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:03:48 +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 c4ed82b6-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:03:46 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172918461568161.967850809187325; Thu, 17 Oct 2024 10:03: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: c4ed82b6-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184617; cv=none; d=zohomail.com; s=zohoarc; b=V7DmMI0IyY1SvQ+dFhr99YoBFyumoEMS2iLrzrNhtS3FHIr0cEuASvy2ks3PKgeWt3NXJom3SFZl0bqUhN98Bj+kinurVkzaS5vw5JrsQF1TydMtBoGsABfPFxGNyNn/zFnszV+lW+h6AiWL2JfPELUzCo7/MU8E3NtIkL7+dOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184617; 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=/GTvBBrsBVsR7hgeazYsrIdIraxYMSG35yaHz9LsVpk=; b=LyzdqAvv1fvhdMI7fB2kuoJZwF59XEDEI6wtjnhlH7TNhiSQqv0jUmfDQlZJiYN+MNsNg6svWGtQkJsSzBpNgbceClQTJl6Oz04PmJLjrmq6YdV1Hq5fHOeb1uwznZ0wS+83EGXnM+MKs1lxQ/cze4QjeIoOHNzEmHL+PtQb0eY= 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=1729184617; 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=/GTvBBrsBVsR7hgeazYsrIdIraxYMSG35yaHz9LsVpk=; b=a5WpW5m87PCRe8fcXRRPRUAcmDl4s0/AfLgGUIgwdMgY8X5sBxuPWqp1ZSmYVNLr 7z5BxbPhGX7cJ0bvMdEn8d0cix3bAHFutEAepwmxWBy5i1IZZOpDseAroEGK1O1TMtT iKQ/QbSl0mZFdj7W0iAi7lRR+jUCmWtD657JeSqE= 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 v6 01/44] x86/boot: move x86 boot module counting into a new boot_info struct Date: Thu, 17 Oct 2024 13:02:41 -0400 Message-Id: <20241017170325.3842-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - moved __init from being in middle of type declaration --- 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..6201ca0fad19 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 Thu Oct 17 17:02: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: 13840469 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 30466D3C526 for ; Thu, 17 Oct 2024 17:04:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820832.1234469 (Exim 4.92) (envelope-from ) id 1t1Tup-0007Om-5j; Thu, 17 Oct 2024 17:03:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820832.1234469; Thu, 17 Oct 2024 17:03: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 1t1Tup-0007Of-1f; Thu, 17 Oct 2024 17:03:59 +0000 Received: by outflank-mailman (input) for mailman id 820832; Thu, 17 Oct 2024 17:03:57 +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 1t1Tun-0006TN-0H for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:03:57 +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 c9f0b45f-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:03:55 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184617025693.5091672796183; Thu, 17 Oct 2024 10:03:37 -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: c9f0b45f-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184619; cv=none; d=zohomail.com; s=zohoarc; b=Gmtj6AN39W5taH+ZtDAgTM9cSAB3DsnuX0gmnoywqsFxdXHlLJ5cJsU3GtKhgZ3rc3wK+WFzOblQXuIHhbGRJnCQEIKhvTV49Nareno5T4bncVyOiOS67dDZX66glaBvQ3/pcTgT2FRFRr4XvRH4Smo61hPApzcAG5jE4V9jIs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184619; 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=ioXQiGftZuaa2y3+MlFiiL8tR31atQ3yfwKB0el8GZ8=; b=VaJcEyEJjFdnj/N4MA3zPIYriY3qvUdSJQRZxarLxrJx4T1H5Uroq8obavFfiXf5maVkuwqQQ7IsVEogrxsB3zFwfZfMuV1VeTackddCBjmxxcbmOi4tyVzV12kBR+caetQJ5i7YxuBRZm47HenEJ4iio1AZ7Ng2vbIDRZ8k44Q= 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=1729184619; 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=ioXQiGftZuaa2y3+MlFiiL8tR31atQ3yfwKB0el8GZ8=; b=YGE1uQkAKaI6cNbuiw4DONdSlNhrnrPRcDhutefcGVvqF/us9MxGP8PD2Xerv1V4 /eZCmxBWPa2Hi9Fv8+BqxxHtszqNRxDe9xeFfSBeiQUXa1aOhvKAeqWWd6TfUy753mw iKQrqN1W9yqhMz8KKCXKzMZpvTZ2FHTrwjHreD+c= 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 v6 02/44] x86/boot: move boot loader name to boot info Date: Thu, 17 Oct 2024 13:02:42 -0400 Message-Id: <20241017170325.3842-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - reorder struct boot_module fields - code style changes --- 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..bec35e7c2f23 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -13,6 +13,8 @@ * bootloader/environment, or derived from the information. */ struct boot_info { + const char *loader; + unsigned int nr_modules; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6201ca0fad19..eac0954f42b8 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 Thu Oct 17 17:02: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: 13840484 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 D5415D3C526 for ; Thu, 17 Oct 2024 17:08:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820894.1234599 (Exim 4.92) (envelope-from ) id 1t1Tyz-00070D-NG; Thu, 17 Oct 2024 17:08:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820894.1234599; Thu, 17 Oct 2024 17:08: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 1t1Tyz-0006zY-JL; Thu, 17 Oct 2024 17:08:17 +0000 Received: by outflank-mailman (input) for mailman id 820894; Thu, 17 Oct 2024 17:08:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tuv-0006TN-3d for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:05 +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 cebfa7dd-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:03 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184618449299.4483272125001; Thu, 17 Oct 2024 10:03: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: cebfa7dd-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184621; cv=none; d=zohomail.com; s=zohoarc; b=Jj69mog7FESSW+fvVP3+RCzMBMmqWmc3v0uPKmHRi8b263x7K6eX/88EhvivAybvDSZJa+Kwk8WgtHtneYbmvzcvenJNbaglQ/syLwxfUkCi3W2iddyWxMHn1+sEsDXlWJUSk0SoyD4hhDJzR/HlBk+1feG0SIXWvd/XQGZDPUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184621; 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=Dr1jKzgUHAaiQbYekBVD6PQo4dQeZnEBKNdNITplfLE=; b=TZkx8ohR4MO2a4uoshPcehr5lwl0XBEyWwM/xabNwAFb84nam0gObY5GPqStjoLYH/j9lxq21KdeAFDSCWsL2OkbdbuVDCwMf9E39nDkKiGpS93UmXu+6tblwaS4WhuSZg939o5wxD4Xv8W6y/hdsLAQuOfbocr2asoZ4AlAdRU= 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=1729184621; 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=Dr1jKzgUHAaiQbYekBVD6PQo4dQeZnEBKNdNITplfLE=; b=GR6WiaXfoG7f/aZ+nKcXzYLlpEwLqBIDprZYcMvRlxkOu42PG34CwqjDnJScBtBX m7yW0hLY5gPRPTLFjrFfE8nsR/dALcfiMNM7IyHCxtM6k2K8yhPsIhyA1NMENl3QY0S ejNWVze6O2NbaMBbZMtJjPcKYoLU3t22/oaw9PUQ= 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 v6 03/44] x86/boot: move cmdline to boot info Date: Thu, 17 Oct 2024 13:02:43 -0400 Message-Id: <20241017170325.3842-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - reorder struct boot_module fields --- 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 bec35e7c2f23..efbbd30cc514 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -14,6 +14,7 @@ */ struct boot_info { const char *loader; + const char *cmdline; unsigned int nr_modules; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index eac0954f42b8..037cdd17386c 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 Thu Oct 17 17:02: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: 13840482 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 710E5D3C526 for ; Thu, 17 Oct 2024 17:08:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820889.1234589 (Exim 4.92) (envelope-from ) id 1t1Tyd-0005tJ-BW; Thu, 17 Oct 2024 17:07:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820889.1234589; Thu, 17 Oct 2024 17:07: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 1t1Tyd-0005tC-8L; Thu, 17 Oct 2024 17:07:55 +0000 Received: by outflank-mailman (input) for mailman id 820889; Thu, 17 Oct 2024 17:07:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tv4-0006TN-7w for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:14 +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 d412f094-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:12 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184619793164.3023967873388; Thu, 17 Oct 2024 10:03: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: d412f094-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184622; cv=none; d=zohomail.com; s=zohoarc; b=cQk1zZ7TwRBci2G9oF6og8rdWMqi3KtNbdnlRxViRtcKnaW9xnnpQ/QW2lVfu8AwXmcFWi74fDK7H0oMV48tBLgP7v8IBm34qYjbivmNZEe6PCTqpNHR63Y5MvMRKyItrPtP2iKenrS+X9wU19nWur/IVZ0u4bP+IB8qenIU2Bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184622; 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=3fsfruenGzMW022TyDqthGbN65HLKdpAAZMOHPTj6cg=; b=Zay2ybEtCrHNIWi/jHt36aQFMMY3HOPjUeNSYbYWMGpZ0bne9jjuinavfDPcoPaxFsVSnfBhSGJh9Ocicflwz2MXMF5NNth755MzJxJNYKDK3rNgCXe0XWycjc9ZbBuxviryB9RJdVbJQWyycCccELdOqBe5kRcWYfqTw1gvWQE= 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=1729184622; 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=3fsfruenGzMW022TyDqthGbN65HLKdpAAZMOHPTj6cg=; b=p1dnh5wu2HChCm67ww/Dz9smgUzf0jbdB+ZDPt61AWymLWVp7LS1BZa1mdg74Sc1 b0LPdA8UMQRKksuGZ29LmKYpTl0kZ7Gc2TMObaLpDcpqTrIiBpkStXNzaIY/YQmAXNX kyHQ5nMZJhwIoPYk4G6Vf8EACMWJlkxDXUeajnhE= 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 v6 04/44] x86/boot: move mmap info to boot info Date: Thu, 17 Oct 2024 13:02:44 -0400 Message-Id: <20241017170325.3842-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - reorder of struct boot_module fields - changed to memmap_length check for memmap detection --- 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 efbbd30cc514..f75a7e72a700 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. @@ -16,6 +18,9 @@ struct boot_info { const char *loader; const char *cmdline; + paddr_t memmap_addr; + size_t memmap_length; + unsigned int nr_modules; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 037cdd17386c..f7ea482920ef 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_length ) { 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 Thu Oct 17 17:02: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: 13840481 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 ADE61D3C525 for ; Thu, 17 Oct 2024 17:07:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820885.1234579 (Exim 4.92) (envelope-from ) id 1t1TyU-0005Lz-3K; Thu, 17 Oct 2024 17:07:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820885.1234579; Thu, 17 Oct 2024 17:07: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 1t1TyU-0005Ln-0h; Thu, 17 Oct 2024 17:07:46 +0000 Received: by outflank-mailman (input) for mailman id 820885; Thu, 17 Oct 2024 17:07:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TvD-0006TN-4t for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:23 +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 d968c908-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:21 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184621129703.1852929433529; Thu, 17 Oct 2024 10:03: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: d968c908-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184623; cv=none; d=zohomail.com; s=zohoarc; b=SEAYWKE7xL9UY82MEuvzA+0SxasmSBKqYzgwbNc4g+lHlj6PMoU7SXxUHjRtw51ROIuh8WlqoChZK7Jkw2+yZyCzgbK4Be3uYG2+0htFRojgMzbGfK8zMkqf36nsd05QpQ5NAGS4JEfYnFmdT8agqiBBuwpL97B4+gmveO3Ctzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184623; 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=8Nn0zA/RVfT8SY13G0Olhb8w8UWUndxx4zU/53Bq7j4=; b=g32lLWqhURhiuSQlrlAiS++0ytl8QPj1Bi/OBsolv/ARRyFCfT2Yt1YY8EspgvwyjdBoNhhS+CgqocxCrsqyBkF6XQVKokkNMcViZCPyxkbsbMujR5xEJg2603tX5oaUnYHgQok21ZpmzAXBuBHKMR82XDy7KQbarykCg8+vb3Y= 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=1729184623; 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=8Nn0zA/RVfT8SY13G0Olhb8w8UWUndxx4zU/53Bq7j4=; b=cS8x22pegiJZg6bepZsRpT6NPWts2WLIAgAEFSXUS569tIWPsS28dRaepcjcvri4 cEghTfCdame0vVv/i0DaV477S/SsegqiftYncKJuIwbw1VrEVQ3ANQOzQgthGdyUUfl ZM5sqHkdwS8hfUzy214zQcZuIr6nvSZqM+TCReKg= 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 v6 05/44] x86/boot: introduce struct boot_module Date: Thu, 17 Oct 2024 13:02:45 -0400 Message-Id: <20241017170325.3842-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - reword comment --- xen/arch/x86/include/asm/bootinfo.h | 10 ++++++++++ xen/arch/x86/setup.c | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index f75a7e72a700..d19473d8941e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,8 +8,17 @@ #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. @@ -22,6 +31,7 @@ struct boot_info { 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 f7ea482920ef..d8ee5741740a 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; } + /* + * Iterate over all modules, including the extra one which should have been + * reserved for Xen itself + */ + for ( i = 0; i <= bi->nr_modules; i++ ) + bi->mods[i].mod = &mods[i]; + return bi; } From patchwork Thu Oct 17 17:02: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: 13840483 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 42E82D3C525 for ; Thu, 17 Oct 2024 17:08:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820895.1234609 (Exim 4.92) (envelope-from ) id 1t1Tz5-0007OE-Tt; Thu, 17 Oct 2024 17:08:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820895.1234609; Thu, 17 Oct 2024 17:08:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tz5-0007O0-R3; Thu, 17 Oct 2024 17:08:23 +0000 Received: by outflank-mailman (input) for mailman id 820895; Thu, 17 Oct 2024 17:08:22 +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 1t1TvL-0006TN-Cm for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:31 +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 de6aa70a-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:29 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184622569551.9933736684571; Thu, 17 Oct 2024 10:03: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: de6aa70a-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184625; cv=none; d=zohomail.com; s=zohoarc; b=JxOPe9KK7rni9b8F2K6sb0JpTMEgtu2VDdjARWYd1Kp30tslpPEQm8P3yMuvFyqO3ovQSvaZ1L5/Ler/EpO49VKusqWouUM1iMZNUO7Dw5arx1yPimgprRJnyxZZRiFGiD7YdkUHpf8NTmKV9D6TajoPMLeBeVdfwpqtjQRU9Hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184625; 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=i/MwelbIDlLsytRqJnx56gOPNpJbq/sBz2YfvwIYl4c=; b=GAQSAHJxfulU7UVno+fvmUbI8jcisFo6uaampi1BTROFbdzvYVFVKUAiN6nOl2ATaH1VE+KYxb1Zxg/rACDZZ/ts0MuCOCZ1nzSjZdTf0By70/W4bNGfsbFc8Yi/SkO6GBnDWpR6gdD/bYy591F0n8xqIPaHronuRevRF9OMSJk= 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=1729184625; 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=i/MwelbIDlLsytRqJnx56gOPNpJbq/sBz2YfvwIYl4c=; b=qcLTaouKMVsM2G/AnEtCSkWyGecFRTR9kUX8ygvq8O1JsNJjln0u/54rOtKTThsA 0HEMECXMh0x2+Or1JUYSpuzdI1VnqWw1dd1kDieGylfsDdE5ZOtWcTbsjeW+s59OW7W AXcjDtgJ8VmYRh6xpS4M3AlU7IpNZ/JtRPQI0X+A= 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 v6 06/44] x86/boot: convert consider_modules to struct boot_module Date: Thu, 17 Oct 2024 13:02:46 -0400 Message-Id: <20241017170325.3842-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - drop unnecessary type cast --- 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 d8ee5741740a..10934bf31d7f 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 = 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 Thu Oct 17 17:02: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: 13840480 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 57501D3C525 for ; Thu, 17 Oct 2024 17:07:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820882.1234569 (Exim 4.92) (envelope-from ) id 1t1TyM-0004rW-SP; Thu, 17 Oct 2024 17:07:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820882.1234569; Thu, 17 Oct 2024 17:07: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 1t1TyM-0004rN-Om; Thu, 17 Oct 2024 17:07:38 +0000 Received: by outflank-mailman (input) for mailman id 820882; Thu, 17 Oct 2024 17:07:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TvU-0006TN-4f for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04: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 e382022c-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184623813332.0053578314786; Thu, 17 Oct 2024 10:03: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: e382022c-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184626; cv=none; d=zohomail.com; s=zohoarc; b=bosGKq7O4GCzRI4fX0jqTRkaseg7RuA6hZrxT1cfZgkyUMfmeh15/QP1CBZfVrpIOztoM28vf92y/HY90CVXoKLU70epYOy5d+pSV+rEB/Qu2H+So9y5jCiL8HTXtaRiQtJlgsk/LF9JQssaRjHvtHbqVd6DNOzhglKLZyRiYCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184626; 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=H7+H2K1xx8lIY92L5+m10RhDN9p6bY+Wrz/xIahDxoc=; b=CZDOVR2sT/N5kYCYadGbQgv7rlUjSFtwQIEleQV5X2jczsVYEUnAY/d2qz+tij+Dx25bVcnjn5JowllPVK1XR0d5zuvg7mSbC7eLMCgNXfR+7gwUusCToPBmo08zS/yRRz/k1M3X+XKkY2Sgdrhmf6sg5qldL0KYMcL0v1m93T4= 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=1729184626; 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=H7+H2K1xx8lIY92L5+m10RhDN9p6bY+Wrz/xIahDxoc=; b=Zr+oNKk3rc/45DjoWREHaupFr7RYaQSsjF4bgSyExxxKzb8XPG6rxwNaA5yCQG2u bEifx013yw++oO58VT46KWzwVotzdCGLdBcJbYiJrzBHdJtAmxEwy1JHe2GNWTUQpdV E8R6eK1YOo6XrYcGEF9Y2c/u94YP6Zo2fduzqrSs= 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 v6 07/44] x86/boot: move headroom to boot modules Date: Thu, 17 Oct 2024 13:02:47 -0400 Message-Id: <20241017170325.3842-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Reviewed-by: Jason Andryuk --- Changes since v5: - reword and expand comment on headroom - consolidated declaration and assignment --- xen/arch/x86/include/asm/bootinfo.h | 13 +++++++++++++ xen/arch/x86/setup.c | 21 ++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index d19473d8941e..5fe4f1387d03 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -17,6 +17,19 @@ struct boot_module { /* Transitionary only */ module_t *mod; + /* + * A boot module may contain a compressed kernel that will require + * additional space, before the module data, into which the kernel will be + * decompressed. + * + * Memory layout at boot: + * [ compressed kernel ] + * After boot module relocation: + * [ estimated headroom + PAGE_SIZE rounding ][ compressed kernel ] + * After kernel decompression: + * [ decompressed kernel ][ unused rounding ] + */ + unsigned long headroom; }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 10934bf31d7f..11e1027d72dd 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,8 @@ 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 = PAGE_ALIGN(bm->headroom + mod[j].mod_end); if ( mod[j].reserved ) continue; @@ -1470,14 +1473,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 +1507,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 +2059,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 Thu Oct 17 17:02: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: 13840486 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 31BA7D3C526 for ; Thu, 17 Oct 2024 17:08:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820897.1234619 (Exim 4.92) (envelope-from ) id 1t1TzE-0007n7-5T; Thu, 17 Oct 2024 17:08:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820897.1234619; Thu, 17 Oct 2024 17:08: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 1t1TzE-0007my-2J; Thu, 17 Oct 2024 17:08:32 +0000 Received: by outflank-mailman (input) for mailman id 820897; Thu, 17 Oct 2024 17:08:31 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tve-0006TN-UP for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:50 +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 e9f9d9f1-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:48 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172918462501326.25612647323169; Thu, 17 Oct 2024 10:03: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: e9f9d9f1-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184627; cv=none; d=zohomail.com; s=zohoarc; b=FUkpM/OCEcp5/uIZbCKalpSYRPxBkMgIREkMD/F/4arWA+FeVEOTkGRJbIY56GbOvFgyrLBSbBDASLoTzUbPwN4MhnLujKQDNiMEafS1P0IO+FVr2W8+MMY+3q/K/MJjfnRcf0WIpSMFAIyXHiPvMcluVrr5+LI+zhpqpizOIZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184627; 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=a1nvXWrB1CLe8R744GeUpJxtCMGjQBOguC52kxhYdIY=; b=CC1W1WtLl1uhPlm47ARFUPNOCPHt/0MqUQOqpo8Hau8V4fIFywMPDQ5q/StNVL7x3t2RwSW3b8UIGtD+1AUCS5dXaF8tKe3VUe6LUXsNMo0yRRPPmt+DUhLhTVZ0PBJaSO5Gj2Nvz3dzgx0Zpz28wV0F1Xmy+kc1N9CSMfU7H/M= 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=1729184627; 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=a1nvXWrB1CLe8R744GeUpJxtCMGjQBOguC52kxhYdIY=; b=NUiiCmVMwLCgLnyONPDG29nW6SCnACEvQQ4OlChClf1q7omdhESPdexQlngzuw6X vDZVxjsZvUZLEqmTufx9ZifwviXQuiXMq/jVTmD8gSZjmo6EIXihCLBHo1UdB7fmsoR BjdWm8JtIM/F2MaPn2cHnzwew1KqhNUWA1C5uP58= 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 v6 08/44] x86/boot: convert mod refs to boot_module mod Date: Thu, 17 Oct 2024 13:02:48 -0400 Message-Id: <20241017170325.3842-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 module_t mod, only in setup.c, to the mod element of struct boot_module. These serves twofold, first to allow the incremental transition from module_t fields to struct boot_module fields. The second is to allow the conversion of function definitions from taking module_t parameters to accepting struct boot_module as needed when a transitioned field will be accessed. Signed-off-by: Daniel P. Smith --- Changes since v5: - rewrote commit message - coding style changes - added comment for initial_images assignment --- xen/arch/x86/setup.c | 64 +++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 11e1027d72dd..1b56eaf26efe 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1341,15 +1341,19 @@ 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; + /* + * The field bi->mods[0].mod points to the first element of the module_t + * array. + */ + 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 +1364,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 +1372,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 = @@ -1460,9 +1465,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * move mod[0], we incorporate this as extra space at the start. */ struct boot_module *bm = &bi->mods[j]; - unsigned long size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); + unsigned long 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). */ @@ -1474,14 +1479,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; } } @@ -1507,13 +1512,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 ) @@ -1591,8 +1598,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; @@ -1666,11 +1674,12 @@ 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 @@ -2059,8 +2068,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 Thu Oct 17 17:02: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: 13840478 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 89650D3C526 for ; Thu, 17 Oct 2024 17:07:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820879.1234549 (Exim 4.92) (envelope-from ) id 1t1TyF-0004Dy-EW; Thu, 17 Oct 2024 17:07:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820879.1234549; Thu, 17 Oct 2024 17:07: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 1t1TyF-0004Dr-Bb; Thu, 17 Oct 2024 17:07:31 +0000 Received: by outflank-mailman (input) for mailman id 820879; Thu, 17 Oct 2024 17:07: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 1t1Tvn-0006TN-8i for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:04:59 +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 eefa78a0-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:04:57 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184626209754.6375868347845; Thu, 17 Oct 2024 10:03: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: eefa78a0-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184628; cv=none; d=zohomail.com; s=zohoarc; b=EhQ00uV5KWcXLb7ZAuzSAi6b9ej2Wl3tJ3B+8kjvf7b6mDzZoeQ8pJaEMRYmYY6CsusInTHpK0D1ZgGhP8ctXlBTjve44IwhZbRqEQl/wxY3ZA7KZFmHpSt35Gv1LKxhvGsKpLU0XDtsjooMe2BgYaWS5cZ32LdogXvHPBHDXMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184628; 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=Gn+NgukrSZNmUBqbS3h19LnxMuHuw+P3qAI40MVL2NA=; b=WeBY9Xq/Qo1W/Abt/lIT3RCAH5yPe01/M3J5tk3+bX0ZzZtyrvtUMuJTV6Crw0R6j3o9YZ+8+Z/8FQI23XOQITWat55/aPT2qmZl4q//5ylQYEu65DPRjQpK2BEo+R0orN3A76XbTBHa41vV4JiGMXYD8Qv/Upfnr1rZZ6MOytU= 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=1729184628; 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=Gn+NgukrSZNmUBqbS3h19LnxMuHuw+P3qAI40MVL2NA=; b=mwJ7JW/xMrsbow9/Z7dd+HrZF1KFwGE7GS2qLwrof2NHO4zBojx07XP5HLcuq7Ay WF+W6hJM6aE5JLNTmmgQswClDlGbC6S9NyPNntm/Tabn3km51o/EM/8uFcrxvRQp1Az yO78/fPqEKa4UH739OfXByt0xtybdiFXJDNU1yf4= 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 v6 09/44] x86/boot: introduce boot module types Date: Thu, 17 Oct 2024 13:02:49 -0400 Message-Id: <20241017170325.3842-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Reviewed-by: Jason Andryuk --- Changes since v5: - added guard around initrd type assignment - removed a missed rebase artifact --- 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 5fe4f1387d03..18281d80fa97 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; @@ -30,6 +38,7 @@ struct boot_module { * [ decompressed kernel ][ unused rounding ] */ unsigned long headroom; + enum bootmod_type type; }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1b56eaf26efe..fed9bef16305 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -311,6 +311,9 @@ 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; + return bi; } @@ -1171,6 +1174,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 ) { @@ -2059,6 +2063,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? "" : "not "); initrdidx = find_first_bit(module_map, bi->nr_modules); + if ( initrdidx < 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 Thu Oct 17 17:02: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: 13840485 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 19F07D3C525 for ; Thu, 17 Oct 2024 17:08:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820898.1234629 (Exim 4.92) (envelope-from ) id 1t1TzF-000849-CC; Thu, 17 Oct 2024 17:08:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820898.1234629; Thu, 17 Oct 2024 17:08: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 1t1TzF-00083w-8k; Thu, 17 Oct 2024 17:08:33 +0000 Received: by outflank-mailman (input) for mailman id 820898; Thu, 17 Oct 2024 17:08:32 +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 1t1Tvv-0006TN-ST for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05: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 f42e10c9-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:05:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184627400845.0097301540941; Thu, 17 Oct 2024 10:03: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: f42e10c9-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184629; cv=none; d=zohomail.com; s=zohoarc; b=SeayuwoQT0saTqC6G096y+49K1bclg5Ivg81bteWsoDLt/adFhxnFW3tKKpe/IWKuCK2jaI8RMq4NqZ3w5Hit3zXBubjRzMX+B0N8cy4mAOfWPTcJf/wEUf4YLj12lfiJYWtazTvbLq8IoUOlC37CmR00icW70Q4sFG8mfbUbXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184629; 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=Dgh7JemAIAyELVZo1MtAbdLIy6CYiHIimrr6e9LjQD8=; b=TS19wJUP0AMUiHWHp2eIISwQGpgs2CJKJCRwnlx1rDwNRQwoqOWgZqqwCnXyLHBMQRtRuIO4V/X70VsAZvI6r8AhW49kWAwEttsFIPPDcFm4ZhOW1cd2yWnnDYQzZ5DZcOnwS3zRwDpAaJgBy/PA+ibqDTqhGQo3/0OG+L8IhTQ= 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=1729184629; 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=Dgh7JemAIAyELVZo1MtAbdLIy6CYiHIimrr6e9LjQD8=; b=K4K1/ZiQiOWJ4pIQWR8kcK25hcKKNHMCIIV0jXCjd2149ZUXycVc3sYYaeqwrsyM 1sfKSVqt1NlVpU6FcdjYIInTnfaoX/QRYLCSXzdsuoMKKGXIy1JGrCnL9EoeLYbioUH rRXqtzfuNVbC3KFj5rGn2C969yTTnhPCXPclm8Xg= 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 v6 10/44] x86/boot: introduce boot module flags Date: Thu, 17 Oct 2024 13:02:50 -0400 Message-Id: <20241017170325.3842-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - removed trailing blank line. --- xen/arch/x86/include/asm/bootinfo.h | 3 +++ xen/arch/x86/setup.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 18281d80fa97..e8ba9390a51f 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -39,6 +39,9 @@ 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 fed9bef16305..f87faa31a2cf 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1357,7 +1357,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; } /* @@ -1471,7 +1470,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &bi->mods[j]; unsigned long 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). */ @@ -1490,7 +1489,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; } } @@ -1516,7 +1515,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 Thu Oct 17 17:02: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: 13840476 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 CA680D3C526 for ; Thu, 17 Oct 2024 17:06:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820874.1234539 (Exim 4.92) (envelope-from ) id 1t1TxD-0002vE-2u; Thu, 17 Oct 2024 17:06:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820874.1234539; Thu, 17 Oct 2024 17:06: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 1t1TxC-0002v7-W3; Thu, 17 Oct 2024 17:06:26 +0000 Received: by outflank-mailman (input) for mailman id 820874; Thu, 17 Oct 2024 17:06:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tw4-0006TN-Dx for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05: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 f9430893-8ca9-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:05:14 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184628693714.7111287097858; Thu, 17 Oct 2024 10:03: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: f9430893-8ca9-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184631; cv=none; d=zohomail.com; s=zohoarc; b=PqX/pyk6X/pI9ldvPH5cVFcVKKcRotmmkSVyyRetCm6EY+W+GXe6GedXJqODel6E9ZT8IDERd6OGwVB5khKFsmUCJdcfzHUU5J4vO0PK2f/LHOIZmn7utQmGiXHmN9DlrhxNOXViMoaIhNb8zpEYX2YsIHr5oos83ioy7rL1YD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184631; 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=jMznZ4/Qnb47L6uS5Mep6oH/AOXeu1gaoH+gJ/apC6A=; b=Q7XLJYKaSTBdJ9nU9OIJaOLc3CZ3xZDIQHHUK1kfIM0nJeKEwWWJUThvg14rZ8r9j8MkwN5xPdPz+UfBZsPUV7E1xPZ2/kviJ116leNKlWNCwZ9W3kFMAKju+ssNUq3R9QeFZyY2e/p0ouTmmYFf3y+iBejLwMWVNp/9MnIAz1k= 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=1729184631; 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=jMznZ4/Qnb47L6uS5Mep6oH/AOXeu1gaoH+gJ/apC6A=; b=oqszHDl5zgvb+fvQ1+Ix9i1lHgNhHIGLAdOVfg+SmLYzC9AKX6dssJ9UAeXeL2fX 08zzCNWIm4+p5swcAYigZJ5ZdxN2Bs+KyRKNgcA9aBnfa9LkuxcTRAuKFTk4I1X7OR4 9MiXrP+4fcXYknOl5YFxo2fKGJGavMpZBraj76Vw= From: "Daniel P. Smith" To: Jan Beulich , xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, =?utf-8?q?Marek_?= =?utf-8?q?Marczykowski-G=C3=B3recki?= , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v6 11/44] x86/boot: add start and size fields to struct boot_module Date: Thu, 17 Oct 2024 13:02:51 -0400 Message-Id: <20241017170325.3842-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External This commit introduces the start and size fields to struct boot_module and assigns their value during boot_info construction. The EFI entry point special cased itself, and pre-converted mod_start and mod_end to mfn and size respectively. This required an additional test in the coversion loop to not convert mod_start and mod_end when the conversion was done for both the multiboot and PVH boot entry points. To simplify the logic populating the start and size fields, the EFI module population logic was coverted to using start and end addresses. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - switched EFI population of mod_start/mod_end to addresses --- xen/arch/x86/efi/efi-boot.h | 4 ++-- xen/arch/x86/include/asm/bootinfo.h | 3 +++ xen/arch/x86/setup.c | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 94f34433640f..779f101c3de7 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -732,8 +732,8 @@ static void __init efi_arch_handle_module(const struct file *file, if ( options ) place_string(&mb_modules[mbi.mods_count].string, options); place_string(&mb_modules[mbi.mods_count].string, local_name.s); - mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT; - mb_modules[mbi.mods_count].mod_end = file->size; + mb_modules[mbi.mods_count].mod_start = file->addr; + mb_modules[mbi.mods_count].mod_end = file->addr + file->size; ++mbi.mods_count; efi_bs->FreePool(ptr); } diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index e8ba9390a51f..5862054b8cef 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -42,6 +42,9 @@ 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/setup.c b/xen/arch/x86/setup.c index f87faa31a2cf..6ee352fc0cde 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) * reserved for Xen itself */ 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; @@ -1351,7 +1356,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ initial_images = bi->mods[0].mod; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) + for ( i = 0; i < bi->nr_modules; i++ ) { if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); From patchwork Thu Oct 17 17:02: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: 13840470 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 657D8D3C526 for ; Thu, 17 Oct 2024 17:05:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820846.1234479 (Exim 4.92) (envelope-from ) id 1t1TwG-0008Tb-GP; Thu, 17 Oct 2024 17:05:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820846.1234479; Thu, 17 Oct 2024 17:05: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 1t1TwG-0008TU-Dg; Thu, 17 Oct 2024 17:05:28 +0000 Received: by outflank-mailman (input) for mailman id 820846; Thu, 17 Oct 2024 17:05:27 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TwF-0008TH-HT for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05:27 +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 ffe5de37-8ca9-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:05:25 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184629973825.0331942335803; Thu, 17 Oct 2024 10:03: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: ffe5de37-8ca9-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184632; cv=none; d=zohomail.com; s=zohoarc; b=lCkBpR3oksT79NRryhLIHUU6Pgz5aNGTPZNaqKRRRGlpH6oI4Yl5/uEaaTROBETeHCePCJHySyAEoucZCHmNmaX/QpYVp91xrrxEgApuPIuvaSee2kfonPFxto4N66hoj3jG4YFYNFkOyVF9zOWItXs/mz9ZMC8Avlu+vO1mSOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184632; 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=zL/cFqK5qkXy9lJ8lYgSqek6O1BwEfk0id77UI0IvV0=; b=W3XtYF+xk2SmhMqBSGTUGpX35JwqsvxKdeUfTLWBd4o55YQNtPrzt16yyNRHIKsbks+OFojA7vVmaVnOwzHXp9un/mj+k66tNkUn7nKKJrKkMK+2ZBOMD8cJiV2rpwer/mSWvR7FX5aEM4kzWJDOTXroyjQH2cDxh4oeKTmaeOY= 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=1729184632; 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=zL/cFqK5qkXy9lJ8lYgSqek6O1BwEfk0id77UI0IvV0=; b=qIvG04TZ4Khikl1EDCNAoiu7IwFFeh6YdcxcvUQxFBRgyBezX++uUNEXhkWXKWbr JA71ZQDdn1qsozaR2ozKwT5CmIUxg93VSlp2ILghflZtx4WgpWjsl2kHAdPz/JFU5nx PWH9JkIVtAeU6mAMwWWZczdeTsam6WmJ0l27vHYQ= 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 v6 12/44] x86/boot: update struct boot_module on module relocation Date: Thu, 17 Oct 2024 13:02:52 -0400 Message-Id: <20241017170325.3842-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - corrected conversion function for a missed switch from mfn to maddr/paddr --- 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 6ee352fc0cde..d51b0b03bc97 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1380,8 +1380,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_maddr(_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 Thu Oct 17 17:02: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: 13840471 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 55CFFD3C525 for ; Thu, 17 Oct 2024 17:05:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820847.1234489 (Exim 4.92) (envelope-from ) id 1t1TwO-0000KL-NB; Thu, 17 Oct 2024 17:05:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820847.1234489; Thu, 17 Oct 2024 17:05: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 1t1TwO-0000KC-KM; Thu, 17 Oct 2024 17:05:36 +0000 Received: by outflank-mailman (input) for mailman id 820847; Thu, 17 Oct 2024 17:05:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TwN-0008TH-PG for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05:35 +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 055c323c-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:05:34 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184631161835.9593205812029; Thu, 17 Oct 2024 10:03: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: 055c323c-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184633; cv=none; d=zohomail.com; s=zohoarc; b=G9DjefLvn7Ru+/zbJhgbQf/oWEtG6w9X3bIJZ96hSFmnck49GVckqDLnmuA3682IGUaWsbYegHLO+bfkKQC90YUP+ymIi9P9qqKsgffrTSru886SSD3PbNPYH0LRCIqXT99Mz5lIz4wDwI6XJzRJe7imGhmwrVYtnCVmlzYKs08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184633; 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=buUYqo46akp40axyhMLTCjGqzGXlUDMWgwiiv0Mju9Y=; b=nxMv2aHM6AytCLReXGvPa1qf+Ko0xf7uCwjHEE7Gd75DErgmdUhimnLuA8e9ioYg3R3Eh3X7YK7VMfWlDRWJemXU5fkb2YVpkwlPP5xNGbhMF0vGxjiEhT1/vyhGJcGsj+9653j70KD9ZQsjEaqtC3TkKHTniCK+4xm3HTeU2QY= 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=1729184633; 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=buUYqo46akp40axyhMLTCjGqzGXlUDMWgwiiv0Mju9Y=; b=Rt4/mpQfEreseFJGJfA1K+wlAgU0prYIMvig84X4FrsQCFL5W336te2DOKwrS1cD n+Gg9EzFSzlzi7s5uLYaJlzCIK5E/VlSKw0YGekg2RAO97mkMxcHIorDzJsDq+TB4K/ 6fOrqw0tCTQhTmKYY4VUZcyEzYJ79B/kC6zErDo8= 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 v6 13/44] x86/boot: transition relocation calculations to struct boot_module Date: Thu, 17 Oct 2024 13:02:53 -0400 Message-Id: <20241017170325.3842-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Reviewed-by: Jason Andryuk --- Changes since v5: - removed unnecessary paddr_to_pfn, allowing condition to collapse to one line - correct a missed conversion from .mod->mod_start to .start --- xen/arch/x86/setup.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d51b0b03bc97..44cec48fc877 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1476,7 +1476,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) * move mod[0], we incorporate this as extra space at the start. */ struct boot_module *bm = &bi->mods[j]; - unsigned long size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); + unsigned long size = PAGE_ALIGN(bm->headroom + bm->size); if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; @@ -1488,15 +1488,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( highmem_start && end > highmem_start ) continue; - if ( s < end && - (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) + if ( s < end && (bm->headroom || (end - size) > 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; } } @@ -1528,11 +1526,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 ) @@ -1610,9 +1607,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; @@ -1686,12 +1682,12 @@ 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)); - 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); + 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), + maddr_to_mfn(bi->mods[i].start), + PFN_UP(bi->mods[i].size), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC From patchwork Thu Oct 17 17:02: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: 13840472 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 F3761D3C526 for ; Thu, 17 Oct 2024 17:05:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820849.1234499 (Exim 4.92) (envelope-from ) id 1t1TwW-0000ge-3e; Thu, 17 Oct 2024 17:05:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820849.1234499; Thu, 17 Oct 2024 17:05:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TwW-0000gX-0G; Thu, 17 Oct 2024 17:05:44 +0000 Received: by outflank-mailman (input) for mailman id 820849; Thu, 17 Oct 2024 17:05:43 +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 1t1TwV-0008TH-2v for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05:43 +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 09cb3731-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:05:42 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184632344879.4637074312935; Thu, 17 Oct 2024 10:03:52 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 09cb3731-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184634; cv=none; d=zohomail.com; s=zohoarc; b=hs0ya0EXGgdii09hB6B50gKi/B5NEM9YlQSpSJmaU5jX0HcI/s+qVQCuK1jh+/5Lp87oKIKItjCU0QEy8bIbX4oLRIHfFqdmSz6/StD7Gda1cLq+llyTEETZ++FfnUErq6a321XvNYhz9Uxx3Vj/BZ9dUakoMTMOMTdXJqZqJ60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184634; 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=3lVlOCpdm5TzR4Ue4fgJ/C+2B6QVGR3l2Wwg3ehYe0k=; b=ZaQoxosUFrBxAC0LF+Oa4INnWTJ90CLG4siiB8Lcw3C9HbKuGQNRs0SOHOyrP9FsgGoXSZNhYNpzpsYiS1QIrO/voamWl53ifnqhd0HIcBnnJzn/S17vP6TEi5/0mJRARLljMA0AjxK3jgW/52Cx+92ImyN2+K91UOi+3lgrq/0= 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=1729184634; 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=3lVlOCpdm5TzR4Ue4fgJ/C+2B6QVGR3l2Wwg3ehYe0k=; b=qQ+jZvZju1WjCYDEgDCHPNCvO7bJ+4EtMAfCSVkHkBCgh5t7VcN+eOL6WhxYHyS3 GDKzV1gffCJoqcHp3ym7MxO+O6AXOGx4rhHgvSovRUXajCMwTCumeXn4z7w0CUZXcgv 0GvL5harq6b90/DfPMPsss9mffo4i4SrhJfonhV0= 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 v6 14/44] x86/boot: introduce boot module interator Date: Thu, 17 Oct 2024 13:02:54 -0400 Message-Id: <20241017170325.3842-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - documented help next_boot_module_index - switch to unsigned int for next_boot_module_index - changes identified that BOOTMOD_XEN was not supported, so added support --- xen/arch/x86/include/asm/bootinfo.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 5862054b8cef..3010e6f4af9c 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -62,8 +62,35 @@ struct boot_info { struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; -#endif /* __XEN_X86_BOOTINFO_H__ */ +/* + * next_boot_module_index: + * Finds the next boot module of type t, starting at array index start. + * + * Returns: + * Success - index in boot_module array + * Failure - a value greater than MAX_NR_BOOTMODS + */ +static inline unsigned int __init next_boot_module_index( + const struct boot_info *bi, enum bootmod_type t, unsigned int start) +{ + unsigned int i; + + if ( t == BOOTMOD_XEN ) + return MAX_NR_BOOTMODS; + for ( i = start; i < bi->nr_modules; i++ ) + { + if ( bi->mods[i].type == t ) + return i; + } + + return MAX_NR_BOOTMODS + 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 Thu Oct 17 17:02: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: 13840473 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 77215D3C528 for ; Thu, 17 Oct 2024 17:06:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820852.1234509 (Exim 4.92) (envelope-from ) id 1t1Twe-00019z-Bw; Thu, 17 Oct 2024 17:05:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820852.1234509; Thu, 17 Oct 2024 17:05:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Twe-00019s-8S; Thu, 17 Oct 2024 17:05:52 +0000 Received: by outflank-mailman (input) for mailman id 820852; Thu, 17 Oct 2024 17:05:50 +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 1t1Twc-0008TH-BQ for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05:50 +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 0dfb6901-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:05:49 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184633549591.1849705803486; Thu, 17 Oct 2024 10:03: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: 0dfb6901-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184635; cv=none; d=zohomail.com; s=zohoarc; b=bRqieGlVFZ/N04xtoYCV2/nB4oT+9dzFbm7jPyI55EBmij42qn6zfrhUYqdYSKj5G+Kph8LV2DNPhq974/BktseYSjAMIjna9UAq+639P74dxcBYtBpvZpiA6Np7iAUnscBnHkKBg/P8pVBeOqH+VMXRE8pqA/6EgPARw4H1e4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184635; 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=UOSq2CQ+avjz4TDy8H9wvkgSNIMCssGHhL5g606izH0=; b=hNwIchschivOXSjMOrWOSXEpKNE9jrHA0ljfizKfslueb5CoLKnhYQ1xRuMFKosmI1SrGnI59m8QmvPnNBKKoCG5C6tcp7MAfT4peG7Dra2kLX6ptRSmqZfq54xZZ4JwuV87g1/jfuhobFivE+yn8w/UrSMaT+e3JcX3HH+04bs= 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=1729184635; 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=UOSq2CQ+avjz4TDy8H9wvkgSNIMCssGHhL5g606izH0=; b=tbfOUxOwC2qw65HyPaOR/AOqCwFrs30Hb+N6c49ws9ZGmdtizFGP1T/ykjx8UE0F MeVyqtcSe8rWG7wsdF31zxBnjVGhhIqwTJ/MRARWIO5raN5kouLAdhDtLVlxXqdfe7C hcxcnmRKE5xYkivyMh14JsrS56RUMMvODZoLfmFk= 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 v6 15/44] x86/boot: introduce consumed flag for struct boot_module Date: Thu, 17 Oct 2024 13:02:55 -0400 Message-Id: <20241017170325.3842-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - first flag assignment can be = instead of |= --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 3010e6f4af9c..6903ab00ec90 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -42,6 +42,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 44cec48fc877..8261a87d9fb4 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; return bi; } @@ -1180,6 +1181,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 ) { @@ -2068,7 +2070,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) initrdidx = find_first_bit(module_map, bi->nr_modules); if ( initrdidx < 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 Thu Oct 17 17:02:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840474 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 125A5D3C526 for ; Thu, 17 Oct 2024 17:06:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820862.1234519 (Exim 4.92) (envelope-from ) id 1t1Twm-0001gj-Ih; Thu, 17 Oct 2024 17:06:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820862.1234519; Thu, 17 Oct 2024 17:06:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Twm-0001ga-Fc; Thu, 17 Oct 2024 17:06:00 +0000 Received: by outflank-mailman (input) for mailman id 820862; Thu, 17 Oct 2024 17:05:59 +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 1t1Twl-00014B-B8 for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:05:59 +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 12ce7763-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:05:57 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184634817591.1928959407942; Thu, 17 Oct 2024 10:03: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: 12ce7763-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184637; cv=none; d=zohomail.com; s=zohoarc; b=M4y3G8O6JKAiI5vqQXyZGSBHMpOQi9SRILP7EUkG1d3qbOcyyr9bqBStZmMSgHXr+Sl1WcFMnPm77pucsYelTNZijkaCMS22LXuvuUyJkxIqDHKfh6wi01dOQxsU+9s+TKJ6QmjQdEFtgN6Qd3mDFae47FYP0M5FwjOGjEW6j38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184637; 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=HqxZ6XJiXLCqmaSWp0mzQral5RGgZ8p3yBsfBpkK9gk=; b=cFj3x4xlFQcRAzC8mUlTRHqwKRuPW4aHFMd2J93PkCwYdzr+h+hC9KUb+l+m/QKV95M9/kuf9XywA5gL/M1YTMatPJsNugJLHFg4tq/i+KMDpA2sUnTgue/+jxCCLooFscao35yCbfPjXSQ5CIYcxANcSfRoEno27Fc6sX0l530= 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=1729184637; 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=HqxZ6XJiXLCqmaSWp0mzQral5RGgZ8p3yBsfBpkK9gk=; b=kUz/DnUCHxdAWmKwQhTk8VJzXlt+TZeZsF59yAWSNZrgdDOcr/uqbP5629PRiXo7 8rRPhKm1ck39Dy9T1R9FHqh4aO1hC9ZVcn651oBaxCA0gH7gg3gRic89kMWTWvtWwyy ZEfrwcjmHlTUPawNquEWUUkB/4IZdaQ8Rf78Q9gk= 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 v6 16/44] x86/boot: split bootstrap_map_addr() out of bootstrap_map() Date: Thu, 17 Oct 2024 13:02:56 -0400 Message-Id: <20241017170325.3842-17-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - moved bootstrap_map_addr() to being static to setup.c --- xen/arch/x86/setup.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8261a87d9fb4..852454c161ee 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -442,24 +442,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) +static 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; @@ -475,6 +473,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 Thu Oct 17 17:02:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840475 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 786A3D3C526 for ; Thu, 17 Oct 2024 17:06:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820865.1234528 (Exim 4.92) (envelope-from ) id 1t1Twu-0002Af-QN; Thu, 17 Oct 2024 17:06:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820865.1234528; Thu, 17 Oct 2024 17:06: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 1t1Twu-0002AY-Na; Thu, 17 Oct 2024 17:06:08 +0000 Received: by outflank-mailman (input) for mailman id 820865; Thu, 17 Oct 2024 17:06:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Twt-00014B-Ui for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06: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 1804ce12-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:06:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184636285638.5734527381169; Thu, 17 Oct 2024 10:03:56 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1804ce12-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184638; cv=none; d=zohomail.com; s=zohoarc; b=Q7r4nHSVDq5gQXeVmJvZns0msN1qkLbRSMFtRD5dm70aFF+PWpFc9HhCBHNHiwhcrnnrVJU5z0T11OUvA7SbRwyS8bBP96XEq725q8PBS3K1ydYyKq0p02JMgxLo06WS1dk0yvRgFdGlM530DJaZDSaGgEVjkzm5KLo0kvlQ9b8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184638; 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=mEfInqFkYxY5RZVtNiKPHgUhdYnWLo2IuwYz96mD0y4=; b=OH1WOhblMEbskTZ5gd+jMxSUbyekb8sDrrjgoZQnFHiPmoNYPa67XBnVOC0AxJdVSv2JR+uWr4KY9I00adDOzWa9rWFbqaydd5wRH59kt92xWbxAZrJlmu5lsH9a83Yh8QEzpVS69p89p8CZ5mfCQj/eG3H7IwaE5hgpK9L21MM= 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=1729184638; 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=mEfInqFkYxY5RZVtNiKPHgUhdYnWLo2IuwYz96mD0y4=; b=MjxdYnmfmkS1pCZB/lpCPSatWm43UxUnNJX+nozJAGKBP0cslJgLTjHS3LJrSHvW 2T87ZTKb7c9Aeds2mQX+kEef9L/3CK8NtlJ2zryo/GEWYvycGDYOCViiBu8s/nNw2Ku VpIdn5Yy5AmnFbTtbgGhfaqCn9M5vw2p9VH1GurE= 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 v6 17/44] x86/boot: convert microcode loading to consume struct boot_info Date: Thu, 17 Oct 2024 13:02:57 -0400 Message-Id: <20241017170325.3842-18-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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. To support loading the microcode boot module in to the bootstrap map, introduce bootstrap_map_bm() for mapping struct boot_module. Signed-off-by: Daniel P. Smith --- Changes since v5: - moved bootstrap_map_bm definition to this commit --- 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/include/asm/setup.h | 2 ++ xen/arch/x86/setup.c | 12 +++++++-- 5 files changed, 38 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 6903ab00ec90..19a0ed16ab27 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/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 3d189521189d..729f68ca23b8 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[]; @@ -37,6 +38,7 @@ 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); +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 852454c161ee..04de06ba1400 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -482,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) { @@ -1377,7 +1385,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 ) { @@ -1929,7 +1937,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 Thu Oct 17 17:02:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840479 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 B386AD3C526 for ; Thu, 17 Oct 2024 17:07:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820881.1234558 (Exim 4.92) (envelope-from ) id 1t1TyG-0004Sf-Kk; Thu, 17 Oct 2024 17:07:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820881.1234558; Thu, 17 Oct 2024 17:07: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 1t1TyG-0004SW-Hs; Thu, 17 Oct 2024 17:07:32 +0000 Received: by outflank-mailman (input) for mailman id 820881; Thu, 17 Oct 2024 17:07: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 1t1Tx1-00014B-Fz for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06:15 +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 1c96bce4-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:06:13 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184637493451.84421739071854; Thu, 17 Oct 2024 10:03:57 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1c96bce4-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184639; cv=none; d=zohomail.com; s=zohoarc; b=ER0ju3p2fPTCk6jegIRIWVHZCZiFqjUM0aihbhLMWQK0hQ2/Ur+sM9Yv/gJYYEHALYcOCVQDNwI0xZFjFXXHiIlb/rzwQpER173Y4eslYDMawLfmG157QePXP6Ux8bWtt/KXW0VajU5bDbhXZFkvRLlFXgbDSRcP2ld/p8sZhl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184639; 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=IYHnqAORfDi1eC8Y7S7zVhUJU72K5GjJXVS7llgVqYI=; b=DctUKoEGuoA8Rdr9m63PNBizaKu5a4n2j/hCYDvddsc3z2F56vCUjzRlsxvgAlp1rLozQMSWC7D9zReEToZpdlbJOeOzJUjVTQA+YWcM3hJGxWGbnyW4bGq9xC4ZFGvHa6ZtNCnFyANbeLEu1+JcCdwE5+AWKIpiDjepXmISV88= 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=1729184639; 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=IYHnqAORfDi1eC8Y7S7zVhUJU72K5GjJXVS7llgVqYI=; b=Gky6augRufFxhCCGQoCHMsQCCvAVH1Ed2IHZ2UOnHu95P5BAUqqfPDkplBb0OqZl usAn+3rUYty4DhUMfO2ScdDvbuekt2MBsOe+i1DDUloVskaIJRMo4pY5g+qhbgUJPyh 4zlbbZviL6xtvzyOXglv3VQPHV8DCPeKo2opNFmk= 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 v6 18/44] x86/boot: convert late microcode loading to struct boot_module Date: Thu, 17 Oct 2024 13:02:58 -0400 Message-Id: <20241017170325.3842-19-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Thu Oct 17 17:02:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840487 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 B4EB0D3C525 for ; Thu, 17 Oct 2024 17:08:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820901.1234639 (Exim 4.92) (envelope-from ) id 1t1TzL-00006x-Qd; Thu, 17 Oct 2024 17:08:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820901.1234639; Thu, 17 Oct 2024 17:08:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TzL-00006n-MI; Thu, 17 Oct 2024 17:08:39 +0000 Received: by outflank-mailman (input) for mailman id 820901; Thu, 17 Oct 2024 17:08:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tx8-00014B-N8 for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06:22 +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 20cfa8ef-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:06:21 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184639096561.6358775710053; Thu, 17 Oct 2024 10:03:59 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 20cfa8ef-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184641; cv=none; d=zohomail.com; s=zohoarc; b=MV3u8BzJ/LpTzbG91Beu7DO1aL2ciVRH+ZszcL8ha8+8/ddu+5Cp+Bx/E2yGoNU91+9mSLTWkcHExtp5JVOZed8Mch5pGIbPTBto1VR8JYmu3DCi5zUymDklg20v4U/6g8FhusjEyC2gukZp++b9lRsDH2wthVAp4abM60NbNhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184641; 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=YOeAlAQ8UqXDMkHJh4D/3cXI9R/bnPhlQYpeQYXz+XQJ6KkzKSlWwgFMRDjcicLHlBrwS/1Z1pJsWxdgNcMNaS9WFiNyLRZkWEbeCH6uZszHRXyDooGz/+eqs22ld6G8S+SUwxMBBYRJ2dFOOudnu/hh7v1DzM7XawbdkUc0LxE= 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=1729184641; 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=aMxZe0CvWweY1pZjHQuHKYRrnyTiYEOiQvK/qww0sZ+x7duhNG7OzwTz//8iS3l8 eHx0u0Xp53vGNZ+my0Ewiu/HSN0l0BWACQVRShO7vPGiQnhJkK+Njl3PRLSFwSwxWa2 PhDaeRIDkoSDo6l+xtSOlKQ6ed3C2wBaaSKGb03k= 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 v6 19/44] x86/boot: use consumed boot module flag for microcode Date: Thu, 17 Oct 2024 13:02:59 -0400 Message-Id: <20241017170325.3842-20-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Thu Oct 17 17:03:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840499 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 DECCED3C526 for ; Thu, 17 Oct 2024 17:19:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820992.1234782 (Exim 4.92) (envelope-from ) id 1t1U9i-0000jv-85; Thu, 17 Oct 2024 17:19:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820992.1234782; Thu, 17 Oct 2024 17:19: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 1t1U9i-0000jm-4M; Thu, 17 Oct 2024 17:19:22 +0000 Received: by outflank-mailman (input) for mailman id 820992; Thu, 17 Oct 2024 17:19:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TxG-0008TH-Pu for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06: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 2621499d-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:06:29 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184640324617.7081638090145; Thu, 17 Oct 2024 10:04:00 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2621499d-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184643; cv=none; d=zohomail.com; s=zohoarc; b=GudBkxNB4uk1sueWWl+b+OP6jTJXLFAeyzYM8YUWdxnyr+bK/gVchS0QTLyxsKoFxE7DdP5s3e08ZWH7fb6uUN7S12N8Hh8PgvTUXlEqmKLBmJ+K/BUMQD46W5ct7jdJCl/aIzotiZELXhjFVH+YWESa4B/KhlhzXLkyZ1mDrxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184643; 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=GjWn8P4/iAki6mlp0w0Xm+yUTIZ9w1BAGBcnDQ6vMwM=; b=LpYrwgK9bfZueJBU+SAUDU1e3bU5wodF29i6gi1+jPXnXoZE9ow843hw6Yc9ovQYURESv9FJZig+f94DZ/daVKxVlntlBzTGIYtN6yc4tJRiCTy8GwX+7faLJNoy3xy1ITWMGysEwE6I7qjep+nArvqkLA1wz5yE203zmPzJVLw= 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=1729184643; 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=GjWn8P4/iAki6mlp0w0Xm+yUTIZ9w1BAGBcnDQ6vMwM=; b=TkoQ29bQlwlOP19lG7oy5Zjm46vD9LKMur7RO34njb2dqGPpF02cR1T43nSTDWSP c3Q+bGHEPk7vTw70gM5qvW6JCt4KYx6X8Pbl2ZpM54BfMqc2M0uOGjbv3JUZF67V2ez 9mPBEwPVrlWQPZz8o/kGuKb3nFAhrBKtVsp1Fulg= 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 v6 20/44] x86/boot: convert xsm policy loading to struct boot_module Date: Thu, 17 Oct 2024 13:03:00 -0400 Message-Id: <20241017170325.3842-21-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - replaced bootstrap_map with bootstrap_map_bm - make init function definitions consistent in dropping const on *bi --- 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 | 17 +++++++++++++---- xen/xsm/xsm_policy.c | 15 ++++++++------- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 19a0ed16ab27..8b63eb27d6dd 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 04de06ba1400..a4ddcb908626 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1863,7 +1863,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..f155d10e718c 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, struct boot_info *bi); int 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); #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, struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index eaa028109bde..6f034f70428d 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,18 +151,26 @@ 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 ) { - bootstrap_map(NULL); + bootstrap_map_bm(NULL); printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); return -EINVAL; } } ret = xsm_core_init(policy_buffer, policy_size); - bootstrap_map(NULL); + 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_bm(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 Thu Oct 17 17:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840491 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 E8057D3C527 for ; Thu, 17 Oct 2024 17:17:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820939.1234682 (Exim 4.92) (envelope-from ) id 1t1U7V-00049g-El; Thu, 17 Oct 2024 17:17:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820939.1234682; Thu, 17 Oct 2024 17:17: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 1t1U7V-00049Z-B1; Thu, 17 Oct 2024 17:17:05 +0000 Received: by outflank-mailman (input) for mailman id 820939; Thu, 17 Oct 2024 17:17:04 +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 1t1TxO-0008TH-ST for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06: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 2b0226f4-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:06:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184642001935.7928067426468; Thu, 17 Oct 2024 10:04:02 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2b0226f4-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184644; cv=none; d=zohomail.com; s=zohoarc; b=VThMhDqlfyEbcCaSZ4XQ//QSDbd2FvoW9cNkyRyOmoBaUzboZAO8jIZQ684Sea4w4Jet6lIYaVAMgXg+iMB2ti8L/iYyXv+VsFB2P1E9HK4xwlnukuQjgUL2Nx1i+WXxDhFDbXLMBlZqCuvu92q538ubRWRT7gc77rCnhBuQl+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184644; 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=a9E8yTqYav2aI/xh1POt8XbQvYtTU40bLqsYbWj2y9s=; b=aIkOl1TcwtmHYXqTQ8rMRfsLaKTijG8zrJvjstr2pTH8AKcEH8seC4pOwmBO+hB7FxMV1Z10c8qWWx8KbEscCD2eyetxKyewZTuCvj1Cf90Hzc0tZRxBXIjff7ykRGOT9B6omFkllzJfiwq6wI706TeSM9dZ3gYgaawPk+03wa0= 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=1729184644; 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=a9E8yTqYav2aI/xh1POt8XbQvYtTU40bLqsYbWj2y9s=; b=NCkCTvtSUm3XGj5CqdsH7YFc300BedFexRbHOP785xaw2+Ixc7K2d9ljI/IjUh5L ny7r0a6y9ONM8g7ygDWHHIQnP0M1FX1HUP2uMY/8KL/dXoqY8F/P86c2RrRo/IPgUh1 AweAdVo2Fvm4nar/s4oJFrUCIx7nmnfINi7tRNpw= 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 v6 21/44] x86/boot: convert ramdisk locating to struct boot_module Date: Thu, 17 Oct 2024 13:03:01 -0400 Message-Id: <20241017170325.3842-22-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - adjusted initrdidx check for prior changes to boot module search function --- xen/arch/x86/setup.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a4ddcb908626..6ba8a893daf0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2083,16 +2083,23 @@ 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); - if ( initrdidx < bi->nr_modules ) + /* + * 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 < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED; + if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS ) + printk(XENLOG_WARNING + "Multiple initrd candidates, picking module #%u\n", + initrdidx); } - if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) - 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 From patchwork Thu Oct 17 17:03:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840501 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 E28D4D3C525 for ; Thu, 17 Oct 2024 17:19:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820991.1234772 (Exim 4.92) (envelope-from ) id 1t1U9g-0000P8-0S; Thu, 17 Oct 2024 17:19:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820991.1234772; Thu, 17 Oct 2024 17:19: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 1t1U9f-0000Ox-Sc; Thu, 17 Oct 2024 17:19:19 +0000 Received: by outflank-mailman (input) for mailman id 820991; Thu, 17 Oct 2024 17:19:18 +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 1t1TxW-0008TH-Pd for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06: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 2fb3dcb7-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:06:45 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184643193190.33025190860144; Thu, 17 Oct 2024 10:04:03 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2fb3dcb7-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184645; cv=none; d=zohomail.com; s=zohoarc; b=aZe4itBBnJA2y9TxgpuNou8I7xD39engfcpAbjXrG+C8EqbJ4vl+doeSIXfiKjkQvwbgPuXe+VRACv/us7s/sY1L1GrnaNwweIdHdfJPKNs3SvF8KiR5PGqYoATKgVEonxNhQ1kvPwWNFT/uJuH+gqAdAH5vzNi6QMYMOJlkTYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184645; 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=fMkGfujHPoOjChPMwwzqPao8q0VWxzzsdGo5pHHHDFY=; b=kCNym6KselYtzkaoiRE54OKnmGVijOgHVABlUOxI5KU2yWgieDHQqzMv/jrig45TyTpTTBA/wcJlB+KbpHxCnfrw/r9w5JFW6ne0jD3MB641n7JmHdToOiAvBEHXGvHEMEqqy012Jyloh3Sw0+P/5Iq57TC7ZcIm0HQR+H+IzmI= 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=1729184645; 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=fMkGfujHPoOjChPMwwzqPao8q0VWxzzsdGo5pHHHDFY=; b=noYIythe3ulKS3B18DOV2DkKiCX8BtzIW/ZfL3MVh6Sk918EvpHtk2ZE9s+XESi6 piRf3NFbfZi+01nPJGk1gJukqCh8jwU8KUSRStPWZkj3jzaRuY9dm47ZCBHzWVEXacm RuSybzs+4hntfMgvXISl/uNbDs45acJ9Bx3F8zCc= 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 v6 22/44] x86/boot: remove module_map usage from microcode loading Date: Thu, 17 Oct 2024 13:03:02 -0400 Message-Id: <20241017170325.3842-23-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - dropped unnecessary parens --- 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..23984c69bce7 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 6ba8a893daf0..e1763d7e6548 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1385,7 +1385,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 ) { @@ -1937,7 +1937,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 Thu Oct 17 17:03:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840494 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 6DE9FD3C525 for ; Thu, 17 Oct 2024 17:18:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820968.1234711 (Exim 4.92) (envelope-from ) id 1t1U8O-0006Ec-2e; Thu, 17 Oct 2024 17:18:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820968.1234711; Thu, 17 Oct 2024 17:18:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1U8O-0006ET-09; Thu, 17 Oct 2024 17:18:00 +0000 Received: by outflank-mailman (input) for mailman id 820968; Thu, 17 Oct 2024 17:17:59 +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 1t1Txe-0008TH-Dk for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:06:54 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3453d31c-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:06:53 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184644453447.45974491621405; Thu, 17 Oct 2024 10:04:04 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3453d31c-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184646; cv=none; d=zohomail.com; s=zohoarc; b=n+mu8ezXWcs5uab9RtWpeEcNuIZz3J4tj/l91FTvYbwJ5O3gPGdos+RdqiEBiO4+AAz5Um26RWduIIRTMlGlzxSMqd/H+6HEfGUgM9pGc5FpxxHQbtdy70IF6LRi/FtOLcKyCuj3lAQPtTNT3jQp5/eJLJ5bHvu80OLijnnQYWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184646; 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=INdU8Vy7H1JFe+GjwDiltbnyksHVP3i84VMPvIn3WAY=; b=IM5m2bZpAHgXSJckzMrAzCyhZWgH94E41bX95fRmC1Nh/rFlgOkfiFKqMhbNMYmTayRi6tYLsTxx6F92p5lrHYyrqN2foBzpUrx70z8xUJyAG9IYG50HoxEaxOxo4NZ3b50zaRMCVk+07NCPvEyFg2QvweEoZ5jUNwOxen9KvuM= 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=1729184646; 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=INdU8Vy7H1JFe+GjwDiltbnyksHVP3i84VMPvIn3WAY=; b=QkiSudRVf/AxMqRDYQidDSOMYr8nhOeZb8TFC7qKG464V2iRvWqCaW/XQKvPGnyz PJKp78zHMrtgPjIfktdSC9X5jy/ZGptWpLFV6094lX+sA4Uh89W+wUbC2MAlu8oLnzJ 4gLy8aB2swQ/A8SUN+vBw4kT+jqcACMg7aeIRT9s= 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 v6 23/44] x86/boot: remove module_map usage from xsm policy loading Date: Thu, 17 Oct 2024 13:03:03 -0400 Message-Id: <20241017170325.3842-24-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - adjust comment to coding style --- xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 9 +++------ xen/xsm/xsm_core.c | 6 ++---- xen/xsm/xsm_policy.c | 9 ++------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e1763d7e6548..91110ba96f73 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1863,7 +1863,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 f155d10e718c..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, struct boot_info *bi); +int xsm_multiboot_init(struct boot_info *bi); int 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); #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, 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 6f034f70428d..50b665759aad 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_bm(NULL); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 921bb254b9d1..453c81df4a2d 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -32,18 +32,14 @@ #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; u32 *_policy_start; unsigned long _policy_len; - /* - * Try all modules and see whichever could be the binary policy. - * Adjust module_map for the module that is the binary policy. - */ + /* Try all modules and see whichever could be the binary policy. */ for ( i = bi->nr_modules-1; i >= 1; i-- ) { if ( bi->mods[i].type != BOOTMOD_UNKNOWN ) @@ -60,7 +56,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 Thu Oct 17 17:03:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840511 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 5BBD3D3C528 for ; Thu, 17 Oct 2024 17:21:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821053.1234862 (Exim 4.92) (envelope-from ) id 1t1UBI-00079m-TO; Thu, 17 Oct 2024 17:21:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821053.1234862; Thu, 17 Oct 2024 17:21:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UBI-00079f-Q8; Thu, 17 Oct 2024 17:21:00 +0000 Received: by outflank-mailman (input) for mailman id 821053; Thu, 17 Oct 2024 17:21:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Txm-00014B-Tg for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:02 +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 38cd6bc6-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:01 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184645708207.7226848723384; Thu, 17 Oct 2024 10:04: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: 38cd6bc6-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184648; cv=none; d=zohomail.com; s=zohoarc; b=SJYiZ1sUG49vabG9vcQXWN55T3uHptNU1UAWTTCUhGuzX4sb0NITpr7LUck7C36p+VnZutGul0pYr3k/mi5VufsxCfhs707nEBT40jWiundcnHOgJ2dgZHbd8o1vQ5VAE6CWUzBYCfQlxElg3z536OpmW8X9hj97UtbtQZgL3FE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184648; 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=AlPw4EAVQKE/AEdlatH3NgpfKfcwbCqOnaIcZsRcFfU=; b=NkkOhsKT9bH/kMaNOkR4KvOxRRnXWpggDWemdGITiY/O8ZMlsVUT6hXAxhjRJNW2DFTk7zpcwIGEqO0wdD0QjNcYDzV82phiDs18mZkNrMIrbEZJzxRj48e6ZMio4mo+95N0fxCKNFQmQNAbrzVfCCnyKZY3x65vToK2GAxFqFE= 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=1729184648; 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=AlPw4EAVQKE/AEdlatH3NgpfKfcwbCqOnaIcZsRcFfU=; b=ncTHZpOwvInORTU5zOa2lR3cK3RNc3VWl35npYLPcApdMoUXNO9cukYWWx/o0ETh niJYbKYIKLrtbv/yQDByfZDl9hjQMNvKBjsxQud9flWzSIK7bwiOcseBGMZfefcFKYs c8oP/zx5pmKlNkMQLFICiZxommBIEArKPW2js30g= 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 v6 24/44] x86/boot: remove module_map usage by ramdisk loading Date: Thu, 17 Oct 2024 13:03:04 -0400 Message-Id: <20241017170325.3842-25-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - set excessive module check down to MAX_NR_BOOTMODS --- 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 91110ba96f73..08319f871a5d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1036,7 +1036,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; @@ -1186,15 +1186,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 ) { - bi->nr_modules = sizeof(module_map) * 8; - printk("Excessive boot modules - using the first %u only\n", + bi->nr_modules = MAX_NR_BOOTMODS; + 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 Thu Oct 17 17:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840516 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 2DA45D3C527 for ; Thu, 17 Oct 2024 17:23:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821087.1234932 (Exim 4.92) (envelope-from ) id 1t1UD3-0002w1-2G; Thu, 17 Oct 2024 17:22:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821087.1234932; Thu, 17 Oct 2024 17:22: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 1t1UD2-0002vs-Uz; Thu, 17 Oct 2024 17:22:48 +0000 Received: by outflank-mailman (input) for mailman id 821087; Thu, 17 Oct 2024 17:22: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 1t1Txw-00014B-BO for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:12 +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 3e59ac53-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:10 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184646961494.5555495958281; Thu, 17 Oct 2024 10:04: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: 3e59ac53-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184649; cv=none; d=zohomail.com; s=zohoarc; b=VB+bghv1DBQjUSk6ujnGUFjyWy7/8DtSUjB1NYK7UJdnn/0ZN/KOflLsCNqflpF1P4VZ+xydvKkSUnQPoK0Ybxu5XiJ6j5QcBvUblWAip2UJfHctY4BUX1Pv8+oGs1pfEpzrXtetcy0x8JuMgHoEazs4VtrAvU5b3NEd5NfQNzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184649; 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=aspkH3LwBaiSwnG3lvyv34jbI4VkIKf8lSHUsreXCUg=; b=m2lyBFLaShauw3nSRXIaG7+9vbEsLffItwmRIGGKsZva3hr5iNUAb+hitv+mW+Gdz2g3Gdv2SaIAFN2SVesusRWIPVVoQSTmsC6Ids1bgAnbd9buBzf8WCgcfrhin+ERIFC96/YV9xss8bgI1qPBggp+lCzdXRYNKkKL4awEbZw= 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=1729184649; 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=aspkH3LwBaiSwnG3lvyv34jbI4VkIKf8lSHUsreXCUg=; b=QPCRMfutIMbiye7CYv0bzR8+gm7BqarP4IB0ntvYD+sjukUu/SthYCBCIlO3mRiM d0JEyPs7Qwr5Mh1NVR1FiZE5Lj4txUdSs1TpTzMtAwTlwx8VN2g6M9gFvcMvqPJI7MF 3MNhBYPPa9vCx3FFXr6MU9EXLb75t+ZCvptM7kT4= 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 v6 25/44] x86/boot: convert create_dom0 to use boot info Date: Thu, 17 Oct 2024 13:03:05 -0400 Message-Id: <20241017170325.3842-26-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - change headroom back to unsigned long - make mod_idx unsigned int --- xen/arch/x86/setup.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 08319f871a5d..5bc667b8b4d4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -945,10 +945,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]; @@ -963,9 +961,22 @@ static struct domain *__init create_dom0(const module_t *image, .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + unsigned long headroom; + unsigned int 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 | @@ -994,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. */ @@ -2104,10 +2115,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 < 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 Thu Oct 17 17:03:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840514 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 AD362D3C526 for ; Thu, 17 Oct 2024 17:22:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821077.1234901 (Exim 4.92) (envelope-from ) id 1t1UCq-0001yy-Bv; Thu, 17 Oct 2024 17:22:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821077.1234901; Thu, 17 Oct 2024 17:22: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 1t1UCq-0001yr-92; Thu, 17 Oct 2024 17:22:36 +0000 Received: by outflank-mailman (input) for mailman id 821077; Thu, 17 Oct 2024 17:22: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 1t1Ty5-00014B-CW for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:21 +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 439ef11c-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:19 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184648189955.1156774966953; Thu, 17 Oct 2024 10:04: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: 439ef11c-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184650; cv=none; d=zohomail.com; s=zohoarc; b=Jx5FWTUJn7kqf8t8QVVpiHAbOaUuY0KYLLS8PjdImFLSDBSgmcb5CqgW2eQ7YO1J8rMna7coslGxDAHaORRg8OJafEAxmupT2+fNsf2RfBdd+d0f77TZO0ovPMZngNT7ilEYSUewhSLcjFa9EjQ86hyktlC40hAFgzkoAjyf6ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184650; 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=8tl89rB/YSG6P4YyPJkHaSNB7c9SwgIpSdiGSHM6J/8=; b=RExN4TJGaQZLLvhfmGSAGdXm1MPg3LiS4f09hJdFqB+EPckERAXHpALFhdhGNhPMYgQrrRoXNEyT91lIdvS54LtkxXJSM5vFU5XtUuR7rrQ/G/Tr68DEm/gCsDe3VV2RBHNoHDevdkhJWTdtI3d+5wleQsL+b7vA8heh01CNHYI= 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=1729184650; 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=8tl89rB/YSG6P4YyPJkHaSNB7c9SwgIpSdiGSHM6J/8=; b=tF0OR6hy1R8IyNULd+7NLrpKf2Ht0ZsIq+rTNtMMoLueOPEEykIyyABOReFP8eqB aa1zVpW58kq/qdZOO+O1tnNtzl0JkQjzs50PbFAH2JEDX+FzMbxUMkbZsu3AGb0OR2n 00MTduYm3x8HgOtCjKBVOj0RjGr6hv0QIIH1vM4g= 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 v6 26/44] x86/boot: convert construct_dom0 to use struct boot_module Date: Thu, 17 Oct 2024 13:03:06 -0400 Message-Id: <20241017170325.3842-27-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 | 19 +++++++++---------- 3 files changed, 18 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 729f68ca23b8..72d183e8a4de 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 5bc667b8b4d4..e7573bc3f40b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -945,7 +945,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]; @@ -961,21 +961,19 @@ static struct domain *__init create_dom0(const struct boot_info *bi, .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned long headroom; unsigned int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - module_t *image, *initrd; + 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 +1000,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 +1027,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 Thu Oct 17 17:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840506 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 DFB2DD3C526 for ; Thu, 17 Oct 2024 17:20:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821038.1234842 (Exim 4.92) (envelope-from ) id 1t1UAu-0005f0-3o; Thu, 17 Oct 2024 17:20:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821038.1234842; Thu, 17 Oct 2024 17:20: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 1t1UAt-0005en-Vx; Thu, 17 Oct 2024 17:20:35 +0000 Received: by outflank-mailman (input) for mailman id 821038; Thu, 17 Oct 2024 17:20:34 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TyG-00014B-Ow for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:32 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4a73a28b-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184649380155.40519092477825; Thu, 17 Oct 2024 10:04:09 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4a73a28b-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184651; cv=none; d=zohomail.com; s=zohoarc; b=Wpe+oEVSbYV3IhV6IBjYPlx3kNNAazLZxGPKXgbAFTVtxCHAg/uvodXXUT/rWOCuD19nIC5W8lVQmZx5Ts1f+Bv5N1XqfQ2gsBsvjMIhyKab5SJRbseFJZO/rILifvLmjtEQhi+tY7xpgyaH+1f8J/KXnG4AHUdZYzxOT57/V5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184651; 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=m7ZLsFa0scaQr3iKRnGjSr9xOOYoJU1g28IpOugO1dA=; b=fKe7VX5oXbm9z9WyEMvAegXBpNfFZ2Hse/EWr6Ch9WPR84VWTOHGyApauOUNWW39+4VAo1j0hgIELO/vScTBytZJQd5Lhv2W4dYORyFTz6kB31RO5leLk0hsJHKTOsAACHFZFRDBtIUGY/ixRxiasV7ZoRfgVkkq5DGapym7r7w= 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=1729184651; 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=m7ZLsFa0scaQr3iKRnGjSr9xOOYoJU1g28IpOugO1dA=; b=hPMDsb+3XYBveCTZ/4OUIthAHB6gh8TRBAWsQR+H7lvmIEYMvuFTlIg+5krCZaHr atgYbglbip2cXpVnKto59kHe+ApwYH80LZ8NjvUuMe0dQhDf5Ub9WL4ehXnOIRPALE1 Wh47WspqpHO/viBaxPtIhxshp6Zi3YbkLbwK8qNE= 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 v6 27/44] x86/boot: relocate kextra into boot info Date: Thu, 17 Oct 2024 13:03:07 -0400 Message-Id: <20241017170325.3842-28-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 8b63eb27d6dd..8dcda42b3400 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -57,6 +57,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 e7573bc3f40b..2574d2f1fdb4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -945,8 +945,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]; @@ -1000,15 +999,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") ) @@ -1102,6 +1101,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); @@ -2114,7 +2114,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 Thu Oct 17 17:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840495 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 6C325D3C526 for ; Thu, 17 Oct 2024 17:19:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820975.1234722 (Exim 4.92) (envelope-from ) id 1t1U9L-000744-Be; Thu, 17 Oct 2024 17:18:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820975.1234722; Thu, 17 Oct 2024 17:18: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 1t1U9L-00073x-8j; Thu, 17 Oct 2024 17:18:59 +0000 Received: by outflank-mailman (input) for mailman id 820975; Thu, 17 Oct 2024 17:18:57 +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 1t1TyO-00014B-9e for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07: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 4f0770c6-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184650633546.6576643682486; Thu, 17 Oct 2024 10:04: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: 4f0770c6-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184653; cv=none; d=zohomail.com; s=zohoarc; b=dfCM84MZcmAEPtFX2MhQRtWyFJmLgrRmDcsXJW7/voj/A8DRPp9Jr7bH5fJI1n2JFiKvk7SABUVFF5nPpQ/ud7Gus5mQvzU5Eplt2TI8FAhcEphOHWb8wGTAx0Vtw8JpWXLrugCxcPjgatw5yv+f0dJUWS4VSCHiWv8EA8i3uzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184653; 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=5pWxQAdhYkQ5A/U/o5fJjyYZh8d6vSIlQX+nrYdkAwQ=; b=BCGY6vLiLdLQldxTLDRyFmUUkcwXutAgzSsstAlv7rguLd4UAv/99whuY8LtUxiUcZFCOh65vKYNnKkYFXp0KgW+0+w5SPw868pec30nmedDuRxi39awWVK7yYxrVU5gZ8p9Izz5kESnH94Y+hoRTF1vaQdKtCPXGwub6HtyYTw= 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=1729184653; 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=5pWxQAdhYkQ5A/U/o5fJjyYZh8d6vSIlQX+nrYdkAwQ=; b=JgKwDM9SC3x8mlCYgwlqEfMC5cbLdkCtwVyGT20FtHidBVMkHTc1Fowme5/FIsIk 6lTWhRRaeMMM9SpgkuLVdSBxfVrokP+x6+2O6g19HHrHjWqEtUQIfRfEk/0L6KP9bAi Hye9m7NzKfzdndWb/N3UqjjgzqhVKeNblTsAZQN8= 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 v6 28/44] x86/boot: add cmdline to struct boot_module Date: Thu, 17 Oct 2024 13:03:08 -0400 Message-Id: <20241017170325.3842-29-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - changed boot_module element cmdline to paddr_t --- 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 8dcda42b3400..24c2f37c7b11 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -46,6 +46,8 @@ struct boot_module { #define BOOTMOD_FLAG_X86_RELOCATED (1U << 0) #define BOOTMOD_FLAG_X86_CONSUMED (1U << 1) + paddr_t cmdline; + paddr_t start; size_t size; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2574d2f1fdb4..e6f1208d5807 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 = (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; } @@ -999,10 +1001,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(image->cmdline), bi->loader)); if ( bi->kextra ) From patchwork Thu Oct 17 17:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840505 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 69C8BD3C525 for ; Thu, 17 Oct 2024 17:20:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821019.1234802 (Exim 4.92) (envelope-from ) id 1t1UAb-00042s-1O; Thu, 17 Oct 2024 17:20:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821019.1234802; Thu, 17 Oct 2024 17:20: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 1t1UAa-00042l-UO; Thu, 17 Oct 2024 17:20:16 +0000 Received: by outflank-mailman (input) for mailman id 821019; Thu, 17 Oct 2024 17:20:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TyW-00014B-0C for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:48 +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 539bd735-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:46 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184651885979.0690248848649; Thu, 17 Oct 2024 10:04: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: 539bd735-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184654; cv=none; d=zohomail.com; s=zohoarc; b=HRGzO+0jOKUR/Meq44FRnVuwdp1uY7NXVVZifN8wuadlwVVxglBTFTCIXNOMEB8rFU0Cn23CGQAH8fS9dSLmSFCTH1d6yGrwoYAATRmAnrYE6secvf2XOSYFVcNJo7LjRPhGziCSf9co7ZcIuzcO87Bq5p8e9gtRbnPLhLiriMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184654; 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=cvWn5Yqu/hyHibZNnNCf1iWRt37Pr6iw0261tw9I/1o=; b=EyN6YhRwhAIouOy4xuxaqLrgtitgsZssr8DVFkozYUmzorXPJYJOFamAt2THm7Jrte3xKEmQtoPsCR4lmvbixRAb3rRQIhzcdNxG+PfoXh6OF0p0/SzBfdFa/BGvCLx6PCpC8oVw8IdIgKxiAWfLv9/AuF94uJVewwyQvBh2+Xo= 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=1729184654; 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=cvWn5Yqu/hyHibZNnNCf1iWRt37Pr6iw0261tw9I/1o=; b=TRxOmHrFkMtsK4fC14yETXVYeGzzRVW+9ez0BTMeFHumoA0qnlqc2BDZXyeVWjas 9aTmOPSvcY6ECR6hWek0Pysc2Vf6JgYRgWMuIp+D9UZI7TI/ds04UiThOcC2CjmnL6L WRTXqFpTlEbcBCf5LEOXbS08992Y2zOsx3gLtdN4= 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 v6 29/44] x86/boot: convert dom0_construct_pv image param to struct boot_module Date: Thu, 17 Oct 2024 13:03:09 -0400 Message-Id: <20241017170325.3842-30-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - replaced bootstrap_map(NULL) with bootstrap_map_bm --- xen/arch/x86/dom0_build.c | 3 +-- xen/arch/x86/include/asm/dom0_build.h | 7 +++---- xen/arch/x86/pv/dom0_build.c | 16 +++++++--------- 3 files changed, 11 insertions(+), 15 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..f59597e50a11 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; @@ -830,7 +829,7 @@ static int __init dom0_construct(struct domain *d, printk("Failed to load the kernel binary\n"); goto out; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); if ( UNSET_ADDR != parms.virt_hypercall ) { @@ -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 Thu Oct 17 17:03:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840515 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 7725DD3C526 for ; Thu, 17 Oct 2024 17:23:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821084.1234922 (Exim 4.92) (envelope-from ) id 1t1UD1-0002gi-S0; Thu, 17 Oct 2024 17:22:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821084.1234922; Thu, 17 Oct 2024 17:22:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UD1-0002gY-Oi; Thu, 17 Oct 2024 17:22:47 +0000 Received: by outflank-mailman (input) for mailman id 821084; Thu, 17 Oct 2024 17:22: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 1t1Tyd-00014B-Kw for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:07:55 +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 58218783-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:07:53 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184653228647.9822276705668; Thu, 17 Oct 2024 10:04: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: 58218783-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184655; cv=none; d=zohomail.com; s=zohoarc; b=Jld2HDSz4LYuX9nEW6HUuGh4+nl1b+M4vtjnzZJX6kqQvNPTjxuJPrjUw3/bC4nuF8SiiEjOB72ejNwFlwp+qc40eeadiuImnIAOtTwGO86x46ORGtbsWWjn0YyQVK/pT2pZNkuYu/Jp6Cw5MwqMZtPODq9Ai5SONtrfomgssJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184655; 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=/WocqNvqWMovNBKSHYsx06yhaw6uzqBVu1livQAQNWE=; b=GtY7Fy0eheiLwmG68C3oilhZ/IrCfd5rZ2SC+9E3QmxsHEvZrJntySo/8BN4Zy/bfGuM5nLJc2QocODobdHomG0aA7FWh+mgkG6vowaSfrbG416+s0ukE/bTHtihXLvV1A/i22ED5t/TV0x/gq+u5Z8m5OP2F8jR8QrblRlIlgg= 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=1729184655; 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=/WocqNvqWMovNBKSHYsx06yhaw6uzqBVu1livQAQNWE=; b=TftWHWDt5PjjLKEvUeJw+DLFHVsXNW7/WDUktKsLLJ1QiLmExiQ3RgXqSJnK4y4J 64z7HcX5gmoMdbw5ALEiKCM3WuB/+20jOAsSWjQP1pKlUS6VxkDTOBzSayeS+6SZy4R BQRjJDBJfmw2s1CGNwNYCZ7Q2WSrDQrOlbfPiI2U= 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 v6 30/44] x86/boot: convert dom0_construct_pv initrd param to struct boot_module Date: Thu, 17 Oct 2024 13:03:10 -0400 Message-Id: <20241017170325.3842-31-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - changed initrd_mfn initialization to _mfn(0) --- 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 f59597e50a11..5e7b543d0cbe 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 = _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 Thu Oct 17 17:03:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13840508 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 9CE48D3C525 for ; Thu, 17 Oct 2024 17:21:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821049.1234852 (Exim 4.92) (envelope-from ) id 1t1UBE-0006nF-Ju; Thu, 17 Oct 2024 17:20:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821049.1234852; Thu, 17 Oct 2024 17:20: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 1t1UBE-0006n6-FK; Thu, 17 Oct 2024 17:20:56 +0000 Received: by outflank-mailman (input) for mailman id 821049; Thu, 17 Oct 2024 17:20:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tym-00014B-Dl for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:04 +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 5cce03bf-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:08:01 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184654449478.7806231697002; Thu, 17 Oct 2024 10:04: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: 5cce03bf-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184656; cv=none; d=zohomail.com; s=zohoarc; b=BlgBeqvn+5njIBvSNaCrFnXfqcjRi9m0UBXa6PxjfXpvZzE0QwNpMivSL8ZtGGpLd38Xry+JuznYGJ4Ns18e8nif6bTgUCzlbp2pooTphmbOqBrZlsUHf2dCVxkZpAbhGlxcfEpgXczcQcR2dbjzGRsElEE6qHgqZQzNQHz+nYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184656; 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=F4Lz7sqO+ktRyIvGIcZPYbApzi/uegkQRLWv0yMSK6A=; b=i1cQlB2zdS+kuEpuagXx7vqCgMt2tUD0HHdNwjMdZ5IzSWteDP7CpMl1tTLo67j27blkl4EfmBkJIgQMKVE9G5Uvt4RBkkepJIumO+TmmIy2SOEQ/Je2FAGk5EkLR1krxTpsfhyM1Vxr09ktOg4Tc9KCQ8MdFk0EZ9yIpiO4cQE= 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=1729184656; 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=F4Lz7sqO+ktRyIvGIcZPYbApzi/uegkQRLWv0yMSK6A=; b=SWjNeTJDj4gjiqiwKRVV+QEHiABcJX5F7SYtw8CGejLsHocWv8fGgt+nbdPVaOLw 5sN38TetRvO1d87E+6R56E6cnSllqkElbnrWU28tYq5E2uwaYjJT79y+DOcV1QnNSKj jEtIr/V/xUPFKYaBB8JKDQ2317HCBZMH3P4Nyx4I= 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 v6 31/44] x86/boot: convert dom0_construct_pvh to struct boot_module Date: Thu, 17 Oct 2024 13:03:11 -0400 Message-Id: <20241017170325.3842-32-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Thu Oct 17 17:03: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: 13840503 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 C791DD3C525 for ; Thu, 17 Oct 2024 17:20:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821027.1234822 (Exim 4.92) (envelope-from ) id 1t1UAf-0004jW-Gv; Thu, 17 Oct 2024 17:20:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821027.1234822; Thu, 17 Oct 2024 17:20:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UAf-0004jN-De; Thu, 17 Oct 2024 17:20:21 +0000 Received: by outflank-mailman (input) for mailman id 821027; Thu, 17 Oct 2024 17:20:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tyu-00014B-LM for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:12 +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 61c44785-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:08:09 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184655620990.0465556999607; Thu, 17 Oct 2024 10:04: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: 61c44785-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184657; cv=none; d=zohomail.com; s=zohoarc; b=dbwr3om9PZ4En8gFJd9v1mNrb/XPwezxwWfc4fiSUCNZ8f7LvijJJRsUkzu1WDfgERsE+TCBvensIXC+4wAiIZDUNkpuU756buzHgDNmR5CudHfWLT/cnkDLoiRaC9/yHIDsgNEgmwx4RWMhX4CCjWmowULHFILKHa07fasUFAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184657; 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=NBDtInGp9YJQJOeasJO8noI67YJSFGQINY+XLRHfqCo=; b=J2aljjfyPDne7TpLJ9XyqIZQjXyWhLlE4XRZmWShk+k/98iBec89enAqplSBsyedkKaFS7/yKtdbO+mB9KunSLURI08q7xPuTsaB0l6N7Y6pPcaaA4WlqT1+eDe4W11Da92ROCCD21TKhEkDD8BFCsZknuZH2bDyQkI3gDu4YbQ= 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=1729184657; 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=NBDtInGp9YJQJOeasJO8noI67YJSFGQINY+XLRHfqCo=; b=Y1txQgXlBFhJcdfypqPQmk4164USOHXRiQqzkaLVEZDVogw2V51hQK7iqt9qrOoA 7Yp6hD1vkM874W9+A4ZVxch2iKrEgBuwbVOmRxDgvaFDec3m0QreqXeqn8yzb/bkX7D 6rRNexlNk1iI2Bl8hnaYQ1VoSLNLSn01btDvQI2E= 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 v6 32/44] x86/boot: convert pvh_load_kernel to struct boot_module Date: Thu, 17 Oct 2024 13:03:12 -0400 Message-Id: <20241017170325.3842-33-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 Thu Oct 17 17:03: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: 13840510 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 3CA97D3C527 for ; Thu, 17 Oct 2024 17:21:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821055.1234867 (Exim 4.92) (envelope-from ) id 1t1UBJ-0007Cm-6c; Thu, 17 Oct 2024 17:21:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821055.1234867; Thu, 17 Oct 2024 17:21:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UBJ-0007Bv-28; Thu, 17 Oct 2024 17:21:01 +0000 Received: by outflank-mailman (input) for mailman id 821055; Thu, 17 Oct 2024 17:21:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tz2-00014B-6A for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:20 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 66b991cd-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:08:18 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172918465678522.81224609932019; Thu, 17 Oct 2024 10:04:16 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 66b991cd-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184659; cv=none; d=zohomail.com; s=zohoarc; b=eJQfjQzV3ePGKVDU/vX+th6KQbjrtVB9sjDQeUGVsjDIFi4di3rClsfJgPbehrTqzz9ebdpK4KpyaUmr1fxVUwwT53IeHcIzP9AfeeqXeGoQC9etWyJ/KMd+ltjqPJmP24qSO9dNJl9y1S2f/TQvoEMcMgqtdOcHF/PwNw0Iu54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184659; 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=Rp7RzI1QNTY5hwhage3xG8298106lOX2KeM4idRZunk=; b=Dk6/hSvBUPh+Pertq86eqcZvACCkSta0TQLCxH7pCwLRVLo5HtlrwUM0KSWTe0dk4frrIxb/EonAhgaQ++trEEmrGNGB7OKkhEAfenwdA1z/HKEvLlawEEczn21KAwg8QFmexu7mxKl6rX2/ELwF/j6kPW3FYCaizrrzBCg4HW4= 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=1729184659; 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=Rp7RzI1QNTY5hwhage3xG8298106lOX2KeM4idRZunk=; b=ai0q7Ip3Elh0GwZq/CZicDNx8l6vfbr4f8leXo+qnk7k+1Ip5MdyjE2yPZ83Qu9B +Wy4X8S/7Re51tzqVgcJ+7HujdkFot0pszNkEZ9j9N5mJeDocyqbaKVXHS6Zu2vbwUA H2RWSvZATWvk3q9dQy7+HhMg9/NpQ5w5NaTw+3lo= 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 v6 33/44] x86/boot: convert initial_images to struct boot_module Date: Thu, 17 Oct 2024 13:03:13 -0400 Message-Id: <20241017170325.3842-34-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - coding style changes --- xen/arch/x86/setup.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e6f1208d5807..f5cd7eeb157c 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; @@ -335,8 +335,8 @@ 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); @@ -352,10 +352,11 @@ 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; @@ -1379,11 +1380,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - /* - * The field bi->mods[0].mod points to the first element of the module_t - * array. - */ - initial_images = bi->mods[0].mod; + initial_images = bi->mods; for ( i = 0; i < bi->nr_modules; i++ ) { From patchwork Thu Oct 17 17:03: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: 13840490 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 2F0EFD3C525 for ; Thu, 17 Oct 2024 17:17:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820935.1234672 (Exim 4.92) (envelope-from ) id 1t1U7M-0003gZ-37; Thu, 17 Oct 2024 17:16:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820935.1234672; Thu, 17 Oct 2024 17:16: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 1t1U7M-0003gS-0I; Thu, 17 Oct 2024 17:16:56 +0000 Received: by outflank-mailman (input) for mailman id 820935; Thu, 17 Oct 2024 17:16: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 1t1TzA-00014B-HW for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08: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 6bd16e38-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:08:26 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184658005873.5613662896585; Thu, 17 Oct 2024 10:04: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: 6bd16e38-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184660; cv=none; d=zohomail.com; s=zohoarc; b=n7ZYi8u/rh/V7Dw9U4AhWRO/mKjxsLHcvk2bf9fVBZUnfCUuCkptJ9yzyu1VdzWzgU44ApHNdSUeLMwndFoWF4w8STrNUXNP5tIgUjpRsPUV5h3xqLf7X0jjv8vy1GjLGC2d5g4Z4C0NZ+6WC8MWDXNk+suElVcTu707am/nnd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184660; 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=JraRp4qDaDWJ2lj1CcSCRxF+QAMscl93p41Cp6mewpw=; b=anJC8yyyrOqRlOC/1FBaHJ6rqFhMr1m84qT2Jy/1vpZuBt5VrI9PqrKei0hXvy+VfxwPyiPtHnig1FlH7IgX7/+ET44C+QkOZWQYQt0pgH3wmFNBruUsAiZ/oxJtc8YOiX8HroIu6z8Z9MjAOE860kQnWTEQVT07+gl04TKXitM= 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=1729184660; 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=JraRp4qDaDWJ2lj1CcSCRxF+QAMscl93p41Cp6mewpw=; b=Ap1tYajcF/sRYx7/Ua6dS2DfhYOwNh/9hyXa3+gMfIPBDe0A9HWtIDb4f9TuVY8/ D4a0iHviwHMpz3h4Wd56ZcB1FpYjQiin12xmSV3itQ1W5v0GxNoWfo1zX6lzD3Xsj98 +YeheXOzZd6g2Ahif2l3CIrhgUw1TsriaOH0bT1w= 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 v6 34/44] x86/boot: drop the use of initial_images unit global Date: Thu, 17 Oct 2024 13:03:14 -0400 Message-Id: <20241017170325.3842-35-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - coding style changes --- xen/arch/x86/setup.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f5cd7eeb157c..f8b9c164c1cb 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) @@ -335,8 +333,8 @@ 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 end = start + PFN_UP(initial_images[i].mod->mod_end); + unsigned long start = bi->mods[i].mod->mod_start; + unsigned long end = start + PFN_UP(bi->mods[i].mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -353,14 +351,12 @@ 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)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].mod->mod_end)); } bi->nr_modules = 0; - initial_images = NULL; } static void __init init_idle_domain(void) @@ -1380,8 +1376,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; i < bi->nr_modules; i++ ) { if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) From patchwork Thu Oct 17 17:03: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: 13840513 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 121E3D3C526 for ; Thu, 17 Oct 2024 17:22:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821079.1234913 (Exim 4.92) (envelope-from ) id 1t1UCs-0002Fb-LZ; Thu, 17 Oct 2024 17:22:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821079.1234913; Thu, 17 Oct 2024 17:22: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 1t1UCs-0002FS-G7; Thu, 17 Oct 2024 17:22:38 +0000 Received: by outflank-mailman (input) for mailman id 821079; Thu, 17 Oct 2024 17:22:36 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TzI-00014B-Ru for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08: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 70cf6943-8caa-11ef-99a3-01e77a169b0f; Thu, 17 Oct 2024 19:08:35 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184659192935.1571835611051; Thu, 17 Oct 2024 10:04: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: 70cf6943-8caa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729184661; cv=none; d=zohomail.com; s=zohoarc; b=cLxxMYz4+nyr7jfi+Ep3ytFff8XZcen7miLa1T8mjFeYdfPvpAohjPHA18fZGV7CwfGx2kYxTRpjiygaILG0fMG+7NsOxVGofa8eurTy/btluC2cESCL1BWJsLsS+2nbA9tHAni7FW3jnK9vbKBqZ3N2ZLqpNWcNY0CpbdbgdSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184661; 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=0gjJz5LNIJtqKeHWTU5DRHYNSoNLJ9iVjYbe2ie5Je8=; b=LXu/AVLme8Hl12MVfGEEhOFM4w+wD3MIYbn9A2rKMcaO22wZzkDN7AOMmtxTg4htOmiiU9TLrNPUSdfP5Fwh0r5GXhZfTttuU7T163/6NactU37BfI7HgxRRsc7a4KTyb/z12Qsb7jd397ejSO9r2Vz64rUlf/Unz7MO2MBEyDY= 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=1729184661; 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=0gjJz5LNIJtqKeHWTU5DRHYNSoNLJ9iVjYbe2ie5Je8=; b=RTC1S6GK7APnbt9YKRdB5S/2iypzfyIc9IJMFjUFLIIMpN9R4tfbcogvXrRTsZye LkRtSdNC5/MznK8MNY5fOVEo5ifLJh0OUK+9SeV8rJ3OlbEhUV+xoMnCW+Ca7OrQSZL d1auH6xRqFx8kJEkgyOfDTD1QnTMEVt4I7lkOwZA= 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 v6 35/44] x86/boot: remove usage of mod_end by discard_initial_images Date: Thu, 17 Oct 2024 13:03:15 -0400 Message-Id: <20241017170325.3842-36-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f8b9c164c1cb..4d53292aa444 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -350,10 +350,9 @@ 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)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].size)); } bi->nr_modules = 0; From patchwork Thu Oct 17 17:03: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: 13840489 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 52419D3C526 for ; Thu, 17 Oct 2024 17:16:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820931.1234662 (Exim 4.92) (envelope-from ) id 1t1U76-0003Es-SU; Thu, 17 Oct 2024 17:16:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820931.1234662; Thu, 17 Oct 2024 17:16: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 1t1U76-0003El-Ot; Thu, 17 Oct 2024 17:16:40 +0000 Received: by outflank-mailman (input) for mailman id 820931; Thu, 17 Oct 2024 17:16:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1TzR-0008TH-14 for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:45 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 764fdd61-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:08:44 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184660412458.4759663546213; Thu, 17 Oct 2024 10:04: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: 764fdd61-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184662; cv=none; d=zohomail.com; s=zohoarc; b=ICoRWKfFh0fwzoJ4RKp+H6tPLezHb7U0FjEexjHQMGfl5abUMQGUcC2HY+M4Q2ZryiXBOQ/I4e8k9uzcgPYvAMW4hQhE9etbli1uZFqUvZrqla/wstbhT74RhD6lJuV9wPSwSwdq2q8GndMFJtt7EQSEcnDnxw0Qrk5gmrcx7JM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184662; 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=yCWAwbuasnt6b9Yd1Y7i2kLi7iLwBuIBFqAlz4Zq4CE=; b=GyZCqXV2sEq9lDb9hy7MIOC+4ClfXxIZZ6HuY54xuuYiOVx8f7hhFIyX0utvAYLP7XXhaAqpqTqzDxyoa50OCsZGX1xz4i1+gKf/8UGg0jnoP5ByyAgI6nrg1cQnDSMw1kFUNZpdL9HOdz4Lxna33FtBemHT6Ilb9tHeXKQRVBQ= 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=1729184662; 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=yCWAwbuasnt6b9Yd1Y7i2kLi7iLwBuIBFqAlz4Zq4CE=; b=GuqVYQ57RFIx63UqbWBa/o9oOsSAbZ3TtsQyhYI50nlocZZwUneOZG4BQfpLe5d+ DTvEIN/YFqdhwENjpg4xc1cDS+qWtm9pyLrpln/Gg+6R6vV3WL394bU3anRMfcN8xEh F9iKhXuErl9N27B0l025V6K0W+Fceu8sOrjPhlMw= 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 v6 36/44] x86/boot: remove remaining module_t references Date: Thu, 17 Oct 2024 13:03:16 -0400 Message-Id: <20241017170325.3842-37-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External Any direct usages of module_t have been transitioned, remove the remaining references to the mod field. This also removes any external use of bootstrap_map(), dropping from setup.h and making it static. Signed-off-by: Daniel P. Smith --- Changes since v5: - commit message rewrite - coding style change - remove export of bootstrap_map() --- xen/arch/x86/include/asm/setup.h | 1 - xen/arch/x86/setup.c | 27 +++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index 72d183e8a4de..f7958b56eab6 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -35,7 +35,6 @@ 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); 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 4d53292aa444..5ae82f3abcb5 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -333,8 +333,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); @@ -471,7 +471,7 @@ static void *__init bootstrap_map_addr(paddr_t start, paddr_t end) return ret; } -void *__init bootstrap_map(const module_t *mod) +static void *__init bootstrap_map(const module_t *mod) { if ( !mod ) return bootstrap_map_addr(0, 0); @@ -661,8 +661,8 @@ static uint64_t __init consider_modules( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = 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; @@ -1377,10 +1377,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; 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; } /* @@ -1401,16 +1399,11 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ bi->mods[xen].start = virt_to_maddr(_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. */ @@ -1511,9 +1504,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; } } From patchwork Thu Oct 17 17:03: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: 13840492 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 1992AD3C526 for ; Thu, 17 Oct 2024 17:17:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820943.1234692 (Exim 4.92) (envelope-from ) id 1t1U7f-0004gO-KP; Thu, 17 Oct 2024 17:17:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820943.1234692; Thu, 17 Oct 2024 17:17:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1U7f-0004gH-Hq; Thu, 17 Oct 2024 17:17:15 +0000 Received: by outflank-mailman (input) for mailman id 820943; Thu, 17 Oct 2024 17:17:13 +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 1t1TzY-0008TH-14 for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:52 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7a61aa24-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:08:51 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184661673704.2726553863293; Thu, 17 Oct 2024 10:04: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: 7a61aa24-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184664; cv=none; d=zohomail.com; s=zohoarc; b=FGaplFOEg0rWI0UwXkCA+tRto+W1AeKjKp/IK1sImY8OaZ0tt2Hwb3CBRrNcwNVSewTgRHEPOPlRZFPQOswlI+1dYOfuxLrEw6PMzvJZsYhV3TDfsOIEq9pxwprgNN2P8NLChp7FSWcHs0+bdZ6xyEd9Ljm+asRWKTH/Eqmo2A8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184664; 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=t8mwfgj0+AG9djRszVKShE80Ero/zF+/yhs316UwKJo=; b=WauNIwkoJRLSMZUi9LAolyhJZfXfdMN1GuLam2sWYVV4151l5t33HuKcCNqIdgohaiwEJ6OEW6DjjJZUBclRbNC6ucxcH7u7HQZsGU3rdmgBWuHT8X9/Ebo4m9EBG2uoto6W06+FLiZOuFcv51LblVaYTNfyCV0CKiFDt6klqrc= 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=1729184664; 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=t8mwfgj0+AG9djRszVKShE80Ero/zF+/yhs316UwKJo=; b=V/XPjZlOPZgdAHyA7bfz3i0WTSD1qZbB+lW7Mi6BUdIyPL8JTejU6Ixn8DiCqQxW Nq6v5VZ8gQZfDhceAcmaSmSaq8g6yIMr+YkjrA820OeUKHtaWugOxLvPXze+TRJHhHP y3d1OCR2oN89UagNAVviywYA7jmq0z/iwLBWphB4= 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 v6 37/44] x86/boot: remove mod from struct boot_module Date: Thu, 17 Oct 2024 13:03:17 -0400 Message-Id: <20241017170325.3842-38-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 | 2 -- 2 files changed, 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h index 24c2f37c7b11..b65b55c0a2c2 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 will require * additional space, before the module data, into which the kernel will be diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5ae82f3abcb5..ae027667eb82 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 = (paddr_t)mods[i].string; bi->mods[i].start = (paddr_t)mods[i].mod_start; From patchwork Thu Oct 17 17:03: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: 13840493 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 57B6FD3C526 for ; Thu, 17 Oct 2024 17:17:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820960.1234701 (Exim 4.92) (envelope-from ) id 1t1U7y-0005Vu-RQ; Thu, 17 Oct 2024 17:17:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820960.1234701; Thu, 17 Oct 2024 17:17: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 1t1U7y-0005Vn-Os; Thu, 17 Oct 2024 17:17:34 +0000 Received: by outflank-mailman (input) for mailman id 820960; Thu, 17 Oct 2024 17:17:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1Tze-0008TH-L2 for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:08:58 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7e4aa548-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:08:57 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184662893105.18560154820727; Thu, 17 Oct 2024 10:04:22 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7e4aa548-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184665; cv=none; d=zohomail.com; s=zohoarc; b=fBe4WLb7EHSW3PylVLEICC3qQRDDiKHL+H0c+uF7mjXUy5PcrmKf+qG1f+lFY1FaTEm+rJdYCMxDPGRJVX/zTJsxy+pLukTSOLLDgnmyVLq5xFzEX6up4Uope85qacc6qakYc9V2YNGofkbqt+JkPuydUFfn31tClzqBDC92t9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184665; 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=S1LW22pFbnxH5JGQ8//MfzLwShQxKtqrPZfaGz84Hgg=; b=Osbbkoh/MPisEEZO+D7hShf3v40EoYGbEGjI6M3dRnpeoX55IQeNvxjd9Jx4ydAjCk71cBZd0stqBiPJ0WZBxqqFDvRnjiNbzWoyF262aBb579DcVinw+ZX1OykfpqBjGwWONu6eZkKHIzC91ulhOJoBpvnSNjip6pLwrN7OD1w= 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=1729184665; 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=S1LW22pFbnxH5JGQ8//MfzLwShQxKtqrPZfaGz84Hgg=; b=is4MgpcB2Qw7lJR60I4biW7RtZlThCKyy2HlGdCtygnA1/Dnl/VtyJOQ5nQ3qnIo x0O/4vni9MAKVmUNEGCWt8jMAhmfvQ8W86OUoQKWUDLaINyE/BzXyvbgI95CPlYSDDY ip+F2EqrX5YhPQ68F5dW77QqzYrrfLoRphOVPLiY= 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 v6 38/44] x86/boot: introduce boot domain Date: Thu, 17 Oct 2024 13:03:18 -0400 Message-Id: <20241017170325.3842-39-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 X-ZohoMailClient: External To begin moving toward allowing the hypervisor to construct more than one domain at boot, a container is needed for a domain's build information. Introduce a new header, , that contains the initial struct boot_domain that encapsulate the build information for a domain. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 28 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/setup.c | 23 +++++++--------------- 3 files changed, 40 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 b65b55c0a2c2..476f71a7633b 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, @@ -63,6 +67,7 @@ struct boot_info { unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ae027667eb82..ccb5052e18be 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -956,20 +956,10 @@ static struct domain *__init create_dom0(struct boot_info *bi) .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned 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 | @@ -995,11 +985,10 @@ 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(image->cmdline), + if ( bd->kernel->cmdline ) + safe_strcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline), bi->loader)); if ( bi->kextra ) @@ -1023,7 +1012,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; @@ -1203,6 +1192,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 ) { @@ -2086,6 +2076,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) < MAX_NR_BOOTMODS ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Thu Oct 17 17:03: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: 13840496 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 A79F0D3C525 for ; Thu, 17 Oct 2024 17:19:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.820978.1234732 (Exim 4.92) (envelope-from ) id 1t1U9W-0007R6-Mv; Thu, 17 Oct 2024 17:19:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 820978.1234732; Thu, 17 Oct 2024 17:19:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1U9W-0007Qx-Je; Thu, 17 Oct 2024 17:19:10 +0000 Received: by outflank-mailman (input) for mailman id 820978; Thu, 17 Oct 2024 17:19:09 +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 1t1Tzm-0008TH-Lk for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:06 +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 823c5b74-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:04 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 17291846641131020.5415294818473; Thu, 17 Oct 2024 10:04: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: 823c5b74-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184666; cv=none; d=zohomail.com; s=zohoarc; b=G9sG10XUydhECPLFpPpP4Gj5/KgVJVQcXfRjaOC5oWlrL8zFzWaAKfK73gv8k9j2jB3VDy+Nu9C2t6YdRKkUX0h5zMc7s+Ytqgp/7KOQjjjW+XAVR2unke/Z4+ucXODc71ln7P+KH8v/02qJNBj7HtvFh8Xc1SAuya0TqqBhcX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184666; 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=BJ5VYIncE7+0Abn8b+L/cjX/uv1rXkaBhM0DRTxUuNQ=; b=OEDj4ZGTx7P0jgg7gqEkpX71lswsW2r7WLNGdghPKfLb+dwez9x0cc5YaEUnA8it8pjzUdylnM+UzdsSL/dlURZB1BoF4cjRfOvzuUtnOJPmz46LCgaeNVBjRlx3BMJuGroGj7pUNuyEpN9pKindfkcMydSUbNHs48Phhw7WM3k= 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=1729184666; 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=BJ5VYIncE7+0Abn8b+L/cjX/uv1rXkaBhM0DRTxUuNQ=; b=IXRNGp/QEirmwMm1/AiJDtxtQJ802FfZ9h8qYsp9jINm9o7ywTzn36Mg3zvorEXe 0YnSOm1w+xfCCh9bf1Pa1YtAc5TDnW8KbXRa2ztLVfUTBeNGZ/r2hlZR+qdfxPtrmLb WikeVFtcw3/ErWtTF8l5Jd/a66LwvC+LTCoM87sw= 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 v6 39/44] x86/boot: introduce domid field to struct boot_domain Date: Thu, 17 Oct 2024 13:03:19 -0400 Message-Id: <20241017170325.3842-40-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 ccb5052e18be..e74526e20b5b 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; } @@ -958,7 +961,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 ) { @@ -974,15 +976,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 Thu Oct 17 17:03: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: 13840509 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 E7F17D3C526 for ; Thu, 17 Oct 2024 17:21:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821058.1234882 (Exim 4.92) (envelope-from ) id 1t1UBN-0007s1-Fr; Thu, 17 Oct 2024 17:21:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821058.1234882; Thu, 17 Oct 2024 17:21: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 1t1UBN-0007rs-Bs; Thu, 17 Oct 2024 17:21:05 +0000 Received: by outflank-mailman (input) for mailman id 821058; Thu, 17 Oct 2024 17:21: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 1t1Tzs-0008TH-3K for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:12 +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 86559b7f-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:11 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184665301732.0723237960185; Thu, 17 Oct 2024 10:04: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: 86559b7f-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184668; cv=none; d=zohomail.com; s=zohoarc; b=VMQ+bGVq9sllLGMYOT9NujBbHIYd1PyHiSqvZcsqfSqi3fbdcyF8uCB4UffqLq+rttutct2vQuff8Cm68oMs2A0PiIKPgh63dCK6kg8db51xA2lfu2XXsImLkSSQZUayMnKGYaNfUqE2bXaPNI9KAh9O4ClgvAQSnduUy9mX2TQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184668; 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=M5ZqTV3hdrjp9T+eS9L5DEYe6kUmW2KTxCnzOajAfpE=; b=cJV/c4hN5XBjioZluQlAfs8pcUWameU1dIIU+vfl/bPdsrP5ouvEGQnbprqmny4isWbTZuxsAxP9OO4G/ZbP+HUkEiFZDR/N4zGq/bURDX51P6zE04PQYZ3TuVG7x2sQeWtjeRyvWa1xorLgGh59638FvzA8aowzkzml9NciV+4= 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=1729184668; 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=M5ZqTV3hdrjp9T+eS9L5DEYe6kUmW2KTxCnzOajAfpE=; b=vWM3I32nrj0Q9VLOHMOj77lAL0+AxCLKzgAmv40s/POtYaQXn7hPJOkvfEVDnFci ZXLo4KHTW97dvYUxoRO+gbdemQMHe8hA47+yxzwOn+xJOYDYZwTPqRsEcPD+1Zk2yJN 4iqmuf1VrDGhJKkZ8qq/WeBp/1Ut2e5a0U0qiMdc= 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 v6 40/44] x86/boot: add cmdline to struct boot_domain Date: Thu, 17 Oct 2024 13:03:20 -0400 Message-Id: <20241017170325.3842-41-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 e74526e20b5b..1aa063facfce 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -946,8 +946,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, @@ -990,16 +988,16 @@ 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(__va(bd->kernel->cmdline), + safe_strcpy(bd->cmdline, cmdline_cook(__va(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 ) { @@ -1007,14 +1005,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 Thu Oct 17 17:03: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: 13840504 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 5CE0CD3C526 for ; Thu, 17 Oct 2024 17:20:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821022.1234811 (Exim 4.92) (envelope-from ) id 1t1UAc-0004Iv-8R; Thu, 17 Oct 2024 17:20:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821022.1234811; Thu, 17 Oct 2024 17:20:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UAc-0004Io-5X; Thu, 17 Oct 2024 17:20:18 +0000 Received: by outflank-mailman (input) for mailman id 821022; Thu, 17 Oct 2024 17:20:16 +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 1t1Tzy-0008TH-MW for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:18 +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 8a49ec72-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:17 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184666649537.2838599744491; Thu, 17 Oct 2024 10:04: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: 8a49ec72-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184669; cv=none; d=zohomail.com; s=zohoarc; b=oHHB7tPYQvisRi3u0iB+bVrCD7dg6zYEq0nvVKIrcPfKLE6HlQR99F591gzujjraocIn3pHreKtEqb1Z2hEvUeJelryz/P9EyOZaHA+mu4jszJlsFngQ8jE0Dsmvgb08JC/3R2OP6wZv1a4YY/EQJAOd4pMkMdZaPH5Oc9zaT2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184669; 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=MA3/IH4VWLQ7jN2aVHhTtAIX9q+RjxglxLS16ZJ3JG4=; b=feHejNNneXvg0zFTeejqjJHLTk+QyLaan0JN1LntEzApZjcwT8oGwJbZK5rlfOvItEHR9gkdDzQVQqHfOfvsUKi/VWdls7Lsc1tDGrJCu2GObsvPstykww8GwOBZSzlKizprAYosZpG5TOv1Twhav/5Kt7kAKIFc9MAK/nXu3Kk= 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=1729184669; 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=MA3/IH4VWLQ7jN2aVHhTtAIX9q+RjxglxLS16ZJ3JG4=; b=jTUtbPFRVzBOQciezzn28jKMB9WTosJ6B1wF4vOpIqx1+QNUdhh2/8QYjT7uSC3N UZAw61ekFunYgRyi+DDns8rVmsxZCnBOhAbGIV2AToRE+I/rQ6H4A4kbn5ARUnY2LRX XE0r8lH/bdeWhR++Qe/N/7kunbGXOuyTfcj2gQWw= 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 v6 41/44] x86/boot: add struct domain to struct boot_domain Date: Thu, 17 Oct 2024 13:03:21 -0400 Message-Id: <20241017170325.3842-42-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - moved back to using variable *d to hold domain reference locally --- xen/arch/x86/include/asm/bootdomain.h | 3 +++ xen/arch/x86/setup.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 1aa063facfce..494e48a7c836 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1012,10 +1012,12 @@ static struct domain *__init create_dom0(struct boot_info *bi) } } + bd->d = d; + if ( construct_dom0(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 Thu Oct 17 17:03: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: 13840512 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 1D35CD3C525 for ; Thu, 17 Oct 2024 17:21:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821059.1234887 (Exim 4.92) (envelope-from ) id 1t1UBN-0007uu-Rm; Thu, 17 Oct 2024 17:21:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821059.1234887; Thu, 17 Oct 2024 17:21: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 1t1UBN-0007tz-KL; Thu, 17 Oct 2024 17:21:05 +0000 Received: by outflank-mailman (input) for mailman id 821059; Thu, 17 Oct 2024 17:21:04 +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 1t1U04-0008TH-IH for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:24 +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 8dc2d6f9-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:23 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184667892741.9331042535918; Thu, 17 Oct 2024 10:04: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: 8dc2d6f9-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184670; cv=none; d=zohomail.com; s=zohoarc; b=WVR/lDK+04iVOVW/0H/mHVl9L6kUHWCNJWWyghZxCuhKlHc4yQfq8WpNiXnkMQugs8k+RIccLmVyDuEDFkMARnlnSPqKZPEAl64FEOlraHKZDogGGgAEF6HzAU9IxcfVwSUHYV8ZJ/A4jhv4/cONHMBDlcbNF156qAXxTUhe268= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184670; 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=+1GsfAAD9TH3Wlh8fsiZ1qgiG1+d1IF1Bk8zaWFZI9U=; b=ebrqyv3CKounmHSUNcjhbQviXOLghOgMdrTbkGE8+YK5rCsdZgkVnYdXASMvjl+x0Nh5ONlzRWzExGSyV2L60T4JDofJbdFIG+bdw4YLtZom81jdKrm0JJekFdYCO9TqHWZ60EcsMVNfIn44RY1Yyi9nSuSh1gDrfB6KVq6TuIk= 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=1729184670; 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=+1GsfAAD9TH3Wlh8fsiZ1qgiG1+d1IF1Bk8zaWFZI9U=; b=l53SLPqO/UvAc2AhBCNFOElQLLyAgDloPG62jPyUtOMKRBeTGvV5kg6bPyC6K/19 ap1KP+Q7nlw1wpt/H1/w+HUzBw2YdaKixh25040M4VyxfJFQG5/Wktq63PkIp/dm4AT tpq7/5t2Uh90tGiSRMfz3G3gCVBEIxKvvW2yHvpg= 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 v6 42/44] x86/boot: convert construct_dom0 to struct boot_domain Date: Thu, 17 Oct 2024 13:03:22 -0400 Message-Id: <20241017170325.3842-43-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - moved back to using variable *d to hold domain reference locally --- xen/arch/x86/dom0_build.c | 8 ++++---- xen/arch/x86/include/asm/setup.h | 4 +--- xen/arch/x86/setup.c | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 71b2e3afc1a1..34b4943de3b1 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -597,10 +597,10 @@ 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; + struct domain *d = bd->d; /* Sanity! */ BUG_ON(!pv_shim && d->domain_id != 0); @@ -610,9 +610,9 @@ 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, initrd, cmdline); + rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd, cmdline); + rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->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 f7958b56eab6..b049dc5ee17e 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 494e48a7c836..d9ad27093611 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1014,7 +1014,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) bd->d = d; - if ( construct_dom0(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 Thu Oct 17 17:03: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: 13840507 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 47D66D3C525 for ; Thu, 17 Oct 2024 17:20:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821036.1234831 (Exim 4.92) (envelope-from ) id 1t1UAs-0005Mx-Qs; Thu, 17 Oct 2024 17:20:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821036.1234831; Thu, 17 Oct 2024 17:20: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 1t1UAs-0005Mk-N8; Thu, 17 Oct 2024 17:20:34 +0000 Received: by outflank-mailman (input) for mailman id 821036; Thu, 17 Oct 2024 17:20:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1U0E-0008TH-Mg for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:34 +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 93ddd747-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:34 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184669125634.2300346641034; Thu, 17 Oct 2024 10:04:29 -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: 93ddd747-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184672; cv=none; d=zohomail.com; s=zohoarc; b=WEKpKvDtClHHQBu0BzpCfBAD/yVFbIu4CI12tll1MvaPJ8DbqPizvrdLlArqNVtruizHVLfyQUaBL2/hn/D0mMnD/6yRx75Sv7VxQYtuVxjCsTaQ3nyEmjmR5jAAIn3uR1+xbIVNGkbH9LF6nml7RqU+/N1cDEQ+/FYjgvh+kc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184672; 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=9+B4OzBQ7rw57Cecbw8dku0IeEJ1zavf5a/aaymJkgU=; b=bAQQDiTx4fZoQDKLiUIW212k+LBPbbQQ4d/2n4gKHKyz7WmT29Lf01/ItbAvk2JkQvYkXUORGuLZ+996sJgHjbSTzsulyZEZg/rktdvt/xjMLPXmpgb/pP5WNir0qCNih2MGS3fIJtdBg05VY39FnqpGCR5en1fVEh8+oAbp04M= 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=1729184672; 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=9+B4OzBQ7rw57Cecbw8dku0IeEJ1zavf5a/aaymJkgU=; b=qjgxSDaDZaunxPeasAy4mEYRX7fljKd0+/lWyCl/lSYWT1T77eG47a998ine8WsD gHt+mqRDzkZV2gJ4aoivpI4W//04DWBCkSHRa4uNwspWAa81t09IAeqBAK89g6CyFmr wF4wWc8uc7vbhtwBlEZ01/h44sOpEAmuwqtwL9+A= 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 v6 43/44] x86/boot: convert dom0_construct_pv to struct boot_domain Date: Thu, 17 Oct 2024 13:03:23 -0400 Message-Id: <20241017170325.3842-44-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - reverted back *v d->vcpu[0] --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 5 ++-- xen/arch/x86/pv/dom0_build.c | 41 ++++++++++++--------------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 34b4943de3b1..96cd1154b037 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -612,7 +612,7 @@ int __init construct_dom0(struct boot_domain *bd) if ( is_hvm_domain(d) ) rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else if ( is_pv_domain(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 5e7b543d0cbe..53c34b7cf358 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 domain *d = bd->d; 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; + 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 Thu Oct 17 17:03: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: 13840517 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 69618D3C525 for ; Thu, 17 Oct 2024 17:23:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.821098.1234942 (Exim 4.92) (envelope-from ) id 1t1UDN-0003mF-A4; Thu, 17 Oct 2024 17:23:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 821098.1234942; Thu, 17 Oct 2024 17:23:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t1UDN-0003m6-7A; Thu, 17 Oct 2024 17:23:09 +0000 Received: by outflank-mailman (input) for mailman id 821098; Thu, 17 Oct 2024 17:23:08 +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 1t1U0L-0008TH-Ha for xen-devel@lists.xenproject.org; Thu, 17 Oct 2024 17:09:41 +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 97e63093-8caa-11ef-a0be-8be0dac302b0; Thu, 17 Oct 2024 19:09:40 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729184670345139.97769028146377; Thu, 17 Oct 2024 10:04: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: 97e63093-8caa-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729184675; cv=none; d=zohomail.com; s=zohoarc; b=h8JXQBZOZrM2p6qZgH3hMcCxqAAhiixQy6xbyCWesNaNXQN80/EoWjREk/VI4hDsVigYxkD2cQ8AWqduewxCD5jRc9TkAdrcKSEashepCRAb/m0Ym8UNCKuq0qL9f8Adqf//U+mfFAaCanF/YULp/tRvrQhhC14nOL69QDayGJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729184675; 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=q6fEPJY/wmWNpsEBUPTBtfhYBFq0uC8xsS/EzPvmcH0=; b=MFL9pWy5djDH5+3K4yX5AHL7Q7OgPzSp/eaJU1VyVEbpNOY4B/4AY8Um7E1ThcNAkIDYWElCNv20YHe5BHMbXH4xccMFbfayUVtPMXBDdGjuNX5yVMei+qNLYwbSFl4DS95C/xcMqt1tUn/VLaLhP6zPQpILQh8remgPbrH9COc= 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=1729184675; 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=q6fEPJY/wmWNpsEBUPTBtfhYBFq0uC8xsS/EzPvmcH0=; b=mm2pa+tS7CPFYPUsuJOT7JtnoBisxyxfn+6/rrXOOFhjav1oHkM9jdlazrPhrwVU l3NR4r2XV5Erynnui2pZUWfWUXUjx1e3Dya2JJHWqw5R9w3uj9YWEO8MpHdy1CJgAmb kliwcbxi327WlCD1HjcWBwygDmSDfjTURYVwAKjc= 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 v6 44/44] x86/boot: convert dom0_construct_pvh to struct boot_domain Date: Thu, 17 Oct 2024 13:03:24 -0400 Message-Id: <20241017170325.3842-45-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241017170325.3842-1-dpsmith@apertussolutions.com> References: <20241017170325.3842-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 --- Changes since v5: - revert back to using *d as local reference for struct domain --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 8 ++++---- xen/arch/x86/include/asm/dom0_build.h | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 96cd1154b037..f0d2c349095b 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -610,7 +610,7 @@ int __init construct_dom0(struct boot_domain *bd) process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + rc = dom0_construct_pvh(bd); else if ( is_pv_domain(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..720e08f9346f 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1299,10 +1299,9 @@ 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) { + struct domain *d = bd->d; paddr_t entry, start_info; int rc; @@ -1345,7 +1344,8 @@ int __init dom0_construct_pvh( return rc; } - rc = pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdline, + rc = pvh_load_kernel(d, bd->kernel, bd->ramdisk, + bootstrap_map_bm(bd->kernel), bd->cmdline, &entry, &start_info); if ( rc ) { 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);