[PATCH v7 024/120] x86/cpu/zhaoxin: Use parsed CPUID(0xc0000001)
"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:37:46 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Use parsed CPUID(0xc0000001). Beside the CPUID parser centralization benefits, this allows using the auto-generated x86-cpuid-db data types, and their full C99 bitfields, instead of doing ugly bitwise operations on the CPUID output. Keep the x86_capability[] CPUID(0xc0000001).EDX assignment. It will be removed once X86_FEATURE translation is integrated into the CPUID model. Signed-off-by: Ahmed S. Darwish <[email protected]> --- arch/x86/kernel/cpu/zhaoxin.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c index 55bc656aaa95..ea76e9594453 100644 --- a/arch/x86/kernel/cpu/zhaoxin.c +++ b/arch/x86/kernel/cpu/zhaoxin.c @@ -11,35 +11,26 @@ #define MSR_ZHAOXIN_FCR57 0x00001257 -#define ACE_PRESENT (1 << 6) -#define ACE_ENABLED (1 << 7) #define ACE_FCR (1 << 7) /* MSR_ZHAOXIN_FCR */ - -#define RNG_PRESENT (1 << 2) -#define RNG_ENABLED (1 << 3) #define RNG_ENABLE (1 << 8) /* MSR_ZHAOXIN_RNG */ static void init_zhaoxin_cap(struct cpuinfo_x86 *c) { - u32 lo, hi; - - /* Test for Extended Feature Flags presence */ - if (cpuid_eax(0xC0000000) >= 0xC0000001) { - u32 tmp = cpuid_edx(0xC0000001); + const struct leaf_0xc0000001_0 *l1 = cpuid_leaf(c, 0xc0000001); + u32 lo, hi; + if (l1) { /* Enable ACE unit, if present and disabled */ - if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) { + if (l1->ace && !l1->ace_en) { rdmsr(MSR_ZHAOXIN_FCR57, lo, hi); - /* Enable ACE unit */ lo |= ACE_FCR; wrmsr(MSR_ZHAOXIN_FCR57, lo, hi); pr_info("CPU: Enabled ACE h/w crypto\n"); } /* Enable RNG unit, if present and disabled */ - if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) { + if (l1->rng && !l1->rng_en) { rdmsr(MSR_ZHAOXIN_FCR57, lo, hi); - /* Enable RNG unit */ lo |= RNG_ENABLE; wrmsr(MSR_ZHAOXIN_FCR57, lo, hi); pr_info("CPU: Enabled h/w RNG\n"); -- 2.54.0