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

[PATCH v5 21/44] x86/boot: convert ramdisk locating to struct boot_module


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Sun, 6 Oct 2024 17:49:32 -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=1728251430; 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=KVTUDBf5itHqMtcxsfp0xgFE01OmBqCDzmFITv9nlQc=; b=BiV8zUzkA4pwde/ZeTvSzmQl7S/0z/w+sZ7jozKPUjtXQfPtdAC7H3xaMaiKMqnqFRuO8IK5+giXdmkzGi85VagWERViZd98Wshh57ttmNuz4EqRDM+ZiPGGHPeLXzIRNGGN+6T8y/v4gfhCqm84doieY3/7gkwVNyQbWkGuSL4=
  • Arc-seal: i=1; a=rsa-sha256; t=1728251430; cv=none; d=zohomail.com; s=zohoarc; b=jJzy7FhjHrKYYkfDzW82tNVzizfhfrM5oeOLo+W/ef03H2uzWQZE1RMJbmomBzr7yuJ5tRm/lTK3cOS7peDUVExqmeZw/GAPey/qiSyJQkNF6+vRm/XnQ0mcf0xSpDvbhzv+UjxmSAp99qVwmxY3y16CbU6jZIBv7l1Uz3Bh5Dk=
  • 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: Sun, 06 Oct 2024 21:57:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Locate the first unclaimed struct boot_module and mark it as ramdisk. If there
are any remaining unclaimed struct boot_module instances, report to the
console. In the change, the new boot module iterator is used to find the
initrd index, which returns a signed int. Switch initrdidx from unsigned to
signed.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
 xen/arch/x86/setup.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index e560fa798d71..e42afb0c30cb 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1033,7 +1033,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long 
mbi_p)
     char *kextra;
     void *bsp_stack;
     struct cpu_info *info = get_cpu_info(), *bsp_info;
-    unsigned int initrdidx, num_parked = 0;
+    unsigned int num_parked = 0;
     struct boot_info *bi;
     multiboot_info_t *mbi;
     module_t *mod;
@@ -1042,7 +1042,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long 
mbi_p)
     unsigned long eb_start, eb_end;
     bool acpi_boot_table_init_done = false, relocated = false;
     bool vm_init_done = false;
-    int ret;
+    int initrdidx, ret;
     struct ns16550_defaults ns16550 = {
         .data_bits = 8,
         .parity    = 'n',
@@ -2085,20 +2085,30 @@ void asmlinkage __init noreturn __start_xen(unsigned 
long mbi_p)
            cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ",
            cpu_has_nx ? "" : "not ");
 
-    initrdidx = find_first_bit(module_map, bi->nr_modules);
-    bi->mods[initrdidx].type = BOOTMOD_RAMDISK;
-    bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED;
-    if ( bitmap_weight(module_map, bi->nr_modules) > 1 )
-        printk(XENLOG_WARNING
-               "Multiple initrd candidates, picking module #%u\n",
-               initrdidx);
+    /*
+     * At this point all capabilities that consume boot modules should have
+     * claimed their boot modules. Find the first unclaimed boot module and
+     * claim it as the initrd ramdisk. Do a second search to see if there are
+     * any remaining unclaimed boot modules, and report them as unusued initrd
+     * candidates.
+     */
+    initrdidx = first_boot_module_index(bi, BOOTMOD_UNKNOWN);
+    if ( initrdidx >= 0 )
+    {
+        bi->mods[initrdidx].type = BOOTMOD_RAMDISK;
+        bi->mods[initrdidx].flags |= BOOTMOD_FLAG_X86_CONSUMED;
+        if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) >= 0 )
+            printk(XENLOG_WARNING
+                   "Multiple initrd candidates, picking module #%u\n",
+                   initrdidx);
+    }
 
     /*
      * We're going to setup domain0 using the module(s) that we stashed safely
      * above our heap. The second module, if present, is an initrd ramdisk.
      */
     dom0 = create_dom0(bi->mods[0].mod, bi->mods[0].headroom,
-                       initrdidx < bi->nr_modules ?
+                       (initrdidx >= 0 && initrdidx < bi->nr_modules) ?
                             bi->mods[initrdidx].mod : NULL,
                        kextra, bi->loader);
     if ( !dom0 )
-- 
2.30.2




 


Rackspace

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