[PATCH v6 50/90] x86/cpu: Use parsed CPUID(0x80000008)
"Ahmed S. Darwish" <[email protected]> Fri, 27 Mar 2026 03:16:04 +0100
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Use parsed CPUID(0x80000008) instead of issuing a direct CPUID query and doing ugly bitwise operations. Signed-off-by: Ahmed S. Darwish <[email protected]> --- arch/x86/kernel/cpu/common.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 5fa5463686ac..2beb53f6bed7 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1100,10 +1100,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c) void get_cpu_address_sizes(struct cpuinfo_x86 *c) { - u32 eax, ebx, ecx, edx; + const struct leaf_0x80000008_0 *el8 = cpuid_leaf(c, 0x80000008); - if (!cpu_has(c, X86_FEATURE_CPUID) || - (c->extended_cpuid_level < 0x80000008)) { + if (!cpu_has(c, X86_FEATURE_CPUID) || !el8) { if (IS_ENABLED(CONFIG_X86_64)) { c->x86_clflush_size = 64; c->x86_phys_bits = 36; @@ -1118,10 +1117,8 @@ void get_cpu_address_sizes(struct cpuinfo_x86 *c) c->x86_phys_bits = 36; } } else { - cpuid(0x80000008, &eax, &ebx, &ecx, &edx); - - c->x86_virt_bits = (eax >> 8) & 0xff; - c->x86_phys_bits = eax & 0xff; + c->x86_virt_bits = el8->virt_addr_bits; + c->x86_phys_bits = el8->phys_addr_bits; /* Provide a sane default if not enumerated: */ if (!c->x86_clflush_size) -- 2.53.0