From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171536; cv=none; d=zohomail.com; s=zohoarc; b=ITqA0M35yl/ZLKoIaFPttkICcw8E8VpXPg16YLBOZP35yQsqgKggX/0E35BBazV0bZYBKkQu+bk1JIeu4+lwVnwH7vQsv67UJuAlmiMxm/QYic6UqKUljoSEe3bDp+ARVDGRHSV37N/4aaVTlkNzU/WvUl4BQLHGD2v8LFO3JZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171536; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e69b5gTZ8xv/z3fBnKcGKtSZdG5ASDalrjgP59JhG/4=; b=jD2+BNdZVrYa6CDsLN2dTzROIKui1egmsvgfiJU4YeVSfbY7HSOaU6S/rk42vBvKg+Pu1qzOtAct6SoS35f35rGz9M4jYkSqumE9Jq8oENqxSa2LIJflfJ3X6vLwHlbNQ9arx8peOdCTiv4xb+EYCFoAYAEfIqPIWxAwZurnJgg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171536878220.32777882752714; Fri, 30 Jun 2023 17:32:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557667.871228 (Exim 4.92) (envelope-from ) id 1qFOWi-0008SK-KP; Sat, 01 Jul 2023 00:31:48 +0000 Received: by outflank-mailman (output) from mailman id 557667.871228; Sat, 01 Jul 2023 00:31:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWi-0008SD-HG; Sat, 01 Jul 2023 00:31:48 +0000 Received: by outflank-mailman (input) for mailman id 557667; Sat, 01 Jul 2023 00:31: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 1qFOWh-0007yM-JQ for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:47 +0000 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [2607:f8b0:4864:20::431]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a6965cda-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:43 +0200 (CEST) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6686708c986so2016989b3a.0 for ; Fri, 30 Jun 2023 17:31:43 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: a6965cda-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171501; x=1690763501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=e69b5gTZ8xv/z3fBnKcGKtSZdG5ASDalrjgP59JhG/4=; b=Uc+bsWyiiVRS6/ak3e7nNWgvDsm07FG9aSfYXLG6IdDkmxgRSFs8uj9+KckytCzS6t 6cDUUVJnRV2B2uZpOKB8qCmEVxhmGYx0aZjVKSVjY4eRB204KAdIfUnuekcB5E/arvLv /R+PwTzfUoF7fsOw2xAR6DYwcPKA5LOxk9TjklR3PEEGvRChPatSxmuxUs5dCzCf5/X0 qc3MzRPX5q8WSOrLf6e0PkvnwGBP5EC2RADreBhEVPcI9SHFkaCCgXOJE1ievl9VWVY4 Cei44fivdtBK1Gc03Mm4fxWEIrO5kuUNHy95/FOobl6bJitol09+NoU/pYc6CDwJ8kd+ 0uVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171501; x=1690763501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e69b5gTZ8xv/z3fBnKcGKtSZdG5ASDalrjgP59JhG/4=; b=Fxyh/4e5wzn2e2yLqb31MBsN1AyWcXfbuqDNyM3cKxAqbQQwX/P3u+vZ4l2c0Bzmle p34PT//Kf++n0AZnJ+z4LGwQ/bXI8c20qnCm9ImT14qwnXN9oHFYiZJZzwQKSYPAKJyr sJOM1B0WF1uaG3qH6nQDgR+ZAc5ec3h0xH6Wi4jhsYNGCCoPKWTZQJsjDdCUau1tGVFz XOlbmHjZPKD5qA8Rx3MF8A8ZBF44KChgeRZhJMCxD1rwezGRG+LgLCQAbZOIqYwLhGtr a9egVXR1eRn6EQEhflwqhgybAwHHSM+RWVlmhK0m/jOsKy7Kf0PQY6xFsgInAEJ6FpvS RxJw== X-Gm-Message-State: ABy/qLbPXKt5I9R9nydBlAtCaac/OdSa9+gfiEDjy4icqUJJXT6YePsl FUn/PDy+LCutjosmYALWB2HlF7fHZOA= X-Google-Smtp-Source: APBJJlGMtpigqkyzfp5YokZTkCRps/5vTqNDZCZQZ1cAwWcehJ1Acq2dvmwyA19KQ10YdU1J+7JULQ== X-Received: by 2002:a05:6a00:2488:b0:681:142f:e8e3 with SMTP id c8-20020a056a00248800b00681142fe8e3mr5518207pfv.14.1688171501037; Fri, 30 Jun 2023 17:31:41 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 01/11] x86 setup: move x86 boot module counting into a new boot_info struct Date: Fri, 30 Jun 2023 17:31:22 -0700 Message-Id: <20230701003132.2210306-2-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171537558100005 Content-Type: text/plain; charset="utf-8" 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. The naming of the header, structure and fields is derived from the boot structures on Arm -- see arm/include/asm/setup.h -- as part of work towards aligning common architecture-neutral boot logic and structures. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: - patch is a subset of patches 2 and 3 --- xen/arch/x86/setup.c | 58 +++++++++++++++++++++++--------------- xen/include/xen/bootinfo.h | 20 +++++++++++++ 2 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 xen/include/xen/bootinfo.h diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 74e3915a4d..708639b236 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -268,7 +269,16 @@ static int __init cf_check parse_acpi_param(const char= *s) custom_param("acpi", parse_acpi_param); =20 static const module_t *__initdata initial_images; -static unsigned int __initdata nr_initial_images; +static struct boot_info __initdata *boot_info; + +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +{ + static struct boot_info __initdata info; + + info.nr_mods =3D mbi->mods_count; + + boot_info =3D &info; +} =20 unsigned long __init initial_images_nrpages(nodeid_t node) { @@ -277,7 +287,7 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) unsigned long nr; unsigned int i; =20 - for ( nr =3D i =3D 0; i < nr_initial_images; ++i ) + for ( nr =3D i =3D 0; i < boot_info->nr_mods; ++i ) { unsigned long start =3D initial_images[i].mod_start; unsigned long end =3D start + PFN_UP(initial_images[i].mod_end); @@ -293,7 +303,7 @@ void __init discard_initial_images(void) { unsigned int i; =20 - for ( i =3D 0; i < nr_initial_images; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { uint64_t start =3D (uint64_t)initial_images[i].mod_start << PAGE_S= HIFT; =20 @@ -301,7 +311,7 @@ void __init discard_initial_images(void) start + PAGE_ALIGN(initial_images[i].mod_end)); } =20 - nr_initial_images =3D 0; + boot_info->nr_mods =3D 0; initial_images =3D NULL; } =20 @@ -1020,6 +1030,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod =3D __va(mbi->mods_addr); } =20 + multiboot_to_bootinfo(mbi); + loader =3D (mbi->flags & MBI_LOADERNAME) ? (char *)__va(mbi->boot_loader_name) : "unknown"; =20 @@ -1127,18 +1139,18 @@ void __init noreturn __start_xen(unsigned long mbi_= p) bootsym(boot_edd_info_nr)); =20 /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count =3D=3D 0) ) + if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods =3D=3D 0) ) panic("dom0 kernel not specified. Check bootloader configuration\n= "); =20 /* Check that we don't have a silly number of modules. */ - if ( mbi->mods_count > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > sizeof(module_map) * 8 ) { - mbi->mods_count =3D sizeof(module_map) * 8; + boot_info->nr_mods =3D sizeof(module_map) * 8; printk("Excessive multiboot modules - using the first %u only\n", - mbi->mods_count); + boot_info->nr_mods); } =20 - bitmap_fill(module_map, mbi->mods_count); + bitmap_fill(module_map, boot_info->nr_mods); __clear_bit(0, module_map); /* Dom0 kernel is always first */ =20 if ( pvh_boot ) @@ -1311,9 +1323,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) kexec_reserve_area(&boot_e820); =20 initial_images =3D mod; - nr_initial_images =3D mbi->mods_count; + boot_info->nr_mods =3D boot_info->nr_mods; =20 - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < mbi->mods_count; i++ ) + for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++= ) { if ( mod[i].mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); @@ -1337,8 +1349,8 @@ void __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 =3D virt_to_mfn(_stext); - mod[mbi->mods_count].mod_end =3D __2M_rwdata_end - _stext; + mod[boot_info->nr_mods].mod_start =3D virt_to_mfn(_stext); + mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 modules_headroom =3D bzimage_headroom(bootstrap_map(mod), mod->mod_end= ); @@ -1398,7 +1410,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end =3D consider_modules(s, e, reloc_size + mask, - mod, mbi->mods_count, -1); + mod, boot_info->nr_mods, -1); end &=3D ~mask; } else @@ -1419,7 +1431,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) } =20 /* Is the region suitable for relocating the multiboot modules? */ - for ( j =3D mbi->mods_count - 1; j >=3D 0; j-- ) + for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { unsigned long headroom =3D j ? 0 : modules_headroom; unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); @@ -1429,7 +1441,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 /* Don't overlap with other modules (or Xen itself). */ end =3D consider_modules(s, e, size, mod, - mbi->mods_count + relocated, j); + boot_info->nr_mods + relocated, j); =20 if ( highmem_start && end > highmem_start ) continue; @@ -1456,7 +1468,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules (or Xen itself). */ e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , mod, - mbi->mods_count + relocated, -1); + boot_info->nr_mods + relocated, -1); if ( s >=3D e ) break; if ( e > kexec_crash_area_limit ) @@ -1471,7 +1483,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 if ( modules_headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); - for ( i =3D 0; i < mbi->mods_count; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; =20 @@ -1540,7 +1552,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) ASSERT(j); } map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; - for ( j =3D 0; j < mbi->mods_count; ++j ) + for ( j =3D 0; j < boot_info->nr_mods; ++j ) { uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + mod[j].mod_end; @@ -1616,7 +1628,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) } } =20 - for ( i =3D 0; i < mbi->mods_count; ++i ) + for ( i =3D 0; i < boot_info->nr_mods; ++i ) { set_pdx_range(mod[i].mod_start, mod[i].mod_start + PFN_UP(mod[i].mod_end)); @@ -1999,8 +2011,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, mbi->mods_count); - if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) + initrdidx =3D find_first_bit(module_map, boot_info->nr_mods); + if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2010,7 +2022,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * above our heap. The second module, if present, is an initrd ramdisk. */ dom0 =3D create_dom0(mod, modules_headroom, - initrdidx < mbi->mods_count ? mod + initrdidx : NUL= L, + initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h new file mode 100644 index 0000000000..6a7d55d20e --- /dev/null +++ b/xen/include/xen/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __XEN_BOOTINFO_H__ +#define __XEN_BOOTINFO_H__ + +#include + +struct boot_info { + unsigned int nr_mods; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171548; cv=none; d=zohomail.com; s=zohoarc; b=gg0XrZBqph0D44KUFw94vxzv3ZUXWwkUrIMrkc/I4xETvUOoaDNLE72LFj6FK9LBkEOUvUsu9eYsthHcNwbNNbvblsHM/MKXx1Nr/gZz0vWbEo3Rcuuob2DNzz+n63KlrHcaHdq4gs1zdskBceRBjppBjfnVioB4jfA8em8MJH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171548; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LY4hOPffrE6QJlk2fTfa3K1ABHuOB1gwqTF+/zyLHhg=; b=QJbXoufEDj5hk8vNDl7mUwhIgOZMzOhJfoTQKWsY4VBzTxxMOaZQ6/TAC04YMN0flMUkUgiQMLvknHHMi2PYSBU/h0ZHlAB2KHJgOZ/zdcF0NyAAF6iSrJ3E/kHxww9T816daNsvRKTnSYjW6vhMklpLjVMpAojft2KpnaVOgK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171548570850.7589883621788; Fri, 30 Jun 2023 17:32:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557666.871213 (Exim 4.92) (envelope-from ) id 1qFOWg-00081u-E1; Sat, 01 Jul 2023 00:31:46 +0000 Received: by outflank-mailman (output) from mailman id 557666.871213; Sat, 01 Jul 2023 00:31: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 1qFOWg-000815-8L; Sat, 01 Jul 2023 00:31:46 +0000 Received: by outflank-mailman (input) for mailman id 557666; Sat, 01 Jul 2023 00:31:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWe-0007yB-Re for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:44 +0000 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [2607:f8b0:4864:20::434]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a73357b3-17a6-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 02:31:44 +0200 (CEST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-668709767b1so1546245b3a.2 for ; Fri, 30 Jun 2023 17:31:44 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: a73357b3-17a6-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171502; x=1690763502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=LY4hOPffrE6QJlk2fTfa3K1ABHuOB1gwqTF+/zyLHhg=; b=pXHV6ClIgQKCL4P3Ydz6t6ZjxJjBbulbFY65VM8m+LoBbAV8zs1butDeeouPUo3kZd yLjXoQ5J7JD6Iys3hs7K/IYhEl3EpOWN/gze9swW/H85U8CB3ExCzs094wHslFX3QblV 4nUEoJ9h9cbnhDnjLiu6jworYv4Y9iQHAqjImZrI9VC10ChyhPhusYLWRdXw46IAuQXw NV8PJH9JSBggK3Y+Uk7g+D4QoEgtMekK8dt4mob37oegIx2bTLIEZ/MwhtKt+rEIFfGo CU/rs5rxRl69LxBBIiAMd8LntZ58QWSTM6fwVBbXp+tZGK4C3JPEf2VmFmoksAe5kOky dc6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171502; x=1690763502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LY4hOPffrE6QJlk2fTfa3K1ABHuOB1gwqTF+/zyLHhg=; b=E/r2X9avrOz3IlhwhdLmu5ka7Aw2lBOeB3mOVE4VW5fbfATOss52LmvicptQvPlnvu xgzeyDeFn1j8e+ZCP8T9OW9mJI7RUKDaz4mJxbzhQR+BvKZ2iNrav48hXser7mEp+G7G muNqctHG848ppXzmDC2iYZBcZNZIGbQ32roJgADjTQ346OJDc1A1qSazjSTr9IGpY17b 1iIyXdypCBKthDZep/TbCuu7+GJqdRyT3jitArmxvardcpcv/924u8uw97kbda+FJbKa hX8Dj8QGvJTb/6mmVKo9FHB70VXjSDJc9XUeV0eVtsoWCKSLCdApyHoTmOSJcveQZBeu LZ/g== X-Gm-Message-State: ABy/qLZqc92QOtS8lp4hyRmNHAUrr5Qcb02tyi0G97ZidaCZSiX+tzoY vqHYfxrSijHXVqRNhC+mp53RELO+EH8= X-Google-Smtp-Source: APBJJlHv6bZX31TSR4MJuxlF3DUMJ4bn9ZYjcCQLZ2D5ZS486PyQXKZjkNmbioyxSSKZr5kp5fdsCA== X-Received: by 2002:a05:6a00:24d3:b0:675:8f71:28f1 with SMTP id d19-20020a056a0024d300b006758f7128f1mr4321858pfv.30.1688171502138; Fri, 30 Jun 2023 17:31:42 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 02/11] x86 setup: per-arch bootmodule structure, headroom field Date: Fri, 30 Jun 2023 17:31:23 -0700 Message-Id: <20230701003132.2210306-3-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171549419100011 Content-Type: text/plain; charset="utf-8" Next step in incremental work towards adding a non-multiboot internal representation of boot modules, converting the fields being accessed for the startup calculations. Add a new array of structs for per-boot-module state, though only allocate space for a single array entry in this change since that is all that is required for functionality modified in this patch: moving the headroom field for the image decompression calculation into a new per-arch boot module struct and then using it in x86 dom0 construction. Introduces a per-arch header for x86 for arch-specific boot module structures, and add a member to the common boot module structure for access to it. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: - patch is a subset of v1 patches 2 and 3 --- xen/arch/x86/bzimage.c | 10 +++++----- xen/arch/x86/hvm/dom0_build.c | 3 ++- xen/arch/x86/include/asm/bootinfo.h | 18 ++++++++++++++++++ xen/arch/x86/include/asm/bzimage.h | 2 +- xen/arch/x86/pv/dom0_build.c | 3 ++- xen/arch/x86/setup.c | 23 ++++++++++++++++------- xen/include/xen/bootinfo.h | 11 +++++++++++ 7 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootinfo.h diff --git a/xen/arch/x86/bzimage.c b/xen/arch/x86/bzimage.c index ac4fd428be..dac2399b89 100644 --- a/xen/arch/x86/bzimage.c +++ b/xen/arch/x86/bzimage.c @@ -69,8 +69,6 @@ static __init int bzimage_check(struct setup_header *hdr,= unsigned long len) return 1; } =20 -static unsigned long __initdata orig_image_len; - unsigned long __init bzimage_headroom(void *image_start, unsigned long image_length) { @@ -91,7 +89,6 @@ unsigned long __init bzimage_headroom(void *image_start, if ( elf_is_elfbinary(image_start, image_length) ) return 0; =20 - orig_image_len =3D image_length; headroom =3D output_length(image_start, image_length); if (gzip_check(image_start, image_length)) { @@ -105,11 +102,14 @@ unsigned long __init bzimage_headroom(void *image_sta= rt, } =20 int __init bzimage_parse(void *image_base, void **image_start, + unsigned int headroom, unsigned long *image_len) { struct setup_header *hdr =3D (struct setup_header *)(*image_start); int err =3D bzimage_check(hdr, *image_len); - unsigned long output_len; + unsigned long output_len, orig_image_len; + + orig_image_len =3D *image_len - headroom; =20 if ( err < 0 ) return err; @@ -125,7 +125,7 @@ int __init bzimage_parse(void *image_base, void **image= _start, =20 BUG_ON(!(image_base < *image_start)); =20 - output_len =3D output_length(*image_start, orig_image_len); + output_len =3D output_length(*image_start, *image_len); =20 if ( (err =3D perform_gunzip(image_base, *image_start, orig_image_len)= ) > 0 ) err =3D decompress(*image_start, orig_image_len, image_base); diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index fd2cbf68bc..bf08998862 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -545,7 +545,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, struct vcpu *v =3D d->vcpu[0]; int rc; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) + if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + &image_len)) !=3D 0 ) { printk("Error trying to detect bz compressed kernel\n"); return rc; diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h new file mode 100644 index 0000000000..a25054f372 --- /dev/null +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -0,0 +1,18 @@ +#ifndef __ARCH_X86_BOOTINFO_H__ +#define __ARCH_X86_BOOTINFO_H__ + +struct arch_bootmodule { + unsigned headroom; +}; + +#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/bzimage.h b/xen/arch/x86/include/asm/= bzimage.h index 7ed69d3910..dd784f32ef 100644 --- a/xen/arch/x86/include/asm/bzimage.h +++ b/xen/arch/x86/include/asm/bzimage.h @@ -5,7 +5,7 @@ =20 unsigned long bzimage_headroom(void *image_start, unsigned long image_leng= th); =20 -int bzimage_parse(void *image_base, void **image_start, +int bzimage_parse(void *image_base, void **image_start, unsigned int headr= oom, unsigned long *image_len); =20 #endif /* __X86_BZIMAGE_H__ */ diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index c99135a552..6ed9f8bbed 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -416,7 +416,8 @@ int __init dom0_construct_pv(struct domain *d, =20 d->max_pages =3D ~0U; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) + if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + &image_len)) !=3D 0 ) return rc; =20 if ( (rc =3D elf_init(&elf, image_start, image_len)) !=3D 0 ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 708639b236..c0e8fc6ab7 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -273,10 +273,16 @@ static struct boot_info __initdata *boot_info; =20 static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) { - static struct boot_info __initdata info; + static struct boot_info __initdata info; + static struct boot_module __initdata boot_mods[1]; + static struct arch_bootmodule __initdata arch_boot_mods[1]; + + info.mods =3D boot_mods; =20 info.nr_mods =3D mbi->mods_count; =20 + boot_mods[0].arch =3D &arch_boot_mods[0]; + boot_info =3D &info; } =20 @@ -961,7 +967,8 @@ static struct domain *__init create_dom0(const module_t= *image, write_cr4(read_cr4() & ~X86_CR4_SMAP); } =20 - if ( construct_dom0(d, image, headroom, initrd, cmdline) !=3D 0 ) + if ( construct_dom0(d, image, boot_info->mods[0].arch->headroom, initr= d, + cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 if ( cpu_has_smap ) @@ -985,7 +992,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked =3D 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; + unsigned long nr_pages, raw_max_page, module_map[1]; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1353,7 +1360,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 - modules_headroom =3D bzimage_headroom(bootstrap_map(mod), mod->mod_end= ); + boot_info->mods[0].arch->headroom =3D bzimage_headroom(bootstrap_map(m= od), + mod->mod_end); bootstrap_map(NULL); =20 #ifndef highmem_start @@ -1433,7 +1441,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Is the region suitable for relocating the multiboot modules? */ for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { - unsigned long headroom =3D j ? 0 : modules_headroom; + struct boot_module *boot_mods =3D boot_info->mods; + unsigned long headroom =3D j ? 0 : boot_mods[0].arch->headroom; unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); =20 if ( mod[j].reserved ) @@ -1481,7 +1490,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) #endif } =20 - if ( modules_headroom && !mod->reserved ) + if ( boot_info->mods[0].arch->headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < boot_info->nr_mods; ++i ) { @@ -2021,7 +2030,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, modules_headroom, + dom0 =3D create_dom0(mod, boot_info->mods[0].arch->headroom, initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, kextra, loader); if ( !dom0 ) diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 6a7d55d20e..b72ae31a66 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -3,8 +3,19 @@ =20 #include =20 +#ifdef CONFIG_X86 +#include +#else + struct arch_bootmodule { }; +#endif + +struct boot_module { + struct arch_bootmodule *arch; +}; + struct boot_info { unsigned int nr_mods; + struct boot_module *mods; }; =20 #endif --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171545; cv=none; d=zohomail.com; s=zohoarc; b=Ak1EXSsB8XUEfiGz9Wvo3Uf2BQEjUgXdcq53pwpsZCgn16o0DhM+1v7zhKgbAWK4v3uyiA8Ir5LfnElTXo0gpwE1Rt8aUIDpn73vRhuVvjTcjDBD7JzsfFmIgvOPbu6QcaQ44H/zLQEIG2OYwAwvkIECeEDvrTHA6GzeEpFx6KU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171545; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sqQqqF0IyJ/PuKXVXwFAfGVp5jzTeAtO0YKlHbSfXAU=; b=PNbJNuzNZq+j7OIbI31unstPyRJXIy3AEzY4VCYVQbhZx3KNbzrqFr3PcW2ICfjmGZvRjEbEjvk5OB4tvVFvDHZ0UHq61cHz4yR8XaY3euEzs5s3qbIl8yUC9Jky7TlgzxAEQAi755KZRCNIwG2DYGYwz/r6IO4oBlmGOC7ty7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171545212644.2101321260435; Fri, 30 Jun 2023 17:32:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557668.871234 (Exim 4.92) (envelope-from ) id 1qFOWi-0008Vl-VE; Sat, 01 Jul 2023 00:31:48 +0000 Received: by outflank-mailman (output) from mailman id 557668.871234; Sat, 01 Jul 2023 00:31:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWi-0008Vc-Pf; Sat, 01 Jul 2023 00:31:48 +0000 Received: by outflank-mailman (input) for mailman id 557668; Sat, 01 Jul 2023 00:31: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 1qFOWh-0007yM-QK for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:47 +0000 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [2607:f8b0:4864:20::112a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a7cb92e4-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:44 +0200 (CEST) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-5701e8f2b79so27334707b3.0 for ; Fri, 30 Jun 2023 17:31:44 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:42 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: a7cb92e4-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171503; x=1690763503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=sqQqqF0IyJ/PuKXVXwFAfGVp5jzTeAtO0YKlHbSfXAU=; b=d+tq/rbAfNr5yHLcrKURrSqr0rJdRYKlNsfHaEao/XBIfLlqSHBeZDOh6Co8fB7AdZ lUj+VBO5+5quL7CbuIRyuJOG5+akeVBPPcpaF/fItBEAOdlsGJ/j0yvO5SBKTGS/DrwT k/ZGa6qjJ1yABSQNwvhpdip4eF2079ZAJ5g5EpA5x3sw4EvMMV7JSxZ5ZhrAw1GPJWeu xFH9LrxE8SIjPMBeE4wDYtpzOsDrD1yY5JDc2rqoqcfcHmDhrztTG+cKFyacpwW0NDAT rPe2NjV6ePCwpCbYnrfg7Rxh/2EH2dA0G5DJM4YStZR20n7Vu4oVD9XZwPZ3jtH9tc6b WarA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171503; x=1690763503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sqQqqF0IyJ/PuKXVXwFAfGVp5jzTeAtO0YKlHbSfXAU=; b=BeRPAKMC7NkuJh14+53YHyJRxcftOMh1U67mwx62IeCagdlroJQKwcYRgx5S/ov8Bd IbzWJAplB+qGjxz/Lvvq/ECzU4vlzlYjqIrCe/ziOSmWPuPJoeqBQF65lqkh8R4f24qg p6Xpd7H7sJkW3J6zRSjgQkV5zX0FY1OrAgOthRk28p05oeEf0fqNzhM2iLXeNc9ftnpE vB+dhrH0cbFkuOXxxFtEh7H94qHK9C39Jt1XOUR8Cz1qOrYe/BwI5VsJqHUzGtPd5eUJ AXyqn4A+7SGS6e6yTU/6WcwCERc21H/RQJjXVuBqZuV3t/HjVQHYCP4JeavU/FeDObg/ 7awA== X-Gm-Message-State: ABy/qLbH3/KLIHZw+ttmPzoyQVmgujsAf5ukPLWVqRJJ63koMZGse5/t oZuIwIogHBShvJ/jLyr8FJ6WXIq6f/4= X-Google-Smtp-Source: APBJJlGhQ1CFMj7J8a/Nqrkm+dSxRfTiP6kfcYG7qn5RNbcc78vyoNL6EmmGS4YOue+8pyYX/4D9jw== X-Received: by 2002:a81:de49:0:b0:56d:2981:e2e2 with SMTP id o9-20020a81de49000000b0056d2981e2e2mr3897669ywl.6.1688171503257; Fri, 30 Jun 2023 17:31:43 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 03/11] x86 setup: change bootstrap map to accept new boot module structures Date: Fri, 30 Jun 2023 17:31:24 -0700 Message-Id: <20230701003132.2210306-4-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171547197100001 Content-Type: text/plain; charset="utf-8" To convert the x86 boot logic from multiboot to boot module structures, change the bootstrap map function to accept a boot module parameter. To allow incremental change from multiboot to boot modules across all x86 setup logic, provide a temporary inline wrapper that still accepts a multiboot module parameter and use it where necessary. The wrapper is placed in a new arch/x86 header to avoid putting a static inline function into an existing header that has no such functions already. This new header will be expanded with additional functions in subsequent patches in this series. No functional change intended. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: - new patch so v1 patch 3 can be implemented via incremental series --- xen/arch/x86/cpu/microcode/core.c | 7 ++++--- xen/arch/x86/hvm/dom0_build.c | 4 +++- xen/arch/x86/include/asm/boot.h | 32 +++++++++++++++++++++++++++++++ xen/arch/x86/include/asm/setup.h | 3 ++- xen/arch/x86/pv/dom0_build.c | 3 ++- xen/arch/x86/setup.c | 18 +++++++++-------- xen/include/xen/bootinfo.h | 3 +++ xen/xsm/xsm_policy.c | 3 ++- 8 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 xen/arch/x86/include/asm/boot.h diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index cd456c476f..e720a89167 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -34,6 +34,7 @@ #include =20 #include +#include #include #include #include @@ -180,7 +181,7 @@ void __init microcode_scan_module( if ( !test_bit(i, module_map) ) continue; =20 - _blob_start =3D bootstrap_map(&mod[i]); + _blob_start =3D bootstrap_map_multiboot(&mod[i]); _blob_size =3D mod[i].mod_end; if ( !_blob_start ) { @@ -794,7 +795,7 @@ int __init microcode_init_cache(unsigned long *module_m= ap, microcode_scan_module(module_map, mbi); =20 if ( ucode_mod.mod_end ) - rc =3D early_update_cache(bootstrap_map(&ucode_mod), + rc =3D early_update_cache(bootstrap_map_multiboot(&ucode_mod), ucode_mod.mod_end); else if ( ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); @@ -817,7 +818,7 @@ static int __init early_microcode_update_cpu(void) else if ( ucode_mod.mod_end ) { len =3D ucode_mod.mod_end; - data =3D bootstrap_map(&ucode_mod); + data =3D bootstrap_map_multiboot(&ucode_mod); } =20 if ( !data ) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index bf08998862..56fe89632b 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -16,6 +16,7 @@ =20 #include =20 +#include #include #include #include @@ -1208,7 +1209,8 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map= (image), + rc =3D pvh_load_kernel(d, image, image_headroom, initrd, + bootstrap_map_multiboot(image), cmdline, &entry, &start_info); if ( rc ) { diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h new file mode 100644 index 0000000000..10b17f12b2 --- /dev/null +++ b/xen/arch/x86/include/asm/boot.h @@ -0,0 +1,32 @@ +#ifndef __ASM_X86_BOOT_H__ +#define __ASM_X86_BOOT_H__ + +#include +#include + +#include + +static inline void *bootstrap_map_multiboot(const module_t *mod) +{ + struct boot_module bm; + + if ( !mod ) + return bootstrap_map(NULL); + + bm.start =3D mod->mod_start << PAGE_SHIFT; + bm.size =3D mod->mod_end; + + return bootstrap_map(&bm); +} + +#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/setup.h b/xen/arch/x86/include/asm/se= tup.h index ae0dd3915a..80d0bb2a21 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -1,6 +1,7 @@ #ifndef __X86_SETUP_H_ #define __X86_SETUP_H_ =20 +#include #include #include =20 @@ -40,7 +41,7 @@ void setup_io_bitmap(struct domain *d); =20 unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); -void *bootstrap_map(const module_t *mod); +void *bootstrap_map(const struct boot_module *mod); =20 int xen_in_range(unsigned long mfn); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 6ed9f8bbed..4fe806b60d 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -14,6 +14,7 @@ #include #include =20 +#include #include #include #include @@ -374,7 +375,7 @@ int __init dom0_construct_pv(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map(image); + void *image_base =3D bootstrap_map_multiboot(image); unsigned long image_len =3D image->mod_end; void *image_start =3D image_base + image_headroom; unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c0e8fc6ab7..3b623a4149 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -32,6 +32,7 @@ #include #endif #include +#include #include #include #include @@ -405,14 +406,14 @@ static void __init normalise_cpu_order(void) * Ensure a given physical memory range is present in the bootstrap mappin= gs. * Use superpage mappings to ensure that pagetable memory needn't be alloc= ated. */ -void *__init bootstrap_map(const module_t *mod) +void *__init bootstrap_map(const struct boot_module *mod) { static unsigned long __initdata map_cur =3D BOOTSTRAP_MAP_BASE; uint64_t start, end, mask =3D (1L << L2_PAGETABLE_SHIFT) - 1; void *ret; =20 if ( system_state !=3D SYS_STATE_early_boot ) - return mod ? mfn_to_virt(mod->mod_start) : NULL; + return mod ? maddr_to_virt(mod->start) : NULL; =20 if ( !mod ) { @@ -421,8 +422,8 @@ void *__init bootstrap_map(const module_t *mod) return NULL; } =20 - start =3D (uint64_t)mod->mod_start << PAGE_SHIFT; - end =3D start + mod->mod_end; + start =3D (uint64_t)mod->start; + end =3D start + mod->size; if ( start >=3D end ) return NULL; =20 @@ -460,7 +461,7 @@ static void __init move_memory( if ( mod.mod_end > blksz ) mod.mod_end =3D blksz; sz =3D mod.mod_end - soffs; - s =3D bootstrap_map(&mod); + s =3D bootstrap_map_multiboot(&mod); =20 mod.mod_start =3D (dst - doffs) >> PAGE_SHIFT; mod.mod_end =3D doffs + size; @@ -468,7 +469,7 @@ static void __init move_memory( mod.mod_end =3D blksz; if ( sz > mod.mod_end - doffs ) sz =3D mod.mod_end - doffs; - d =3D bootstrap_map(&mod); + d =3D bootstrap_map_multiboot(&mod); =20 memmove(d + doffs, s + soffs, sz); =20 @@ -1360,8 +1361,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; } =20 - boot_info->mods[0].arch->headroom =3D bzimage_headroom(bootstrap_map(m= od), - mod->mod_end); + boot_info->mods[0].arch->headroom =3D + bzimage_headroom(bootstrap_map_multiboot(mod), mod->mod_end); + bootstrap_map(NULL); =20 #ifndef highmem_start diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index b72ae31a66..eb93cc3439 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -10,6 +10,9 @@ #endif =20 struct boot_module { + paddr_t start; + size_t size; + struct arch_bootmodule *arch; }; =20 diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc9381..c6df8c6e06 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -20,6 +20,7 @@ =20 #include #ifdef CONFIG_MULTIBOOT +#include #include #include #endif @@ -49,7 +50,7 @@ int __init xsm_multiboot_policy_init( if ( !test_bit(i, module_map) ) continue; =20 - _policy_start =3D bootstrap_map(mod + i); + _policy_start =3D bootstrap_map_multiboot(mod + i); _policy_len =3D mod[i].mod_end; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171550; cv=none; d=zohomail.com; s=zohoarc; b=MS+91uZ05OdvzMa1AJEhckebhmqQWUX8jLvtlDC0eFm5ZryiZr865bXVkfpbO7rNvlj1J0L8Xkf9x/+iXPCnIqgKvM1UArylch+BeSKBKeGY8bWc7oiPAqRR1KrNXQBHq6Ps/kVymOO+JtM7MJFYSHb34GtQ7lXhDgbXgFVGNGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171550; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y7s+a48s6nJcYJpi0CKsRE8Fk9vJ+e5NEZSgNSxP5/8=; b=Q4Rr1R04u+LdznVEqu8LFCejhOBbeC8GGCDaiZCrIIE7YanVNNapjOrVdWDhLHya9J1Y9LMEETPyBWFNZWqS+MJ9xu5+TftAEIfhBHKpnwJNTWescOvrc0DJNOfUfgAnWxEB1ctguwcVWp+FAhsdJU6pxgfQ+0AXis68VGjISlU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171550111439.2439197055627; Fri, 30 Jun 2023 17:32:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557670.871257 (Exim 4.92) (envelope-from ) id 1qFOWl-0000o5-Ow; Sat, 01 Jul 2023 00:31:51 +0000 Received: by outflank-mailman (output) from mailman id 557670.871257; Sat, 01 Jul 2023 00:31:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWl-0000mP-L1; Sat, 01 Jul 2023 00:31:51 +0000 Received: by outflank-mailman (input) for mailman id 557670; Sat, 01 Jul 2023 00:31:50 +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 1qFOWk-0007yM-C9 for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:50 +0000 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [2607:f8b0:4864:20::22c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a96729e1-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:47 +0200 (CEST) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3a1a47b33d8so1881850b6e.2 for ; Fri, 30 Jun 2023 17:31:47 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:43 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: a96729e1-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171506; x=1690763506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=y7s+a48s6nJcYJpi0CKsRE8Fk9vJ+e5NEZSgNSxP5/8=; b=W/Ori2UF5GdZ2XTZUYb7SeemZMmXHFyT5AmYNUYzZYR8m3DlTjhAIlYMyFrqeTXavn ApUJYnarY5VGN5Tu9EM1aQnNSUmAba1kJGAiVzVu3dYiGQFTOj1zZb4QCDP6qkUQsEg3 /AYkZJiTd10O0+u5oCZzM5XUQCWyDv9QPiVV5l/W1Z/gUunTNlDLSjsGwKU5MQhQLvo4 lNX1yE37dfgzMaBoCgFG+haXttyy7gTUaQmTx+F9FTcZarjT7WPvQSZQ+sEb1Aoyg+8H dYhW5gOEl7FHl4wZWB4IN/T+asWd+xews11MoYsBcLjnSnyg3ev+AM8/pT4J6RxDobpr BFRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171506; x=1690763506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=y7s+a48s6nJcYJpi0CKsRE8Fk9vJ+e5NEZSgNSxP5/8=; b=jJP5mWtb3jelZ0x3lMPFBTK8MhQK8vUlW1X3/xXhkRaQeAwEuptJ9LdOjc9As/2TxQ MvJ8jwe1LGpqR+1UoKM9Bkp1uwnXCO0ykMy0efGQaMSiIwgVmmt/QxMz7nw+Z9cQY9+B AU9JM3jJyBUdsjW6OHgrkZU7RjaTJCec6Kde5K8RDVly81bbdtUOITUJz23elL7jZVj6 Rd/QeUH/S/a6rKE2f19aw5VZmWlZny7KQOOv9ELSEOdVBRCfJPc0YBdMm7HfiqX+Mk4z oIsPRBAte+/77TBklb51FfqxeUZIN3baQNMwHue8QhjFYYesRfso6M/OZYcXn8AUHroE Y2Wg== X-Gm-Message-State: AC+VfDyd7EWNkgijy/lTGrHDAtTrE6a673a2r9dMw7tTtl4Co5tbjJcj vmITOnGYG8McfZP2Oe7eV2SeneZ2iH4= X-Google-Smtp-Source: ACHHUZ7Jdwgu9s3VF78UoKENhjUUxgTBZur8e6sBoFcYKPjtIKlqM0Dh2E7ma7w5eCQzKVE4ipK9gg== X-Received: by 2002:a05:6808:1b0c:b0:3a1:b309:a409 with SMTP id bx12-20020a0568081b0c00b003a1b309a409mr5339601oib.4.1688171505329; Fri, 30 Jun 2023 17:31:45 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 04/11] x86 setup: porting dom0 construction logic to boot module structures Date: Fri, 30 Jun 2023 17:31:25 -0700 Message-Id: <20230701003132.2210306-5-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171551354100013 Content-Type: text/plain; charset="utf-8" Adjust the PV and PVH dom0 construction entry points to take boot module structures as parameters, and add further fields to the boot module structures to plumb the data needed to support this use. Populate these from the multiboot module data. This change removes multiboot from the PV and PVH dom0 construction logic. Introduce and use new inline accessor functions for navigating the boot module structures. The per-boot-module arrays are expanded from singletons to accommodate all modules, up to a static maximum of 64 modules including Xen that can be accepted from a bootloader to match the previous value from the module map check. The field that identifies the type of a boot module (kernel, ramdisk, etc) is introduced to the common boot module structure and declared as a non-enum integer type to allow the field to be of a known-size and so structure can be packed in a subsequent patch in the series, and it will then be reconciled with the equivalent Arm boot field type. The command line provided by multiboot for each boot module is added directly to the boot_module structure, which is appropriate for this logic just replacing multiboot. The maximum number of boot modules that a bootloader can provide in addition to the Xen hypervisor is preserved from prior logic with the module_map at 63. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: a subset of patch 3 - retains module_map for now as still used functions outside setup - move the static inline functions to a separate dedicated header - include mm-frame.h and compiler.h as simpler dependencies than mm.h --- xen/arch/x86/dom0_build.c | 10 +- xen/arch/x86/hvm/dom0_build.c | 43 +++--- xen/arch/x86/include/asm/boot.h | 36 +++++ xen/arch/x86/include/asm/bootinfo.h | 24 +++ xen/arch/x86/include/asm/dom0_build.h | 13 +- xen/arch/x86/include/asm/setup.h | 4 +- xen/arch/x86/pv/dom0_build.c | 32 ++-- xen/arch/x86/setup.c | 206 +++++++++++++++----------- xen/include/xen/bootinfo.h | 27 ++++ 9 files changed, 254 insertions(+), 141 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 79234f18ff..b38cd1550e 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -4,6 +4,7 @@ * Copyright (c) 2002-2005, K A Fraser */ =20 +#include #include #include #include @@ -574,9 +575,8 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct domain *d, const module_t *image, - unsigned long image_headroom, module_t *initrd, - char *cmdline) +int __init construct_dom0(struct domain *d, const struct boot_module *imag= e, + struct boot_module *initrd, char *cmdline) { int rc; =20 @@ -588,9 +588,9 @@ int __init construct_dom0(struct domain *d, const modul= e_t *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image, image_headroom, initrd, cmdlin= e); + rc =3D dom0_construct_pvh(d, image, initrd, cmdline); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, image_headroom, initrd, cmdline= ); + rc =3D dom0_construct_pv(d, image, initrd, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 56fe89632b..c094863bb8 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -8,9 +8,9 @@ */ =20 #include +#include #include #include -#include #include #include =20 @@ -530,14 +530,13 @@ static paddr_t __init find_memory( return INVALID_PADDR; } =20 -static int __init pvh_load_kernel(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, void *image_base, - 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, char *cmdline, paddr_t *= entry, + paddr_t *start_info_addr) { - void *image_start =3D image_base + image_headroom; - unsigned long image_len =3D image->mod_end; + void *image_start =3D image_base + image->arch->headroom; + unsigned long image_len =3D image->size; struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -546,7 +545,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, struct vcpu *v =3D d->vcpu[0]; int rc; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + if ( (rc =3D bzimage_parse(image_base, &image_start, image->arch->head= room, &image_len)) !=3D 0 ) { printk("Error trying to detect bz compressed kernel\n"); @@ -594,7 +593,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, * simplify it. */ last_addr =3D find_memory(d, &elf, sizeof(start_info) + - (initrd ? ROUNDUP(initrd->mod_end, PAGE_SIZE) + + (initrd ? ROUNDUP(initrd->size, PAGE_SIZE) + sizeof(mod) : 0) + (cmdline ? ROUNDUP(strlen(cmdline) + 1, @@ -608,8 +607,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_s= tart), - initrd->mod_end, v); + rc =3D hvm_copy_to_guest_phys(last_addr, maddr_to_virt(initrd->sta= rt), + initrd->size, v); if ( rc ) { printk("Unable to copy initrd to guest\n"); @@ -617,11 +616,11 @@ static int __init pvh_load_kernel(struct domain *d, c= onst module_t *image, } =20 mod.paddr =3D last_addr; - mod.size =3D initrd->mod_end; - last_addr +=3D ROUNDUP(initrd->mod_end, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + mod.size =3D initrd->size; + last_addr +=3D ROUNDUP(initrd->size, elf_64bit(&elf) ? 8 : 4); + if ( initrd->string.len ) { - char *str =3D __va(initrd->string); + char *str =3D initrd->string.bytes; size_t len =3D strlen(str) + 1; =20 rc =3D hvm_copy_to_guest_phys(last_addr, str, len, v); @@ -1176,10 +1175,9 @@ static void __hwdom_init pvh_setup_mmcfg(struct doma= in *d) } } =20 -int __init dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline) +int __init dom0_construct_pvh( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline) { paddr_t entry, start_info; int rc; @@ -1209,9 +1207,8 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, - bootstrap_map_multiboot(image), - cmdline, &entry, &start_info); + rc =3D pvh_load_kernel(d, image, initrd, bootstrap_map(image), cmdline, + &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h index 10b17f12b2..bcf4f2e2e3 100644 --- a/xen/arch/x86/include/asm/boot.h +++ b/xen/arch/x86/include/asm/boot.h @@ -19,6 +19,42 @@ static inline void *bootstrap_map_multiboot(const module= _t *mod) return bootstrap_map(&bm); } =20 +static inline unsigned long bootmodule_index( + const struct boot_info *info, bootmod_type_t bootmod_type, + unsigned long start) +{ + for ( ; start < info->nr_mods; start++ ) + if ( info->mods[start].bootmod_type =3D=3D bootmod_type ) + return start; + + return info->nr_mods + 1; +} + +static inline struct boot_module *bootmodule_next( + const struct boot_info *info, bootmod_type_t bootmod_type) +{ + unsigned long i; + + for ( i =3D 0; i < info->nr_mods; i++ ) + if ( info->mods[i].bootmod_type =3D=3D bootmod_type ) + return &info->mods[i]; + + return NULL; +} + +static inline void bootmodule_update_start(struct boot_module *bm, + paddr_t new_start) +{ + bm->start =3D new_start; + bm->mfn =3D maddr_to_mfn(new_start); +} + +static inline void bootmodule_update_mfn(struct boot_module *bm, mfn_t new= _mfn) +{ + bm->mfn =3D new_mfn; + bm->start =3D mfn_to_maddr(new_mfn); +} + #endif =20 /* diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index a25054f372..30c27980e0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -2,9 +2,33 @@ #define __ARCH_X86_BOOTINFO_H__ =20 struct arch_bootmodule { +#define BOOTMOD_FLAG_X86_RELOCATED 1U << 0 + uint32_t flags; unsigned headroom; }; =20 +struct arch_boot_info { + uint32_t flags; +#define BOOTINFO_FLAG_X86_CMDLINE 1U << 2 +#define BOOTINFO_FLAG_X86_MODULES 1U << 3 +#define BOOTINFO_FLAG_X86_MEMMAP 1U << 6 +#define BOOTINFO_FLAG_X86_LOADERNAME 1U << 9 + + char *boot_loader_name; + + uint32_t mmap_length; + paddr_t mmap_addr; +}; + +struct __packed mb_memmap { + uint32_t size; + uint32_t base_addr_low; + uint32_t base_addr_high; + uint32_t length_low; + uint32_t length_high; + uint32_t type; +}; + #endif =20 /* diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index a5f8c9e67f..ca502269f2 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -1,6 +1,7 @@ #ifndef _DOM0_BUILD_H_ #define _DOM0_BUILD_H_ =20 +#include #include #include =20 @@ -13,15 +14,11 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -int dom0_construct_pv(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline); +int dom0_construct_pv(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline); =20 -int dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - char *cmdline); +int dom0_construct_pvh(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, char *cmdline); =20 unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 80d0bb2a21..2d620d04c7 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -34,8 +34,8 @@ static inline void vesa_init(void) {}; =20 int construct_dom0( struct domain *d, - const module_t *kernel, unsigned long kernel_headroom, - module_t *initrd, + const struct boot_module *kernel, + struct boot_module *initrd, char *cmdline); void setup_io_bitmap(struct domain *d); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 4fe806b60d..bc0af7cf27 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -4,12 +4,12 @@ * Copyright (c) 2002-2005, K A Fraser */ =20 +#include #include #include #include #include #include -#include #include #include #include @@ -356,9 +356,8 @@ static struct page_info * __init alloc_chunk(struct dom= ain *d, } =20 int __init dom0_construct_pv(struct domain *d, - const module_t *image, - unsigned long image_headroom, - module_t *initrd, + const struct boot_module *image, + struct boot_module *initrd, char *cmdline) { int i, rc, order, machine; @@ -375,10 +374,10 @@ int __init dom0_construct_pv(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map_multiboot(image); - unsigned long image_len =3D image->mod_end; - void *image_start =3D image_base + image_headroom; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + void *image_base =3D bootstrap_map(image); + unsigned long image_len =3D image->size; + void *image_start =3D image_base + image->arch->headroom; + unsigned long initrd_len =3D initrd ? initrd->size : 0; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; l2_pgentry_t *l2tab =3D NULL, *l2start =3D NULL; @@ -417,7 +416,7 @@ int __init dom0_construct_pv(struct domain *d, =20 d->max_pages =3D ~0U; =20 - if ( (rc =3D bzimage_parse(image_base, &image_start, image_headroom, + if ( (rc =3D bzimage_parse(image_base, &image_start, image->arch->head= room, &image_len)) !=3D 0 ) return rc; =20 @@ -612,7 +611,7 @@ int __init dom0_construct_pv(struct domain *d, initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D mfn =3D initrd->mod_start; + initrd_mfn =3D mfn =3D mfn_x(initrd->mfn); count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) @@ -627,12 +626,13 @@ int __init dom0_construct_pv(struct domain *d, free_domheap_pages(page, order); page +=3D 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 =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D (paddr_t)initrd->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); - initrd->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(page)); + bootmodule_update_mfn(initrd, page_to_mfn(page)); + initrd_mfn =3D mfn_x(initrd->mfn); } else { @@ -640,7 +640,7 @@ int __init dom0_construct_pv(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->mod_end =3D 0; + initrd->size =3D 0; =20 iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); @@ -654,7 +654,7 @@ int __init dom0_construct_pv(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D initrd->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -880,7 +880,7 @@ int __init dom0_construct_pv(struct domain *d, if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D initrd->mod_start + (pfn - initrd_pfn); + mfn =3D mfn_x(initrd->mfn) + (pfn - initrd_pfn); else mfn -=3D PFN_UP(initrd_len); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3b623a4149..f9b04daebd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,9 @@ #include #include =20 +/* Max number of boot modules a bootloader can provide in addition to Xen = */ +#define MAX_NR_BOOTMODS 63 + /* opt_nosmp: If true, secondary processors are ignored. */ static bool __initdata opt_nosmp; boolean_param("nosmp", opt_nosmp); @@ -269,20 +273,44 @@ static int __init cf_check parse_acpi_param(const cha= r *s) } custom_param("acpi", parse_acpi_param); =20 -static const module_t *__initdata initial_images; static struct boot_info __initdata *boot_info; =20 -static void __init multiboot_to_bootinfo(multiboot_info_t *mbi) +static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *= mods) { static struct boot_info __initdata info; - static struct boot_module __initdata boot_mods[1]; - static struct arch_bootmodule __initdata arch_boot_mods[1]; + static struct arch_boot_info __initdata arch_info; + static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1= ]; + static struct arch_bootmodule __initdata arch_boot_mods[ + MAX_NR_BOOTMODS + 1= ]; =20 + int i; + + info.arch =3D &arch_info; info.mods =3D boot_mods; =20 + info.cmdline =3D __va(mbi->cmdline); + + /* The BOOTINFO_FLAG_X86_* flags are a 1-1 map to MBI_* */ + arch_info.flags =3D mbi->flags; + arch_info.mmap_length =3D mbi->mmap_length; + arch_info.mmap_addr =3D mbi->mmap_addr; + arch_info.boot_loader_name =3D __va(mbi->boot_loader_name); + info.nr_mods =3D mbi->mods_count; + for ( i =3D 0; i <=3D MAX_NR_BOOTMODS; i++ ) + { + boot_mods[i].arch =3D &arch_boot_mods[i]; =20 - boot_mods[0].arch =3D &arch_boot_mods[0]; + if ( i < info.nr_mods ) + { + bootmodule_update_start(&boot_mods[i], mods[i].mod_start); + boot_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + + boot_mods[i].string.len =3D strlcpy(boot_mods[i].string.bytes, + __va(mods[i].string), + BOOTMOD_STRING_MAX_LEN); + } + } =20 boot_info =3D &info; } @@ -296,8 +324,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < boot_info->nr_mods; ++i ) { - unsigned long start =3D initial_images[i].mod_start; - unsigned long end =3D start + PFN_UP(initial_images[i].mod_end); + unsigned long start =3D mfn_x(boot_info->mods[i].mfn); + unsigned long end =3D start + PFN_UP(boot_info->mods[i].size); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -312,14 +340,13 @@ void __init discard_initial_images(void) =20 for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - uint64_t start =3D (uint64_t)initial_images[i].mod_start << PAGE_S= HIFT; + uint64_t start =3D boot_info->mods[i].start; =20 init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(boot_info->mods[i].size)); } =20 boot_info->nr_mods =3D 0; - initial_images =3D NULL; } =20 extern unsigned char __init_begin[], __init_end[]; @@ -450,26 +477,26 @@ static void __init move_memory( =20 while ( size ) { - module_t mod; + struct boot_module mod; unsigned int soffs =3D src & mask; unsigned int doffs =3D dst & mask; unsigned int sz; void *d, *s; =20 - mod.mod_start =3D (src - soffs) >> PAGE_SHIFT; - mod.mod_end =3D soffs + size; - if ( mod.mod_end > blksz ) - mod.mod_end =3D blksz; - sz =3D mod.mod_end - soffs; - s =3D bootstrap_map_multiboot(&mod); - - mod.mod_start =3D (dst - doffs) >> PAGE_SHIFT; - mod.mod_end =3D doffs + size; - if ( mod.mod_end > blksz ) - mod.mod_end =3D blksz; - if ( sz > mod.mod_end - doffs ) - sz =3D mod.mod_end - doffs; - d =3D bootstrap_map_multiboot(&mod); + mod.start =3D src - soffs; + mod.size =3D soffs + size; + if ( mod.size > blksz ) + mod.size =3D blksz; + sz =3D mod.size - soffs; + s =3D bootstrap_map(&mod); + + mod.start =3D dst - doffs; + mod.size =3D doffs + size; + if ( mod.size > blksz ) + mod.size =3D blksz; + if ( sz > mod.size - doffs ) + sz =3D mod.size - doffs; + d =3D bootstrap_map(&mod); =20 memmove(d + doffs, s + soffs, sz); =20 @@ -602,7 +629,7 @@ static void __init noinline move_xen(void) #undef BOOTSTRAP_MAP_LIMIT =20 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 *mod, unsigned int nr_mods, unsigned int this_mod) { unsigned int i; @@ -612,8 +639,8 @@ static uint64_t __init consider_modules( =20 for ( i =3D 0; i < nr_mods ; ++i ) { - uint64_t start =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; - uint64_t end =3D start + PAGE_ALIGN(mod[i].mod_end); + uint64_t start =3D mod[i].start; + uint64_t end =3D start + PAGE_ALIGN(mod[i].size); =20 if ( i =3D=3D this_mod ) continue; @@ -883,9 +910,8 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kex= tra, +static struct domain *__init create_dom0(const struct boot_info *bootinfo, + const char *kextra, const char *loader) { struct xen_domctl_createdomain dom0_cfg =3D { @@ -899,9 +925,14 @@ static struct domain *__init create_dom0(const module_= t *image, .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + struct boot_module *image =3D bootmodule_next(bootinfo, BOOTMOD_KERNEL= ); + struct boot_module *initrd =3D bootmodule_next(bootinfo, BOOTMOD_RAMDI= SK); struct domain *d; char *cmdline; - domid_t domid; + domid_t domid =3D 0; + + if ( image =3D=3D NULL ) + panic("Error creating d%uv0\n", domid); =20 if ( opt_dom0_pvh ) { @@ -928,7 +959,7 @@ static struct domain *__init create_dom0(const module_t= *image, panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - cmdline =3D image->string ? __va(image->string) : NULL; + cmdline =3D image->string.len ? image->string.bytes : NULL; if ( cmdline || kextra ) { static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; @@ -968,8 +999,7 @@ static struct domain *__init create_dom0(const module_t= *image, write_cr4(read_cr4() & ~X86_CR4_SMAP); } =20 - if ( construct_dom0(d, image, boot_info->mods[0].arch->headroom, initr= d, - cmdline) !=3D 0 ) + if ( construct_dom0(d, image, initrd, cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 if ( cpu_has_smap ) @@ -1038,14 +1068,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) mod =3D __va(mbi->mods_addr); } =20 - multiboot_to_bootinfo(mbi); + multiboot_to_bootinfo(mbi, mod); =20 - loader =3D (mbi->flags & MBI_LOADERNAME) - ? (char *)__va(mbi->boot_loader_name) : "unknown"; + loader =3D (boot_info->arch->flags & BOOTINFO_FLAG_X86_LOADERNAME) + ? boot_info->arch->boot_loader_name : "unknown"; =20 /* Parse the command-line options. */ - cmdline =3D cmdline_cook((mbi->flags & MBI_CMDLINE) ? - __va(mbi->cmdline) : NULL, + cmdline =3D cmdline_cook((boot_info->arch->flags & BOOTINFO_FLAG_X86_C= MDLINE) ? + boot_info->cmdline : NULL, loader); if ( (kextra =3D strstr(cmdline, " -- ")) !=3D NULL ) { @@ -1147,19 +1177,22 @@ void __init noreturn __start_xen(unsigned long mbi_= p) bootsym(boot_edd_info_nr)); =20 /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (boot_info->nr_mods =3D=3D 0) ) + if ( !(boot_info->arch->flags & BOOTINFO_FLAG_X86_MODULES) || + (boot_info->nr_mods =3D=3D 0) ) panic("dom0 kernel not specified. Check bootloader configuration\n= "); =20 /* Check that we don't have a silly number of modules. */ - if ( boot_info->nr_mods > sizeof(module_map) * 8 ) + if ( boot_info->nr_mods > MAX_NR_BOOTMODS + 1 ) { - boot_info->nr_mods =3D sizeof(module_map) * 8; + boot_info->nr_mods =3D MAX_NR_BOOTMODS + 1; printk("Excessive multiboot modules - using the first %u only\n", boot_info->nr_mods); } =20 - bitmap_fill(module_map, boot_info->nr_mods); + /* Dom0 kernel is the first boot module */ + bitmap_fill(module_map, mbi->mods_count); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + boot_info->mods[0].bootmod_type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) { @@ -1189,13 +1222,13 @@ void __init noreturn __start_xen(unsigned long mbi_= p) { memmap_type =3D "Xen-e820"; } - else if ( mbi->flags & MBI_MEMMAP ) + else if ( boot_info->arch->flags & BOOTINFO_FLAG_X86_MEMMAP ) { memmap_type =3D "Multiboot-e820"; - while ( bytes < mbi->mmap_length && + while ( bytes < boot_info->arch->mmap_length && e820_raw.nr_map < ARRAY_SIZE(e820_raw.map) ) { - memory_map_t *map =3D __va(mbi->mmap_addr + bytes); + struct mb_memmap *map =3D __va(boot_info->arch->mmap_addr + by= tes); =20 /* * This is a gross workaround for a BIOS bug. Some bootloaders= do @@ -1330,17 +1363,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(&boot_e820); =20 - initial_images =3D mod; - boot_info->nr_mods =3D boot_info->nr_mods; - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < boot_info->nr_mods; i++= ) - { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( boot_info->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - mod[i].mod_end -=3D mod[i].mod_start; - mod[i].mod_start >>=3D PAGE_SHIFT; - mod[i].reserved =3D 0; - } =20 /* * TODO: load ucode earlier once multiboot modules become accessible @@ -1357,12 +1382,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[boot_info->nr_mods].mod_start =3D virt_to_mfn(_stext); - mod[boot_info->nr_mods].mod_end =3D __2M_rwdata_end - _stext; + bootmodule_update_start(&boot_info->mods[boot_info->nr_mods], + virt_to_maddr(_stext)); + boot_info->mods[boot_info->nr_mods].size =3D __2M_rwdata_end - _st= ext; } =20 boot_info->mods[0].arch->headroom =3D - bzimage_headroom(bootstrap_map_multiboot(mod), mod->mod_end); + bzimage_headroom(bootstrap_map(&boot_info->mods[0]), + boot_info->mods[0].size); =20 bootstrap_map(NULL); =20 @@ -1420,7 +1447,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) { /* Don't overlap with modules. */ end =3D consider_modules(s, e, reloc_size + mask, - mod, boot_info->nr_mods, -1); + boot_info->mods, boot_info->nr_mods, -1= ); end &=3D ~mask; } else @@ -1443,15 +1470,15 @@ void __init noreturn __start_xen(unsigned long mbi_= p) /* Is the region suitable for relocating the multiboot modules? */ for ( j =3D boot_info->nr_mods - 1; j >=3D 0; j-- ) { - struct boot_module *boot_mods =3D boot_info->mods; - unsigned long headroom =3D j ? 0 : boot_mods[0].arch->headroom; - unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); + struct boot_module *boot_mod =3D boot_info->mods; + unsigned long headroom =3D j ? 0 : boot_mod[0].arch->headroom; + unsigned long size =3D PAGE_ALIGN(headroom + boot_mod[j].size); =20 - if ( mod[j].reserved ) + if ( boot_mod[j].arch->flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ - end =3D consider_modules(s, e, size, mod, + end =3D consider_modules(s, e, size, boot_info->mods, boot_info->nr_mods + relocated, j); =20 if ( highmem_start && end > highmem_start ) @@ -1459,14 +1486,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 if ( s < end && (headroom || - ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) + ((end - size) >> PAGE_SHIFT) > mfn_x(boot_mod[j].mfn)) ) { move_memory(end - size + headroom, - (uint64_t)mod[j].mod_start << PAGE_SHIFT, - mod[j].mod_end); - mod[j].mod_start =3D (end - size) >> PAGE_SHIFT; - mod[j].mod_end +=3D headroom; - mod[j].reserved =3D 1; + (uint64_t)boot_mod[j].start, + boot_mod[j].size); + bootmodule_update_start(&boot_mod[j], end - size); + boot_mod[j].size +=3D headroom; + boot_mod[j].arch->flags |=3D BOOTMOD_FLAG_X86_RELOCATED; } } =20 @@ -1478,7 +1505,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) while ( !kexec_crash_area.start ) { /* Don't overlap with modules (or Xen itself). */ - e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , mod, + e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), + boot_info->mods, boot_info->nr_mods + relocated, -1); if ( s >=3D e ) break; @@ -1492,13 +1520,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) #endif } =20 - if ( boot_info->mods[0].arch->headroom && !mod->reserved ) + if ( boot_info->mods[0].arch->headroom && + !(boot_info->mods[0].arch->flags & BOOTMOD_FLAG_X86_RELOCATED) ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s =3D (uint64_t)boot_info->mods[i].start; =20 - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end)); + reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(boot_info->mods[i].= size)); } =20 if ( !xen_phys_start ) @@ -1565,8 +1594,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < boot_info->nr_mods; ++j ) { - uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end =3D mfn_to_maddr(boot_info->mods[j].mfn) + + boot_info->mods[j].size; =20 if ( map_e < end ) map_e =3D end; @@ -1641,11 +1670,12 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 for ( i =3D 0; i < boot_info->nr_mods; ++i ) { - set_pdx_range(mod[i].mod_start, - mod[i].mod_start + PFN_UP(mod[i].mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(mod[i].mod_start), - _mfn(mod[i].mod_start), - PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR); + set_pdx_range(mfn_x(boot_info->mods[i].mfn), + mfn_x(boot_info->mods[i].mfn) + + PFN_UP(boot_info->mods[i].size)); + map_pages_to_xen((unsigned long)maddr_to_virt(boot_info->mods[i].s= tart), + boot_info->mods[i].mfn, + PFN_UP(boot_info->mods[i].size), PAGE_HYPERVISOR); } =20 #ifdef CONFIG_KEXEC @@ -2022,8 +2052,12 @@ void __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, boot_info->nr_mods); - if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 ) + initrdidx =3D bootmodule_index(boot_info, BOOTMOD_UNKNOWN, 0); + if ( initrdidx < boot_info->nr_mods ) + boot_info->mods[initrdidx].bootmod_type =3D BOOTMOD_RAMDISK; + + if ( bootmodule_index(boot_info, BOOTMOD_UNKNOWN, 0) > + boot_info->nr_mods ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", initrdidx); @@ -2032,9 +2066,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, boot_info->mods[0].arch->headroom, - initrdidx < boot_info->nr_mods ? mod + initrdidx : = NULL, - kextra, loader); + dom0 =3D create_dom0(boot_info, kextra, loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index eb93cc3439..2f4284a91f 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -2,23 +2,50 @@ #define __XEN_BOOTINFO_H__ =20 #include +#include +#include =20 #ifdef CONFIG_X86 #include #else struct arch_bootmodule { }; + struct arch_boot_info { }; #endif =20 +/* Boot module binary type / purpose */ +#define BOOTMOD_UNKNOWN 0 +#define BOOTMOD_XEN 1 +#define BOOTMOD_FDT 2 +#define BOOTMOD_KERNEL 3 +#define BOOTMOD_RAMDISK 4 +#define BOOTMOD_XSM 5 +#define BOOTMOD_UCODE 6 +#define BOOTMOD_GUEST_DTB 7 +typedef unsigned int bootmod_type_t; + +#define BOOTMOD_STRING_MAX_LEN 1024 +struct boot_string { + char bytes[BOOTMOD_STRING_MAX_LEN]; + size_t len; +}; + struct boot_module { + bootmod_type_t bootmod_type; paddr_t start; + mfn_t mfn; size_t size; =20 struct arch_bootmodule *arch; + struct boot_string string; }; =20 struct boot_info { + char *cmdline; + unsigned int nr_mods; struct boot_module *mods; + + struct arch_boot_info *arch; }; =20 #endif --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171541; cv=none; d=zohomail.com; s=zohoarc; b=XVbLCw3r949I8eV66pDBjPPjE0Qx1JdjIIp0WAuwUHWadj/3b4DjD8Zn9s4Eg8uGWWbkVlrb0OL5XcYrjM8GTBEN/PBFEx4JNgKNPgLknNz67OhODbFRQqYpTLMgLHibC2WwAGvKXVKcTARWHhdYyBlCVu8seUkmAyUgSmanlTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171541; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/bZBd6eRTKkd5JZ++Hy2rgV0U3swA0RaaPb02+sFNEo=; b=MPjPTBXfDoVUJsYQGeT+n8KKEsTbPEEPVTZOneroSOqpWu8iIrl+fM8WbQSImYXH71+v7T9iOaVC/6WqruAC8FM/5WSz+jZeWH051hBBvvLhguB/I5zs15G+GI0rSl3Gl9gd2LW+EcfuxsqkNj81/eZR9PKefQ13LVh54YHck90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171541676466.15558688017745; Fri, 30 Jun 2023 17:32:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557669.871248 (Exim 4.92) (envelope-from ) id 1qFOWk-0000X7-Dg; Sat, 01 Jul 2023 00:31:50 +0000 Received: by outflank-mailman (output) from mailman id 557669.871248; Sat, 01 Jul 2023 00:31:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWk-0000Wj-A8; Sat, 01 Jul 2023 00:31:50 +0000 Received: by outflank-mailman (input) for mailman id 557669; Sat, 01 Jul 2023 00:31:49 +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 1qFOWj-0007yB-4e for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:49 +0000 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [2607:f8b0:4864:20::436]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a9c2fbe6-17a6-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 02:31:48 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-666ecf9a081so1885991b3a.2 for ; Fri, 30 Jun 2023 17:31:48 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:46 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: a9c2fbe6-17a6-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171506; x=1690763506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=/bZBd6eRTKkd5JZ++Hy2rgV0U3swA0RaaPb02+sFNEo=; b=MTxzrGAITsLT46i4OhAoywi7PDozDmK8q/T2F09c3zFbuT2Y6eKs24RxEJO8+Kay4q jzAoyn0OCFx9AzDmriIAAn1h7oGp8to6nRjh5QqLvOXlA6AxT9iukyh/tuGKczv/pOcB RSQpcQguU7OWMAB1w2lNbdBWlPfejpXiFctURmffmSFX1P4XbhBij44g0d9HLgafSgBs h1mVKbeQbjXDv8ABL2W7VKqtbspGQabdM+E4yJOCx/QM5RNaKMd8Wqg+Jg/v70fGASUg GPXdgxQeS8nud8TZGue1Z66u7qh+el26tdF24UEaRrr8g9yq/UchAr0Ilt7Cz2Nqbf0y gcAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171506; x=1690763506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/bZBd6eRTKkd5JZ++Hy2rgV0U3swA0RaaPb02+sFNEo=; b=NYhfJ/Zrx8ez3SXhyFF4S/kE1hf1GZ9GLtlBrKT8PYQqX8q4wL1nVYAqsAPifrfoD8 lYLTTLeGSDMTxaOCbMpMe6qQuC6Bhd4vHkLCyx9cuqUt2mraiGReZ+Txzy4XoT3uBU7B o8us4suwoe3U8hn4aKhnda0qydRdVCRMk1vt2Ms07rqseIc+EjJJjo8S4AZBypXNvTni N7HoclEWxojtlLiyyV12oSeNydzSZzEQyyjl4rV4DbDPxXKBb058YDGMi4lUxB6JMnEH ndi28fMuivx0gd+414bRzK2IuleSV+QzjvlDE3eTiXJanaDeONoVjDQSbo02HoL3mDT3 4SmA== X-Gm-Message-State: ABy/qLbyufxNuorruzQAws8xnK2Aq5qgzW68g53fEh+v+3duuRJnhZAB qYuekxw022N2TUD16DI5OXd1UfVjNew= X-Google-Smtp-Source: APBJJlFBq6b+oL8y3j9HKkjC37NmJlsGa0wteQeagNzkCv7VOsuYvWWt9UFRAHuwAgSrK9WgXeiGbA== X-Received: by 2002:a05:6a00:18a4:b0:680:40b2:5419 with SMTP id x36-20020a056a0018a400b0068040b25419mr6592110pfh.4.1688171506475; Fri, 30 Jun 2023 17:31:46 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 05/11] xsm: switch XSM init to boot info structures Date: Fri, 30 Jun 2023 17:31:26 -0700 Message-Id: <20230701003132.2210306-6-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171542991100003 Content-Type: text/plain; charset="utf-8" Change the XSM implementation to use the boot info structure instead of the multiboot module_map. Drops a dependency on CONFIG_MULTIBOOT, so boot module logic is now used whenever the DEVICE_TREE specific logic (for Arm) is not, with the bootinfo header conditionally included to ensure no change on Arm. Adds a multiboot header inclusion into guest/xen/pvh-boot.c since it is no longer provided via transitive inclusion and the source in that file uses multiboot structures. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith Changes since v1: - derived from patches 2 and 3 - added pvh-boot.c multiboot header inclusion - conditional inclusion of bootinfo.h to avoid breaking Arm --- xen/arch/x86/guest/xen/pvh-boot.c | 1 + xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 28 +++++++-------- xen/xsm/xsm_core.c | 47 +++++++++++++++--------- xen/xsm/xsm_policy.c | 59 ++++++++++++++++--------------- 5 files changed, 77 insertions(+), 60 deletions(-) diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh= -boot.c index 9cbe87b61b..1ed04d035c 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include #include diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f9b04daebd..a616ccc0a8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1835,7 +1835,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges =3D rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); =20 - xsm_multiboot_init(module_map, mbi); + xsm_bootmodule_init(boot_info); =20 /* * IOMMU-related ACPI table parsing may require some of the system dom= ains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 8dad03fd3d..d409c30be6 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -16,8 +16,10 @@ #define __XSM_H__ =20 #include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif #include -#include =20 /* policy magic number (defined by XSM_MAGIC) */ typedef uint32_t xsm_magic_t; @@ -776,15 +778,14 @@ static inline int xsm_argo_send(const struct domain *= d, const struct domain *t) =20 #endif /* XSM_NO_WRAPPERS */ =20 -#ifdef CONFIG_MULTIBOOT -int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi); -int xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, - void **policy_buffer, size_t *policy_size); -#endif +#ifndef CONFIG_HAS_DEVICE_TREE +int xsm_bootmodule_init(const struct boot_info *info); +int xsm_bootmodule_policy_init( + const struct boot_info *info, const unsigned char **policy_buffer, + size_t *policy_size); + +#else =20 -#ifdef CONFIG_HAS_DEVICE_TREE /* * Initialize XSM * @@ -826,15 +827,14 @@ static const inline struct xsm_ops *silo_init(void) =20 #include =20 -#ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init ( - unsigned long *module_map, const multiboot_info_t *mbi) +#ifndef CONFIG_HAS_DEVICE_TREE +static inline int xsm_bootmodule_init(const struct boot_info *info) { return 0; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + static inline int xsm_dt_init(void) { return 0; diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index eaa028109b..301ae4dc8b 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -10,8 +10,12 @@ * as published by the Free Software Foundation. */ =20 -#include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif #include +#include +#include #include #include =20 @@ -138,26 +142,35 @@ static int __init xsm_core_init(const void *policy_bu= ffer, size_t policy_size) return 0; } =20 -#ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi) +/* + * ifdef'ing this against multiboot is no longer valid as the boot module + * is agnostic and it will be possible to dropped the ifndef should Arm + * adopt boot info + */ +#ifndef CONFIG_HAS_DEVICE_TREE +int __init xsm_bootmodule_init(const struct boot_info *bootinfo) { int ret =3D 0; - void *policy_buffer =3D NULL; + const unsigned char *policy_buffer =3D NULL; size_t policy_size =3D 0; =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 if ( XSM_MAGIC ) { - ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, - &policy_size); - if ( ret ) - { - bootstrap_map(NULL); - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; - } + int ret =3D xsm_bootmodule_policy_init(bootinfo, &policy_buffer, + &policy_size); + bootstrap_map(NULL); + + if ( ret =3D=3D -ENOENT ) + /* + * The XSM module needs a policy file but one was not located. + * Report as a warning and continue as the XSM module may late + * load a policy file. + */ + printk(XENLOG_WARNING "xsm: starting without a policy loaded!\= n"); + else if ( ret ) + panic("Error %d initializing XSM policy\n", ret); } =20 ret =3D xsm_core_init(policy_buffer, policy_size); @@ -165,9 +178,9 @@ int __init xsm_multiboot_init( =20 return 0; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + int __init xsm_dt_init(void) { int ret =3D 0; @@ -215,9 +228,9 @@ bool __init has_xsm_magic(paddr_t start) =20 return false; } -#endif +#endif /* CONFIG_HAS_DEVICE_TREE */ =20 -#endif +#endif /* CONFIG_XSM */ =20 long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index c6df8c6e06..f1970c8964 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -18,62 +18,65 @@ * */ =20 -#include -#ifdef CONFIG_MULTIBOOT -#include -#include -#include -#endif #include +#ifndef CONFIG_HAS_DEVICE_TREE +# include +#endif +#include #ifdef CONFIG_HAS_DEVICE_TREE -# include # include +#else +#include #endif =20 -#ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, - void **policy_buffer, size_t *policy_size) +#include + +#ifndef CONFIG_HAS_DEVICE_TREE +int __init xsm_bootmodule_policy_init( + const struct boot_info *bootinfo, const unsigned char **policy_buffer, + size_t *policy_size) { - int i; - module_t *mod =3D (module_t *)__va(mbi->mods_addr); - int rc =3D 0; + unsigned long i; + int rc =3D -ENOENT; u32 *_policy_start; unsigned long _policy_len; =20 - /* - * Try all modules and see whichever could be the binary policy. - * Adjust module_map for the module that is the binary policy. - */ - for ( i =3D mbi->mods_count-1; i >=3D 1; i-- ) - { - if ( !test_bit(i, module_map) ) - continue; +#ifdef CONFIG_XSM_FLASK_POLICY + /* Initially set to builtin policy, overriden if boot module is found.= */ + *policy_buffer =3D xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; + rc =3D 0; +#endif =20 - _policy_start =3D bootstrap_map_multiboot(mod + i); - _policy_len =3D mod[i].mod_end; + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, 0); + while ( i < bootinfo->nr_mods ) + { + _policy_start =3D bootstrap_map(&bootinfo->mods[i]); + _policy_len =3D bootinfo->mods[i].size; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { - *policy_buffer =3D _policy_start; + *policy_buffer =3D (unsigned char *)_policy_start; *policy_size =3D _policy_len; =20 printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - __clear_bit(i, module_map); + bootinfo->mods[i].bootmod_type =3D BOOTMOD_XSM; + rc =3D 0; break; =20 } =20 bootstrap_map(NULL); + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, ++i); } =20 return rc; } -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE +#else + int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size) { struct bootmodule *mod =3D boot_module_find_by_kind(BOOTMOD_XSM); --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171547; cv=none; d=zohomail.com; s=zohoarc; b=TKCAGYEq4yGfkSnUwRMT7TMfJj1pd02qpN47wfAqIlOZk2NLYdaGQQMyp+d/e8NhnTm/gTSbt1Lh2UvQCHAoCTKIV+FZ3C56otYaH8bxltdsIa7wqpYUFSKpayS394g85Pe0KjiIv5Vq6nO+Vfsc8CTxqr5eGzXxQ8w4awmbz0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171547; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tNP8VdblK4Rt8e2FoRKT44HjkzeP53PPJ4jpSpNQaUw=; b=WT75EX+Mm69BMx6gV8+Ly1DyqliTvkm77T7gktBnz7hlfJpa0A9O00ZUDNdPgwiIIx2dI2ZT3U709qoDh8Uzzlmzi42v9YV0jCAE9RwuTROgItICXatnPxjtREhC6BU5bH45rg27Ccb7y2cmmkthagaYXol+llK4HL1avI145eo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171547356758.0363219371051; Fri, 30 Jun 2023 17:32:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557672.871272 (Exim 4.92) (envelope-from ) id 1qFOWn-000193-Nt; Sat, 01 Jul 2023 00:31:53 +0000 Received: by outflank-mailman (output) from mailman id 557672.871272; Sat, 01 Jul 2023 00:31:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWn-00017y-Gt; Sat, 01 Jul 2023 00:31:53 +0000 Received: by outflank-mailman (input) for mailman id 557672; Sat, 01 Jul 2023 00:31:51 +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 1qFOWl-0007yM-CS for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:51 +0000 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [2607:f8b0:4864:20::731]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id aa5d7fcc-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:49 +0200 (CEST) Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-76728ae3162so224236785a.3 for ; Fri, 30 Jun 2023 17:31:49 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:46 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: aa5d7fcc-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171507; x=1690763507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=tNP8VdblK4Rt8e2FoRKT44HjkzeP53PPJ4jpSpNQaUw=; b=dZsj6vciSfnMLCMaU0cMPpVzsvTf2cA6H5rK4dqitVEHa7PIl9bqnNbVX3YCmArVSD IMEXc7JXp9i0n/PGdZX9qMeKuVaEdqi1JfQcIbGoD4A3Tg/fYHZ5qWS5LnG8xrnN8FH1 Qri/PoGiBRsUxe8lInpy/Y3tNDsK+N/06FDCG77bszgiEqbDDNt1ISOCF7hrbk0zEJZF u3xEDplqMMf5QyYIZXM+igxM68XL6fyrQU/HlA+q/V8iig/rjo8PHvxFVZnmdcg9lZsV 5KpUfri4831gj2h32ooplKW5XrDdfAHBoQV/NLL9yEaAH4ZJQQM+UxajHNgk+edO/lhN CM9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171507; x=1690763507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tNP8VdblK4Rt8e2FoRKT44HjkzeP53PPJ4jpSpNQaUw=; b=OzBtmcktinPgWc4XhtkaIz/SXeaJ6nzCQuxZxTc2JMoAV2ZcCRLdjcX+gt+dJcGZKY A6IzBRT5MOmL5RBHqkdqyRD4PR4clvF+tD583EyrF+YdyOfAUuylU1Cg3BQEIi4g1SjI OvuG/96KKedmGW08c1W8twytVnn3Z4IZpNGIGldqXFu1T6hQHnrUL8gQZDRU6aAH+w1h uDrAevlVcDerI55VGHvTwEQ640xI9B1QjbD8QQoEVSJ/XhKgBFcr4RHmGZRggjQyyNA4 Y9f0KegaY0Pgq1kn560TCPt0rE2xrEWFotxKeIJf2QUS4dpbS74EmzR33hdzSKUHaHUP RpKg== X-Gm-Message-State: ABy/qLawIMHRzXLb3UaViZv69lx9jqBV9Ddkd89tCgnFNahEBlioCNmd uhRiyZjbQweGuNo9EAqK8cFOjEtlfxw= X-Google-Smtp-Source: APBJJlHXadhO0zI3fny7/VsDSq54jA5+/G/AaPurjt0vF6Vo+E7TEPOAcjmOGo6hXLaSNWVGV0iNyg== X-Received: by 2002:a05:620a:29d2:b0:767:3999:5277 with SMTP id s18-20020a05620a29d200b0076739995277mr5531547qkp.70.1688171507611; Fri, 30 Jun 2023 17:31:47 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 06/11] x86 setup, microcode: switch to the new bootinfo structures Date: Fri, 30 Jun 2023 17:31:27 -0700 Message-Id: <20230701003132.2210306-7-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171548973100009 Content-Type: text/plain; charset="utf-8" Next step in incremental work towards adding a non-multiboot internal representation of boot modules, converting the fields being accessed for the startup calculations. Move the per-module scan logic into a dedicated function from the iteration loop and set the BOOTMOD_UCODE module type when microcode is foun= d. Completes the conversion from the module_map bitmap in x86 setup so it can be removed, along with the temporary bootstrap_map multiboot wrapper since the last code that uses it is removed in this change. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: - an incremental subset of patch 3 - added the drop of the temporary bootstrap map --- xen/arch/x86/cpu/microcode/core.c | 148 +++++++++++++++------------ xen/arch/x86/include/asm/boot.h | 13 --- xen/arch/x86/include/asm/microcode.h | 7 +- xen/arch/x86/setup.c | 8 +- 4 files changed, 89 insertions(+), 87 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index e720a89167..c674ccf88c 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -22,12 +22,12 @@ */ =20 #include +#include #include #include #include #include #include -#include #include #include #include @@ -57,7 +57,6 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 =20 -static module_t __initdata ucode_mod; static signed int __initdata ucode_mod_idx; static bool_t __initdata ucode_mod_forced; static unsigned int nr_cores; @@ -150,75 +149,109 @@ static int __init cf_check parse_ucode(const char *s) } custom_param("ucode", parse_ucode); =20 -void __init microcode_scan_module( - unsigned long *module_map, - const multiboot_info_t *mbi) +#define MICROCODE_MODULE_MATCH 1 +#define MICROCODE_MODULE_NONMATCH 0 + +static int __init microcode_check_module(struct boot_module *mod) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); uint64_t *_blob_start; unsigned long _blob_size; - struct cpio_data cd; + struct cpio_data cd =3D { NULL, 0 }; long offset; const char *p =3D NULL; - int i; - - ucode_blob.size =3D 0; - if ( !ucode_scan ) - return; =20 if ( boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD ) p =3D "kernel/x86/microcode/AuthenticAMD.bin"; else if ( boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL ) p =3D "kernel/x86/microcode/GenuineIntel.bin"; else + return -EFAULT; + + _blob_start =3D bootstrap_map(mod); + _blob_size =3D mod->size; + if ( !_blob_start ) + { + printk("Could not map multiboot module (0x%lx) (size: %ld)\n", + mod->start, _blob_size); + /* Non-fatal error, so just say no match */ + return MICROCODE_MODULE_NONMATCH; + } + + cd =3D find_cpio_data(p, _blob_start, _blob_size, &offset /* ignore */= ); + + if ( cd.data ) + { + ucode_blob.size =3D cd.size; + ucode_blob.data =3D cd.data; + + mod->bootmod_type =3D BOOTMOD_UCODE; + return MICROCODE_MODULE_MATCH; + } + + bootstrap_map(NULL); + + return MICROCODE_MODULE_NONMATCH; +} + +void __init microcode_scan_module(struct boot_info *bootinfo) +{ + int i; + + if ( !ucode_scan ) return; =20 - /* - * Try all modules and see whichever could be the microcode blob. - */ - for ( i =3D 1 /* Ignore dom0 kernel */; i < mbi->mods_count; i++ ) + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, 0); + while ( i < bootinfo->nr_mods ) { - if ( !test_bit(i, module_map) ) - continue; + int ret =3D microcode_check_module(&bootinfo->mods[i]); =20 - _blob_start =3D bootstrap_map_multiboot(&mod[i]); - _blob_size =3D mod[i].mod_end; - if ( !_blob_start ) + switch ( ret ) { - printk("Could not map multiboot module #%d (size: %ld)\n", - i, _blob_size); + case MICROCODE_MODULE_MATCH: + return; + case MICROCODE_MODULE_NONMATCH: + i =3D bootmodule_index(bootinfo, BOOTMOD_UNKNOWN, ++i); continue; + default: + printk("%s: (err: %d) unable to check microcode\n", + __func__, ret); + return; } - cd.data =3D NULL; - cd.size =3D 0; - cd =3D find_cpio_data(p, _blob_start, _blob_size, &offset /* ignor= e */); - if ( cd.data ) - { - ucode_blob.size =3D cd.size; - ucode_blob.data =3D cd.data; - break; - } - bootstrap_map(NULL); } } =20 -static void __init microcode_grab_module( - unsigned long *module_map, - const multiboot_info_t *mbi) +static void __init microcode_grab_module(struct boot_info *bootinfo) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); + ucode_blob.size =3D 0; =20 if ( ucode_mod_idx < 0 ) - ucode_mod_idx +=3D mbi->mods_count; - if ( ucode_mod_idx <=3D 0 || ucode_mod_idx >=3D mbi->mods_count || - !__test_and_clear_bit(ucode_mod_idx, module_map) ) - goto scan; - ucode_mod =3D mod[ucode_mod_idx]; -scan: + ucode_mod_idx +=3D bootinfo->nr_mods; + if ( ucode_mod_idx >=3D 0 && ucode_mod_idx <=3D bootinfo->nr_mods && + bootinfo->mods[ucode_mod_idx].bootmod_type =3D=3D BOOTMOD_UNKNOWN= ) + { + int ret =3D microcode_check_module(&bootinfo->mods[ucode_mod_idx]); + + switch ( ret ) + { + case MICROCODE_MODULE_MATCH: + return; + case MICROCODE_MODULE_NONMATCH: + break; + default: + printk("%s: (err: %d) unable to check microcode\n", + __func__, ret); + return; + } + } + if ( ucode_scan ) - microcode_scan_module(module_map, mbi); + microcode_scan_module(bootinfo); } =20 +/* Undefining as they are not needed anymore */ +#undef MICROCODE_MODULE_MATCH +#undef MICROCODE_MODULE_NONMATCH + static struct microcode_ops __ro_after_init ucode_ops; =20 static DEFINE_SPINLOCK(microcode_mutex); @@ -737,11 +770,6 @@ static int __init cf_check microcode_init(void) ucode_blob.size =3D 0; ucode_blob.data =3D NULL; } - else if ( ucode_mod.mod_end ) - { - bootstrap_map(NULL); - ucode_mod.mod_end =3D 0; - } =20 return 0; } @@ -785,19 +813,15 @@ static int __init early_update_cache(const void *data= , size_t len) return rc; } =20 -int __init microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init microcode_init_cache(struct boot_info *bootinfo) { int rc =3D 0; =20 if ( ucode_scan ) /* Need to rescan the modules because they might have been relocat= ed */ - microcode_scan_module(module_map, mbi); + microcode_scan_module(bootinfo); =20 - if ( ucode_mod.mod_end ) - rc =3D early_update_cache(bootstrap_map_multiboot(&ucode_mod), - ucode_mod.mod_end); - else if ( ucode_blob.size ) + if ( ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); =20 return rc; @@ -815,11 +839,6 @@ static int __init early_microcode_update_cpu(void) len =3D ucode_blob.size; data =3D ucode_blob.data; } - else if ( ucode_mod.mod_end ) - { - len =3D ucode_mod.mod_end; - data =3D bootstrap_map_multiboot(&ucode_mod); - } =20 if ( !data ) return -ENOMEM; @@ -838,8 +857,7 @@ static int __init early_microcode_update_cpu(void) return microcode_update_cpu(patch); } =20 -int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init early_microcode_init(struct boot_info *bootinfo) { const struct cpuinfo_x86 *c =3D &boot_cpu_data; int rc =3D 0; @@ -863,11 +881,11 @@ int __init early_microcode_init(unsigned long *module= _map, return -ENODEV; } =20 - microcode_grab_module(module_map, mbi); + microcode_grab_module(bootinfo); =20 ucode_ops.collect_cpu_info(); =20 - if ( ucode_mod.mod_end || ucode_blob.size ) + if ( ucode_blob.size ) rc =3D early_microcode_update_cpu(); =20 return rc; diff --git a/xen/arch/x86/include/asm/boot.h b/xen/arch/x86/include/asm/boo= t.h index bcf4f2e2e3..e51fd32280 100644 --- a/xen/arch/x86/include/asm/boot.h +++ b/xen/arch/x86/include/asm/boot.h @@ -6,19 +6,6 @@ =20 #include =20 -static inline void *bootstrap_map_multiboot(const module_t *mod) -{ - struct boot_module bm; - - if ( !mod ) - return bootstrap_map(NULL); - - bm.start =3D mod->mod_start << PAGE_SHIFT; - bm.size =3D mod->mod_end; - - return bootstrap_map(&bm); -} - static inline unsigned long bootmodule_index( const struct boot_info *info, bootmod_type_t bootmod_type, unsigned long start) diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/as= m/microcode.h index 62ce3418f7..803fbbb270 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -1,6 +1,7 @@ #ifndef ASM_X86__MICROCODE_H #define ASM_X86__MICROCODE_H =20 +#include #include #include =20 @@ -23,10 +24,8 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig); =20 void microcode_set_module(unsigned int idx); int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); -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 early_microcode_init(struct boot_info *bootinfo); +int microcode_init_cache(struct boot_info *bootinfo); int microcode_update_one(void); =20 #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a616ccc0a8..50a1a124b0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1023,7 +1023,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned int initrdidx, num_parked =3D 0; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, module_map[1]; + unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1190,8 +1190,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) } =20 /* Dom0 kernel is the first boot module */ - bitmap_fill(module_map, mbi->mods_count); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ boot_info->mods[0].bootmod_type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) @@ -1371,7 +1369,7 @@ void __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(boot_info); =20 if ( xen_phys_start ) { @@ -1906,7 +1904,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 timer_init(); =20 - microcode_init_cache(module_map, mbi); /* Needs xmalloc() */ + microcode_init_cache(boot_info); /* Needs xmalloc() */ =20 tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ =20 --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171534; cv=none; d=zohomail.com; s=zohoarc; b=KuL61X9wcRz+mI4R+ZsAXxJ/U5nhjhvtqqPpIVGKhom537keVUZb1nln8Gq1Dx49meN2yvB2YWF+xiIwJb2NNTTck3/SxXke4F5M4ixLw/U4XbLD0sNyZFR7BOKm/YL/C7rIvEiGH3jiwLJxObrRiAo1U9Tek0wYh5EFNfOqcjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0U+LCev7aRUe6kzgwNY1PJd28KyRT3ussnezbfZRMiA=; b=m8BUY0j4JuUJzOo7vT1dd1e/FLvVdvOQ5m3pxa1Hz5uOr/5tw/MZxr8wTCwGK+qMGKVELXm/VzwfU89dpc0OqgCX15yzsAo0MdhjNN8r/AmOyTfYSFzQ1jnwXwvllb930odGPYXAXWg0YxUKjjzgbQVcVtFnzcB15r4XRpWegeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171534978634.0063063438613; Fri, 30 Jun 2023 17:32:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557671.871267 (Exim 4.92) (envelope-from ) id 1qFOWn-00016a-Bp; Sat, 01 Jul 2023 00:31:53 +0000 Received: by outflank-mailman (output) from mailman id 557671.871267; Sat, 01 Jul 2023 00:31:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWn-000161-7S; Sat, 01 Jul 2023 00:31:53 +0000 Received: by outflank-mailman (input) for mailman id 557671; Sat, 01 Jul 2023 00:31:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWl-0007yB-9M for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:51 +0000 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [2001:4860:4864:20::31]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ab2fcc9f-17a6-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 02:31:50 +0200 (CEST) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1b0156a1c49so2153119fac.0 for ; Fri, 30 Jun 2023 17:31:50 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: ab2fcc9f-17a6-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171508; x=1690763508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=0U+LCev7aRUe6kzgwNY1PJd28KyRT3ussnezbfZRMiA=; b=WV+aJ1zVjq4nXbKPyve69zH6JoluUFgsXQ5zQkMXcB2gh0mkT3mMnKBgSwybZpyzla jz0D5iwm/fIfnp1y0vMlFyN2W64XDxHa8OCwuKwCSNZV9N22ACjvKBfz98txPImUb88z JYcqXFqcGCJM5LNpzRMBe1pSvD1kKEXulmDgIjnjCxwRV48RgP7CcQonF5yUB1MhPvZF EjQVnESOoVXDThQ9H148u0UULZB6DO37JfHnRgFkgbEbykyvqnnoxp5d9NIv6tuOZLnT VVr74xNXIplbDpbObtcZPEk/gCfqoRnuSwHRP5HG7tE8lBwxytN+STeILwOg9+UCeY9G WExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171508; x=1690763508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0U+LCev7aRUe6kzgwNY1PJd28KyRT3ussnezbfZRMiA=; b=FpFC3LGawWmZMiPWcWoBen4PLZTgTLVeaMwnU1qnx4ZXJTKn1AvmgJF9wdyQ9GXDg9 kBVPX5AaiJDFQCfgVKXWFok859htOEe1zvIg2QNLMyEBaTmUTfiqSFlZdYHd/tvPx8sY wfcpn6xsozoyDzoaDxiUe5+0pWo5EWV7IWyoyrsKfQTL2fNky8RaghsEpTcNFi0/+jCi KRsM3ZYYS9INRL1rSK9vXuqCXwSsObRVRAtrDtXHew/O0AOBqyFpJSL1JdpUMVqmmWG3 qyWyyxuobhN+GiNWu5dzxYEwag7Y8PwGOI5fJdddc9EbuEM3TLPIgVhf7eSTlmM5aGUZ uCmA== X-Gm-Message-State: ABy/qLatbhEfMEIVUkEWREUZNSvJtzs0+qGhEeobA0vT3V3tztWodjYc ox0YsjrAhtVvOE/BwvJdi+SCtwYlvmk= X-Google-Smtp-Source: APBJJlF3sIquE7SEmuOVCL336/ZZA3DJYpw9wCSH58nhp6htUSRqmBAs9VrAM0wy0VnaimSdTk7oBw== X-Received: by 2002:a05:6870:ac26:b0:1ad:5634:750b with SMTP id kw38-20020a056870ac2600b001ad5634750bmr4621178oab.13.1688171508647; Fri, 30 Jun 2023 17:31:48 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 07/11] x86 boot: define paddr_t and add macros for typedefing struct pointers Date: Fri, 30 Jun 2023 17:31:28 -0700 Message-Id: <20230701003132.2210306-8-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171535803100001 Content-Type: text/plain; charset="utf-8" Pointer fields within structs need to be defined as fixed size types in the x86 boot build environment. Using a typedef for the field type rather than a struct pointer type enables the type definition to be changed in the 32-bit boot build and the main hypervisor build, allowing for a single common structure definition and a common header file. Introduces DEFINE_STRUCT_PTR_TYPE which will generate typedefs with a _ptr_t suffix for pointers to the specified struct. This is then used in The 32-bit behaviour is obtained by inclusion of "defs.h" first with a check for such an existing definition on the version. paddr_t is used in so a definition is added here to the x86 boot environment defs.h header. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith New in v2 of series --- xen/arch/x86/boot/defs.h | 5 +++++ xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/include/xen/bootinfo.h | 7 ++++--- xen/include/xen/types.h | 5 +++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index f9840044ec..867df6d18d 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -60,4 +60,9 @@ typedef u64 uint64_t; #define U16_MAX ((u16)(~0U)) #define UINT_MAX (~0U) =20 +typedef unsigned long long paddr_t; + +#define DEFINE_STRUCT_PTR_TYPE(struct_name) \ + typedef uint64_t struct_name ## _ptr_t; + #endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 30c27980e0..8d1261503d 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -6,6 +6,7 @@ struct arch_bootmodule { uint32_t flags; unsigned headroom; }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); =20 struct arch_boot_info { uint32_t flags; @@ -19,6 +20,7 @@ struct arch_boot_info { uint32_t mmap_length; paddr_t mmap_addr; }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); =20 struct __packed mb_memmap { uint32_t size; diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 2f4284a91f..8ee3ee36e9 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -35,17 +35,18 @@ struct boot_module { mfn_t mfn; size_t size; =20 - struct arch_bootmodule *arch; + arch_bootmodule_ptr_t arch; struct boot_string string; }; +DEFINE_STRUCT_PTR_TYPE(boot_module); =20 struct boot_info { char *cmdline; =20 unsigned int nr_mods; - struct boot_module *mods; + boot_module_ptr_t mods; =20 - struct arch_boot_info *arch; + arch_boot_info_ptr_t arch; }; =20 #endif diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 6aba80500a..78a2079619 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -71,4 +71,9 @@ typedef bool bool_t; #define test_and_set_bool(b) xchg(&(b), true) #define test_and_clear_bool(b) xchg(&(b), false) =20 +#ifndef DEFINE_STRUCT_PTR_TYPE +#define DEFINE_STRUCT_PTR_TYPE(struct_name) \ + typedef struct struct_name * struct_name ## _ptr_t; +#endif + #endif /* __TYPES_H__ */ --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171546; cv=none; d=zohomail.com; s=zohoarc; b=KpY7rZSuf4gP8XYiC8zai/HbBcurNJhQ7K3YXkadAy/ZUyau0vcxY6evQoPqNUfdiH5Q8FwvQMgFTxNU+MzuC5+TkE2MVBD39Dx3pN10nYmxwLGFJjS59r78sapT15Zzla2EBtteav1RG9lbCUS9uh53EsJyhb49jDAHN8nnT8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171546; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=goxmEkry0U1HLmMVQmvP8Gde9Okz3AzqGSy+FqLUKTI=; b=eH/sgnw/w5QE3AIydZVUjmKHU6gF5d+g2T70tgrnQ3ZpuD6Oy3HgJrestsGpkoQZIsn+4J0UlSc5dtg4YMSIKXU0dU1Uaq1WYNNQIZbuwEDEyd5G0u5wPRC510770sPux2t5DJQ9faAuRxYDnBM3jQ35lGOTDi4XzyWAlcFMG8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171546356548.001694924488; Fri, 30 Jun 2023 17:32:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557674.871288 (Exim 4.92) (envelope-from ) id 1qFOWp-0001aT-68; Sat, 01 Jul 2023 00:31:55 +0000 Received: by outflank-mailman (output) from mailman id 557674.871288; Sat, 01 Jul 2023 00:31: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 1qFOWo-0001Yr-RA; Sat, 01 Jul 2023 00:31:54 +0000 Received: by outflank-mailman (input) for mailman id 557674; Sat, 01 Jul 2023 00:31: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 1qFOWn-0007yM-5t for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:53 +0000 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [2607:f8b0:4864:20::b34]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id abc9c57b-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:51 +0200 (CEST) Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-c2cf4e61bc6so2479592276.3 for ; Fri, 30 Jun 2023 17:31:51 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:49 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: abc9c57b-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171510; x=1690763510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=goxmEkry0U1HLmMVQmvP8Gde9Okz3AzqGSy+FqLUKTI=; b=RlFU8aKTsmTkSL803ovUEfnOumnnC/JpNxk55d3A7YSbtFDeqvpjZ6/eL3TunyDqWh zaWgXHHrtXf8xX0sgRwwabeQE86Cm9/vsUzKHuqIQ/XbSMJRM2zm/aSRzGCL/Qz54s12 bkP/KZqdfw8A7X9ZEQyg6pf90WWkKh3x1f89t7X/jio6qN17ae7jXrFtJYnGzvaEgzut B9zrWTvWQYTmA8r23TnpcqdP7KjWBrVOAwyjMRDIw0XruQen8xsrU/HRQt2WoN2QN4/P zGdzzWbBLixZFiF19BmePZ3k55LeGaLKxtAr3d8EjmWqAPSZSIXnotYHZsgOc/94ocNl 1igg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171510; x=1690763510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=goxmEkry0U1HLmMVQmvP8Gde9Okz3AzqGSy+FqLUKTI=; b=VfHNBX/5Ahf/xpFhLFcUItScY4OaFWNI9I1W7tRaF7S9ugIAZvk1L7P36L0PridW9G XhOGxNrqwmev6pjJoiQTsrb0c7MvT1QLtprsDZqmbHEPfomevyJkvkObXy4QtZBZ7s6w qM7RC+3TDcSkzaTu3SuIDSzEiNxblgDu3Hfzsn7FdN4Dt4fS+ZCMxR4rUUA/hnV6k8Cq obRXYSwrlFo1C3CeXNpSnH+vHBQDcoA923KrTFovqr9lwHoxQpeODSkr+zm1jsfzFChG L1rMeiJd1+sTxIVnR5psQwu0j3xaMreRRdk+ojGLs8+YnnFvSYHPGO/eqLBplHAFmJ0H rNGQ== X-Gm-Message-State: ABy/qLYRi9b026y8iWCQPKiYlF7HgRoQH9miSGZwQQoEYQIMQRviKgW0 5VoI+iOWRbhvjW+XN9nthYDMJQuzyr8= X-Google-Smtp-Source: APBJJlEARNWgLjZpa74rQHLaxgPV1NZ3cvoIaJB/ZTsURcawLd8v/B1Kpv9K2P83VDZePWvxDNRJ0w== X-Received: by 2002:a25:cb4e:0:b0:c1e:a1b8:1667 with SMTP id b75-20020a25cb4e000000b00c1ea1b81667mr4227415ybg.22.1688171509994; Fri, 30 Jun 2023 17:31:49 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 08/11] types, x86 boot: define DEFINE_PTR_TYPE and char_ptr_t Date: Fri, 30 Jun 2023 17:31:29 -0700 Message-Id: <20230701003132.2210306-9-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171547569100007 Content-Type: text/plain; charset="utf-8" Pointer fields within structs need to be defined as fixed size types in the x86 boot build environment. Using a typedef for the field type enables the definition to be changed in the 32-bit boot build and the main hypervisor build, allowing for a single common structure definition and a common header file. Add a macro for defining pointer types for fields and use this macro for pointers to chars in and as preparation for using these headers in the x86 boot build. The 32-bit behaviour is obtained by inclusion of "defs.h" first with a check for such an existing definition on the version. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith New in v2 --- xen/arch/x86/boot/defs.h | 4 ++++ xen/arch/x86/include/asm/bootinfo.h | 2 +- xen/include/xen/bootinfo.h | 2 +- xen/include/xen/types.h | 6 ++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index 867df6d18d..bc0f1b5cf8 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -65,4 +65,8 @@ typedef unsigned long long paddr_t; #define DEFINE_STRUCT_PTR_TYPE(struct_name) \ typedef uint64_t struct_name ## _ptr_t; =20 +#define DEFINE_PTR_TYPE(type) \ + typedef uint64_t type ## _ptr_t; +DEFINE_PTR_TYPE(char); + #endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 8d1261503d..989fb7a1da 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -15,7 +15,7 @@ struct arch_boot_info { #define BOOTINFO_FLAG_X86_MEMMAP 1U << 6 #define BOOTINFO_FLAG_X86_LOADERNAME 1U << 9 =20 - char *boot_loader_name; + char_ptr_t boot_loader_name; =20 uint32_t mmap_length; paddr_t mmap_addr; diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 8ee3ee36e9..8389da4f72 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -41,7 +41,7 @@ struct boot_module { DEFINE_STRUCT_PTR_TYPE(boot_module); =20 struct boot_info { - char *cmdline; + char_ptr_t cmdline; =20 unsigned int nr_mods; boot_module_ptr_t mods; diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 78a2079619..e807ffe255 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -76,4 +76,10 @@ typedef bool bool_t; typedef struct struct_name * struct_name ## _ptr_t; #endif =20 +#ifndef DEFINE_PTR_TYPE +#define DEFINE_PTR_TYPE(type) \ + typedef type * type ## _ptr_t; +DEFINE_PTR_TYPE(char); +#endif + #endif /* __TYPES_H__ */ --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171539; cv=none; d=zohomail.com; s=zohoarc; b=LwwcYv8VoQitduBuUC4iUFLh+J/aneDf4gVxTJp7qkBCSRKLzaYg6/kV+gT1jWLmvEIoU//BwMf/e9Ge+nx5pMjvlSwMuPSezjCxx0Ywprkbz8XS7dUUJcDGxWkZax6G2lFGac8Mz+v51I8sO1ThvP3nMsz/dZpntf/W6JlXsOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171539; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CmW5UL4mCfeFM30iYwmo6ORQbNbEDrG26I97OFcvUzw=; b=HcNpXUo0TsrHUWJzqK87yZXx4UDR9R1G3gyVFYMSqvnCP67GIk8Gn0D9OTTNfYUS3rBQwVVBRMWlHCzIc7rMU3eNpxrx2jmQlgZ1Sf0xiQ1uggzdW9/tivS0s2FXDa3jvccUvthBrglcSRwJRkOuzJ7fh4zuxzBNjcezOggxHOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 168817153971577.13984092482235; Fri, 30 Jun 2023 17:32:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557675.871293 (Exim 4.92) (envelope-from ) id 1qFOWp-0001jL-QV; Sat, 01 Jul 2023 00:31:55 +0000 Received: by outflank-mailman (output) from mailman id 557675.871293; Sat, 01 Jul 2023 00:31: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 1qFOWp-0001hu-Kk; Sat, 01 Jul 2023 00:31:55 +0000 Received: by outflank-mailman (input) for mailman id 557675; Sat, 01 Jul 2023 00:31: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 1qFOWo-0007yM-Lf for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:54 +0000 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [2607:f8b0:4864:20::1032]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac76a5b0-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:53 +0200 (CEST) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-262e3c597b9so1620980a91.0 for ; Fri, 30 Jun 2023 17:31:52 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: ac76a5b0-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171511; x=1690763511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=CmW5UL4mCfeFM30iYwmo6ORQbNbEDrG26I97OFcvUzw=; b=mDKgu0N+J33pO8y0qR4pSU8R7axaOqaVgxvtdIbHJ/u5JctG4BQbpTI1b8p0w6bMxj vBWwRDK2eoOR5P9dkryVjt5TX0WBEPhbhga2jxGg5Vb61RbW9ZtEutPIhi/rZtxxBsR0 4F8CEALSdMAiVUH7yX86MmPiH0ejByPiN5EDvdXMaR1DMEimhq7JT6vRvgTqUsL0cKUA vqUeyprCLh7K6Op05ef3VP0rWttXdevLjPaXqhhpPmeeJcaiY+GPx1vML2mt3/G5IcyM jtiWQEJFHX+gk4Id3se+AhfCekKQavsgUuRccMqLcTFrqcPs4SUl7LvaQHGFOEZYe+o0 Xv7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171511; x=1690763511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CmW5UL4mCfeFM30iYwmo6ORQbNbEDrG26I97OFcvUzw=; b=dJYjYyFU1zKU79X4H1VUfv/78iWDGlpP22nyiB51VNVrLFGYb4OfB32ws7wAQpl1hF nH30KzAsEiM68Wy1G1O+gLcIBMMz+Pj9A2uVYyaTDZeRNSjvbONzRB0ecba0k24B8CH+ /94dJhr7QlSDaecJsfUcKlKLEWPno6FwhJC59ySfjahmuOecVUQ2YjtGs02Zbc91A1ti Rc2U3zHJITVTkMCe7sS2UqLJawagpqqegaZ9aKrbu3KDKjWyEjRBdAPncCspz+FGjugL gWhehBNQy2jK+Zaz31SZIodqxB0RoEuz9PvvQlSVM9S7lfCpo8anJrPxc5Loa1r9+ukN pZEA== X-Gm-Message-State: ABy/qLYG9wtwcn6sUvSNp3RnXiXciJQduXNhKU7nDwn0iXSkuyq4Qlma DRZP4zqn9xaV5TJoje/uu1SPpcn+1tg= X-Google-Smtp-Source: APBJJlGMLddV7br5bz18vAf2YOGfu1jHgiMmcg8DV5OkPbHOCTMCceaaVMmcoUwcBKrRC46JWnECog== X-Received: by 2002:a17:90a:f00c:b0:262:c9f4:141 with SMTP id bt12-20020a17090af00c00b00262c9f40141mr3264484pjb.42.1688171510911; Fri, 30 Jun 2023 17:31:50 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 09/11] x86, arm, riscv: add per-arch bootinfo headers to allow x86 boot include Date: Fri, 30 Jun 2023 17:31:30 -0700 Message-Id: <20230701003132.2210306-10-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171541539100001 Content-Type: text/plain; charset="utf-8" The header contains structures that will be used in efi logic prior to the main start of Xen, so will soon be included in Arm builds. This same header will also used in early x86 boot, where asm/* headers are not reachable and yet it contains a needed include of , so... Add initial per-arch headers to Arm and RISC-V so that inclusion of succeeds in each main arch build and then gate that inclusion from on CONFIG variables so that it does not take effect in the early x86 boot build where CONFIG_X86 is not defined to prevent build failure there. The early x86 boot logic can then directly include asm/bootinfo.h via a specified directory path to bring in the necessary definitions. Is this fantastic? No. Does it help? Yep. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith New for v2 series. --- xen/arch/arm/include/asm/bootinfo.h | 20 ++++++++++++++++++++ xen/arch/riscv/include/asm/bootinfo.h | 20 ++++++++++++++++++++ xen/include/xen/bootinfo.h | 7 ++----- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 xen/arch/arm/include/asm/bootinfo.h create mode 100644 xen/arch/riscv/include/asm/bootinfo.h diff --git a/xen/arch/arm/include/asm/bootinfo.h b/xen/arch/arm/include/asm= /bootinfo.h new file mode 100644 index 0000000000..5316c87a3d --- /dev/null +++ b/xen/arch/arm/include/asm/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_ARM_BOOTINFO_H__ +#define __ARCH_ARM_BOOTINFO_H__ + +struct __packed arch_bootmodule { }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); + +struct __packed arch_boot_info { }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); + +#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/riscv/include/asm/bootinfo.h b/xen/arch/riscv/include= /asm/bootinfo.h new file mode 100644 index 0000000000..5316c87a3d --- /dev/null +++ b/xen/arch/riscv/include/asm/bootinfo.h @@ -0,0 +1,20 @@ +#ifndef __ARCH_ARM_BOOTINFO_H__ +#define __ARCH_ARM_BOOTINFO_H__ + +struct __packed arch_bootmodule { }; +DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); + +struct __packed arch_boot_info { }; +DEFINE_STRUCT_PTR_TYPE(arch_boot_info); + +#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/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index 8389da4f72..bf5586a76b 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -5,11 +5,8 @@ #include #include =20 -#ifdef CONFIG_X86 -#include -#else - struct arch_bootmodule { }; - struct arch_boot_info { }; +#if defined CONFIG_X86 || CONFIG_ARM || CONFIG_RISCV +# include #endif =20 /* Boot module binary type / purpose */ --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171546; cv=none; d=zohomail.com; s=zohoarc; b=HLWeW2+NsNuvCG5lU5TMKGb4wkrf8jDm/jzao06GwtQ4m66WjH35d3nqdRlGfDmd8o236bHIAcgQy1fv0dfxErbxZdr2uq/U2gEokFk2w0lkBgweXMxXU8QekIDTyzbmgGzdpVwkCcJmFo1KM4GNWIHpGHRGwC6PDI17h8WDHjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171546; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eobWsLudL6LP1s0XBewioDQ6KL/Td7X9osJXVUd2EmM=; b=GuV+pwHRG6Waj4nAfNEn4svNqrpfSitGK7v46tjdbIO4jlTWhIi+4KtMka1IvlOjgjGQowLxH+4/w4daG/KjewLeUDQxI0BDVLQB7Csjjt3dTqyf39U9LM57m2ZoQlFENDKQUCkEmiCStNDhm+uNnIMFAp3IeYwAFSRwQ/oiDgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171546426525.8435336209911; Fri, 30 Jun 2023 17:32:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557676.871305 (Exim 4.92) (envelope-from ) id 1qFOWr-00029E-B3; Sat, 01 Jul 2023 00:31:57 +0000 Received: by outflank-mailman (output) from mailman id 557676.871305; Sat, 01 Jul 2023 00:31:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWr-000285-2V; Sat, 01 Jul 2023 00:31:57 +0000 Received: by outflank-mailman (input) for mailman id 557676; Sat, 01 Jul 2023 00:31: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 1qFOWp-0007yM-98 for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:55 +0000 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [2607:f8b0:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id acfe17ca-17a6-11ee-8611-37d641c3527e; Sat, 01 Jul 2023 02:31:53 +0200 (CEST) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6b886456f66so1790531a34.0 for ; Fri, 30 Jun 2023 17:31:53 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:51 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: acfe17ca-17a6-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171512; x=1690763512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=eobWsLudL6LP1s0XBewioDQ6KL/Td7X9osJXVUd2EmM=; b=pf3RZgrNX5scU+U3lhARSed2bh0CIo65idYmRx10QaH4gLLS1AJULsKiycGFXhiGfl NR2ogZiVsBDBGt3Al4XEWq65oaE/xBuon/T1vnxmR1vInlsO18XF1426wwxJRTyvC6vt wdE3IMbxClp05AKOlX+gLsnb7A713aLkJC9XmSVGbvXPTKXgerTwQunxPbT1rPpQ4uCI gf5iY0TjNrztpZ2Z0uATKtn9OOm+nvGbf4bF3r6a5aBLAt/a5plRrriYkQFO/Lyde2aE gEdgnFYryrGJuCLoDhzliHOQOeL0lt21t2AgiOHS1B7cc3hcZwsTWCzhTtZCG2RfXYba P8Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171512; x=1690763512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eobWsLudL6LP1s0XBewioDQ6KL/Td7X9osJXVUd2EmM=; b=cnwYgqDUuvFUBdbso+NhkQZ516fNARucsuZOJ0WsjMgo7Vqk7iRpS0cmbM4Uf3pA0i mvb9RN/zhVRFk42VRtvaF7MbjigCPBW4gTh1wx2Zx5z2n/AdTLfHfsx/yCPwymWsVTUa VfKmHj80saEV7tpnap13Y5XkXHc8Q8sf+fZAdGilCExZdhZ0m3cdBcJHuxn/axxTxecP JUQr5ziFy7EazWIdB3t4XSm8jltBv6qWGMBu4QyOnrL9KoRoGkQSYl6pys9WB6GVt0bQ Q6/zA7lRCrm6qbOcA4odpWyTDa3DKmNFw1f4Y+lL2vjEXDX5ujSfxNFDMZD3lTy6oa4E 9Cjg== X-Gm-Message-State: AC+VfDzYMHzhSPSSU1lM/6yIC8UtTGVGKRhpSwJ5QuJRwgv27aACBusr AhG7AgGHresco+B6e/kXXhFchdZA9/c= X-Google-Smtp-Source: ACHHUZ4Aj8NvkVJllvxkQKfVm9FJZ4c/6HPUItf+wawkjEKnebTGZb1aBVz7wrUVpJI/QgyMqF2BdQ== X-Received: by 2002:a05:6830:1104:b0:6b8:7db6:9ab5 with SMTP id w4-20020a056830110400b006b87db69ab5mr4305120otq.12.1688171512057; Fri, 30 Jun 2023 17:31:52 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 10/11] arm setup: include for bootmod defns, replacing enum Date: Fri, 30 Jun 2023 17:31:31 -0700 Message-Id: <20230701003132.2210306-11-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171547322100003 Content-Type: text/plain; charset="utf-8" This change enables and begins introducion of into Arm builds: it replace the enum definition of bootmodule_kind with bootmod_type_t which is a fixed size type as needed for packed structs, to be used in the boot structures in subsequent changes. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith New for v2 series. --- xen/arch/arm/include/asm/setup.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 38e2ce255f..ce3882ca67 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -3,6 +3,7 @@ =20 #include #include +#include #include =20 #define MIN_FDT_ALIGN 8 @@ -12,15 +13,7 @@ =20 #define MAX_MODULES 32 /* Current maximum useful modules */ =20 -typedef enum { - BOOTMOD_XEN, - BOOTMOD_FDT, - BOOTMOD_KERNEL, - BOOTMOD_RAMDISK, - BOOTMOD_XSM, - BOOTMOD_GUEST_DTB, - BOOTMOD_UNKNOWN -} bootmodule_kind; +typedef bootmod_type_t bootmodule_kind; =20 enum membank_type { /* --=20 2.25.1 From nobody Sun Feb 8 11:02:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688171545; cv=none; d=zohomail.com; s=zohoarc; b=caeHqoCJijBVAyhTzPyBrbAuzxU96hY3Cn9/XQ+NfCIKsDQF+T6MJU3iPHr/wfp5efobQbQCRPP6xKsAw/xqvpwQV9sGhpxkAv/M0601BrrMuaYJNeUxTlK/BtUNgLFMkh8XNoqtwNgIVdz0YkgJVzLUMjL6rPfM9Qmj2epdJH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688171545; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lc4F58lZGArBW0YBbdm+a1mT2bCVXrWRmAPLEIHYE0U=; b=dqClqtnDqx288DnWyrHLffPdooM3o/rhBPJ7TaXzxYmAfRFMpzf94YdwUhjuBSKVsjgboJ9/vspYHvxwVg9azhA6w1GcuwX349fOs0p+eqZJYigNguj+PoY2RyS9ojUzvKAqgipios2QuMn3oKcUPoFUTR7QB6LXP4/tDGp5FCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1688171545461954.4564295809263; Fri, 30 Jun 2023 17:32:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.557678.871317 (Exim 4.92) (envelope-from ) id 1qFOWs-0002Wh-TI; Sat, 01 Jul 2023 00:31:58 +0000 Received: by outflank-mailman (output) from mailman id 557678.871317; Sat, 01 Jul 2023 00:31:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qFOWs-0002W6-LQ; Sat, 01 Jul 2023 00:31:58 +0000 Received: by outflank-mailman (input) for mailman id 557678; Sat, 01 Jul 2023 00:31:57 +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 1qFOWq-0007yB-PN for xen-devel@lists.xenproject.org; Sat, 01 Jul 2023 00:31:57 +0000 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [2607:f8b0:4864:20::c32]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id adc67b96-17a6-11ee-b237-6b7b168915f2; Sat, 01 Jul 2023 02:31:55 +0200 (CEST) Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5634db21a58so1666089eaf.0 for ; Fri, 30 Jun 2023 17:31:54 -0700 (PDT) Received: from cog-dev.home ([70.103.208.83]) by smtp.gmail.com with ESMTPSA id s68-20020a632c47000000b0055b61cd99a1sm1824296pgs.81.2023.06.30.17.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 17:31:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-Inumbo-ID: adc67b96-17a6-11ee-b237-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688171513; x=1690763513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Lc4F58lZGArBW0YBbdm+a1mT2bCVXrWRmAPLEIHYE0U=; b=RH+jyvfx1XbiemxdH/8VzA6hoZYenfI0d8V09JZi98CP5PRtk4Vj1NX56nlOtabZaT ds0grTQkfIB/03q3iC4bW94Qs0s6wmIMtlAMJwi5fM2LXo6an55PnNKhb4DWSwooZ0ZQ ofDBUAhUGcW+xOowTswUKS7m88zIaqHBNnUnymOKXKXLxNltVRZ/2ftuGAZYIXseBtDx DyErGYzNb2pFb8jf5dwCQEXOsTw2UmyWsHJxA8grvlcXdTefUiNX49sIqiiZvs1OVSv7 ub6MDDCvnNS1XGFPLukt8UYbIR1bgceZEaf6L9piJyRry+EIY6S5pqoJml1lAXppVZFE PvfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688171513; x=1690763513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lc4F58lZGArBW0YBbdm+a1mT2bCVXrWRmAPLEIHYE0U=; b=GYVKRAQcw/kLcRIpcP2jNVeFfrz6XOhVycosOSLU9bI1k6eY2Mgtklj3m4e1KLvJDp CTKQN3sVAf5LSGyI5kFWO0pGtwoZUo6WJEsZh8AvIalRDE1vV1GsaJU6pHTbpGU0zAen xx84bmvVWy51tYJaR1FBUdVzc8CzkkeQ99oT5lpPo6GOshE9icc0DzAN717yFUny+Fa0 rNraGbdOQkXaMn+GEZnCY2D1ZY8WqxMm+/5F4p8o1M678IDkpXfNOdi1WYyzbrsV0Z7n xc2xjZzmRbpdabORdCb90+4+kRD7vVzIMLubluAp6dESgLi0lPBByn1Lnfk39XpqqMDn Yi0Q== X-Gm-Message-State: AC+VfDyw5nN9f/Z8Crs6ROMcQNnopdglpQJRexYIPD9JjDlD8H137y2v XudzlBenZ9/L5tIBxjBZgjvOsadmD04= X-Google-Smtp-Source: ACHHUZ4OyiOTJ7Y+BDtup3FLBUjhuwwXpv7JZBUCRgYkED6g1b1biZAa7cJMMUNZs36CyoB5weiuWw== X-Received: by 2002:a05:6808:8c8:b0:3a1:ead3:bf20 with SMTP id k8-20020a05680808c800b003a1ead3bf20mr3981522oij.33.1688171513115; Fri, 30 Jun 2023 17:31:53 -0700 (PDT) Sender: Christopher Clark From: Christopher Clark To: xen-devel@lists.xenproject.org Cc: Daniel Smith , stefano.stabellini@amd.com, Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Luca Fancellu , Volodymyr Babchuk , Rich Persaud Subject: [PATCH 11/11] x86 setup: refactor entrypoints to new boot info Date: Fri, 30 Jun 2023 17:31:32 -0700 Message-Id: <20230701003132.2210306-12-christopher.w.clark@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701003132.2210306-1-christopher.w.clark@gmail.com> References: <20230701003132.2210306-1-christopher.w.clark@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688171547365100004 Previous commits added a transition point from multiboot v1 structures to the new boot info structures at the earliest common point for all the x86 entrypoints. The result is that each of the entrypoints would construct a multiboot v1 structure from the structures used by each entrypoint. =C2=A0This meant that multiboot2, EFI, and PVH all converted their structures over to mutliboot v1 to only be converted again upon entering __start_xen(). This commit drops the translation function and moves the population of the new boot info structures down into the various entrypoints. Signed-off-by: Christopher Clark Signed-off-by: Daniel P. Smith changes since v1: - based on v1 series patch 4 - use main bootinfo headers in boot logic instead of adding a 32-bit version - apply packing to boot structures here rather than in earlier changes - use a defined maximum rather than Kconfig'd variable --- xen/arch/arm/efi/efi-boot.h | 6 + xen/arch/x86/boot/defs.h | 1 + xen/arch/x86/boot/reloc.c | 192 +++++++++++++++------- xen/arch/x86/efi/efi-boot.h | 95 ++++++----- xen/arch/x86/guest/xen/pvh-boot.c | 64 +++++--- xen/arch/x86/include/asm/bootinfo.h | 7 +- xen/arch/x86/include/asm/guest/pvh-boot.h | 6 +- xen/arch/x86/setup.c | 73 +++----- xen/common/efi/boot.c | 4 +- xen/include/xen/bootinfo.h | 9 +- 10 files changed, 278 insertions(+), 179 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index bb64925d70..d931fe06ed 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -1003,6 +1003,12 @@ static void __init efi_arch_flush_dcache_area(const = void *vaddr, UINTN size) __flush_dcache_area(vaddr, size); } =20 +static struct boot_info __init *efi_arch_bootinfo_init(void) +{ + /* boot modules not currently in use on Arm so no init required here */ + return NULL; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index bc0f1b5cf8..519ca4dae6 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -44,6 +44,7 @@ _x > _y ? _x : _y; }) =20 #define _p(val) ((void *)(unsigned long)(val)) +#define _addr(val) ((unsigned long)(void *)(val)) =20 #define tolower(c) ((c) | 0x20) =20 diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index e22bb974bf..8a48572d5f 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -27,6 +27,8 @@ asm ( ); =20 #include "defs.h" +#include "../include/asm/bootinfo.h" +#include "../../../include/xen/bootinfo.h" #include "../../../include/xen/multiboot.h" #include "../../../include/xen/multiboot2.h" =20 @@ -138,65 +140,116 @@ static struct hvm_start_info *pvh_info_reloc(u32 in) return out; } =20 -static multiboot_info_t *mbi_reloc(u32 mbi_in) +static struct boot_info *mbi_reloc(u32 mbi_in) { + const multiboot_info_t *mbi =3D _p(mbi_in); + struct boot_info *binfo; + struct arch_boot_info *arch_binfo; int i; - multiboot_info_t *mbi_out; + uint32_t ptr; =20 - mbi_out =3D _p(copy_mem(mbi_in, sizeof(*mbi_out))); + ptr =3D alloc_mem(sizeof(*binfo)); + zero_mem(ptr, sizeof(*binfo)); + binfo =3D _p(ptr); =20 - if ( mbi_out->flags & MBI_CMDLINE ) - mbi_out->cmdline =3D copy_string(mbi_out->cmdline); + ptr =3D alloc_mem(sizeof(*arch_binfo)); + zero_mem(ptr, sizeof(*arch_binfo)); + binfo->arch =3D ptr; + arch_binfo =3D _p(ptr); =20 - if ( mbi_out->flags & MBI_MODULES ) + if ( mbi->flags & MBI_CMDLINE ) + { + ptr =3D copy_string(mbi->cmdline); + binfo->cmdline =3D ptr; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_CMDLINE; + } + + if ( mbi->flags & MBI_MODULES ) { module_t *mods; + struct boot_module *bi_mods; + struct arch_bootmodule *arch_bi_mods; + + /* + * We have to allocate one more module slot here. At some point + * __start_xen() may put Xen image placement into it. + */ + ptr =3D alloc_mem((mbi->mods_count + 1) * sizeof(*bi_mods)); + binfo->nr_mods =3D mbi->mods_count; + binfo->mods =3D ptr; + bi_mods =3D _p(ptr); =20 - mbi_out->mods_addr =3D copy_mem(mbi_out->mods_addr, - mbi_out->mods_count * sizeof(module_= t)); + ptr =3D alloc_mem((mbi->mods_count + 1) * sizeof(*arch_bi_mods)); + arch_bi_mods =3D _p(ptr); =20 - mods =3D _p(mbi_out->mods_addr); + /* map the +1 allocated for Xen image */ + bi_mods[mbi->mods_count].arch =3D _addr(&arch_bi_mods[mbi->mods_co= unt]); =20 - for ( i =3D 0; i < mbi_out->mods_count; i++ ) + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MODULES; + + mods =3D _p(mbi->mods_addr); + + for ( i =3D 0; i < mbi->mods_count; i++ ) { + bi_mods[i].start =3D mods[i].mod_start; + bi_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + if ( mods[i].string ) - mods[i].string =3D copy_string(mods[i].string); + { + int j; + char *c =3D _p(mods[i].string); + + for ( j =3D 0; *c !=3D '\0'; j++, c++ ) + bi_mods[i].string.bytes[j] =3D *c; + + bi_mods[i].string.len =3D j + 1; + } + + bi_mods[i].arch =3D _addr(&arch_bi_mods[i]); } } =20 - if ( mbi_out->flags & MBI_MEMMAP ) - mbi_out->mmap_addr =3D copy_mem(mbi_out->mmap_addr, mbi_out->mmap_= length); - - if ( mbi_out->flags & MBI_LOADERNAME ) - mbi_out->boot_loader_name =3D copy_string(mbi_out->boot_loader_nam= e); + if ( mbi->flags & MBI_MEMMAP ) + { + arch_binfo->mmap_addr =3D copy_mem(mbi->mmap_addr, mbi->mmap_lengt= h); + arch_binfo->mmap_length =3D mbi->mmap_length; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MEMMAP; + } =20 - /* Mask features we don't understand or don't relocate. */ - mbi_out->flags &=3D (MBI_MEMLIMITS | - MBI_CMDLINE | - MBI_MODULES | - MBI_MEMMAP | - MBI_LOADERNAME); + if ( mbi->flags & MBI_LOADERNAME ) + { + ptr =3D copy_string(mbi->boot_loader_name); + arch_binfo->boot_loader_name =3D ptr; + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_LOADERNAME; + } =20 - return mbi_out; + return binfo; } =20 -static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) +static struct boot_info *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) { const multiboot2_fixed_t *mbi_fix =3D _p(mbi_in); const multiboot2_memory_map_t *mmap_src; const multiboot2_tag_t *tag; - module_t *mbi_out_mods =3D NULL; memory_map_t *mmap_dst; - multiboot_info_t *mbi_out; + struct boot_info *binfo; + struct arch_boot_info *arch_binfo; + struct boot_module *bi_mods; + struct arch_bootmodule *arch_bi_mods; #ifdef CONFIG_VIDEO struct boot_video_info *video =3D NULL; #endif u32 ptr; unsigned int i, mod_idx =3D 0; =20 - ptr =3D alloc_mem(sizeof(*mbi_out)); - mbi_out =3D _p(ptr); - zero_mem(ptr, sizeof(*mbi_out)); + ptr =3D alloc_mem(sizeof(*binfo)); + zero_mem(ptr, sizeof(*binfo)); + binfo =3D _p(ptr); + + ptr =3D alloc_mem(sizeof(*arch_binfo)); + zero_mem(ptr, sizeof(*arch_binfo)); + binfo->arch =3D ptr; + arch_binfo =3D _p(ptr); =20 /* Skip Multiboot2 information fixed part. */ ptr =3D ALIGN_UP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); @@ -206,21 +259,28 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) tag =3D _p(ALIGN_UP((u32)tag + tag->size, MULTIBOOT2_TAG_ALIGN))= ) { if ( tag->type =3D=3D MULTIBOOT2_TAG_TYPE_MODULE ) - ++mbi_out->mods_count; + ++binfo->nr_mods; else if ( tag->type =3D=3D MULTIBOOT2_TAG_TYPE_END ) break; } =20 - if ( mbi_out->mods_count ) + if ( binfo->nr_mods ) { - mbi_out->flags |=3D MBI_MODULES; /* * We have to allocate one more module slot here. At some point * __start_xen() may put Xen image placement into it. */ - mbi_out->mods_addr =3D alloc_mem((mbi_out->mods_count + 1) * - sizeof(*mbi_out_mods)); - mbi_out_mods =3D _p(mbi_out->mods_addr); + ptr =3D alloc_mem((binfo->nr_mods + 1) * sizeof(*bi_mods)); + binfo->mods =3D ptr; + bi_mods =3D _p(ptr); + + ptr =3D alloc_mem((binfo->nr_mods + 1) * sizeof(*arch_bi_mods)); + arch_bi_mods =3D _p(ptr); + + /* map the +1 allocated for Xen image */ + bi_mods[binfo->nr_mods].arch =3D _addr(&arch_bi_mods[binfo->nr_mod= s]); + + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MODULES; } =20 /* Skip Multiboot2 information fixed part. */ @@ -232,39 +292,42 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) switch ( tag->type ) { case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME: - mbi_out->flags |=3D MBI_LOADERNAME; ptr =3D get_mb2_string(tag, string, string); - mbi_out->boot_loader_name =3D copy_string(ptr); + arch_binfo->boot_loader_name =3D copy_string(ptr); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_LOADERNAME; break; =20 case MULTIBOOT2_TAG_TYPE_CMDLINE: - mbi_out->flags |=3D MBI_CMDLINE; ptr =3D get_mb2_string(tag, string, string); - mbi_out->cmdline =3D copy_string(ptr); + binfo->cmdline =3D copy_string(ptr); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_CMDLINE; break; =20 case MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO: - mbi_out->flags |=3D MBI_MEMLIMITS; - mbi_out->mem_lower =3D get_mb2_data(tag, basic_meminfo, mem_lo= wer); - mbi_out->mem_upper =3D get_mb2_data(tag, basic_meminfo, mem_up= per); + arch_binfo->mem_lower =3D get_mb2_data(tag, basic_meminfo, + mem_lower); + arch_binfo->mem_upper =3D get_mb2_data(tag, basic_meminfo, + mem_upper); break; =20 case MULTIBOOT2_TAG_TYPE_MMAP: if ( get_mb2_data(tag, mmap, entry_size) < sizeof(*mmap_src) ) break; =20 - mbi_out->flags |=3D MBI_MEMMAP; - mbi_out->mmap_length =3D get_mb2_data(tag, mmap, size); - mbi_out->mmap_length -=3D sizeof(multiboot2_tag_mmap_t); - mbi_out->mmap_length /=3D get_mb2_data(tag, mmap, entry_size); - mbi_out->mmap_length *=3D sizeof(*mmap_dst); + arch_binfo->mmap_length =3D get_mb2_data(tag, mmap, size); + arch_binfo->mmap_length -=3D sizeof(multiboot2_tag_mmap_t); + arch_binfo->mmap_length /=3D get_mb2_data(tag, mmap, entry_siz= e); + arch_binfo->mmap_length *=3D sizeof(*mmap_dst); =20 - mbi_out->mmap_addr =3D alloc_mem(mbi_out->mmap_length); + arch_binfo->mmap_addr =3D alloc_mem(arch_binfo->mmap_length); + arch_binfo->flags |=3D BOOTINFO_FLAG_X86_MEMMAP; =20 mmap_src =3D get_mb2_data(tag, mmap, entries); - mmap_dst =3D _p(mbi_out->mmap_addr); + mmap_dst =3D _p(arch_binfo->mmap_addr); =20 - for ( i =3D 0; i < mbi_out->mmap_length / sizeof(*mmap_dst); i= ++ ) + for ( i =3D 0; + i < arch_binfo->mmap_length / sizeof(*mmap_dst); + i++ ) { /* Init size member properly. */ mmap_dst[i].size =3D sizeof(*mmap_dst); @@ -280,14 +343,27 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) break; =20 case MULTIBOOT2_TAG_TYPE_MODULE: - if ( mod_idx >=3D mbi_out->mods_count ) + if ( mod_idx >=3D binfo->nr_mods ) break; =20 - mbi_out_mods[mod_idx].mod_start =3D get_mb2_data(tag, module, = mod_start); - mbi_out_mods[mod_idx].mod_end =3D get_mb2_data(tag, module, mo= d_end); + bi_mods[mod_idx].start =3D get_mb2_data(tag, module, mod_start= ); + bi_mods[mod_idx].size =3D get_mb2_data(tag, module, mod_end) + - bi_mods[mod_idx].start; + ptr =3D get_mb2_string(tag, module, cmdline); - mbi_out_mods[mod_idx].string =3D copy_string(ptr); - mbi_out_mods[mod_idx].reserved =3D 0; + if ( ptr ) + { + int i; + char *c =3D _p(ptr); + + for ( i =3D 0; *c !=3D '\0'; i++, c++ ) + bi_mods[mod_idx].string.bytes[i] =3D *c; + + bi_mods[mod_idx].string.len =3D i + 1; + } + + bi_mods[mod_idx].arch =3D _addr(&arch_bi_mods[mod_idx]); + ++mod_idx; break; =20 @@ -344,11 +420,11 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, = uint32_t video_out) video->orig_video_isVGA =3D 0x23; #endif =20 - return mbi_out; + return binfo; } =20 -void *__stdcall reloc(uint32_t magic, uint32_t in, uint32_t trampoline, - uint32_t video_info) +void *__stdcall reloc( + uint32_t magic, uint32_t in, uint32_t trampoline, uint32_t video_info) { alloc =3D trampoline; =20 diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index c94e53d139..5f14065c9c 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -11,14 +11,17 @@ #include =20 static struct file __initdata ucode; -static multiboot_info_t __initdata mbi =3D { - .flags =3D MBI_MODULES | MBI_LOADERNAME -}; + +static struct boot_info __initdata efi_bi; +static struct arch_boot_info __initdata efi_bi_arch; /* * The array size needs to be one larger than the number of modules we * support - see __start_xen(). */ -static module_t __initdata mb_modules[5]; +static struct boot_module __initdata efi_mods[MAX_NR_BOOTMODS + 1]; +static struct arch_bootmodule __initdata efi_arch_mods[MAX_NR_BOOTMODS + 1= ]; + +static const char *__initdata efi_loader =3D "PVH Directboot"; =20 static void __init edd_put_string(u8 *dst, size_t n, const char *src) { @@ -271,20 +274,37 @@ static void __init noreturn efi_arch_post_exit_boot(v= oid) : [cr3] "r" (idle_pg_table), [cs] "i" (__HYPERVISOR_CS), [ds] "r" (__HYPERVISOR_DS), - "D" (&mbi) + "D" (&efi_bi) : "memory" ); unreachable(); } =20 -static void __init efi_arch_cfg_file_early(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, - const char *section) +static struct boot_info __init *efi_arch_bootinfo_init(void) { + int i; + + efi_bi.arch =3D &efi_bi_arch; + efi_bi.mods =3D efi_mods; + + for ( i=3D0; i <=3D MAX_NR_BOOTMODS; i++ ) + efi_bi.mods[i].arch =3D &efi_arch_mods[i]; + + efi_bi_arch.boot_loader_name =3D _p(efi_loader); + + efi_bi_arch.flags =3D BOOTINFO_FLAG_X86_MODULES | + BOOTINFO_FLAG_X86_LOADERNAME; + return &efi_bi; } =20 -static void __init efi_arch_cfg_file_late(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, - const char *section) +static void __init efi_arch_cfg_file_early( + const EFI_LOADED_IMAGE *image, EFI_FILE_HANDLE dir_handle, + const char *section) +{ +} + +static void __init efi_arch_cfg_file_late( + const EFI_LOADED_IMAGE *image, EFI_FILE_HANDLE dir_handle, + const char *section) { union string name; =20 @@ -296,16 +316,15 @@ static void __init efi_arch_cfg_file_late(const EFI_L= OADED_IMAGE *image, name.s =3D get_value(&cfg, "global", "ucode"); if ( name.s ) { - microcode_set_module(mbi.mods_count); + microcode_set_module(efi_bi.nr_mods); split_string(name.s); read_file(dir_handle, s2w(&name), &ucode, NULL); efi_bs->FreePool(name.w); } } =20 -static void __init efi_arch_handle_cmdline(CHAR16 *image_name, - CHAR16 *cmdline_options, - const char *cfgfile_options) +static void __init efi_arch_handle_cmdline( + CHAR16 *image_name, CHAR16 *cmdline_options, const char *cfgfile_optio= ns) { union string name; =20 @@ -313,10 +332,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *im= age_name, { name.w =3D cmdline_options; w2s(&name); - place_string(&mbi.cmdline, name.s); + place_string((uint32_t *)efi_bi.cmdline, name.s); } if ( cfgfile_options ) - place_string(&mbi.cmdline, cfgfile_options); + place_string((uint32_t *)efi_bi.cmdline, cfgfile_options); /* Insert image name last, as it gets prefixed to the other options. */ if ( image_name ) { @@ -325,16 +344,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *im= age_name, } else name.s =3D "xen"; - place_string(&mbi.cmdline, name.s); + place_string((uint32_t *)efi_bi.cmdline, name.s); =20 - if ( mbi.cmdline ) - mbi.flags |=3D MBI_CMDLINE; - /* - * These must not be initialized statically, since the value must - * not get relocated when processing base relocations later. - */ - mbi.boot_loader_name =3D (long)"EFI"; - mbi.mods_addr =3D (long)mb_modules; + if ( efi_bi.cmdline ) + efi_bi_arch.flags |=3D BOOTINFO_FLAG_X86_CMDLINE; } =20 static void __init efi_arch_edd(void) @@ -704,9 +717,8 @@ static void __init efi_arch_memory_setup(void) #undef l2_4G_offset } =20 -static void __init efi_arch_handle_module(const struct file *file, - const CHAR16 *name, - const char *options) +static void __init efi_arch_handle_module( + const struct file *file, const CHAR16 *name, const char *options) { union string local_name; void *ptr; @@ -724,17 +736,24 @@ static void __init efi_arch_handle_module(const struc= t file *file, w2s(&local_name); =20 /* - * If options are provided, put them in - * mb_modules[mbi.mods_count].string after the filename, with a space - * separating them. place_string() prepends strings and adds separati= ng - * spaces, so the call order is reversed. + * Set module string to filename and if options are provided, put them= in + * after the filename, with a space separating them. */ + strlcpy(efi_bi.mods[efi_bi.nr_mods].string.bytes, local_name.s, + BOOTMOD_STRING_MAX_LEN); 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 =3D file->addr >> PAGE_SHIFT; - mb_modules[mbi.mods_count].mod_end =3D file->size; - ++mbi.mods_count; + { + strlcat(efi_bi.mods[efi_bi.nr_mods].string.bytes, " ", + BOOTMOD_STRING_MAX_LEN); + strlcat(efi_bi.mods[efi_bi.nr_mods].string.bytes, options, + BOOTMOD_STRING_MAX_LEN); + } + + efi_bi.mods[efi_bi.nr_mods].start =3D file->addr; + efi_bi.mods[efi_bi.nr_mods].mfn =3D maddr_to_mfn(file->addr); + efi_bi.mods[efi_bi.nr_mods].size =3D file->size; + + ++efi_bi.nr_mods; efi_bs->FreePool(ptr); } =20 diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh= -boot.c index 1ed04d035c..dd10a358da 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -6,6 +6,7 @@ * * Copyright (c) 2017 Citrix Systems Ltd. */ +#include #include #include #include @@ -20,12 +21,28 @@ bool __initdata pvh_boot; uint32_t __initdata pvh_start_info_pa; =20 -static multiboot_info_t __initdata pvh_mbi; -static module_t __initdata pvh_mbi_mods[8]; -static const char *__initdata pvh_loader =3D "PVH Directboot"; +static struct boot_info __initdata pvh_bi; +static struct arch_boot_info __initdata arch_pvh_bi; +static struct boot_module __initdata pvh_mods[MAX_NR_BOOTMODS + 1]; +static struct arch_bootmodule __initdata arch_pvh_mods[MAX_NR_BOOTMODS + 1= ]; +static char __initdata *pvh_loader =3D "PVH Directboot"; =20 -static void __init convert_pvh_info(multiboot_info_t **mbi, - module_t **mod) +static struct boot_info __init *init_pvh_info(void) +{ + int i; + + pvh_bi.arch =3D &arch_pvh_bi; + pvh_bi.mods =3D pvh_mods; + + for ( i=3D0; i <=3D MAX_NR_BOOTMODS; i++ ) + pvh_bi.mods[i].arch =3D &arch_pvh_mods[i]; + + pvh_bi.arch->boot_loader_name =3D pvh_loader; + + return &pvh_bi; +} + +static void __init convert_pvh_info(struct boot_info *bi) { const struct hvm_start_info *pvh_info =3D __va(pvh_start_info_pa); const struct hvm_modlist_entry *entry; @@ -39,23 +56,22 @@ static void __init convert_pvh_info(multiboot_info_t **= mbi, * required. The extra element is used to aid relocation. See * arch/x86/setup.c:__start_xen(). */ - if ( ARRAY_SIZE(pvh_mbi_mods) <=3D pvh_info->nr_modules ) + if ( ARRAY_SIZE(pvh_mods) <=3D pvh_info->nr_modules ) panic("The module array is too small, size %zu, requested %u\n", - ARRAY_SIZE(pvh_mbi_mods), pvh_info->nr_modules); + ARRAY_SIZE(pvh_mods), pvh_info->nr_modules); =20 /* * Turn hvm_start_info into mbi. Luckily all modules are placed under = 4GB * boundary on x86. */ - pvh_mbi.flags =3D MBI_CMDLINE | MBI_MODULES | MBI_LOADERNAME; + bi->arch->flags =3D BOOTINFO_FLAG_X86_CMDLINE | BOOTINFO_FLAG_X86_MODU= LES + | BOOTINFO_FLAG_X86_LOADERNAME; =20 BUG_ON(pvh_info->cmdline_paddr >> 32); - pvh_mbi.cmdline =3D pvh_info->cmdline_paddr; - pvh_mbi.boot_loader_name =3D __pa(pvh_loader); + bi->cmdline =3D _p(__va(pvh_info->cmdline_paddr)); =20 - BUG_ON(pvh_info->nr_modules >=3D ARRAY_SIZE(pvh_mbi_mods)); - pvh_mbi.mods_count =3D pvh_info->nr_modules; - pvh_mbi.mods_addr =3D __pa(pvh_mbi_mods); + BUG_ON(pvh_info->nr_modules >=3D ARRAY_SIZE(pvh_mods)); + bi->nr_mods =3D pvh_info->nr_modules; =20 entry =3D __va(pvh_info->modlist_paddr); for ( i =3D 0; i < pvh_info->nr_modules; i++ ) @@ -63,15 +79,18 @@ static void __init convert_pvh_info(multiboot_info_t **= mbi, BUG_ON(entry[i].paddr >> 32); BUG_ON(entry[i].cmdline_paddr >> 32); =20 - pvh_mbi_mods[i].mod_start =3D entry[i].paddr; - pvh_mbi_mods[i].mod_end =3D entry[i].paddr + entry[i].size; - pvh_mbi_mods[i].string =3D entry[i].cmdline_paddr; + bi->mods[i].start =3D entry[i].paddr; + bi->mods[i].size =3D entry[i].size; + if ( entry[i].cmdline_paddr) + { + char *c =3D _p(__va(entry[i].cmdline_paddr)); + + safe_strcpy(bi->mods[i].string.bytes, c); + bi->mods[i].string.kind =3D BOOTSTR_CMDLINE; + } } =20 rsdp_hint =3D pvh_info->rsdp_paddr; - - *mbi =3D &pvh_mbi; - *mod =3D pvh_mbi_mods; } =20 static void __init get_memory_map(void) @@ -88,13 +107,16 @@ static void __init get_memory_map(void) sanitize_e820_map(e820_raw.map, &e820_raw.nr_map); } =20 -void __init pvh_init(multiboot_info_t **mbi, module_t **mod) +void __init pvh_init(struct boot_info **bi) { - convert_pvh_info(mbi, mod); + *bi =3D init_pvh_info(); + convert_pvh_info(*bi); =20 hypervisor_probe(); ASSERT(xen_guest); =20 + (*bi)->arch->xen_guest =3D xen_guest; + get_memory_map(); } =20 diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 989fb7a1da..c1ed76fd3e 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -1,14 +1,14 @@ #ifndef __ARCH_X86_BOOTINFO_H__ #define __ARCH_X86_BOOTINFO_H__ =20 -struct arch_bootmodule { +struct __packed arch_bootmodule { #define BOOTMOD_FLAG_X86_RELOCATED 1U << 0 uint32_t flags; unsigned headroom; }; DEFINE_STRUCT_PTR_TYPE(arch_bootmodule); =20 -struct arch_boot_info { +struct __packed arch_boot_info { uint32_t flags; #define BOOTINFO_FLAG_X86_CMDLINE 1U << 2 #define BOOTINFO_FLAG_X86_MODULES 1U << 3 @@ -17,6 +17,9 @@ struct arch_boot_info { =20 char_ptr_t boot_loader_name; =20 + uint32_t mem_lower; + uint32_t mem_upper; + uint32_t mmap_length; paddr_t mmap_addr; }; diff --git a/xen/arch/x86/include/asm/guest/pvh-boot.h b/xen/arch/x86/inclu= de/asm/guest/pvh-boot.h index 247ba6899e..c820b0bf88 100644 --- a/xen/arch/x86/include/asm/guest/pvh-boot.h +++ b/xen/arch/x86/include/asm/guest/pvh-boot.h @@ -8,13 +8,13 @@ #ifndef __X86_PVH_BOOT_H__ #define __X86_PVH_BOOT_H__ =20 -#include +#include =20 #ifdef CONFIG_PVH_GUEST =20 extern bool pvh_boot; =20 -void pvh_init(multiboot_info_t **mbi, module_t **mod); +void __init pvh_init(struct boot_info **bi); void pvh_print_info(void); =20 #else @@ -23,7 +23,7 @@ void pvh_print_info(void); =20 #define pvh_boot 0 =20 -static inline void pvh_init(multiboot_info_t **mbi, module_t **mod) +static inline void __init pvh_init(struct boot_info **bi) { ASSERT_UNREACHABLE(); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 50a1a124b0..05a76a5959 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -60,9 +59,6 @@ #include #include =20 -/* Max number of boot modules a bootloader can provide in addition to Xen = */ -#define MAX_NR_BOOTMODS 63 - /* opt_nosmp: If true, secondary processors are ignored. */ static bool __initdata opt_nosmp; boolean_param("nosmp", opt_nosmp); @@ -275,46 +271,6 @@ custom_param("acpi", parse_acpi_param); =20 static struct boot_info __initdata *boot_info; =20 -static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *= mods) -{ - static struct boot_info __initdata info; - static struct arch_boot_info __initdata arch_info; - static struct boot_module __initdata boot_mods[MAX_NR_BOOTMODS + 1= ]; - static struct arch_bootmodule __initdata arch_boot_mods[ - MAX_NR_BOOTMODS + 1= ]; - - int i; - - info.arch =3D &arch_info; - info.mods =3D boot_mods; - - info.cmdline =3D __va(mbi->cmdline); - - /* The BOOTINFO_FLAG_X86_* flags are a 1-1 map to MBI_* */ - arch_info.flags =3D mbi->flags; - arch_info.mmap_length =3D mbi->mmap_length; - arch_info.mmap_addr =3D mbi->mmap_addr; - arch_info.boot_loader_name =3D __va(mbi->boot_loader_name); - - info.nr_mods =3D mbi->mods_count; - for ( i =3D 0; i <=3D MAX_NR_BOOTMODS; i++ ) - { - boot_mods[i].arch =3D &arch_boot_mods[i]; - - if ( i < info.nr_mods ) - { - bootmodule_update_start(&boot_mods[i], mods[i].mod_start); - boot_mods[i].size =3D mods[i].mod_end - mods[i].mod_start; - - boot_mods[i].string.len =3D strlcpy(boot_mods[i].string.bytes, - __va(mods[i].string), - BOOTMOD_STRING_MAX_LEN); - } - } - - boot_info =3D &info; -} - unsigned long __init initial_images_nrpages(nodeid_t node) { unsigned long node_start =3D node_start_pfn(node); @@ -1014,15 +970,13 @@ static struct domain *__init create_dom0(const struc= t boot_info *bootinfo, /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) =20 -void __init noreturn __start_xen(unsigned long mbi_p) +void __init noreturn __start_xen(unsigned long bi_p) { char *memmap_type =3D NULL; char *cmdline, *kextra, *loader; void *bsp_stack; struct cpu_info *info =3D get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked =3D 0; - multiboot_info_t *mbi; - module_t *mod; unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; @@ -1059,16 +1013,29 @@ void __init noreturn __start_xen(unsigned long mbi_= p) =20 if ( pvh_boot ) { - ASSERT(mbi_p =3D=3D 0); - pvh_init(&mbi, &mod); + ASSERT(bi_p =3D=3D 0); + pvh_init(&boot_info); } else { - mbi =3D __va(mbi_p); - mod =3D __va(mbi->mods_addr); - } + /* + * Since addresses were setup before virtual addressing was enable= d, + * fixup pointers to virtual addresses for proper dereferencing. + */ + boot_info =3D __va(bi_p); + boot_info->cmdline =3D __va(boot_info->cmdline); + boot_info->mods =3D __va(boot_info->mods); + boot_info->arch =3D __va(boot_info->arch); + + boot_info->arch->boot_loader_name =3D + __va(boot_info->arch->boot_loader_name); =20 - multiboot_to_bootinfo(mbi, mod); + for ( i =3D 0; i <=3D boot_info->nr_mods; i++ ) + { + boot_info->mods[i].mfn =3D maddr_to_mfn(boot_info->mods[i].sta= rt); + boot_info->mods[i].arch =3D __va(boot_info->mods[i].arch); + } + } =20 loader =3D (boot_info->arch->flags & BOOTINFO_FLAG_X86_LOADERNAME) ? boot_info->arch->boot_loader_name : "unknown"; diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index c5850c26af..09b38b497c 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -1359,6 +1359,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *S= ystemTable) =20 efi_arch_relocate_image(0); =20 + efi_arch_bootinfo_init(); + if ( use_cfg_file ) { EFI_FILE_HANDLE dir_handle; diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index bf5586a76b..6e09be6899 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -20,13 +20,16 @@ #define BOOTMOD_GUEST_DTB 7 typedef unsigned int bootmod_type_t; =20 +/* Max number of boot modules a bootloader can provide in addition to Xen = */ +#define MAX_NR_BOOTMODS 63 + #define BOOTMOD_STRING_MAX_LEN 1024 -struct boot_string { +struct __packed boot_string { char bytes[BOOTMOD_STRING_MAX_LEN]; size_t len; }; =20 -struct boot_module { +struct __packed boot_module { bootmod_type_t bootmod_type; paddr_t start; mfn_t mfn; @@ -37,7 +40,7 @@ struct boot_module { }; DEFINE_STRUCT_PTR_TYPE(boot_module); =20 -struct boot_info { +struct __packed boot_info { char_ptr_t cmdline; =20 unsigned int nr_mods; --=20 2.25.1