linux-stable/arch/x86/lib
Ard Biesheuvel 046545314c x86/boot: Move mem_encrypt= parsing to the decompressor
commit cd0d9d92c8 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-10 16:36:07 +02:00
..
.gitignore
atomic64_32.c
atomic64_386_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
atomic64_cx8_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
cache-smp.c
checksum_32.S x86/checksum_32: Remove .fixup usage 2021-12-11 09:09:49 +01:00
clear_page_64.S x86: improve on the non-rep 'clear_user' function 2023-04-18 17:05:28 -07:00
cmdline.c x86/lib: Fix compiler and kernel-doc warnings 2023-01-03 18:46:21 +01:00
cmpxchg8b_emu.S percpu: Wire up cmpxchg128 2023-06-05 09:36:37 +02:00
cmpxchg16b_emu.S percpu: Wire up cmpxchg128 2023-06-05 09:36:37 +02:00
copy_mc.c iov_iter, x86: Be consistent about the __user tag on copy_mc_to_user() 2023-11-20 11:58:52 +01:00
copy_mc_64.S x86/copy_mc_64: Remove .fixup usage 2021-12-11 09:09:46 +01:00
copy_page_64.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
copy_user_64.S x86: bring back rep movsq for user access on CPUs without ERMS 2023-08-30 09:45:12 -07:00
copy_user_uncached_64.S x86: rewrite '__copy_user_nocache' function 2023-04-20 18:53:49 -07:00
cpu.c
csum-copy_64.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
csum-partial_64.c x86/csum: clean up `csum_partial' further 2024-01-20 11:51:47 +01:00
csum-wrappers_64.c net: unexport csum_and_copy_{from,to}_user 2022-04-29 14:37:59 -07:00
delay.c x86/delay: Fix the wrong asm constraint in delay_loop() 2022-04-05 21:21:57 +02:00
error-inject.c x86/error_inject: Align function properly 2022-10-17 16:40:59 +02:00
getuser.S x86/lib: Revert to _ASM_EXTABLE_UA() for {get,put}_user() fixups 2024-02-16 19:10:54 +01:00
hweight.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
inat.c x86/insn: Add a __ignore_sync_check__ marker 2021-03-15 11:00:57 +01:00
insn-eval.c x86/insn: Avoid namespace clash by separating instruction decoder MMIO type from MMIO trace type 2023-01-03 18:46:06 +01:00
insn.c x86/insn: Use get_unaligned() instead of memcpy() 2021-10-06 11:56:37 +02:00
iomap_copy_64.S x86/asm: Fix an assembler warning with current binutils 2023-01-03 17:55:11 +01:00
iomem.c x86: kmsan: handle open-coded assembly in lib/iomem.c 2022-10-03 14:03:24 -07:00
kaslr.c x86/kaslr: Fix build warning in KASLR code in boot stub 2022-04-11 09:41:12 +02:00
Makefile x86/boot: Move mem_encrypt= parsing to the decompressor 2024-04-10 16:36:07 +02:00
memcpy_32.c x86/mem: Move memmove to out of line assembler 2022-11-01 15:44:07 -07:00
memcpy_64.S x86/asm: Fix build of UML with KASAN 2023-09-18 19:30:08 +02:00
memmove_32.S x86/mem: Move memmove to out of line assembler 2022-11-01 15:44:07 -07:00
memmove_64.S x86/asm: Fix build of UML with KASAN 2023-09-18 19:30:08 +02:00
memset_64.S x86/asm: Fix build of UML with KASAN 2023-09-18 19:30:08 +02:00
misc.c x86/lib: Fix overflow when counting digits 2024-01-25 15:35:12 -08:00
msr-reg-export.c
msr-reg.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
msr-smp.c x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes 2021-03-22 21:37:03 +01:00
msr.c x86/lib/msr: Clean up kernel-doc notation 2023-06-06 15:19:50 +02:00
pc-conf-reg.c x86: Add support for 0x22/0x23 port I/O configuration space 2021-08-10 23:31:43 +02:00
putuser.S x86/lib: Revert to _ASM_EXTABLE_UA() for {get,put}_user() fixups 2024-02-16 19:10:54 +01:00
retpoline.S x86/retpoline: Add NOENDBR annotation to the SRSO dummy return thunk 2024-04-10 16:36:01 +02:00
string_32.c lib/string: Move helper functions out of string.c 2021-09-25 08:20:49 -07:00
strstr_32.c
usercopy.c x86/uaccess: instrument copy_from_user_nmi() 2022-11-08 15:57:24 -08:00
usercopy_32.c x86/usercopy: Remove .fixup usage 2021-12-11 09:09:50 +01:00
usercopy_64.c x86/usercopy: Include arch_wb_cache_pmem() declaration 2023-05-18 11:56:18 -07:00
x86-opcode-map.txt x86/opcode: Add the LKGS instruction to x86-opcode-map 2023-01-12 13:06:36 +01:00