android_kernel_samsung_sm8650/arch
Tom Lendacky 100cd6d0e5 x86/head/64: Switch to KERNEL_CS as soon as new GDT is installed
[ Upstream commit a37f2699c36a7f6606ba3300f243227856c5ad6b ]

The call to startup_64_setup_env() will install a new GDT but does not
actually switch to using the KERNEL_CS entry until returning from the
function call.

Commit bcce829083 ("x86/sev: Detect/setup SEV/SME features earlier in
boot") moved the call to sme_enable() earlier in the boot process and in
between the call to startup_64_setup_env() and the switch to KERNEL_CS.
An SEV-ES or an SEV-SNP guest will trigger #VC exceptions during the call
to sme_enable() and if the CS pushed on the stack as part of the exception
and used by IRETQ is not mapped by the new GDT, then problems occur.
Today, the current CS when entering startup_64 is the kernel CS value
because it was set up by the decompressor code, so no issue is seen.

However, a recent patchset that looked to avoid using the legacy
decompressor during an EFI boot exposed this bug. At entry to startup_64,
the CS value is that of EFI and is not mapped in the new kernel GDT. So
when a #VC exception occurs, the CS value used by IRETQ is not valid and
the guest boot crashes.

Fix this issue by moving the block that switches to the KERNEL_CS value to
be done immediately after returning from startup_64_setup_env().

Fixes: bcce829083 ("x86/sev: Detect/setup SEV/SME features earlier in boot")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/all/6ff1f28af2829cc9aea357ebee285825f90a431f.1684340801.git.thomas.lendacky%40amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-06-21 16:00:51 +02:00
..
alpha alpha: fix R_ALPHA_LITERAL reloc for large modules 2023-03-17 08:50:31 +01:00
arc ARC: mm: fix leakage of memory allocated for PTE 2022-10-17 16:32:12 -07:00
arm ARM: dts: at91: sama7g5ek: fix debounce delay property for shdwc 2023-06-14 11:15:30 +02:00
arm64 arm64: dts: imx8mn-beacon: Fix SPI CS pinmux 2023-06-14 11:15:31 +02:00
csky - hfs and hfsplus kmap API modernization from Fabio Francesco 2022-10-12 11:00:22 -07:00
hexagon - hfs and hfsplus kmap API modernization from Fabio Francesco 2022-10-12 11:00:22 -07:00
ia64 ia64: fix an addr to taddr in huge_pte_offset() 2023-05-11 23:03:40 +09:00
loongarch LoongArch: Mark 3 symbol exports as non-GPL 2023-04-26 14:28:38 +02:00
m68k m68k: Move signal frame following exception on 68020/030 2023-05-30 14:03:18 +01:00
microblaze kbuild: fix "cat: .version: No such file or directory" 2022-11-24 09:26:02 +09:00
mips MIPS: fw: Allow firmware to pass a empty env 2023-05-11 23:03:01 +09:00
nios2 nios2: add FORCE for vmlinuz.gz 2022-11-27 08:28:41 +09:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-11 23:03:35 +09:00
parisc parisc: Handle kprobes breakpoints only in kernel context 2023-05-30 14:03:18 +01:00
powerpc powerpc/xmon: Use KSYM_NAME_LEN in array size 2023-06-09 10:34:26 +02:00
riscv riscv: fix kprobe __user string arg print fault issue 2023-06-14 11:15:32 +02:00
s390 s390/topology: honour nr_cpu_ids when adding CPUs 2023-06-09 10:34:13 +02:00
sh sh: nmi_debug: fix return value of __setup handler 2023-05-17 11:53:45 +02:00
sparc sparc: allow PM configs for sparc32 COMPILE_TEST 2023-03-10 09:33:27 +01:00
um um: harddog: fix modular build 2023-06-09 10:34:10 +02:00
x86 x86/head/64: Switch to KERNEL_CS as soon as new GDT is installed 2023-06-21 16:00:51 +02:00
xtensa xtensa: add __bswap{si,di}2 helpers 2023-05-30 14:03:18 +01:00
.gitignore
Kconfig ftrace: Allow WITH_ARGS flavour of graph tracer with shadow call stack 2022-12-31 13:32:45 +01:00