]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/sev: Evict cache lines during SNP memory validation
authorTom Lendacky <thomas.lendacky@amd.com>
Wed, 30 Jul 2025 14:26:00 +0000 (09:26 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:09:08 +0000 (12:09 +0200)
commit1fb873971e23c35c53823c62809a474a92bc3022
treecaae9655f9855da4ec1f22c68c8a49d4566b57ce
parentfdf6959b700be6367d5ad922ee0262ba0a3d81a9
x86/sev: Evict cache lines during SNP memory validation

Commit 7b306dfa326f70114312b320d083b21fa9481e1e upstream.

An SNP cache coherency vulnerability requires a cache line eviction
mitigation when validating memory after a page state change to private.
The specific mitigation is to touch the first and last byte of each 4K
page that is being validated. There is no need to perform the mitigation
when performing a page state change to shared and rescinding validation.

CPUID bit Fn8000001F_EBX[31] defines the COHERENCY_SFW_NO CPUID bit that,
when set, indicates that the software mitigation for this vulnerability is
not needed.

Implement the mitigation and invoke it when validating memory (making it
private) and the COHERENCY_SFW_NO bit is not set, indicating the SNP guest
is vulnerable.

Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/boot/compressed/sev.c
arch/x86/boot/cpuflags.c
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/scattered.c
arch/x86/kernel/sev-shared.c
arch/x86/kernel/sev.c