]> 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:12:37 +0000 (09:12 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:39:33 +0000 (16:39 +0200)
commitf92af52e6dbd8d066d77beba451e0230482dc45b
tree95910d27a8b4839e45fcb87bfda576be63fb12ed
parent4f681834f06af9263bd4c45d18c441b7e536f822
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/cpuflags.c
arch/x86/boot/startup/sev-shared.c
arch/x86/coco/sev/core.c
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/sev.h
arch/x86/kernel/cpu/scattered.c