x86/efi: Test for EFI_MEMMAP functionality when iterating EFI memmap
authorMatt Fleming <matt@codeblueprint.co.uk>
Tue, 21 Jun 2016 22:11:38 +0000 (23:11 +0100)
committerMatt Fleming <matt@codeblueprint.co.uk>
Fri, 9 Sep 2016 15:06:34 +0000 (16:06 +0100)
Both efi_find_mirror() and efi_fake_memmap() really want to know
whether the EFI memory map is available, not just whether the machine
was booted using EFI. efi_fake_memmap() even has a check for
EFI_MEMMAP at the start of the function.

Since we've already got other code that has this dependency, merge
everything under one if() conditional, and remove the now superfluous
check from efi_fake_memmap().

Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
arch/x86/kernel/setup.c
drivers/firmware/efi/fake_mem.c

index 0fa60f5f5a1641dc8eb2c82968dbadd650ed6e37..4fd69e532c15d94480e02bc37d549f187cc8c830 100644 (file)
@@ -1096,19 +1096,18 @@ void __init setup_arch(char **cmdline_p)
        memblock_set_current_limit(ISA_END_ADDRESS);
        memblock_x86_fill();
 
-       if (efi_enabled(EFI_BOOT)) {
+       reserve_bios_regions();
+
+       if (efi_enabled(EFI_MEMMAP)) {
                efi_fake_memmap();
                efi_find_mirror();
-       }
-
-       reserve_bios_regions();
 
-       /*
-        * The EFI specification says that boot service code won't be called
-        * after ExitBootServices(). This is, in fact, a lie.
-        */
-       if (efi_enabled(EFI_MEMMAP))
+               /*
+                * The EFI specification says that boot service code won't be
+                * called after ExitBootServices(). This is, in fact, a lie.
+                */
                efi_reserve_boot_services();
+       }
 
        /* preallocate 4k for mptable mpc */
        early_reserve_e820_mpc_new();
index 48430aba13c189d3cad7f04c6e5ee036701f113c..c437388a7b8521f9392b5dde96e14ab24429b9c2 100644 (file)
@@ -64,7 +64,7 @@ void __init efi_fake_memmap(void)
        void *old, *new;
        int i;
 
-       if (!nr_fake_mem || !efi_enabled(EFI_MEMMAP))
+       if (!nr_fake_mem)
                return;
 
        /* count up the number of EFI memory descriptor */