[PATCH v7 046/120] x86/apic: Use parsed and refreshed CPUID(0x1)
From: Ahmed S. Darwish
Date: Thu May 28 2026 - 12:23:21 EST
Use parsed CPUID(0x1) instead of doing manual bitwise operations and a
direct CPUID query.
Refresh CPUID(0x1).EDX since one apic_verify() caller may force local APIC
enablement through an MSR write beforehand.
Note, using the CPUID APIs here is safe since setup_arch() calls
early_cpu_init() way before invoking any of the APIC initialization code.
Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
---
arch/x86/kernel/apic/apic.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 8c614750a19b..0ecd923b5809 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1960,14 +1960,15 @@ static bool __init detect_init_APIC(void)
static bool __init apic_verify(unsigned long addr)
{
- u32 features, h, l;
+ const struct leaf_0x1_0 *l1;
+ u32 h, l;
/*
- * The APIC feature bit should now be enabled
- * in `cpuid'
+ * The APIC feature bit should now be enabled in CPUID
*/
- features = cpuid_edx(1);
- if (!(features & (1 << X86_FEATURE_APIC))) {
+ cpuid_refresh_leaf(&boot_cpu_data, 0x1);
+ l1 = cpuid_leaf(&boot_cpu_data, 0x1);
+ if (!l1 || !l1->apic) {
pr_warn("Could not enable APIC!\n");
return false;
}
--
2.54.0