lkml.org 
[lkml]   [2019]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH 00/10] efi/x86: confine type unsafe casting to mixed mode
Date
Currently, we support mixed mode (64-bit Linux running on 32-bit firmware)
by explicitly reasoning about pointer sizes for every call into the
firmware: on x86, there are 32-bit and 64-bit versions of each protocol
interface, and each call gets routed via one of the two, depending on the
native size of the firmware.

There is a lot of casting and pointer mangling involved in this, and as
a result, we end up with much less coverage in terms of type checking by
the compiler, due to the indirection via an anonymous, variadic thunking
routine.

This peculiarity of x86 is also leaking into generic EFI code, which is
shared with ia64, arm64, ARM and likely RiscV in the future. So let's
try to clean this up a bit.

The approach taken by this series is to replace the 32/64 bit distinction
with a distinction between native calls and mixed mode calls, where the
former can be either 32 or 64 bit [depending on the platform] and use
the ordinary native protocol definitions, while mixed mode calls retain
the existing casting/thunking approach based on the 32-bit protocol
definitions.

Given that GCC now supports emitting function calls using the MS calling
convention, we can get rid of all the wrapping and casting, and emit the
indirect calls directly.

Code can be found here
https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=efistub-x86-cleanup

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Matthew Garrett <matthewgarrett@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Arvind Sankar <nivedita@alum.mit.edu>

Ard Biesheuvel (10):
efi/libstub: remove unused __efi_call_early() macro
efi/x86: rename efi_is_native() to efi_is_mixed()
efi/libstub: use a helper to iterate over a EFI handle array
efi/libstub: add missing apple_properties_protocol_t definition
efi/libstub: distinguish between native/mixed not 32/64 bit
efi/libstub/x86: use mixed mode helpers to populate efi_config
efi/libstub: drop explicit 64-bit protocol definitions
efi/libstub: use stricter typing for firmware function pointers
efi/libstub: annotate firmware routines as __efiapi
efi/libstub/x86: avoid thunking for native firmware calls

arch/arm/include/asm/efi.h | 3 +-
arch/arm64/include/asm/efi.h | 3 +-
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 2 +-
arch/x86/boot/compressed/eboot.c | 51 ++--
arch/x86/boot/compressed/eboot.h | 11 +-
arch/x86/boot/compressed/efi_stub_32.S | 87 ------
arch/x86/boot/compressed/efi_stub_64.S | 5 -
arch/x86/boot/compressed/head_32.S | 8 +-
arch/x86/boot/compressed/head_64.S | 12 -
arch/x86/include/asm/efi.h | 64 ++--
arch/x86/platform/efi/efi.c | 12 +-
arch/x86/platform/efi/efi_64.c | 6 +-
arch/x86/platform/efi/quirks.c | 2 +-
.../firmware/efi/libstub/efi-stub-helper.c | 46 ++-
drivers/firmware/efi/libstub/gop.c | 9 +-
drivers/firmware/efi/libstub/pci.c | 9 +-
drivers/firmware/efi/libstub/random.c | 13 +-
drivers/firmware/efi/libstub/tpm.c | 4 +-
include/linux/efi.h | 278 ++++++------------
20 files changed, 195 insertions(+), 431 deletions(-)
delete mode 100644 arch/x86/boot/compressed/efi_stub_32.S
delete mode 100644 arch/x86/boot/compressed/efi_stub_64.S

--
2.17.1

\
 
 \ /
  Last update: 2019-12-14 18:58    [W:0.174 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site