• Peter Jones's avatar
    efi/x86: Prune invalid memory map entries and fix boot regression · 0100a3e6
    Peter Jones authored
    Some machines, such as the Lenovo ThinkPad W541 with firmware GNET80WW
    (2.28), include memory map entries with phys_addr=0x0 and num_pages=0.
    
    These machines fail to boot after the following commit,
    
      commit 8e80632f ("efi/esrt: Use efi_mem_reserve() and avoid a kmalloc()")
    
    Fix this by removing such bogus entries from the memory map.
    
    Furthermore, currently the log output for this case (with efi=debug)
    looks like:
    
     [    0.000000] efi: mem45: [Reserved           |   |  |  |  |  |  |  |  |  |  |  |  ] range=[0x0000000000000000-0xffffffffffffffff] (0MB)
    
    This is clearly wrong, and also not as informative as it could be.  This
    patch changes it so that if we find obviously invalid memory map
    entries, we print an error and skip those entries.  It also detects the
    display of the address range calculation overflow, so the new output is:
    
     [    0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries:
     [    0.000000] efi: mem45: [Reserved           |   |  |  |  |  |  |  |   |  |  |  |  ] range=[0x0000000000000000-0x0000000000000000] (invalid)
    
    It also detects memory map sizes that would overflow the physical
    address, for example phys_addr=0xfffffffffffff000 and
    num_pages=0x0200000000000001, and prints:
    
     [    0.000000] efi: [Firmware Bug]: Invalid EFI memory map entries:
     [    0.000000] efi: mem45: [Reserved           |   |  |  |  |  |  |  |   |  |  |  |  ] range=[phys_addr=0xfffffffffffff000-0x20ffffffffffffffff] (invalid)
    
    It then removes these entries from the memory map.
    Signed-off-by: default avatarPeter Jones <pjones@redhat.com>
    Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
    [ardb: refactor for clarity with no functional changes, avoid PAGE_SHIFT]
    Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
    [Matt: Include bugzilla info in commit log]
    Cc: <stable@vger.kernel.org> # v4.9+
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=191121Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    0100a3e6
efi.c 26.6 KB