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>
---
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