]> xenbits.xensource.com Git - xen.git/commitdiff
x86/boot: introduce boot module types
authorDaniel P. Smith <dpsmith@apertussolutions.com>
Sat, 2 Nov 2024 17:25:40 +0000 (13:25 -0400)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 6 Nov 2024 19:00:23 +0000 (19:00 +0000)
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@apertussolutions.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/microcode/core.c
xen/arch/x86/include/asm/bootinfo.h
xen/arch/x86/setup.c
xen/xsm/xsm_policy.c

index 54ce1b5e2ba6247e566e0fd7c2388299875e7149..c0619b124e311b99bc6a817af198d1365b4e1ba0 100644 (file)
@@ -821,6 +821,10 @@ static int __init early_microcode_load(struct boot_info *bi)
                 continue;
             }
 
+            /*
+             * Do not alter this boot module's type.  We're most likely
+             * peeking at dom0's initrd.
+             */
             data = cd.data;
             size = cd.size;
             goto found;
@@ -852,6 +856,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]);
index 6237da7e4d863571b997d260e7472af8035f4b12..fc74e3b224e72c310d9248b6857c577a8e556263 100644 (file)
 /* 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;
 };
 
 /*
index 5db57e1b1af254579b391d4e1b22667fbfe6a439..fac08b6242e984a8438a09b3916750e35c931caa 100644 (file)
@@ -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",
index 35f36c6f2359a87374c110f0bf4940b3c56bbcc9..4c195411d05b916992d516bd00f2495fde4e90d1 100644 (file)
@@ -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;
 
         }