linux-stable/arch/x86
Ard Biesheuvel b8d56aaa23 x86/decompressor: Don't rely on upper 32 bits of GPRs being preserved
[ Upstream commit 264b82fdb4 ]

The 4-to-5 level mode switch trampoline disables long mode and paging in
order to be able to flick the LA57 bit. According to section 3.4.1.1 of
the x86 architecture manual [0], 64-bit GPRs might not retain the upper
32 bits of their contents across such a mode switch.

Given that RBP, RBX and RSI are live at this point, preserve them on the
stack, along with the return address that might be above 4G as well.

[0] Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1: Basic Architecture

  "Because the upper 32 bits of 64-bit general-purpose registers are
   undefined in 32-bit modes, the upper 32 bits of any general-purpose
   register are not preserved when switching from 64-bit mode to a 32-bit
   mode (to protected mode or compatibility mode). Software must not
   depend on these bits to maintain a value after a 64-bit to 32-bit
   mode switch."

Fixes: 194a9749c7 ("x86/boot/compressed/64: Handle 5-level paging boot if kernel is above 4G")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20230807162720.545787-2-ardb@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:47:58 +02:00
..
boot x86/decompressor: Don't rely on upper 32 bits of GPRs being preserved 2023-09-13 09:47:58 +02:00
coco x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad() 2023-07-19 16:35:14 +02:00
configs
crypto This push fixes an alignment crash in x86/aria. 2023-05-29 07:05:49 -04:00
entry x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:32:22 +02:00
events perf/x86: Fix lockdep warning in for_each_sibling_event() on SPR 2023-07-23 13:54:10 +02:00
hyperv x86/hyperv: add noop functions to x86_init mpparse functions 2023-09-13 09:47:53 +02:00
ia32
include locking/arch: Avoid variable shadowing in local_try_cmpxchg() 2023-09-13 09:47:57 +02:00
kernel x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4 2023-08-30 14:52:37 +02:00
kvm KVM: x86/mmu: Add "never" option to allow sticky disabling of nx_huge_pages 2023-09-13 09:47:56 +02:00
lib x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-23 17:32:41 +02:00
math-emu
mm x86/mm: Allow guest.enc_status_change_prepare() to fail 2023-07-19 16:35:14 +02:00
net bpf: Fix a bpf_jit_dump issue for x86_64 with sysctl bpf_jit_enable. 2023-06-12 16:47:18 +02:00
pci xen: branch for v6.4-rc4 2023-05-27 09:42:56 -07:00
platform x86/efi: Make efi_set_virtual_address_map IBT safe 2023-07-19 16:36:25 +02:00
power x86/cpu: Mark {hlt,resume}_play_dead() __noreturn 2023-04-14 17:31:27 +02:00
purgatory x86/purgatory: remove PGO flags 2023-06-12 11:31:50 -07:00
ras
realmode
tools ELF: fix all "Elf" typos 2023-04-08 13:45:37 -07:00
um um: make stub data pages size tweakable 2023-04-20 23:08:43 +02:00
video
virt/vmx/tdx
xen x86/xen: Fix secondary processors' FPU initialization 2023-08-08 20:04:51 +02:00
.gitignore
Kbuild
Kconfig x86/srso: Add a Speculative RAS Overflow mitigation 2023-08-08 20:04:51 +02:00
Kconfig.assembler crypto: x86/aria-avx - fix build failure with old binutils 2023-01-20 18:29:31 +08:00
Kconfig.cpu
Kconfig.debug docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
Makefile x86/unwind/orc: Add ELF section with ORC version identifier 2023-06-16 17:17:42 +02:00
Makefile.um um: Only disable SSE on clang to work around old GCC bugs 2023-04-04 09:57:05 +02:00
Makefile_32.cpu