• Borislav Petkov's avatar
    x86/efi: Make efi virtual runtime map passing more robust · b7b898ae
    Borislav Petkov authored
    Currently, running SetVirtualAddressMap() and passing the physical
    address of the virtual map array was working only by a lucky coincidence
    because the memory was present in the EFI page table too. Until Toshi
    went and booted this on a big HP box - the krealloc() manner of resizing
    the memmap we're doing did allocate from such physical addresses which
    were not mapped anymore and boom:
    
    http://lkml.kernel.org/r/1386806463.1791.295.camel@misato.fc.hp.com
    
    One way to take care of that issue is to reimplement the krealloc thing
    but with pages. We start with contiguous pages of order 1, i.e. 2 pages,
    and when we deplete that memory (shouldn't happen all that often but you
    know firmware) we realloc the next power-of-two pages.
    
    Having the pages, it is much more handy and easy to map them into the
    EFI page table with the already existing mapping code which we're using
    for building the virtual mappings.
    
    Thanks to Toshi Kani and Matt for the great debugging help.
    Reported-by: default avatarToshi Kani <toshi.kani@hp.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Tested-by: default avatarToshi Kani <toshi.kani@hp.com>
    Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
    b7b898ae
efi_64.c 6.74 KB