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

[xen master] x86/boot: introduce boot module types



commit 5899b749b8f1a074919232cc76e8209d13f47439
Author:     Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
AuthorDate: Sat Nov 2 13:25:40 2024 -0400
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Nov 6 19:00:23 2024 +0000

    x86/boot: introduce boot module types
    
    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>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/cpu/microcode/core.c   |  5 +++++
 xen/arch/x86/include/asm/bootinfo.h | 12 ++++++++++++
 xen/arch/x86/setup.c                |  4 ++++
 xen/xsm/xsm_policy.c                |  1 +
 4 files changed, 22 insertions(+)

diff --git a/xen/arch/x86/cpu/microcode/core.c 
b/xen/arch/x86/cpu/microcode/core.c
index 54ce1b5e2b..c0619b124e 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -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]);
diff --git a/xen/arch/x86/include/asm/bootinfo.h 
b/xen/arch/x86/include/asm/bootinfo.h
index 6237da7e4d..fc74e3b224 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 5db57e1b1a..fac08b6242 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 35f36c6f23..4c195411d0 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;
 
         }
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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