]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/apic: Make the ISR clearing sane
authorThomas Gleixner <tglx@linutronix.de>
Thu, 31 Jul 2025 14:12:19 +0000 (16:12 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 25 Aug 2025 09:05:27 +0000 (11:05 +0200)
commit1b558e14f3c17dc29ce2e8cd0b8bd385e108734b
treee17cd85dfd8382e5e2db6b54966ef5921877eb83
parent1b237f190eb3d36f52dffe07a40b5eb210280e00
x86/apic: Make the ISR clearing sane

apic_pending_intr_clear() is fundamentally voodoo programming. It's primary
purpose is to clear stale ISR bits in the local APIC, which would otherwise
lock the corresponding interrupt priority level.

The comments and the implementation claim falsely that after clearing the
stale ISR bits, eventually stale IRR bits would be turned into ISR bits and
can be cleared as well. That's just wishful thinking because:

  1) If interrupts are disabled, the APIC does not propagate an IRR bit to
     the ISR.

  2) If interrupts are enabled, then the APIC propagates the IRR bit to the
     ISR and raises the interrupt in the CPU, which means that code _cannot_
     observe the ISR bit for any of those IRR bits.

Rename the function to reflect the purpose and make exactly _one_ attempt
to EOI the pending ISR bits and add comments why traversing the pending bit
map in low to high priority order is correct.

Instead of trying to "clear" IRR bits, simply print a warning message when
the IRR is not empty.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/871ppwih4s.ffs@tglx
arch/x86/kernel/apic/apic.c