Skip to content

efi: Constify all the things

Lukas Wunner linux-efi 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10efi: use typed function pointers for runtime services tableinclude/linux/efi.h+18 -180 replies
2/10efi: Constify GetVariable() / SetVariable() signaturesarch/ia64/kernel/efi.c arch/x86/include/asm/xen/interface.h arch/x86/platform/efi/efi_64.c +7 more+55 -441 reply
3/10efi: Constify GetVariable() / SetVariable() argumentsarch/ia64/kernel/efi.c arch/x86/platform/efi/quirks.c drivers/firmware/efi/efi-pstore.c +4 more+12 -255 replies
4/10efi: Constify HandleProtocol() / LocateHandle() / LocateProtocol()arch/x86/boot/compressed/eboot.c drivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/gop.c +2 more+39 -460 replies
5/10efi: Constify InstallConfigurationTable()drivers/firmware/efi/libstub/arm32-stub.c drivers/firmware/efi/libstub/random.c include/linux/efi.h+4 -50 replies
6/10efi: Constify EFI_FILE_PROTOCOL.GetInfo()drivers/firmware/efi/libstub/efi-stub-helper.c include/linux/efi.h+3 -40 replies
7/10efi: Constify EFI_RNG_PROTOCOL.GetRNG()drivers/firmware/efi/libstub/random.c+2 -30 replies
8/10efi: Constify EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()arch/x86/boot/compressed/eboot.c drivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/efi-stub-helper.c +2 more+5 -50 replies
9/10efi: Constify efi_guidcmp() argumentsdrivers/firmware/efi/efi-pstore.c drivers/firmware/efi/libstub/fdt.c+3 -60 replies
10/10uuid: Constify UUID compound literalsinclude/uapi/linux/uuid.h+2 -23 replies

Reviews trailers per patch

2 of 10 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJuergen GrossDennis DalessandroKees Cook
SeriesR-b
1/10
2/10A-b
3/10A-b
4/10
5/10
6/10
7/10
8/10
9/10
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/10] efi: Constify all the things

When disassembling the EFI stub I noticed that GUIDs and efi_char16_t strings are not placed in rodata but generated on the stack at runtime. GUIDs occupy up to 80 bytes of text instead of just 16 bytes rodata which annoyed me enough to go down the rabbit hole of fixing it. This series constifies all GUIDs and EFI-related strings I could find.

The most important patch is [10/10] to constify the EFI_GUID() macro. This has to be at the end of the series to avoid compiler warnings. Reviewers may want to read its commit message first as it contains background information. In particular it explains why this series only fixes the kernel side of things. Additional work is necessary on the compiler side to actually have all the GUIDs and strings in rodata. At the moment both gcc and clang achieve that only partially.

Ard Biesheuvel expressed an interest in these patches in November but stressed the importance that arguments to EFI boot/runtime/protocol services may only be declared const if the spec marks them "IN":
https://lkml.org/lkml/2016/11/21/459

Hence I've split the series by boot/runtime/protocol services to allow for easy verification of this fact. Constification of GetVariable() / SetVariable() is further split in one patch for the function signatures and another for the actual arguments because changing the function signatures is quite involved in this case.

efi.git/next needs to be rebased on v4.10-rc1 before this series can be applied because it requires commits f6697df36bdf ("x86/efi: Prevent mixed mode boot corruption with CONFIG_VMAP_STACK=y") and 2fbadc3002c5 ("arm/arm64: xen: Move shared architecture headers to include/xen/arm").

Unfortunately I was not able to compile-test on ia64, there's no cross- compiler package available on Debian. :-( I did not receive complaints from 0-day, so I'm cautiously optimistic that I didn't cause breakage there.

I've pushed the patches to GitHub to ease reviewing/fetching:
https://github.com/l1k/linux/commits/efi_const_v1

Thanks,

Lukas

Ard Biesheuvel (1):
efi: use typed function pointers for runtime services table

Lukas Wunner (9):
efi: Constify GetVariable() / SetVariable() signatures
efi: Constify GetVariable() / SetVariable() arguments
efi: Constify HandleProtocol() / LocateHandle() / LocateProtocol()
efi: Constify InstallConfigurationTable()
efi: Constify EFI_FILE_PROTOCOL.GetInfo()
efi: Constify EFI_RNG_PROTOCOL.GetRNG()
efi: Constify EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString()
efi: Constify efi_guidcmp() arguments
uuid: Constify UUID compound literals

 arch/ia64/kernel/efi.c                         | 24 ++++------
 arch/x86/boot/compressed/eboot.c               | 50 ++++++++++-----------
 arch/x86/include/asm/xen/interface.h           |  1 +
 arch/x86/platform/efi/efi_64.c                 | 18 ++++----
 arch/x86/platform/efi/quirks.c                 |  2 +-
 drivers/firmware/efi/efi-pstore.c              | 10 ++---
 drivers/firmware/efi/efibc.c                   |  3 +-
 drivers/firmware/efi/libstub/arm-stub.c        | 17 +++----
 drivers/firmware/efi/libstub/arm32-stub.c      |  2 +-
 drivers/firmware/efi/libstub/efi-stub-helper.c |  7 ++-
 drivers/firmware/efi/libstub/efistub.h         |  2 +-
 drivers/firmware/efi/libstub/fdt.c             |  3 +-
 drivers/firmware/efi/libstub/gop.c             | 12 +++--
 drivers/firmware/efi/libstub/random.c          | 16 +++----
 drivers/firmware/efi/runtime-wrappers.c        | 15 ++++---
 drivers/firmware/google/gsmi.c                 | 10 ++---
 drivers/infiniband/hw/hfi1/efivar.c            |  6 +--
 drivers/scsi/isci/probe_roms.c                 |  2 +-
 drivers/xen/efi.c                              | 12 ++---
 include/linux/efi.h                            | 61 ++++++++++++++------------
 include/uapi/linux/uuid.h                      |  4 +-
 include/xen/arm/interface.h                    |  1 +
 include/xen/interface/platform.h               | 11 ++++-
 include/xen/xen-ops.h                          | 12 ++---
 24 files changed, 143 insertions(+), 158 deletions(-)
Signature · 1 line
2.11.0