[PATCH 2/5] KVM: x86: Expose Zhaoxin CCS (SM3 + SM4) CPUID feature
From: Ewan Hai
Date: Wed May 13 2026 - 04:31:41 EST
Advertise the Zhaoxin CCS (Chinese Cryptography Standard) feature toguests via CPUID 0xC0000001 EDX bits 4 (CCS) and 5 (CCS_EN). CCS groupstwo user-mode instructions for Chinese national cryptographicprimitives, documented in the Zhaoxin GMI Instruction Set Reference,chapter 2 ("CCS instruction group"): - SM3 (encoding F3 0F A6 E8, subsection 2.1) implements the SM3 hash algorithm specified in GM/T 0004-2012. It supports two modes selected by RAX: auto-padding stream mode (RAX=0) and pre-padded block mode (RAX=-1). - SM4 (encoding F3 0F A7 F0, subsection 2.2) implements the SM4 block cipher specified in GM/T 0002-2012, supporting ECB / CBC / CFB / OFB / CTR modes via a control word in RAX, and CBC-MAC / CFB-MAC when RAX bit[11] is set.Both instructions are user-mode and available in all CPU modes, with noassociated MSR control. The CCS and CCS_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 CCS availability.Signed-off-by: Ewan Hai <ewanhai-oc@xxxxxxxxxxx>--- arch/x86/kvm/cpuid.c | 2 ++ arch/x86/kvm/reverse_cpuid.h | 2 ++ 2 files changed, 4 insertions(+)diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.cindex 1eb4b88aaa80..8aaa3f20670e 100644--- a/arch/x86/kvm/cpuid.c+++ b/arch/x86/kvm/cpuid.c@@ -1276,6 +1276,8 @@ void kvm_initialize_cpu_caps(void) F(SM2_EN), F(XSTORE), F(XSTORE_EN),+ F(CCS),+ F(CCS_EN), F(XCRYPT), F(XCRYPT_EN), F(ACE2),diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.hindex 7b55110cc046..a1cd9116ef63 100644--- a/arch/x86/kvm/reverse_cpuid.h+++ b/arch/x86/kvm/reverse_cpuid.h@@ -79,6 +79,8 @@ /* 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)+#define X86_FEATURE_CCS KVM_X86_FEATURE(CPUID_C000_0001_EDX, 4)+#define X86_FEATURE_CCS_EN KVM_X86_FEATURE(CPUID_C000_0001_EDX, 5) struct cpuid_reg { u32 function;-- 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.