acrn-kernel/arch
Ard Biesheuvel 1d9a735d4e 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:42:28 +02:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:27:31 +02:00
arc ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard 2023-07-19 16:21:42 +02:00
arm ARM: ptrace: Restore syscall skipping for tracers 2023-09-13 09:42:28 +02:00
arm64 arm64/ptrace: Clean up error handling path in sve_set_common() 2023-09-13 09:42:28 +02:00
csky csky: fix up lock_mm_and_find_vma() conversion 2023-07-01 13:16:27 +02:00
hexagon mm/fault: convert remaining simple cases to lock_mm_and_find_vma() 2023-07-01 13:16:25 +02:00
ia64 ia64/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:03:46 +02:00
loongarch LoongArch: Fix the write_fcsr() macro 2023-09-13 09:42:25 +02:00
m68k m68k: Fix invalid .section syntax 2023-09-13 09:42:21 +02:00
microblaze mm: always expand the stack with the mmap write lock held 2023-07-01 13:16:25 +02:00
mips Revert "MIPS: unhide PATA_PLATFORM" 2023-09-13 09:42:20 +02:00
nios2 mm/fault: convert remaining simple cases to lock_mm_and_find_vma() 2023-07-01 13:16:25 +02:00
openrisc mm: always expand the stack with the mmap write lock held 2023-07-01 13:16:25 +02:00
parisc parisc: sys_parisc: parisc_personality() is called from asm code 2023-09-02 09:16:19 +02:00
powerpc powerpc/powermac: Use early_* IO variants in via_calibrate_decr() 2023-09-13 09:42:24 +02:00
riscv riscv: Fix build errors using binutils2.37 toolchains 2023-08-30 16:11:08 +02:00
s390 KVM: s390: fix sthyi error handling 2023-08-11 12:08:11 +02:00
sh sh/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:03:47 +02:00
sparc sparc/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:03:47 +02:00
um um/cpu: Switch to arch_cpu_finalize_init() 2023-08-08 20:03:47 +02:00
x86 x86/decompressor: Don't rely on upper 32 bits of GPRs being preserved 2023-09-13 09:42:28 +02:00
xtensa init: Remove check_bugs() leftovers 2023-08-08 20:03:47 +02:00
.gitignore
Kconfig init: Provide arch_cpu_finalize_init() 2023-08-08 20:03:46 +02:00