[PATCH v2 3/4] x86/apic: Remove redundant check from x2apic_phys_probe()
From: Grzegorz Jaszczyk
Date: Thu Sep 24 2026 - 07:32:40 EST
Commit 9ebd680bd029 ("x86, apic: Use probe routines to simplify apic
selection") introduced x2apic_phys_probe() with a generic fallback check
for 'apic == &apic_x2apic_phys' to preserve any prior selection of
apic_x2apic_phys by default_acpi_madt_oem_check():
if (x2apic_mode && x2apic_phys)
return 1;
return apic == &apic_x2apic_phys;
At the time, x2apic_acpi_madt_oem_check() only checked
'x2apic_phys && x2apic_enabled()', so that fallback was already
redundant. Commit ea0dcf903e7d ("x86/apic: Use x2apic physical mode
based on FADT setting") later added the ACPI_FADT_APIC_PHYSICAL check
only to x2apic_acpi_madt_oem_check(), temporarily relying on the
'apic == &apic_x2apic_phys' fallback in x2apic_phys_probe() when
x2APIC was pre-enabled by BIOS.
Subsequently, commit cb214ede7657 ("x86/apic: Work around boot failure
on HP ProLiant DL980 G7 Server systems") factored out x2apic_fadt_phys()
and added it directly to x2apic_phys_probe(). Because
default_acpi_madt_oem_check() (via the .acpi_madt_oem_check callback) is
the only path that can install apic_x2apic_phys prior to
x2apic_phys_probe(), and x2apic_acpi_madt_oem_check() checks the exact
same 'x2apic_phys || x2apic_fadt_phys()' condition, the fallback
'apic == &apic_x2apic_phys' check became completely unreachable again.
Remove the redundant check and the associated forward declaration of
apic_x2apic_phys. In addition to cleaning up dead code, this allows
apic_x2apic_phys to be installed as an early boot default driver when
hardware x2APIC is pre-enabled without preventing x2apic_cluster from
being probed and selected later during boot.
Signed-off-by: Grzegorz Jaszczyk <jaszczyk@xxxxxxxxxxxx>
---
arch/x86/kernel/apic/x2apic_phys.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index 090647cc5a784..5bf86839e84c3 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -6,8 +6,6 @@
#include "local.h"
int x2apic_phys;
-
-static struct apic apic_x2apic_phys;
u32 x2apic_max_apicid __ro_after_init = UINT_MAX;
void __init x2apic_set_max_apicid(u32 apicid)
@@ -110,10 +108,7 @@ static int x2apic_phys_probe(void)
if (!x2apic_mode)
return 0;
- if (x2apic_phys || x2apic_fadt_phys())
- return 1;
-
- return apic == &apic_x2apic_phys;
+ return x2apic_phys || x2apic_fadt_phys();
}
u32 x2apic_get_apic_id(u32 id)
--
2.56.0.rc1.315.gc6ed9934b7-goog