From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v8 08/10] xen/arm: take the rank lock before accessing ipriority
Date: Thu, 10 Jul 2014 19:13:21 +0100 [thread overview]
Message-ID: <1405016003-19131-8-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1407101908280.29039@kaball.uk.xensource.com>
Currently we read ipriority from vgic_vcpu_inject_irq without taking the
rank lock. Fix that by taking the rank lock and reading ipriority at the
beginning of the function.
As vgic_vcpu_inject_irq is called from the irq.c upon receiving an
interrupt, we need to change the implementation of vgic_lock/unlock_rank
to spin_lock_irqsave to make it safe in irq context.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Changes in v2:
- rebased on ab78724fc5628318b172b4344f7280621a151e1b;
- remove warning on changing priority of active irqs.
---
xen/arch/arm/vgic-v2.c | 2 ++
xen/arch/arm/vgic.c | 6 +++++-
xen/include/asm-arm/vgic.h | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
index 5116a99..ae31dbf 100644
--- a/xen/arch/arm/vgic-v2.c
+++ b/xen/arch/arm/vgic-v2.c
@@ -39,6 +39,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
register_t *r = select_user_reg(regs, dabt.reg);
struct vgic_irq_rank *rank;
int gicd_reg = (int)(info->gpa - v->domain->arch.vgic.dbase);
+ unsigned long flags;
switch ( gicd_reg )
{
@@ -269,6 +270,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
struct vgic_irq_rank *rank;
int gicd_reg = (int)(info->gpa - v->domain->arch.vgic.dbase);
uint32_t tr;
+ unsigned long flags;
switch ( gicd_reg )
{
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 569a859..fc51e87 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -175,6 +175,7 @@ struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int irq)
{
struct vcpu *v_target;
struct vgic_irq_rank *rank = vgic_rank_irq(v, irq);
+ unsigned long flags;
vgic_lock_rank(v, rank);
v_target = _vgic_get_target_vcpu(v, irq);
@@ -386,6 +387,10 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)
bool_t running;
struct vcpu *vcpu_migrate_from;
+ vgic_lock_rank(v, rank);
+ priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq, DABT_WORD)], 0, irq & 0x3);
+ vgic_unlock_rank(v, rank);
+
spin_lock_irqsave(&v->arch.vgic.lock, flags);
/* vcpu offline */
@@ -418,7 +423,6 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)
goto out;
}
- priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq, DABT_WORD)], 0, irq & 0x3);
n->irq = irq;
n->priority = priority;
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index e961780..5d6a8ad 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -106,8 +106,8 @@ struct vgic_ops {
#define vgic_lock(v) spin_lock_irq(&(v)->domain->arch.vgic.lock)
#define vgic_unlock(v) spin_unlock_irq(&(v)->domain->arch.vgic.lock)
-#define vgic_lock_rank(v, r) spin_lock(&(r)->lock)
-#define vgic_unlock_rank(v, r) spin_unlock(&(r)->lock)
+#define vgic_lock_rank(v, r) spin_lock_irqsave(&(r)->lock, flags)
+#define vgic_unlock_rank(v, r) spin_unlock_irqrestore(&(r)->lock, flags)
/*
* Rank containing GICD_<FOO><n> for GICD_<FOO> with
--
1.7.10.4
next prev parent reply other threads:[~2014-07-10 18:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-10 18:12 [PATCH v8 00/10] gic and vgic fixes and improvements Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 01/10] xen/arm: observe itargets setting in vgic_enable_irqs and vgic_disable_irqs Stefano Stabellini
2014-07-11 13:01 ` Julien Grall
2014-07-23 15:31 ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 02/10] xen/arm: move setting GIC_IRQ_GUEST_QUEUED earlier Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 03/10] xen/arm: inflight irqs during migration Stefano Stabellini
2014-07-17 12:44 ` Ian Campbell
2014-07-23 14:45 ` Stefano Stabellini
2014-07-23 15:38 ` Ian Campbell
2014-07-24 14:48 ` Stefano Stabellini
2014-07-24 16:41 ` Ian Campbell
2014-07-24 16:45 ` Stefano Stabellini
2014-07-24 16:48 ` Ian Campbell
2014-07-24 16:49 ` Stefano Stabellini
2014-07-25 9:08 ` Ian Campbell
2014-07-10 18:13 ` [PATCH v8 04/10] xen/arm: support irq delivery to vcpu > 0 Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 05/10] xen/arm: physical irq follow virtual irq Stefano Stabellini
2014-07-11 13:07 ` Julien Grall
2014-07-23 15:00 ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 06/10] xen: introduce sched_move_irqs Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 07/10] xen/arm: remove workaround to inject evtchn_irq on irq enable Stefano Stabellini
2014-07-11 13:10 ` Julien Grall
2014-07-17 12:50 ` Ian Campbell
2014-07-23 15:04 ` Stefano Stabellini
2014-07-23 16:09 ` Stefano Stabellini
2014-07-23 16:11 ` Ian Campbell
2014-07-23 16:12 ` Stefano Stabellini
2014-07-23 16:16 ` Ian Campbell
2014-07-24 14:37 ` Stefano Stabellini
2014-07-10 18:13 ` Stefano Stabellini [this message]
2014-07-17 12:51 ` [PATCH v8 08/10] xen/arm: take the rank lock before accessing ipriority Ian Campbell
2014-07-23 14:57 ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 09/10] xen: introduce bit access macros for the IRQ line status flags Stefano Stabellini
2014-07-11 13:15 ` Julien Grall
2014-07-23 14:52 ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 10/10] xen/arm: make accesses to desc->status flags atomic Stefano Stabellini
2014-07-17 12:52 ` Ian Campbell
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=1405016003-19131-8-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).