This commit introduces module types of xen, kernel, and ramdisk to allow boot
module detect code to tag the purpose of a boot module. 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>
---
xen/arch/x86/include/asm/bootinfo.h | 9 +++++++++
xen/arch/x86/setup.c | 3 +++
2 files changed, 12 insertions(+)
diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h
index 3e0e36df096b..1b1b640f83f7 100644
--- a/xen/arch/x86/include/asm/bootinfo.h
+++ b/xen/arch/x86/include/asm/bootinfo.h
@@ -11,9 +11,18 @@
#include <xen/multiboot.h>
#include <xen/types.h>
+/* Boot module binary type / purpose */
+enum bootmod_type {
+ BOOTMOD_UNKNOWN,
+ BOOTMOD_XEN,
+ BOOTMOD_KERNEL,
+ BOOTMOD_RAMDISK,
+};
+
struct boot_module {
module_t *early_mod;
unsigned long headroom;
+ enum bootmod_type type;
};
struct boot_info {
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index d4f557b4c50d..8d5450c981a8 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -314,6 +314,7 @@ static void __init multiboot_to_bootinfo(multiboot_info_t *mbi, module_t *mods)
boot_mods[i].early_mod = &mods[i];
/* map the last mb module for xen entry */
+ boot_mods[info.nr_mods].type = BOOTMOD_XEN;
boot_mods[info.nr_mods].early_mod = &mods[info.nr_mods];
boot_info = &info;
@@ -1197,6 +1198,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
bitmap_fill(module_map, boot_info->nr_mods);
__clear_bit(0, module_map); /* Dom0 kernel is always first */
+ boot_info->mods[0].type = BOOTMOD_KERNEL;
if ( pvh_boot )
{
@@ -2085,6 +2087,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
cpu_has_nx ? "" : "not ");
initrdidx = find_first_bit(module_map, boot_info->nr_mods);
+ boot_info->mods[initrdidx].type = BOOTMOD_RAMDISK;
if ( bitmap_weight(module_map, boot_info->nr_mods) > 1 )
printk(XENLOG_WARNING
"Multiple initrd candidates, picking module #%u\n",
--
2.30.2