[PATCH v6 50/90] x86/cpu: Use parsed CPUID(0x80000008)

Ahmed S. Darwish posted 90 patches 6 days, 16 hours ago
[PATCH v6 50/90] x86/cpu: Use parsed CPUID(0x80000008)
Posted by Ahmed S. Darwish 6 days, 16 hours ago
Use parsed CPUID(0x80000008) instead of issuing a direct CPUID query and
doing ugly bitwise operations.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
 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