]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
x86: reserve EFI memory map with reserve_early
authorHuang, Ying <ying.huang@intel.com>
Mon, 2 Jun 2008 06:26:21 +0000 (14:26 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 5 Jun 2008 13:10:02 +0000 (15:10 +0200)
This patch reserves the EFI memory map with reserve_early(). Because EFI
memory map is allocated by bootloader, if it is not reserved by
reserved_early(), it may be overwritten through address returned by
find_e820_area().

Signed-off-by: Huang Ying <ying.huang@intel.com>
Cc: andi@firstfloor.org
Cc: mingo@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/efi.c
arch/x86/kernel/efi_64.c
arch/x86/kernel/setup_32.c
arch/x86/kernel/setup_64.c
include/asm-x86/efi.h

index 4a1a26d5931fc488f818b400b03cb3f283dd455c..d5c7fcdd18610690fe51e116105198736b096f7f 100644 (file)
@@ -238,6 +238,23 @@ static void __init add_efi_memmap(void)
        sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 }
 
+void __init efi_reserve_early(void)
+{
+       unsigned long pmap;
+
+       pmap = boot_params.efi_info.efi_memmap;
+#ifdef CONFIG_X86_64
+       pmap += (__u64)boot_params.efi_info.efi_memmap_hi << 32;
+#endif
+       memmap.phys_map = (void *)pmap;
+       memmap.nr_map = boot_params.efi_info.efi_memmap_size /
+               boot_params.efi_info.efi_memdesc_size;
+       memmap.desc_version = boot_params.efi_info.efi_memdesc_version;
+       memmap.desc_size = boot_params.efi_info.efi_memdesc_size;
+       reserve_early(pmap, pmap + memmap.nr_map * memmap.desc_size,
+                     "EFI memmap");
+}
+
 #if EFI_DEBUG
 static void __init print_efi_memmap(void)
 {
@@ -267,21 +284,11 @@ void __init efi_init(void)
        int i = 0;
        void *tmp;
 
-#ifdef CONFIG_X86_32
        efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
-       memmap.phys_map = (void *)boot_params.efi_info.efi_memmap;
-#else
-       efi_phys.systab = (efi_system_table_t *)
-               (boot_params.efi_info.efi_systab |
-                ((__u64)boot_params.efi_info.efi_systab_hi<<32));
-       memmap.phys_map = (void *)
-               (boot_params.efi_info.efi_memmap |
-                ((__u64)boot_params.efi_info.efi_memmap_hi<<32));
+#ifdef CONFIG_X86_64
+       efi_phys.systab = (void *)efi_phys.systab +
+               ((__u64)boot_params.efi_info.efi_systab_hi<<32);
 #endif
-       memmap.nr_map = boot_params.efi_info.efi_memmap_size /
-               boot_params.efi_info.efi_memdesc_size;
-       memmap.desc_version = boot_params.efi_info.efi_memdesc_version;
-       memmap.desc_size = boot_params.efi_info.efi_memdesc_size;
 
        efi.systab = early_ioremap((unsigned long)efi_phys.systab,
                                   sizeof(efi_system_table_t));
index 21a7b759687a59a0b07b4c615184fdb2508eca83..652c5287215fdb9500e4013794d559cfc4ace801 100644 (file)
@@ -97,12 +97,6 @@ void __init efi_call_phys_epilog(void)
        early_runtime_code_mapping_set_exec(0);
 }
 
-void __init efi_reserve_bootmem(void)
-{
-       reserve_bootmem_generic((unsigned long)memmap.phys_map,
-                               memmap.nr_map * memmap.desc_size);
-}
-
 void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size)
 {
        static unsigned pages_mapped __initdata;
index 0ec6480aaa27a1b0ff4708f0a8195e18919ab6fe..2960cbecfa5aac64c148da7cb8a0832862dcfc03 100644 (file)
@@ -67,6 +67,7 @@
 #include <asm/bios_ebda.h>
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
+#include <asm/efi.h>
 
 /* This value is set up by the early boot code to point to the value
    immediately after the boot time page tables.  It contains a *physical*
@@ -683,8 +684,10 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_EFI
        if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-                    "EL32", 4))
+                    "EL32", 4)) {
                efi_enabled = 1;
+               efi_reserve_early();
+       }
 #endif
 
        ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
index 2599b27442073772ff6067ee4389a9c941aeec96..078c02f6f5f99bace4212c40ae8075859e22894b 100644 (file)
@@ -330,8 +330,10 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #ifdef CONFIG_EFI
        if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-                    "EL64", 4))
+                    "EL64", 4)) {
                efi_enabled = 1;
+               efi_reserve_early();
+       }
 #endif
 
        ARCH_SETUP
@@ -457,9 +459,6 @@ void __init setup_arch(char **cmdline_p)
        acpi_reserve_bootmem();
 #endif
 
-       if (efi_enabled)
-               efi_reserve_bootmem();
-
 #ifdef CONFIG_X86_MPPARSE
        /*
        * Find and reserve possible boot-time SMP configuration:
index d53004b855cce82b6303cbe8adde1bf47d450977..7ed2bd7a7f51c3621b26acde91bdaa65f36d9f96 100644 (file)
@@ -90,7 +90,7 @@ extern void *efi_ioremap(unsigned long addr, unsigned long size);
 
 #endif /* CONFIG_X86_32 */
 
-extern void efi_reserve_bootmem(void);
+extern void efi_reserve_early(void);
 extern void efi_call_phys_prelog(void);
 extern void efi_call_phys_epilog(void);