[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 02/15] xen/arm/gic: Enable interrupt assignment to running VM


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Sat, 11 May 2024 15:29:47 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hSIOxDBb6opTW+eXESXU5shvpcAEyhf3/skZqhC1BIw=; b=W8WKfdfdIJZLbYgLccE6OheeEZ5+5mjIX48pBZCaMSazC50LmHMxMvsVRnnOP+UQoy7m0ECPkvAILerTOT8SHfhoJAPr9E4NV3m4BO6X1gIvWkKPWcorlMTlCAaRZjQX6Re+XvcZTvoNIEiKhxkPosspN7L+3h0i16xncuDSJ9aGIsYuFsiaY/+SNXfUtCRvfRvWDBJIyzGxrZF838Fzm2PLJjWtuIfuJ9jhJ6+aIvzuVTmtvlf+m7/6U2Pc/hX9pHLP21q19LvRbL34mapjWfugOhDjCLZbQIN7daj9D1cxT+tTnntoCX1ku6vZwWWRw5gzTOv4byjdIhUrcf8gUw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HD5PtHUD/UEHJ3cPC5NTNAN4rvPJ4RwTRc0j7wPcSfoD4Nk/p/a/DSe0vXPRUNN48+KQ9gOMnfSVv8CDetQv9Lf3cfSzyanVu8VM64EXVZFhPzbYSHVgBZVPr7HeYHWvCKoMoXLmn/gsHVyXcz6CIxYkGsAAZY8PDOEMEbKQuz/W4OTXmtB66ohtUEHJng6rCmxcE9jHxAYvTbUypdCd7ucV5qquhBE/OK/JrLxj8OEuqDLb+lZA98sPZ1NpHjiIhmgv046cIyPX6u6ccaqc8KD1hrDOqZTFV0ZQKBx7vLits3XaDNaE1vtGuXXDABUgCzWTKxMx7FSb7ZIR3IxZ8g==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
  • Delivery-date: Sat, 11 May 2024 07:30:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 5/10/2024 4:54 PM, Julien Grall wrote:
Hi,

On 09/05/2024 16:31, Henry Wang wrote:
On 5/9/2024 4:46 AM, Julien Grall wrote:
Hi Henry,
[...]
```
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index a775f886ed..d3f9cd2299 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -135,16 +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.
-     */
-#ifndef CONFIG_OVERLAY_DTB
-    if ( d->creation_finished )
-        return -EBUSY;
-#endif
-
      ret = vgic_connect_hw_irq(d, NULL, virq, desc, true);

This is checking if the interrupt is already enabled. Do we also need to check for active/pending?

Thank you for raising this! I assume you meant this?
@@ -444,7 +444,9 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq,
     {
         /* The VIRQ should not be already enabled by 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_ACTIVE, &p->status) &&
+             !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) )
             p->desc = desc;
         else
             ret = -EBUSY;

I think adding the check for active/pending check at the time of routing the IRQ makes sense, so I will add them (both for old and new vGIC implementation).

      if ( ret )
          return ret;
@@ -169,20 +159,40 @@ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq,
      ASSERT(test_bit(_IRQ_GUEST, &desc->status));
      ASSERT(!is_lpi(virq));

-    /*
-     * Removing an interrupt while the domain is running may have
-     * undesirable effect on the vGIC emulation.
-     */
-#ifndef CONFIG_OVERLAY_DTB
-    if ( !d->is_dying )
-        return -EBUSY;
-#endif
-
      desc->handler->shutdown(desc);

      /* EOI the IRQ if it has not been done by the guest */
      if ( test_bit(_IRQ_INPROGRESS, &desc->status) )
+    {

I assume this is just a PoC state, but I just want to point out that this will not work with the new vGIC (some of the functions doesn't exist there).

Thank you. Yes currently we can discuss for the old vGIC implementation. After we reach the final conclusion I will do the changes for both old and new vGIC.

+        /*
+         * Handle the LR where the physical interrupt is de-assigned from the
+         * guest before it was EOIed
+         */
+        struct vcpu *v_target = vgic_get_target_vcpu(d->vcpu[0], virq);

This will return a vCPU from the current affinity. This may not be where the interrupt was injected. From a brief look, I can't tell whether we have an easy way to know where the interrupt was injected (other than the pending_irq is in the list lr_queue/inflight)

I doubt if we need to handle more than this - I think if the pending_irq is not in the lr_queue/inflight list, it would not belong to the corner case we are talking about (?).

+        }
+ spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags);
+
+        vgic_lock_rank(v_target, rank, flags);
+        vgic_disable_irqs(v_target, (~rank->ienable) & rank->ienable, rank->index);
+        vgic_unlock_rank(v_target, rank, flags);

Why do you need to call vgic_disable_irqs()?

I will drop this part.

Kind regards,
Henry



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.