]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/sme: Move early SME kernel encryption handling into .head.text
authorArd Biesheuvel <ardb@kernel.org>
Tue, 27 Feb 2024 15:19:15 +0000 (16:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:36:07 +0000 (16:36 +0200)
commitaf90ced75242b5a1ca4fc861f4bd55890a4ed873
treec30fd5bafe08c7a2f4a8eb05b34c08a274f6b663
parentdc4cbf9e2df4d2ad361659aa037f5a9b0d32691f
x86/sme: Move early SME kernel encryption handling into .head.text

commit 48204aba801f1b512b3abed10b8e1a63e03f3dd1 upstream.

The .head.text section is the initial primary entrypoint of the core
kernel, and is entered with the CPU executing from a 1:1 mapping of
memory. Such code must never access global variables using absolute
references, as these are based on the kernel virtual mapping which is
not active yet at this point.

Given that the SME startup code is also called from this early execution
context, move it into .head.text as well. This will allow more thorough
build time checks in the future to ensure that early startup code only
uses RIP-relative references to global variables.

Also replace some occurrences of __pa_symbol() [which relies on the
compiler generating an absolute reference, which is not guaranteed] and
an open coded RIP-relative access with RIP_REL_REF().

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20240227151907.387873-18-ardb+git@google.com
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/mem_encrypt.h
arch/x86/mm/mem_encrypt_identity.c