[PATCH] x86/apic/32: avoid bogus LDR warnings

From: Jan Beulich
Date: Tue Oct 29 2019 - 05:35:16 EST


The removal of the LDR initialization for bigsmp has surfaced a warning per AP:

WARNING: CPU: 1 PID: 0 at arch/x86/kernel/apic/apic.c:1626 setup_local_APIC.cold+0x26/0x8c
Modules linked in:
Supported: No, Unreleased kernel
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.3.4-2019-10-04-jb32 #3 SLE0 (unreleased)
Hardware name: Dell Inc. Precision Tower 7810/0GWHMW, BIOS A27 06/25/2018
EIP: setup_local_APIC.cold+0x5b/0xc5
Code: ...
EAX: 00000024 EBX: 00000000 ECX: c15947f8 EDX: 00200082
ESI: 00000002 EDI: 00000001 EBP: 00000000 ESP: e9887f38
DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 EFLAGS: 00210096
CR0: 80050033 CR2: 00000000 CR3: 0164f000 CR4: 001406b0
Call Trace:
? vprintk_default+0xf/0x20
? fpu__init_cpu_generic+0x5c/0x60
? cpu_init+0x174/0x330
? apic_ap_setup+0x5/0x10
? start_secondary+0x4d/0x180
? startup_32_smp+0x164/0x168

Only do the check and override when the APIC is actually run in a setup
using logical destination mode.

Fixes: bae3a8d3308 ("x86/apic: Do not initialize LDR and DFR for bigsmp")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1586,9 +1586,6 @@ static void setup_local_APIC(void)
{
int cpu = smp_processor_id();
unsigned int value;
-#ifdef CONFIG_X86_32
- int logical_apicid, ldr_apicid;
-#endif

if (disable_apic) {
disable_ioapic_support();
@@ -1626,16 +1623,21 @@ static void setup_local_APIC(void)
apic->init_apic_ldr();

#ifdef CONFIG_X86_32
- /*
- * APIC LDR is initialized. If logical_apicid mapping was
- * initialized during get_smp_config(), make sure it matches the
- * actual value.
- */
- logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
- ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
- WARN_ON(logical_apicid != BAD_APICID && logical_apicid != ldr_apicid);
- /* always use the value from LDR */
- early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid;
+ if (apic->dest_logical) {
+ int logical_apicid, ldr_apicid;
+
+ /*
+ * APIC LDR is initialized. If logical_apicid mapping was
+ * initialized during get_smp_config(), make sure it matches
+ * the actual value.
+ */
+ logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu);
+ ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR));
+ if (logical_apicid != BAD_APICID)
+ WARN_ON(logical_apicid != ldr_apicid);
+ /* Always use the value from LDR. */
+ early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid;
+ }
#endif

/*