Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/kexec: Disable LASS during relocate kernel

The relocate kernel mechanism uses an identity mapping to copy the new
kernel, which leads to a LASS violation when executing from a low
address.

LASS must be disabled after the original CR4 value is saved because
kexec paths that preserve context need to restore CR4.LASS. But,
disabling it along with CET during identity_mapped() is too late. So,
disable LASS immediately after saving CR4, along with PGE, and before
jumping to the identity-mapped page.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20251118182911.2983253-6-sohil.mehta%40intel.com

authored by

Sohil Mehta and committed by
Dave Hansen
731d4375 b3a7e973

+5 -2
+5 -2
arch/x86/kernel/relocate_kernel_64.S
··· 95 95 /* Leave CR4 in %r13 to enable the right paging mode later. */ 96 96 movq %cr4, %r13 97 97 98 - /* Disable global pages immediately to ensure this mapping is RWX */ 98 + /* 99 + * Disable global pages immediately to ensure this mapping is RWX. 100 + * Disable LASS before jumping to the identity mapped page. 101 + */ 99 102 movq %r13, %r12 100 - andq $~(X86_CR4_PGE), %r12 103 + andq $~(X86_CR4_PGE | X86_CR4_LASS), %r12 101 104 movq %r12, %cr4 102 105 103 106 /* Save %rsp and CRs. */