]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/setup: simplify handling of initrdidx when no initrd present
authorDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 31 Jan 2020 22:41:30 +0000 (22:41 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 18 Mar 2020 08:54:26 +0000 (08:54 +0000)
Remove a ternary operator that made my brain hurt.

Replace it with something simpler that makes it somewhat clearer that
the check for initrdidx < mbi->mods_count is because larger values are
what find_first_bit() will return when it doesn't find anything.

Also drop the explicit check for module #0 since that would be the
dom0 kernel and the corresponding bit is always clear in module_map.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Acked-by: Julien Grall <julien@xen.org>
xen/arch/x86/setup.c

index c87040c8906e0537993a242c1a70ecca9ef3418e..2986cf5a3a698621b90c5c7684ccb714918d2ccd 100644 (file)
@@ -688,7 +688,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     char *cmdline, *kextra, *loader;
     unsigned int initrdidx, num_parked = 0;
     multiboot_info_t *mbi;
-    module_t *mod;
+    module_t *mod, *initrd = NULL;
     unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1];
     int i, j, e820_warn = 0, bytes = 0;
     bool acpi_boot_table_init_done = false, relocated = false;
@@ -1798,6 +1798,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         xen_processor_pmbits |= XEN_PROCESSOR_PM_CX;
 
     initrdidx = find_first_bit(module_map, mbi->mods_count);
+    if ( initrdidx < mbi->mods_count )
+        initrd = mod + initrdidx;
     if ( bitmap_weight(module_map, mbi->mods_count) > 1 )
         printk(XENLOG_WARNING
                "Multiple initrd candidates, picking module #%u\n",
@@ -1822,9 +1824,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
      * 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.
      */
-    if ( construct_dom0(dom0, mod, modules_headroom,
-                        (initrdidx > 0) && (initrdidx < mbi->mods_count)
-                        ? mod + initrdidx : NULL, cmdline) != 0)
+    if ( construct_dom0(dom0, mod, modules_headroom, initrd, cmdline) != 0 )
         panic("Could not set up DOM0 guest OS\n");
 
     if ( cpu_has_smap )