linux-stable/arch/x86/kernel/apic
Thomas Gleixner 7d65f9e806 x86/apic: Mark _all_ legacy interrupts when IO/APIC is missing
PIC interrupts do not support affinity setting and they can end up on
any online CPU. Therefore, it's required to mark the associated vectors
as system-wide reserved. Otherwise, the corresponding irq descriptors
are copied to the secondary CPUs but the vectors are not marked as
assigned or reserved. This works correctly for the IO/APIC case.

When the IO/APIC is disabled via config, kernel command line or lack of
enumeration then all legacy interrupts are routed through the PIC, but
nothing marks them as system-wide reserved vectors.

As a consequence, a subsequent allocation on a secondary CPU can result in
allocating one of these vectors, which triggers the BUG() in
apic_update_vector() because the interrupt descriptor slot is not empty.

Imran tried to work around that by marking those interrupts as allocated
when a CPU comes online. But that's wrong in case that the IO/APIC is
available and one of the legacy interrupts, e.g. IRQ0, has been switched to
PIC mode because then marking them as allocated will fail as they are
already marked as system vectors.

Stay consistent and update the legacy vectors after attempting IO/APIC
initialization and mark them as system vectors in case that no IO/APIC is
available.

Fixes: 69cde0004a ("x86/vector: Use matrix allocator for vector assignment")
Reported-by: Imran Khan <imran.f.khan@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20210519233928.2157496-1-imran.f.khan@oracle.com
2021-05-29 11:41:14 +02:00
..
apic.c x86/apic: Mark _all_ legacy interrupts when IO/APIC is missing 2021-05-29 11:41:14 +02:00
apic_common.c x86/apic: Fix signedness bug in APIC ID validity checks 2018-04-10 16:46:39 +02:00
apic_flat_64.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
apic_noop.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
apic_numachip.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
bigsmp_32.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
hw_nmi.c locking/seqlock, headers: Untangle the spaghetti monster 2020-08-06 16:13:13 +02:00
io_apic.c Merge branch 'linus' into x86/cleanups, to resolve conflict 2021-03-21 22:16:08 +01:00
ipi.c x86/apic: Replace pointless apic:: Dest_logical usage 2020-10-28 20:26:24 +01:00
local.h x86/headers: Remove APIC headers from <asm/smp.h> 2020-08-06 16:13:09 +02:00
Makefile x86/PCI: Remove unused HyperTransport interrupt support 2017-11-23 20:18:18 +01:00
msi.c x86/hpet: Move MSI support into hpet.c 2020-10-28 20:26:25 +01:00
probe_32.c x86/apic: Cleanup destination mode 2020-10-28 20:26:25 +01:00
probe_64.c x86/irq: Move apic_post_init() invocation to one place 2020-09-16 16:52:35 +02:00
vector.c x86/apic: Mark _all_ legacy interrupts when IO/APIC is missing 2021-05-29 11:41:14 +02:00
x2apic_cluster.c x86/apic: Add extra serialization for non-serializing MSRs 2021-02-04 19:36:31 +01:00
x2apic_phys.c x86/apic: Add extra serialization for non-serializing MSRs 2021-02-04 19:36:31 +01:00
x2apic_uv_x.c x86/platform/uv: Use x2apic enabled bit as set by BIOS to indicate APIC mode 2021-04-16 12:51:03 +02:00