From 4dc3e6e634b01288339d6ba6911e414fe767372e Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 20 Mar 2026 16:27:48 +0800 Subject: [PATCH 1/2] KVM: x86: Add support for CPUID leaf 0x8C860000 CPUID leaf 0x8C860000 on Hygon processors advertises support for the SM3 and SM4 cryptographic algorithms. Expose this leaf to KVM guests to allow the guest OS to detect these features and enable hardware-accelerated SM3/SM4 operations. Hygon-SIG: commit none hygon KVM: x86: Add support for CPUID leaf 0x8C860000 Signed-off-by: Wei Wang Tested-by: Yongwei Xu Tested-by: Yabin Li Tested-by: Liyang Han --- arch/x86/kvm/cpuid.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 9c28cc22dae0..cafb32791072 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -798,6 +798,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function, break; case 0x8000001e: break; + case 0x8C860000: + entry->eax = 0x8C860000; + if (boot_cpu_has(X86_FEATURE_HYGON_SM3)) + entry->edx |= F(HYGON_SM3); + if (boot_cpu_has(X86_FEATURE_HYGON_SM3)) + entry->edx |= F(HYGON_SM4); + break; /*Add support for Centaur's CPUID instruction*/ case 0xC0000000: /*Just support up to 0xC0000004 now*/ @@ -913,6 +920,20 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid, if (ent->qualifier && !ent->qualifier(ent)) continue; + /* + * 0x8C860000 is a Hygon‑specific CPUID leaf that exceeds the + ` * extended CPUID limit reported by 0x80000000, so it must be + * handled as a special case. + */ + if ((ent->func == 0x80000000) && + (boot_cpu_has(X86_FEATURE_HYGON_SM3) || + boot_cpu_has(X86_FEATURE_HYGON_SM4))) { + r = do_cpuid_func(&cpuid_entries[nent], 0x8C860000, + &nent, cpuid->nent, type); + if (r) + goto out_free; + } + r = do_cpuid_func(&cpuid_entries[nent], ent->func, &nent, cpuid->nent, type); -- Gitee From a0c2b3c12ed5de1b748b19ba35eba570f4c37405 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 8 Apr 2026 16:54:57 +0800 Subject: [PATCH 2/2] KVM: x86: Expose AVX512_VP2INTERSECT to guest AVX512_VP2INTERSECT is supported on Hygon 7447v and many Intel and AMD machines. Expose it to the guest. Signed-off-by: Wei Wang --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index cafb32791072..541b1d2c29fe 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -374,7 +374,7 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) const u32 kvm_cpuid_7_0_edx_x86_features = F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) | F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) | - F(MD_CLEAR); + F(MD_CLEAR) | F(AVX512_VP2INTERSECT); /* cpuid 7.1.eax */ const u32 kvm_cpuid_7_1_eax_x86_features = -- Gitee