[PATCH 3/5] KVM: x86: Expose Zhaoxin RNG2 CPUID feature

From: Ewan Hai

Date: Wed May 13 2026 - 04:33:28 EST


Advertise the Zhaoxin second-generation hardware RNG to guests viaCPUID 0xC0000001 EDX bits 22 (RNG2) and 23 (RNG2_EN).RNG2 is exposed by the REP XRNG2 instruction (encoding F3 0F A7 F8),documented in the Zhaoxin PadLock Instruction Reference, subsection 1.3("REP XRNG2"). It produces random bytes from two on-die RNG sourcesselectable via RAX bits[10:9] and an output mode (raw vs post-processed)controlled by RDX bits[1:0], providing high-quality entropy intendedfor cryptographic operations.REP XRNG2 is user-mode and available in all CPU modes, with noassociated MSR control. The RNG2 and RNG2_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 RNG2 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 8aaa3f20670e..087c41341240 100644--- a/arch/x86/kvm/cpuid.c+++ b/arch/x86/kvm/cpuid.c@@ -1286,6 +1286,8 @@ void kvm_initialize_cpu_caps(void) F(PHE_EN), F(PMM), F(PMM_EN),+ F(RNG2),+ F(RNG2_EN), ); /*diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.hindex a1cd9116ef63..859ba43126d8 100644--- a/arch/x86/kvm/reverse_cpuid.h+++ b/arch/x86/kvm/reverse_cpuid.h@@ -81,6 +81,8 @@ #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)+#define X86_FEATURE_RNG2 KVM_X86_FEATURE(CPUID_C000_0001_EDX, 22)+#define X86_FEATURE_RNG2_EN KVM_X86_FEATURE(CPUID_C000_0001_EDX, 23) 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.