[lkml]   [2020]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 3.16 033/148] x86/ioapic: Prevent inconsistent state when moving an interrupt
3.16.82-rc1 review patch.  If anyone has any objections, please let me know.


From: Thomas Gleixner <>

commit df4393424af3fbdcd5c404077176082a8ce459c4 upstream.

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

if (setaffinity_pending) {

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

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

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 <>
Cc: Andy Shevchenko <>
Cc: Linus Torvalds <>
Cc: Peter Zijlstra <>
Cc: Sebastian Siewior <>
Fixes: 3aa551c9b4c4 ("genirq: add threaded interrupt handler support")
Signed-off-by: Ingo Molnar <>
[bwh: Backported to 3.16: Keep using {,un}mask_iopaic_irq()]
Signed-off-by: Ben Hutchings <>
arch/x86/kernel/apic/io_apic.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2377,9 +2377,10 @@ static bool io_apic_level_ack_pending(st

static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
- /* If we are moving the irq we need to mask it */
+ /* If we are moving the IRQ we need to mask it */
if (unlikely(irqd_is_setaffinity_pending(data))) {
- mask_ioapic(cfg);
+ if (!irqd_irq_masked(data))
+ mask_ioapic(cfg);
return true;
return false;
@@ -2417,7 +2418,9 @@ static inline void ioapic_irqd_unmask(st
if (!io_apic_level_ack_pending(cfg))
- unmask_ioapic(cfg);
+ /* If the IRQ is masked in the core, leave it: */
+ if (!irqd_irq_masked(data))
+ unmask_ioapic(cfg);
 \ /
  Last update: 2020-02-08 19:31    [W:0.352 / U:1.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site