]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/sev: Avoid global variable to store virtual address of SVSM area
authorArd Biesheuvel <ardb@kernel.org>
Thu, 28 Aug 2025 10:22:09 +0000 (12:22 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 3 Sep 2025 15:58:15 +0000 (17:58 +0200)
commita5f03880f06a6da6ea5f1d966fffffcb3fc65462
treec74cbddebdc916a9203060d6f3d824e83d09b99a
parent37dbd78f98a80e89b5413f4649d0fbd023d99b2f
x86/sev: Avoid global variable to store virtual address of SVSM area

The boottime SVSM calling area is used both by the startup code running from
a 1:1 mapping, and potentially later on running from the ordinary kernel
mapping.

This SVSM calling area is statically allocated, and so its physical address
doesn't change. However, its virtual address depends on the calling context
(1:1 mapping or kernel virtual mapping), and even though the variable that
holds the virtual address of this calling area gets updated from 1:1 address
to kernel address during the boot, it is hard to reason about why this is
guaranteed to be safe.

So instead, take the RIP-relative address of the boottime SVSM calling area
whenever its virtual address is required, and only use a global variable for
the physical address.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/20250828102202.1849035-30-ardb+git@google.com
arch/x86/boot/compressed/sev.c
arch/x86/boot/startup/sev-shared.c
arch/x86/boot/startup/sev-startup.c
arch/x86/coco/sev/core.c
arch/x86/include/asm/sev-internal.h
arch/x86/include/asm/sev.h
arch/x86/mm/mem_encrypt_amd.c