]> git.itanic.dy.fi Git - linux-stable/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:38:23 +0000 (16:38 +0200)
commit2ff01ae567b20c38f89da0e3ec7d7ed2242d9f63
tree9ec905c2eaf007ae2e16d245cd5741fce365d0cf
parent7596a378a1aeead848b13bf442a4a678ce64cfce
x86/boot: Move mem_encrypt= parsing to the decompressor

commit cd0d9d92c8bb46e77de62efd7df13069ddd61e7d upstream.

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
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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