From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xen.org
Cc: andre.przywara@arm.com, Julien Grall <julien.grall@arm.com>,
sstabellini@kernel.org
Subject: [PATCH 1/4] xen/arm: gic: Ensure we have an ISB between ack and do_IRQ()
Date: Tue, 23 Oct 2018 19:17:06 +0100 [thread overview]
Message-ID: <20181023181709.11883-2-julien.grall@arm.com> (raw)
In-Reply-To: <20181023181709.11883-1-julien.grall@arm.com>
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.
Based on Linux commit 39a06b67c2c1256bcf2361a1f67d2529f70ab206
"irqchip/gic: Ensure we have an ISB between ack and ->handle_irq".
Signed-off-by: Julien Grall <julien.grall@arm.com>
---
This patch is a candidate for backporting up to Xen 4.9.
---
xen/arch/arm/gic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 8d7e491060..305fbd66dd 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -388,12 +388,14 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
if ( likely(irq >= 16 && irq < 1020) )
{
local_irq_enable();
+ isb();
do_IRQ(regs, irq, is_fiq);
local_irq_disable();
}
else if ( is_lpi(irq) )
{
local_irq_enable();
+ isb();
gic_hw_ops->do_LPI(irq);
local_irq_disable();
}
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-10-23 18:17 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-23 18:17 [PATCH 0/4] xen/arm: GIC fixes and improvement Julien Grall
2018-10-23 18:17 ` Julien Grall [this message]
2018-10-24 9:38 ` [PATCH 1/4] xen/arm: gic: Ensure we have an ISB between ack and do_IRQ() Andrii Anisov
2018-10-24 14:41 ` Julien Grall
2018-10-25 14:11 ` Andrii Anisov
2018-10-25 14:22 ` Julien Grall
2018-10-25 17:45 ` Andrii Anisov
2018-10-26 12:49 ` Andrii Anisov
2018-10-26 21:55 ` Julien Grall
2018-10-27 12:14 ` Andrii Anisov
2018-10-28 11:46 ` Julien Grall
2018-10-29 10:06 ` Andrii Anisov
2018-10-29 13:36 ` Julien Grall
2018-10-29 16:16 ` Andrii Anisov
2018-10-29 16:22 ` Julien Grall
2018-10-30 8:07 ` Andrii Anisov
2018-11-09 14:42 ` Andrii Anisov
2018-11-09 17:47 ` Julien Grall
2018-11-19 15:54 ` Andrii Anisov
2018-11-19 16:42 ` Julien Grall
2018-11-20 18:10 ` Andrii Anisov
2018-11-20 18:47 ` Julien Grall
2018-11-22 16:51 ` Andrii Anisov
2018-11-22 17:22 ` Julien Grall
2018-11-23 10:09 ` Andrii Anisov
2018-11-23 12:18 ` Andre Przywara
2018-11-23 13:04 ` Andrii Anisov
2018-11-30 19:52 ` Andrii Anisov
2018-12-03 13:46 ` Andre Przywara
2018-12-03 13:53 ` Juergen Gross
2018-12-03 14:36 ` Andrii Anisov
2018-12-04 17:16 ` Julien Grall
2018-12-03 15:28 ` Andrii Anisov
2018-11-28 0:30 ` Stefano Stabellini
2018-11-22 18:04 ` Andre Przywara
2018-11-23 12:58 ` Andrii Anisov
2018-11-23 13:27 ` Julien Grall
2018-11-27 13:30 ` Andrii Anisov
2018-11-27 15:13 ` Julien Grall
2018-12-03 12:08 ` Andrii Anisov
2018-12-03 12:17 ` Julien Grall
2018-12-03 12:58 ` Andrii Anisov
2018-12-03 13:10 ` Julien Grall
2018-10-25 17:46 ` Andrii Anisov
2018-11-09 23:02 ` Stefano Stabellini
2018-10-23 18:17 ` [PATCH 2/4] xen/arm: gic: Ensure ordering between read of INTACK and shared data Julien Grall
2018-10-24 15:40 ` Andrii Anisov
2018-11-09 23:02 ` Stefano Stabellini
2018-10-23 18:17 ` [PATCH 3/4] xen/arm: gic: Remove duplicated comment in do_sgi Julien Grall
2018-10-24 10:26 ` Andrii Anisov
2018-11-09 23:03 ` Stefano Stabellini
2018-10-23 18:17 ` [PATCH 4/4] xen/arm: gic: Relax barrier when sending an SGI Julien Grall
2018-10-24 13:32 ` Andrii Anisov
2018-10-24 14:46 ` Julien Grall
2018-10-24 15:40 ` Andrii Anisov
2018-10-24 15:44 ` Julien Grall
2018-11-09 23:14 ` Stefano Stabellini
2018-11-12 12:15 ` Julien Grall
-- strict thread matches above, loose matches on Subject: below --
2018-10-29 16:46 [PATCH 1/4] xen/arm: gic: Ensure we have an ISB between ack and do_IRQ() Andrii Anisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181023181709.11883-2-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=andre.przywara@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.