[PATCH 1/5] KVM: x86: Expose Zhaoxin SM2 CPUID feature

From: Ewan Hai

Date: Wed May 13 2026 - 04:50:04 EST


Advertise the Zhaoxin SM2 instruction support to guests via CPUID0xC0000001 EDX bits 0 (SM2) and 1 (SM2_EN).The SM2 instruction (encoding F2 0F A6 C0) implements the SM2elliptic-curve public-key cryptography algorithm specified inGM/T 0003-2012; the hardware-level behavior is documented in theZhaoxin GMI Instruction Set Reference, chapter 1 ("SM2"). Theinstruction multiplexes its sub-functions on the RDX[5:0] controlword: encryption (subsection 1.1), decryption (1.2), signing (1.3),signature verification (1.4), the three key-exchange sub-operationsof section 1.5 (1.5.1 SM2 key-pair generation, which the spec alsouses for the initiator's ephemeral key; 1.5.2 responder shared-keyderivation; 1.5.3 initiator shared-key derivation), and twopreprocess steps for identity and message hashing (1.6.1 and 1.6.2).The instruction is user-mode and available in all CPU modes, with noassociated MSR control. The SM2 and SM2_EN bits are redundant byhardware design (set or cleared together) and both serve purely asCPUID-level feature-presence reporting flags requiring no KVMemulation. Both bits are advertised because different software mayprobe either one when checking for SM2 availability.Signed-off-by: Ewan Hai <ewanhai-oc@xxxxxxxxxxx>--- arch/x86/kvm/cpuid.c | 2 ++ arch/x86/kvm/reverse_cpuid.h | 4 ++++ 2 files changed, 6 insertions(+)diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.cindex e69156b54cff..1eb4b88aaa80 100644--- a/arch/x86/kvm/cpuid.c+++ b/arch/x86/kvm/cpuid.c@@ -1272,6 +1272,8 @@ void kvm_initialize_cpu_caps(void) kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE); kvm_cpu_cap_init(CPUID_C000_0001_EDX,+ F(SM2),+ F(SM2_EN), F(XSTORE), F(XSTORE_EN), F(XCRYPT),diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.hindex 657f5f743ed9..7b55110cc046 100644--- a/arch/x86/kvm/reverse_cpuid.h+++ b/arch/x86/kvm/reverse_cpuid.h@@ -76,6 +76,10 @@ #define KVM_X86_FEATURE_TSA_SQ_NO KVM_X86_FEATURE(CPUID_8000_0021_ECX, 1) #define KVM_X86_FEATURE_TSA_L1_NO KVM_X86_FEATURE(CPUID_8000_0021_ECX, 2) +/* Zhaoxin/Centaur sub-features, CPUID level 0xC0000001 (EDX) */+#define X86_FEATURE_SM2 KVM_X86_FEATURE(CPUID_C000_0001_EDX, 0)+#define X86_FEATURE_SM2_EN KVM_X86_FEATURE(CPUID_C000_0001_EDX, 1)+ struct cpuid_reg { u32 function; u32 index;-- 2.34.1




ä¿?å¯?声æ??
æ?¬é?®ä»¶å?«æ??ä¿?å¯?æ??ä¸?æ??ä¿¡æ?¯ï¼?ä»?ä¾?æ??å®?æ?¶ä»¶äººä½¿ç?¨ã??严ç¦?对æ?¬é?®ä»¶æ??å?¶å??容å??ä»»ä½?æ?ªç»?æ??æ??ç??æ?¥é??ã??使ç?¨ã??å¤?å?¶æ??转å??ã??

This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.