]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
x86/ioapic: Prevent inconsistent state when moving an interrupt
authorThomas Gleixner <tglx@linutronix.de>
Thu, 17 Oct 2019 10:19:01 +0000 (12:19 +0200)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 6 Jan 2020 14:16:03 +0000 (08:16 -0600)
commitb4feacde9b88e874113e87da2545c0fa9f2a040b
treeae1e4b0c5a9d4f428b0d074e39c66e186ea8626a
parentf41305bbbc1690eedc050828949274882cea7cd8
x86/ioapic: Prevent inconsistent state when moving an interrupt

BugLink: https://bugs.launchpad.net/bugs/1858428
[ Upstream commit df4393424af3fbdcd5c404077176082a8ce459c4 ]

There is an issue with threaded interrupts which are marked ONESHOT
and using the fasteoi handler:

  if (IS_ONESHOT())
    mask_irq();
  ....
  cond_unmask_eoi_irq()
    chip->irq_eoi();
      if (setaffinity_pending) {
         mask_ioapic();
         ...
 move_affinity();
 unmask_ioapic();
      }

So if setaffinity is pending the interrupt will be moved and then
unconditionally unmasked at the ioapic level, which is wrong in two
aspects:

 1) It should be kept masked up to the point where the threaded handler
    finished.

 2) The physical chip state and the software masked state are inconsistent

Guard both the mask and the unmask with a check for the software masked
state. If the line is marked masked then the ioapic line is also masked, so
both mask_ioapic() and unmask_ioapic() can be skipped safely.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Fixes: 3aa551c9b4c4 ("genirq: add threaded interrupt handler support")
Link: https://lkml.kernel.org/r/20191017101938.321393687@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
arch/x86/kernel/apic/io_apic.c