[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 01/12] x86/boot: introduce boot module types


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Sat, 2 Nov 2024 13:25:40 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568367; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Gr0Bo47Cp6rQWLc3HgBA4fLt5SBG4Kw79tWuOGibWjw=; b=YEHhRXWhPRKmxq7TQtkZ+2NLoZaFumFTmmeQ137suNCGxKEPtACcFjD81jKRKwYwiwMrWuc/DIAlfmsAzMo50Gx0til4OmfzmjCFJZVCRIEzq6AoVPUhP42On9AlUbS9myf4F3ho0Q28wGN21+qMbQAPdMJ9OkNoHpwp5zHhlZg=
  • Arc-seal: i=1; a=rsa-sha256; t=1730568367; cv=none; d=zohomail.com; s=zohoarc; b=gOXvqeIJINXmDJf/CC0P5TlgB3n0EUwvGeb85hEV3ewSRZFI1GOG1Kv0dEwF4cw3zEjQC0aO2A1bJe4YcKq7pBRlyywkOMvGNym+OwxYxllX+4fcfptq1HDgUUoL0hFhW0vc5xgwh8F6CsdLZtNoP5MEPj+OKExfrAUQjX6VDPU=
  • Cc: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, jason.andryuk@xxxxxxx, christopher.w.clark@xxxxxxxxx, stefano.stabellini@xxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Sat, 02 Nov 2024 17:26:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This commit introduces module types for the types of boot modules that may be
passed to Xen. These include xen, kernel, ramdisk, microcode, and xsm policy.
This reduces the need for hard coded order assumptions and global variables to
be used by consumers of boot modules, such as domain construction.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
Changes since v7:
- merged the addition of microcode and xsm boot mod types

Changes since v5:
- added guard around initrd type assignment
- removed a missed rebase artifact
---
 xen/arch/x86/cpu/microcode/core.c   |  1 +
 xen/arch/x86/include/asm/bootinfo.h | 12 ++++++++++++
 xen/arch/x86/setup.c                |  4 ++++
 xen/xsm/xsm_policy.c                |  1 +
 4 files changed, 18 insertions(+)

diff --git a/xen/arch/x86/cpu/microcode/core.c 
b/xen/arch/x86/cpu/microcode/core.c
index 1fa6cbf3d364..f46464241557 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -845,6 +845,7 @@ static int __init early_microcode_load(struct boot_info *bi)
             printk(XENLOG_WARNING "Microcode: Chosen module %d already 
used\n", idx);
             return -ENODEV;
         }
+        bi->mods[idx].type = BOOTMOD_MICROCODE;
 
         size = bi->mods[idx].mod->mod_end;
         data = bootstrap_map_bm(&bi->mods[idx]);
diff --git a/xen/arch/x86/include/asm/bootinfo.h 
b/xen/arch/x86/include/asm/bootinfo.h
index 6237da7e4d86..fc74e3b224e7 100644
--- a/xen/arch/x86/include/asm/bootinfo.h
+++ b/xen/arch/x86/include/asm/bootinfo.h
@@ -14,9 +14,21 @@
 /* Max number of boot modules a bootloader can provide in addition to Xen */
 #define MAX_NR_BOOTMODS 63
 
+/* Boot module binary type / purpose */
+enum bootmod_type {
+    BOOTMOD_UNKNOWN,
+    BOOTMOD_XEN,
+    BOOTMOD_KERNEL,
+    BOOTMOD_RAMDISK,
+    BOOTMOD_MICROCODE,
+    BOOTMOD_XSM_POLICY,
+};
+
 struct boot_module {
     /* Transitionary only */
     module_t *mod;
+
+    enum bootmod_type type;
 };
 
 /*
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 5db57e1b1af2..fac08b6242e9 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -316,6 +316,7 @@ static struct boot_info *__init multiboot_fill_boot_info(
 
     /* Variable 'i' should be one entry past the last module. */
     bi->mods[i].mod = &mods[bi->nr_modules];
+    bi->mods[i].type = BOOTMOD_XEN;
 
     return bi;
 }
@@ -1217,6 +1218,7 @@ void asmlinkage __init noreturn __start_xen(void)
 
     bitmap_fill(module_map, bi->nr_modules);
     __clear_bit(0, module_map); /* Dom0 kernel is always first */
+    bi->mods[0].type = BOOTMOD_KERNEL;
 
     if ( pvh_boot )
     {
@@ -2097,6 +2099,8 @@ void asmlinkage __init noreturn __start_xen(void)
            cpu_has_nx ? "" : "not ");
 
     initrdidx = find_first_bit(module_map, bi->nr_modules);
+    if ( initrdidx < bi->nr_modules )
+        bi->mods[initrdidx].type = BOOTMOD_RAMDISK;
     if ( bitmap_weight(module_map, bi->nr_modules) > 1 )
         printk(XENLOG_WARNING
                "Multiple initrd candidates, picking module #%u\n",
diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c
index 35f36c6f2359..4c195411d05b 100644
--- a/xen/xsm/xsm_policy.c
+++ b/xen/xsm/xsm_policy.c
@@ -59,6 +59,7 @@ int __init xsm_multiboot_policy_init(
                    _policy_len,_policy_start);
 
             __clear_bit(i, bi->module_map);
+            bi->mods[i].type = BOOTMOD_XSM_POLICY;
             break;
 
         }
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.