aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2017-07-18 13:37:55 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2017-08-02 11:55:59 -0400
commit39a06b67c2c1256bcf2361a1f67d2529f70ab206 (patch)
tree07935760ebcc62f2550a5d5f184c11751aa1c541
parentd1ce263feb40e6b3208f3e1ebec6dbe86df6f522 (diff)
irqchip/gic: Ensure we have an ISB between ack and ->handle_irq
Devices that expose their interrupt status registers via system registers (e.g. Statistical profiling, CPU PMU, DynamIQ PMU, arch timer, vgic (although unused by Linux), ...) rely on a context synchronising operation on the CPU to ensure that the updated status register is visible to the CPU when handling the interrupt. This usually happens as a result of taking the IRQ exception in the first place, but there are two race scenarios where this isn't the case. For example, let's say we have two peripherals (X and Y), where Y uses a system register for its interrupt status. Case 1: 1. CPU takes an IRQ exception as a result of X raising an interrupt 2. Y then raises its interrupt line, but the update to its system register is not yet visible to the CPU 3. The GIC decides to expose Y's interrupt number first in the Ack register 4. The CPU runs the IRQ handler for Y, but the status register is stale Case 2: 1. CPU takes an IRQ exception as a result of X raising an interrupt 2. CPU reads the interrupt number for X from the Ack register and runs its IRQ handler 3. Y raises its interrupt line and the Ack register is updated, but again, the update to its system register is not yet visible to the CPU. 4. Since the GIC drivers poll the Ack register, we read Y's interrupt number and run its handler without a context synchronisation operation, therefore seeing the stale register value. In either case, we run the risk of missing an IRQ. This patch solves the problem by ensuring that we execute an ISB in the GIC drivers prior to invoking the interrupt handler. This is already the case for GICv3 and EOIMode 1 (the usual case for the host). Cc: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--drivers/irqchip/irq-gic-v3.c2
-rw-r--r--drivers/irqchip/irq-gic.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 5ba64a7584a3..984c3ecfd22c 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -353,6 +353,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
353 353
354 if (static_key_true(&supports_deactivate)) 354 if (static_key_true(&supports_deactivate))
355 gic_write_eoir(irqnr); 355 gic_write_eoir(irqnr);
356 else
357 isb();
356 358
357 err = handle_domain_irq(gic_data.domain, irqnr, regs); 359 err = handle_domain_irq(gic_data.domain, irqnr, regs);
358 if (err) { 360 if (err) {
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 940c16278758..d3e7c43718b8 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -361,6 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
361 if (likely(irqnr > 15 && irqnr < 1020)) { 361 if (likely(irqnr > 15 && irqnr < 1020)) {
362 if (static_key_true(&supports_deactivate)) 362 if (static_key_true(&supports_deactivate))
363 writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); 363 writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
364 isb();
364 handle_domain_irq(gic->domain, irqnr, regs); 365 handle_domain_irq(gic->domain, irqnr, regs);
365 continue; 366 continue;
366 } 367 }
@@ -401,10 +402,12 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
401 goto out; 402 goto out;
402 403
403 cascade_irq = irq_find_mapping(chip_data->domain, gic_irq); 404 cascade_irq = irq_find_mapping(chip_data->domain, gic_irq);
404 if (unlikely(gic_irq < 32 || gic_irq > 1020)) 405 if (unlikely(gic_irq < 32 || gic_irq > 1020)) {
405 handle_bad_irq(desc); 406 handle_bad_irq(desc);
406 else 407 } else {
408 isb();
407 generic_handle_irq(cascade_irq); 409 generic_handle_irq(cascade_irq);
410 }
408 411
409 out: 412 out:
410 chained_irq_exit(chip, desc); 413 chained_irq_exit(chip, desc);