linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] efi/x86: confine type unsafe casting to mixed mode
@ 2019-12-14 17:57 Ard Biesheuvel
  2019-12-14 17:57 ` [PATCH 01/10] efi/libstub: remove unused __efi_call_early() macro Ard Biesheuvel
                   ` (9 more replies)
  0 siblings, 10 replies; 29+ messages in thread
From: Ard Biesheuvel @ 2019-12-14 17:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-efi, Ard Biesheuvel, Hans de Goede, Matthew Garrett,
	Ingo Molnar, Andy Lutomirski, Thomas Gleixner, Arvind Sankar

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


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2019-12-17 15:01 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-14 17:57 [PATCH 00/10] efi/x86: confine type unsafe casting to mixed mode Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 01/10] efi/libstub: remove unused __efi_call_early() macro Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 02/10] efi/x86: rename efi_is_native() to efi_is_mixed() Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 03/10] efi/libstub: use a helper to iterate over a EFI handle array Ard Biesheuvel
2019-12-14 20:32   ` Arvind Sankar
2019-12-14 20:40     ` Ard Biesheuvel
2019-12-14 21:04       ` Ard Biesheuvel
2019-12-14 21:11         ` Arvind Sankar
2019-12-14 21:07       ` Arvind Sankar
2019-12-14 17:57 ` [PATCH 04/10] efi/libstub: add missing apple_properties_protocol_t definition Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 05/10] efi/libstub: distinguish between native/mixed not 32/64 bit Ard Biesheuvel
2019-12-14 19:46   ` Arvind Sankar
2019-12-14 19:49     ` Arvind Sankar
2019-12-14 19:54       ` Ard Biesheuvel
2019-12-14 20:13         ` Arvind Sankar
2019-12-14 20:27           ` Ard Biesheuvel
2019-12-14 21:17             ` Arvind Sankar
2019-12-14 21:30               ` Ard Biesheuvel
2019-12-14 22:14                 ` Arvind Sankar
2019-12-14 22:14                 ` Ard Biesheuvel
2019-12-14 23:02                   ` Arvind Sankar
2019-12-14 17:57 ` [PATCH 06/10] efi/libstub/x86: use mixed mode helpers to populate efi_config Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 07/10] efi/libstub: drop explicit 64-bit protocol definitions Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 08/10] efi/libstub: use stricter typing for firmware function pointers Ard Biesheuvel
2019-12-14 17:57 ` [PATCH 09/10] efi/libstub: annotate firmware routines as __efiapi Ard Biesheuvel
2019-12-17 15:01   ` Brian Gerst
2019-12-14 17:57 ` [PATCH 10/10] efi/libstub/x86: avoid thunking for native firmware calls Ard Biesheuvel
2019-12-15 19:30   ` Arvind Sankar
2019-12-17  8:32     ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).