]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/boot: Move mem_encrypt= parsing to the decompressor
authorArd Biesheuvel <ardb@kernel.org>
Tue, 27 Feb 2024 15:19:14 +0000 (16:19 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 4 Mar 2024 17:12:28 +0000 (18:12 +0100)
commitcd0d9d92c8bb46e77de62efd7df13069ddd61e7d
tree35194564c9b44bc5f42c38ac593ca739064d445b
parent7205f06e847422b66c1506eee01b9998ffc75d76
x86/boot: Move mem_encrypt= parsing to the decompressor

The early SME/SEV code parses the command line very early, in order to
decide whether or not memory encryption should be enabled, which needs
to occur even before the initial page tables are created.

This is problematic for a number of reasons:
- this early code runs from the 1:1 mapping provided by the decompressor
  or firmware, which uses a different translation than the one assumed by
  the linker, and so the code needs to be built in a special way;
- parsing external input while the entire kernel image is still mapped
  writable is a bad idea in general, and really does not belong in
  security minded code;
- the current code ignores the built-in command line entirely (although
  this appears to be the case for the entire decompressor)

Given that the decompressor/EFI stub is an intrinsic part of the x86
bootable kernel image, move the command line parsing there and out of
the core kernel. This removes the need to build lib/cmdline.o in a
special way, or to use RIP-relative LEA instructions in inline asm
blocks.

This involves a new xloadflag in the setup header to indicate
that mem_encrypt=on appeared on the kernel command line.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20240227151907.387873-17-ardb+git@google.com
arch/x86/boot/compressed/misc.c
arch/x86/include/uapi/asm/bootparam.h
arch/x86/lib/Makefile
arch/x86/mm/mem_encrypt_identity.c
drivers/firmware/efi/libstub/x86-stub.c