]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/EFI: avoid Xen image when looking for module/kexec position
authorJan Beulich <jbeulich@suse.com>
Mon, 20 Mar 2017 08:27:12 +0000 (09:27 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 20 Mar 2017 08:27:12 +0000 (09:27 +0100)
When booting straight from EFI, we don't further try to relocate Xen.
As a result, so far we also didn't avoid the area Xen uses when looking
for a location to put modules or the kexec area. Introduce a fake
module slot to deal with that without having to fiddle with a lot of
code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/efi/efi-boot.h
xen/arch/x86/setup.c

index 15f6d2ed9e220a1dd483749e023de61a10b07fc7..0e1c190539ec49104b426610d741204bd44b12b9 100644 (file)
@@ -13,7 +13,11 @@ static struct file __initdata ucode;
 static multiboot_info_t __initdata mbi = {
     .flags = MBI_MODULES | MBI_LOADERNAME
 };
-static module_t __initdata mb_modules[4];
+/*
+ * The array size needs to be one larger than the number of modules we
+ * support - see __start_xen().
+ */
+static module_t __initdata mb_modules[5];
 
 static void __init edd_put_string(u8 *dst, size_t n, const char *src)
 {
index 7ff62a79feb381dd20470af29f585ea2d8fd733c..1cd290e4657ac80fdc7837ef093bbf7f7b831580 100644 (file)
@@ -887,6 +887,16 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         mod[i].reserved = 0;
     }
 
+    if ( efi_enabled(EFI_LOADER) )
+    {
+        /*
+         * This needs to remain in sync with xen_in_range() and the
+         * respective reserve_e820_ram() invocation below.
+         */
+        mod[mbi->mods_count].mod_start = virt_to_mfn(_stext);
+        mod[mbi->mods_count].mod_end = __2M_rwdata_end - _stext;
+    }
+
     modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end);
     bootstrap_map(NULL);
 
@@ -1067,8 +1077,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             if ( mod[j].reserved )
                 continue;
 
-            /* Don't overlap with other modules. */
-            end = consider_modules(s, e, size, mod, mbi->mods_count, j);
+            /* Don't overlap with other modules (or Xen itself). */
+            end = consider_modules(s, e, size, mod,
+                                   mbi->mods_count + efi_enabled(EFI_LOADER),
+                                   j);
 
             if ( highmem_start && end > highmem_start )
                 continue;
@@ -1093,9 +1105,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)
          */
         while ( !kexec_crash_area.start )
         {
-            /* Don't overlap with modules. */
-            e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size),
-                                 mod, mbi->mods_count, -1);
+            /* Don't overlap with modules (or Xen itself). */
+            e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), mod,
+                                 mbi->mods_count + efi_enabled(EFI_LOADER), -1);
             if ( s >= e )
                 break;
             if ( e > kexec_crash_area_limit )