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 6/9] arm: vgic: fix race in vgic_vcpu_inject_irq
Date: Wed, 6 Mar 2013 08:54:33 +0000 [thread overview]
Message-ID: <1362560076-25897-6-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>
The initial check for a still pending interrupt (!list_empty(&n->inflight))
needs to be covered by the vgic lock to avoid trying to insert the IRQ into the
inflight list simultaneously on 2 pCPUS. Expand the area covered by the lock
appropriately.
Also consolidate the unlocks on the exit path into one location.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
xen/arch/arm/vgic.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index dbfcd04..b30da78 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -584,9 +584,14 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)
struct pending_irq *iter, *n = irq_to_pending(v, irq);
unsigned long flags;
- /* irq still pending */
+ spin_lock_irqsave(&v->arch.vgic.lock, flags);
+
+ /* irq already pending */
if (!list_empty(&n->inflight))
+ {
+ spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
return;
+ }
priority = byte_read(rank->ipriority[REG_RANK_INDEX(8, idx)], 0, byte);
@@ -601,20 +606,18 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)
if ( rank->ienable & (1 << (irq % 32)) )
gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
- spin_lock_irqsave(&v->arch.vgic.lock, flags);
list_for_each_entry ( iter, &v->arch.vgic.inflight_irqs, inflight )
{
if ( iter->priority > priority )
{
list_add_tail(&n->inflight, &iter->inflight);
- spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
goto out;
}
}
list_add_tail(&n->inflight, &v->arch.vgic.inflight_irqs);
+out:
spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
/* we have a new higher priority irq, inject it into the guest */
-out:
vcpu_unblock(v);
}
--
1.7.10.4
next prev 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 ` Ian Campbell [this message]
2013-03-19 16:10 ` [PATCH 6/9] arm: vgic: fix race in vgic_vcpu_inject_irq Stefano Stabellini
2013-04-11 8:59 ` Ian Campbell
2013-03-06 8:54 ` [PATCH 7/9] arm: vgic: fix race between evtchn upcall and evtchnop_send Ian Campbell
2013-03-19 16:18 ` 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-6-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.