All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ijc@hellion.org.uk>
To: xen-devel@lists.xen.org
Cc: stefano.stabellini@citrix.com, tim@xen.org,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 7/9] arm: vgic: fix race between evtchn upcall and evtchnop_send
Date: Wed,  6 Mar 2013 08:54:34 +0000	[thread overview]
Message-ID: <1362560076-25897-7-git-send-email-ijc@hellion.org.uk> (raw)
In-Reply-To: <1362559920.8941.98.camel@hastur.hellion.org.uk>

From: Ian Campbell <ian.campbell@citrix.com>

On ARM the evtchn upcall is done by using a local PPI interrupt. However the
guest will clear the evtchn_upcall_pending bit before it EOIs that PPI (which
happens late). This means vgic_vcpu_inject_irq (called via
vcpu_mark_events_pending) sees the PPI as in flight and ends up not reinjecting
it, if this happens after the guest has finished its event channel processing
loop but before the EOI then we have lost the upcall.

We therefore also need to call gic_restore_pending_irqs on the exit to guest
path in order to pickup any newly inject IRQ and propagate it into a free LR.
This doesn't currently support bumping a lower priority interrupt out of the
LRs in order to inject a new higher priority interrupt. We don't yet implement
interrupt prioritisation (and guests don't use it either) so this will do for
now.

Since gic_restore_pending_irqs is now called in the return to guest path it is
called with interrupts disabled and accordinly must use the irqsave/irqrestore
spinlock primitives.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 xen/arch/arm/gic.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 6592562..59e007a 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -556,17 +556,18 @@ static void gic_restore_pending_irqs(struct vcpu *v)
 {
     int i;
     struct pending_irq *p, *t;
+    unsigned long flags;
 
     list_for_each_entry_safe ( p, t, &v->arch.vgic.lr_pending, lr_queue )
     {
         i = find_first_zero_bit(&this_cpu(lr_mask), nr_lrs);
         if ( i >= nr_lrs ) return;
 
-        spin_lock_irq(&gic.lock);
+        spin_lock_irqsave(&gic.lock, flags);
         gic_set_lr(i, p->irq, GICH_LR_PENDING, p->priority);
         list_del_init(&p->lr_queue);
         set_bit(i, &this_cpu(lr_mask));
-        spin_unlock_irq(&gic.lock);
+        spin_unlock_irqrestore(&gic.lock, flags);
     }
 
 }
@@ -589,6 +590,10 @@ static void gic_inject_irq_stop(void)
 
 void gic_inject(void)
 {
+    if ( vcpu_info(current, evtchn_upcall_pending) )
+        vgic_vcpu_inject_irq(current, VGIC_IRQ_EVTCHN_CALLBACK, 1);
+
+    gic_restore_pending_irqs(current);
     if (!this_cpu(lr_mask))
         gic_inject_irq_stop();
     else
-- 
1.7.10.4

  parent reply	other threads:[~2013-03-06  8:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  8:52 [PATCH 00/09] arm: host SMP support Ian Campbell
2013-03-06  8:54 ` [PATCH 1/9] arm: initialise VCPU SCTLR in vcpu_initialise Ian Campbell
2013-03-19 15:58   ` Stefano Stabellini
2013-04-11  8:58     ` Ian Campbell
2013-03-06  8:54 ` [PATCH 2/9] arm: consolidate setup of hypervisor traps and second stage paging Ian Campbell
2013-03-19 17:34   ` Stefano Stabellini
2013-04-11  8:58     ` Ian Campbell
2013-03-06  8:54 ` [PATCH 3/9] arm: gic: implement IPIs using SGI mechanism Ian Campbell
2013-03-19 17:28   ` Stefano Stabellini
2013-04-09 14:51     ` Ian Campbell
2013-04-11 15:53       ` Ian Campbell
2013-04-11 16:17       ` Ian Campbell
2013-04-11 22:40         ` Julien Grall
2013-04-12  8:00           ` Ian Campbell
2013-03-06  8:54 ` [PATCH 4/9] arm64: correct secondary CPU bringup Ian Campbell
2013-04-11  8:27   ` Ian Campbell
2013-04-18 13:33     ` Stefano Stabellini
2013-03-06  8:54 ` [PATCH 5/9] arm: vgic: typo s/securty/security/ Ian Campbell
2013-03-19 16:06   ` Stefano Stabellini
2013-04-11  8:59     ` Ian Campbell
2013-03-06  8:54 ` [PATCH 6/9] arm: vgic: fix race in vgic_vcpu_inject_irq Ian Campbell
2013-03-19 16:10   ` Stefano Stabellini
2013-04-11  8:59     ` Ian Campbell
2013-03-06  8:54 ` Ian Campbell [this message]
2013-03-19 16:18   ` [PATCH 7/9] arm: vgic: fix race between evtchn upcall and evtchnop_send Stefano Stabellini
2013-04-09 14:39     ` Ian Campbell
2013-04-11  8:59     ` Ian Campbell
2013-03-06  8:54 ` [PATCH 8/9] arm: gic: fix build on arm64 Ian Campbell
2013-03-19 16:05   ` Stefano Stabellini
2013-04-11  9:00     ` Ian Campbell
2013-03-06  8:54 ` [PATCH 9/9] arm: tweak/improve logging for host SMP Ian Campbell
2013-03-19 16:05   ` Stefano Stabellini
2013-04-11  9:00     ` Ian Campbell
2013-03-22 14:50 ` [PATCH 00/09] arm: host SMP support Stefano Stabellini
2013-03-22 15:05   ` Stefano Stabellini

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=1362560076-25897-7-git-send-email-ijc@hellion.org.uk \
    --to=ijc@hellion.org.uk \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.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.