From: Henry Wang <xin.wang2@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
"Henry Wang" <xin.wang2@amd.com>
Subject: [PATCH v4 4/9] xen/arm/gic: Allow adding interrupt to running VMs
Date: Thu, 23 May 2024 15:40:35 +0800 [thread overview]
Message-ID: <20240523074040.1611264-5-xin.wang2@amd.com> (raw)
In-Reply-To: <20240523074040.1611264-1-xin.wang2@amd.com>
Currently, adding physical interrupts are only allowed at
the domain creation time. For use cases such as dynamic device
tree overlay addition, the adding of physical IRQ to
running domains should be allowed.
Drop the above-mentioned domain creation check. Since this
will introduce interrupt state unsync issues for cases when the
interrupt is active or pending in the guest, therefore for these
cases we simply reject the operation. Do it for both new and old
vGIC implementations.
Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
v4:
- Split the original patch, only do the adding IRQ stuff in this
patch.
v3:
- Update in-code comments.
- Correct the if conditions.
- Add taking/releasing the vgic lock of the vcpu.
v2:
- Reject the case where the IRQ is active or pending in guest.
---
xen/arch/arm/gic-vgic.c | 9 +++++++--
xen/arch/arm/gic.c | 8 --------
xen/arch/arm/vgic/vgic.c | 7 +++++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c
index 56490dbc43..b99e287224 100644
--- a/xen/arch/arm/gic-vgic.c
+++ b/xen/arch/arm/gic-vgic.c
@@ -442,9 +442,14 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq,
if ( connect )
{
- /* The VIRQ should not be already enabled by the guest */
+ /*
+ * The VIRQ should not be already enabled by the guest nor
+ * active/pending in the guest.
+ */
if ( !p->desc &&
- !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) )
+ !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) &&
+ !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) &&
+ !test_bit(GIC_IRQ_GUEST_ACTIVE, &p->status) )
p->desc = desc;
else
ret = -EBUSY;
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 44c40e86de..b3467a76ae 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -135,14 +135,6 @@ int gic_route_irq_to_guest(struct domain *d, unsigned int virq,
ASSERT(virq < vgic_num_irqs(d));
ASSERT(!is_lpi(virq));
- /*
- * When routing an IRQ to guest, the virtual state is not synced
- * back to the physical IRQ. To prevent get unsync, restrict the
- * routing to when the Domain is been created.
- */
- if ( d->creation_finished )
- return -EBUSY;
-
ret = vgic_connect_hw_irq(d, NULL, virq, desc, true);
if ( ret )
return ret;
diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c
index b9463a5f27..048e12c562 100644
--- a/xen/arch/arm/vgic/vgic.c
+++ b/xen/arch/arm/vgic/vgic.c
@@ -876,8 +876,11 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *vcpu,
if ( connect ) /* assign a mapped IRQ */
{
- /* The VIRQ should not be already enabled by the guest */
- if ( !irq->hw && !irq->enabled )
+ /*
+ * The VIRQ should not be already enabled by the guest nor
+ * active/pending in the guest
+ */
+ if ( !irq->hw && !irq->enabled && !irq->active && !irq->pending_latch )
{
irq->hw = true;
irq->hwintid = desc->irq;
--
2.34.1
next prev parent reply other threads:[~2024-05-23 7:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 7:40 [PATCH v4 0/9] Remaining patches for dynamic node programming using overlay dtbo Henry Wang
2024-05-23 7:40 ` [PATCH v4 1/9] tools/xl: Correct the help information and exit code of the dt-overlay command Henry Wang
2024-05-24 0:55 ` Stefano Stabellini
2024-05-23 7:40 ` [PATCH v4 2/9] xen/arm, doc: Add a DT property to specify IOMMU for Dom0less domUs Henry Wang
2024-05-23 21:23 ` Julien Grall
2024-05-23 7:40 ` [PATCH v4 3/9] tools/arm: Introduce the "nr_spis" xl config entry Henry Wang
2024-05-23 23:05 ` Julien Grall
2024-05-24 2:19 ` Stefano Stabellini
2024-05-23 7:40 ` Henry Wang [this message]
2024-05-23 21:27 ` [PATCH v4 4/9] xen/arm/gic: Allow adding interrupt to running VMs Julien Grall
2024-05-23 7:40 ` [PATCH v4 5/9] xen/arm: Add XEN_DOMCTL_dt_overlay and device attachment to domains Henry Wang
2024-05-23 21:55 ` Julien Grall
2024-05-24 2:19 ` Stefano Stabellini
2024-05-23 7:40 ` [PATCH v4 6/9] xen/arm/gic: Allow removing interrupt to running VMs Henry Wang
2024-05-23 7:40 ` [PATCH v4 7/9] xen/arm: Support device detachment from domains Henry Wang
2024-05-23 22:42 ` Julien Grall
2024-05-23 7:40 ` [PATCH v4 8/9] tools: Introduce the "xl dt-overlay {attach,detach}" commands Henry Wang
2024-05-23 23:11 ` Julien Grall
2024-05-24 2:19 ` Stefano Stabellini
2024-05-23 7:40 ` [PATCH v4 9/9] docs: Add device tree overlay documentation Henry Wang
2024-05-23 22:48 ` Julien Grall
2024-05-24 2:19 ` Stefano Stabellini
2024-05-23 21:29 ` [PATCH v4 0/9] Remaining patches for dynamic node programming using overlay dtbo Julien Grall
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=20240523074040.1611264-5-xin.wang2@amd.com \
--to=xin.wang2@amd.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--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.