All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
To: <xen-devel@lists.xenproject.org>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>
Subject: [Xen-devel] [XEN PATCH v3 07/11] xen: arm: vgic: allow delivery of PPIs to guests
Date: Fri, 15 Nov 2019 15:10:33 -0500	[thread overview]
Message-ID: <20191115201037.44982-3-stewart.hildebrand@dornerworks.com> (raw)
In-Reply-To: <20191115200115.44890-1-stewart.hildebrand@dornerworks.com>

Allow vgic_get_hw_irq_desc to be called with a vcpu argument.

Use vcpu argument in vgic_connect_hw_irq.

vgic_connect_hw_irq is called for PPIs and SPIs, not SGIs. Enforce with
ASSERTs.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>

---
v3: new patch

---
Note: I have only modified the old vgic to allow delivery of PPIs.
---
 xen/arch/arm/gic-vgic.c | 24 ++++++++++++++++--------
 xen/arch/arm/vgic.c     |  6 +++---
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c
index 98c021f1a8..2c66a8fa92 100644
--- a/xen/arch/arm/gic-vgic.c
+++ b/xen/arch/arm/gic-vgic.c
@@ -418,7 +418,7 @@ struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v,
 {
     struct pending_irq *p;
 
-    ASSERT(!v && virq >= 32);
+    ASSERT((!v && (virq >= 32)) || (!d && v && (virq >= 16) && (virq < 32)));
 
     if ( !v )
         v = d->vcpu[0];
@@ -434,15 +434,23 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq,
                         struct irq_desc *desc, bool connect)
 {
     unsigned long flags;
-    /*
-     * Use vcpu0 to retrieve the pending_irq struct. Given that we only
-     * route SPIs to guests, it doesn't make any difference.
-     */
-    struct vcpu *v_target = vgic_get_target_vcpu(d->vcpu[0], virq);
-    struct vgic_irq_rank *rank = vgic_rank_irq(v_target, virq);
-    struct pending_irq *p = irq_to_pending(v_target, virq);
+    struct vcpu *v_target;
+    struct vgic_irq_rank *rank;
+    struct pending_irq *p;
     int ret = 0;
 
+    if (v)
+        v_target = v;
+    else
+        /* Use vcpu0 to retrieve the pending_irq struct. */
+        v_target = vgic_get_target_vcpu(d->vcpu[0], virq);
+
+    rank = vgic_rank_irq(v_target, virq);
+    p = irq_to_pending(v_target, virq);
+
+    ASSERT(virq >= NR_SGIS);
+    ASSERT(p->irq >= NR_SGIS);
+
     /* "desc" is optional when we disconnect an IRQ. */
     ASSERT(!connect || desc);
 
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 82f524a35c..c3933c2687 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -410,10 +410,10 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
             irq_set_affinity(p->desc, cpumask_of(v_target->processor));
             spin_lock_irqsave(&p->desc->lock, flags);
             /*
-             * The irq cannot be a PPI, we only support delivery of SPIs
-             * to guests.
+             * The irq cannot be a SGI, we only support delivery of SPIs
+             * and PPIs to guests.
              */
-            ASSERT(irq >= 32);
+            ASSERT(irq >= NR_SGIS);
             if ( irq_type_set_by_domain(d) )
                 gic_set_irq_type(p->desc, vgic_get_virq_type(v, n, i));
             p->desc->handler->enable(p->desc);
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-11-15 20:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 20:01 [Xen-devel] [XEN PATCH v3 00/11] xen: arm: context switch vtimer PPI state Stewart Hildebrand
2019-11-15 20:01 ` [Xen-devel] [XEN PATCH v3 01/11] xen: arm: fix indentation of struct vtimer Stewart Hildebrand
2019-11-23 18:40   ` Julien Grall
2019-11-23 18:45     ` Julien Grall
2019-11-15 20:01 ` [Xen-devel] [XEN PATCH v3 02/11] xen: arm: fix typo in the description of struct pending_irq->desc Stewart Hildebrand
2019-11-23 18:47   ` Julien Grall
2019-11-15 20:01 ` [Xen-devel] [XEN PATCH v3 03/11] xen: arm: Refactor route_irq_to_guest Stewart Hildebrand
2019-11-23 19:21   ` Julien Grall
2019-11-15 20:01 ` [Xen-devel] [XEN PATCH v3 04/11] xen: arm: remove is_assignable_irq Stewart Hildebrand
2019-11-23 19:28   ` Julien Grall
2019-11-15 20:10 ` [Xen-devel] [XEN PATCH v3 05/11] xen: arm: add interfaces to save/restore the state of a PPI Stewart Hildebrand
2019-11-17 23:10   ` Stewart Hildebrand
2019-11-25 21:23   ` Julien Grall
2019-11-26 23:15   ` Stefano Stabellini
2019-11-15 20:10 ` [Xen-devel] [XEN PATCH v3 06/11] Add NR_SGIS and NR_PPIS definitions to irq.h Stewart Hildebrand
2019-11-27 17:49   ` Julien Grall
2019-11-15 20:10 ` Stewart Hildebrand [this message]
2019-11-23 20:35   ` [Xen-devel] [XEN PATCH v3 07/11] xen: arm: vgic: allow delivery of PPIs to guests Julien Grall
2019-11-25 15:05     ` Julien Grall
2019-11-26  1:20       ` Stefano Stabellini
2019-11-26 13:58         ` Julien Grall
2019-11-26 22:36       ` Stefano Stabellini
2019-11-26 22:42         ` Julien Grall
2019-11-27 18:48           ` Stefano Stabellini
2019-11-27 19:17             ` Julien Grall
2019-11-26 23:16   ` Stefano Stabellini
2019-11-27  0:13     ` Julien Grall
2019-11-28  1:07       ` Stefano Stabellini
2019-11-28  9:53         ` Julien Grall
2019-11-15 20:10 ` [Xen-devel] [RFC XEN PATCH v3 08/11] xen: arm: vgic: don't fail if IRQ is already connected Stewart Hildebrand
2019-11-26 23:16   ` Stefano Stabellini
2019-12-03 14:24   ` Julien Grall
2019-11-15 20:10 ` [Xen-devel] [XEN PATCH v3 09/11] xen: arm: gic: supporting routing a PPI to the current vcpu Stewart Hildebrand
2019-11-17 23:11   ` Stewart Hildebrand
2019-11-15 20:14 ` [Xen-devel] [RFC XEN PATCH v3 10/11] xen: arm: context switch vtimer PPI state Stewart Hildebrand
2019-11-25 21:55   ` Julien Grall
2019-11-26 23:16     ` Stefano Stabellini
2019-11-15 20:14 ` [Xen-devel] [HACK XEN PATCH v3 11/11] HACK: Force virt timer to PPI0 (IRQ16) Stewart Hildebrand

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=20191115201037.44982-3-stewart.hildebrand@dornerworks.com \
    --to=stewart.hildebrand@dornerworks.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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.