[PATCH v1 3/4] x86/cpuid: Add dependencies of SHA512, SM3 and SM4 on AVX

From: Guixiong Wei

Date: Tue Aug 11 2026 - 22:00:14 EST


SHA512, SM3 and SM4 are VEX-encoded and operate on the YMM registers, so
they depend on AVX, but they are missing from cpuid_deps[]. As a result,
clearing AVX (e.g. via "clearcpuid=", "noxsave" or the GDS mitigation)
leaves them set, which KVM then advertises to guests without AVX - an
inconsistent CPUID state that check_cpufeature_deps() does not catch.

Add the missing dependencies, following the existing convention that
VEX-encoded/YMM instructions depend on AVX (see AVX-VNNI, VAES and
VPCLMULQDQ).

Fixes: a0423af92cb3 ("x86: KVM: Advertise CPUIDs for new instructions in Clearwater Forest")
Signed-off-by: Guixiong Wei <weiguixiong@xxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/cpuid-deps.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index 6b1df617a423..94ed933897df 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -50,6 +50,9 @@ static const struct cpuid_dep cpuid_deps[] = {
{ X86_FEATURE_VAES, X86_FEATURE_AVX },
{ X86_FEATURE_VPCLMULQDQ, X86_FEATURE_AVX },
{ X86_FEATURE_AVX_IFMA, X86_FEATURE_AVX },
+ { X86_FEATURE_SHA512, X86_FEATURE_AVX },
+ { X86_FEATURE_SM3, X86_FEATURE_AVX },
+ { X86_FEATURE_SM4, X86_FEATURE_AVX },
{ X86_FEATURE_AVX2, X86_FEATURE_AVX, },
{ X86_FEATURE_AVX512F, X86_FEATURE_AVX, },
{ X86_FEATURE_AVX512IFMA, X86_FEATURE_AVX512F },
--
2.50.1 (Apple Git-155)