• Ard Biesheuvel's avatar
    efi/libstub/x86: Work around page freeing issue in mixed mode · 23e60394
    Ard Biesheuvel authored
    Mixed mode translates calls from the 64-bit kernel into the 32-bit
    firmware by wrapping them in a call to a thunking routine that
    pushes a 32-bit word onto the stack for each argument passed to the
    function, regardless of the argument type. This works surprisingly
    well for most services and protocols, with the exception of ones that
    take explicit 64-bit arguments.
    
    efi_free() invokes the FreePages() EFI boot service, which takes
    a efi_physical_addr_t as its address argument, and this is one of
    those 64-bit types. This means that the 32-bit firmware will
    interpret the (addr, size) pair as a single 64-bit quantity, and
    since it is guaranteed to have the high word set (as size > 0),
    it will always fail due to the fact that EFI memory allocations are
    always < 4 GB on 32-bit firmware.
    
    So let's fix this by giving the thunking code a little hand, and
    pass two values for the address, and a third one for the size.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Cc: Arvind Sankar <nivedita@alum.mit.edu>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: James Morse <james.morse@arm.com>
    Cc: Matt Fleming <matt@codeblueprint.co.uk>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-efi@vger.kernel.org
    Link: https://lkml.kernel.org/r/20191224151025.32482-21-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    23e60394
efi-stub-helper.c 22.4 KB