[PATCH] x86/srat: Conditional apic_id vs MAX_LOCAL_APIC comparison
From: WangYuli
Date: Fri Feb 28 2025 - 00:22:01 EST
The apic_id employed within the acpi_numa_processor_affinity_init()
function is derived from the acpi_srat_cpu_affinity structure defined
in acpi/actbl3.h.
When CONFIG_X86_X2APIC is not enabled, its maximum value is limited
to 255. It is only capable of exceeding 256 and 32768 — which
corresponds to the definition of MAX_LOCAL_APIC — when CONFIG_X86_X2APIC
is activated.
Consequently, with CONFIG_X86_X2APIC disabled, this code segment will
elicit the compiler's "-Wtautological-constant-out-of-range-compare"
warning, as a variable capped at 255 can never satisfy a condition
requiring it to be greater than or equal to 256 or 32768.
Compiling the kernel with the W=1e flag will, in this scenario, lead
to compilation failure.
Suggested-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
Co-developed-by: Wentao Guan <guanwentao@xxxxxxxxxxxxx>
Signed-off-by: Wentao Guan <guanwentao@xxxxxxxxxxxxx>
Signed-off-by: WangYuli <wangyuli@xxxxxxxxxxxxx>
---
arch/x86/mm/srat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index 6f8e0f21c710..93e5bcc58ead 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -90,10 +90,12 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
else
apic_id = pa->apic_id;
+#ifdef CONFIG_X86_X2APIC
if (apic_id >= MAX_LOCAL_APIC) {
printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
return;
}
+#endif /* CONFIG_X86_X2APIC */
set_apicid_to_node(apic_id, node);
node_set(node, numa_nodes_parsed);
--
2.47.2