x86/boot/compressed/64: Switch to __KERNEL_CS after GDT is loaded
authorJoerg Roedel <jroedel@suse.de>
Tue, 28 Apr 2020 15:16:22 +0000 (17:16 +0200)
committerBorislav Petkov <bp@suse.de>
Mon, 4 May 2020 17:53:08 +0000 (19:53 +0200)
commit34bb49229f19399a5b45c323afb5749f31f7876c
treef0611bd624af6d4fbae8921ef378642f4108f803
parent40ba9309c76f29d012a5cc0cf938f8ff7dc6fef2
x86/boot/compressed/64: Switch to __KERNEL_CS after GDT is loaded

When the pre-decompression code loads its first GDT in startup_64(), it
is still running on the CS value of the previous GDT. In the case of
SEV-ES, this is the EFI GDT but it can be anything depending on what has
loaded the kernel (boot loader, container runtime, etc.)

To make exception handling work (especially IRET) the CPU needs to
switch to a CS value in the current GDT, so jump to __KERNEL_CS after
the first GDT is loaded. This is prudent also as a general sanitization
of CS to a known good value.

 [ bp: Massage commit message. ]

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200428151725.31091-13-joro@8bytes.org
arch/x86/boot/compressed/head_64.S