From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: tim@xen.org, Ian.Campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 2/4] xen/arm: support for guest SGI
Date: Thu, 21 Mar 2013 18:42:31 +0000 [thread overview]
Message-ID: <1363891353-13827-2-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1303211837140.5135@kaball.uk.xensource.com>
Trap writes to GICD_SGIR, parse the requests, inject SGIs into the right
guest vcpu.
Add a useful debug printk to vgic_vcpu_inject_irq.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/vgic.c | 53 +++++++++++++++++++++++++++++++++++++++++---
xen/include/asm-arm/gic.h | 3 ++
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 8495384..26279f9 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -370,6 +370,7 @@ static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
{
+ struct domain *d = v->domain;
struct hsr_dabt dabt = info->dabt;
struct cpu_user_regs *regs = guest_cpu_user_regs();
uint32_t *r = select_user_reg(regs, dabt.reg);
@@ -498,10 +499,51 @@ static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
goto write_ignore;
case GICD_SGIR:
- if ( dabt.size != 2 ) goto bad_width;
- printk("vGICD: unhandled write %#"PRIx32" to ICFGR%d\n",
- *r, gicd_reg - GICD_ICFGR);
- return 0;
+ {
+ cpumask_t vcpu_mask;
+ int virtual_irq;
+ int filter;
+ int vcpuid;
+ struct vcpu *vt;
+ int i;
+
+ if ( dabt.size != 2 ) goto bad_width;
+
+ filter = (*r & GICD_SGI_TARGET_LIST_MASK);
+ virtual_irq = (*r & GICD_SGI_INTID_MASK);
+
+ cpumask_clear(&vcpu_mask);
+ switch ( filter )
+ {
+ case GICD_SGI_TARGET_LIST:
+ cpumask_bits(&vcpu_mask)[0] = (*r & GICD_SGI_TARGET_MASK) >> GICD_SGI_TARGET_SHIFT;
+ break;
+ case GICD_SGI_TARGET_OTHERS:
+ for ( i = 0; i < d->max_vcpus; i++ )
+ {
+ if ( i != current->vcpu_id && d->vcpu[i] != NULL )
+ cpumask_set_cpu(i, &vcpu_mask);
+ }
+ case GICD_SGI_TARGET_SELF:
+ cpumask_of(current->vcpu_id);
+ break;
+ default:
+ printk("vGICD: unhandled GICD_SGIR write %x with wrong TargetListFilter field\n", *r);
+ return 0;
+ }
+
+ for_each_cpu( vcpuid, &vcpu_mask )
+ {
+ if ( vcpuid >= d->max_vcpus || (vt = d->vcpu[vcpuid]) == NULL ||
+ virtual_irq >= 16 )
+ {
+ printk("vGICD: GICD_SGIR write %x, wrong CPUTargetList\n", *r);
+ return 0;
+ }
+ vgic_vcpu_inject_irq(vt, virtual_irq, 1);
+ }
+ return 1;
+ }
case GICD_CPENDSGIR ... GICD_CPENDSGIRN:
if ( dabt.size != 0 && dabt.size != 2 ) goto bad_width;
@@ -600,6 +642,9 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)
/* the irq is enabled */
if ( rank->ienable & (1 << (irq % 32)) )
gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
+ else
+ printk("%s: trying to inject irq %d to d%d:v%d, but it is not enabled\n",
+ __func__, irq, v->domain->domain_id, v->vcpu_id);
spin_lock_irqsave(&v->arch.vgic.lock, flags);
list_for_each_entry ( iter, &v->arch.vgic.inflight_irqs, inflight )
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 907c495..ab45b41 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -51,12 +51,15 @@
#define GICD_SPENDSGIRN (0xF2C/4)
#define GICD_ICPIDR2 (0xFE8/4)
+#define GICD_SGI_TARGET_LIST_SHIFT (24)
+#define GICD_SGI_TARGET_LIST_MASK (0x3UL << GICD_SGI_TARGET_LIST_SHIFT)
#define GICD_SGI_TARGET_LIST (0UL<<24)
#define GICD_SGI_TARGET_OTHERS (1UL<<24)
#define GICD_SGI_TARGET_SELF (2UL<<24)
#define GICD_SGI_TARGET_SHIFT (16)
#define GICD_SGI_TARGET_MASK (0xFFUL<<GICD_SGI_TARGET_SHIFT)
#define GICD_SGI_GROUP1 (1UL<<15)
+#define GICD_SGI_INTID_MASK (0xFUL)
#define GICC_CTLR (0x0000/4)
#define GICC_PMR (0x0004/4)
--
1.7.2.5
next prev parent reply other threads:[~2013-03-21 18:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-21 18:42 [PATCH 0/4] xen/arm: guest SMP support Stefano Stabellini
2013-03-21 18:42 ` [PATCH 1/4] xen/arm: basic PSCI support, implement cpu_on Stefano Stabellini
2013-04-09 13:57 ` Ian Campbell
2013-04-09 14:23 ` Marc Zyngier
2013-04-10 10:13 ` Ian Campbell
2013-04-10 10:41 ` Marc Zyngier
2013-04-10 10:50 ` Ian Campbell
2013-04-11 12:29 ` Ian Campbell
2013-04-11 23:42 ` Stefano Stabellini
2013-04-12 7:46 ` Ian Campbell
2013-04-18 12:59 ` Stefano Stabellini
2013-04-11 13:32 ` hypervisor/firmware calling conventions (Was: Re: [Xen-devel] [PATCH 1/4] xen/arm: basic PSCI support, implement cpu_on) Ian Campbell
2013-04-11 17:10 ` Dave Martin
2013-04-12 11:16 ` Ian Campbell
2013-04-12 14:22 ` Dave Martin
2013-03-21 18:42 ` Stefano Stabellini [this message]
2013-04-09 14:01 ` [PATCH 2/4] xen/arm: support for guest SGI Ian Campbell
2013-04-23 11:50 ` Stefano Stabellini
2013-04-23 11:57 ` Ian Campbell
2013-04-23 12:08 ` Stefano Stabellini
2013-04-23 13:10 ` Ian Campbell
2013-03-21 18:42 ` [PATCH 3/4] xen/arm: support vcpu_op hypercalls Stefano Stabellini
2013-04-09 14:02 ` Ian Campbell
2013-04-23 11:32 ` Stefano Stabellini
2013-04-23 13:52 ` Ian Campbell
2013-03-21 18:42 ` [PATCH 4/4] xen: move VCPUOP_register_vcpu_info to common code Stefano Stabellini
2013-04-09 14:04 ` Ian Campbell
2013-04-12 14:12 ` 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=1363891353-13827-2-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=tim@xen.org \
--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).