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

[PATCH] x86/dpci: EOI interrupt regardless of it's masking status


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 5 Jan 2021 19:31:43 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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-SenderADCheck; bh=CjHgdWgPnLPu/MxYHbPlytIJkzEAREeuae78TUct0gE=; b=LTHNIl4JBMnHyeOlffAeBnMyjYhjpshCttOKSktQCKoZLdF6hgNoX/XYUzkrCLlnSkEnm9OlJfzwbz4IaxCD+dDRO9k5vNUz6tvWzOZKUTTYcsyDsjOB2vrlB5772aHMXq4Sb1qVpQh9EBVyNS2+OmAul2KlJ7QhufvFaNkG6QihxpT/hSsceFgM5wHswa79yKgs7HHiAe8LZmXY/D2jw++1+r/d11uW41SFWei/dlZZXFOWhqLBPdAMKtiuyXeIMxNJDM8EW32z3C0j9BBJ2vqe5e2hy4ihMzQSW0LpOrAfNswdT7dfUrDATjtG7uXktLIoDTFXU06ImhKGJurBsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IiitC5D2o50gD+oCDydou3LllJeUA3iA3clVvgx5swKyYGNjPmRxvySbLV9HhThn85fdf6OKXoXoM0aLZVSn9HpMOp/d/+l0v2vI1wj9IbO2dxm5hI7TPGnJ7e+orZX72BJhz0wkV+YIjdyWDqKHwVqQRTyhPvpWqxWC7IC5cywmLoubc9UH0tp+75T7IMf2caQqzo4jOacpiC31EdPS56DrB1826NLqFei4FTnWhs9MUMu3GYjjWZgMqvzW9VmC39W6aKUtJojZXwMsyHgDBAwsU0g8/Q9dYUGSH5F4wltJVUGlzrv4YDV+8jyDpQ8r3rKlDII28uUGOi6REAx+cw==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Tue, 05 Jan 2021 18:32:06 +0000
  • Ironport-sdr: roztjlgBBJ0w6PMRoVjF+Pqi7H6WyAMIJidnyJgU22jcNN1NxJ8tlCJMh24HH1thsCbB+cRCuE LfOfdu31FknRA5Lo/wmlpvR23H2Wq5cXDS3GDHc48gKLyHU9u/1EiOT7nnf439USKIGBfenL/V RO6wngPMe7Mn8H3/hVMcpBkZyoMr3SpMys+ry3CgKEaGhHMoYiWjET8pKpwsuuBy97RirXKGpf XMu6qyUJL1PGB6oDFYouWn4G/BAZykrU8mnuaOXuecisWd7AuTdDFaaI0HGIfpJzPaJz+6/Xgz K+E=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Modify hvm_pirq_eoi to always EOI the interrupt if required, instead
of not doing such EOI if the interrupt is routed through the vIO-APIC
and the entry is masked at the time the EOI is performed.

Further unmask of the vIO-APIC pin won't EOI the interrupt, and thus
the guest OS has to wait for the timeout to expire and the automatic
EOI to be performed.

This allows to simplify the helpers and drop the vioapic_redir_entry
parameter from all of them.

Fixes: ccfe4e08455 ('Intel vt-d specific changes in arch/x86/hvm/vmx/vtd.')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Kind of RFC, I've been trying to figure out how this was supposed to
work, and couldn't find any reason why the EOI is not performed if the
interrupt is masked on the emulated IO-APIC. I might be missing
something, but relying on the EOI timeout in that case seems wrong.
---
 xen/arch/x86/hvm/vioapic.c        |  2 +-
 xen/arch/x86/hvm/vpic.c           |  3 +--
 xen/drivers/passthrough/x86/hvm.c | 21 ++++++++-------------
 xen/include/asm-x86/hvm/io.h      |  3 +--
 4 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index 7c462a44d4..eb6c143f74 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -521,7 +521,7 @@ void vioapic_update_EOI(struct domain *d, u8 vector)
             if ( is_iommu_enabled(d) )
             {
                 spin_unlock(&d->arch.hvm.irq_lock);
-                hvm_dpci_eoi(d, vioapic->base_gsi + pin, ent);
+                hvm_dpci_eoi(d, vioapic->base_gsi + pin);
                 spin_lock(&d->arch.hvm.irq_lock);
             }
 
diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c
index 3cf12581e9..c1c1de7fd0 100644
--- a/xen/arch/x86/hvm/vpic.c
+++ b/xen/arch/x86/hvm/vpic.c
@@ -263,8 +263,7 @@ static void vpic_ioport_write(
                 vpic_update_int_output(vpic);
                 vpic_unlock(vpic);
                 hvm_dpci_eoi(current->domain,
-                             hvm_isa_irq_to_gsi((addr >> 7) ? (pin | 8) : pin),
-                             NULL);
+                             hvm_isa_irq_to_gsi((addr >> 7) ? (pin | 8) : 
pin));
                 return; /* bail immediately */
             case 6: /* Set Priority                */
                 vpic->priority_add = (val + 1) & 7;
diff --git a/xen/drivers/passthrough/x86/hvm.c 
b/xen/drivers/passthrough/x86/hvm.c
index 41cfa2e200..edc8059518 100644
--- a/xen/drivers/passthrough/x86/hvm.c
+++ b/xen/drivers/passthrough/x86/hvm.c
@@ -950,8 +950,7 @@ static void hvm_dirq_assist(struct domain *d, struct 
hvm_pirq_dpci *pirq_dpci)
     spin_unlock(&d->event_lock);
 }
 
-static void hvm_pirq_eoi(struct pirq *pirq,
-                         const union vioapic_redir_entry *ent)
+static void hvm_pirq_eoi(struct pirq *pirq)
 {
     struct hvm_pirq_dpci *pirq_dpci;
 
@@ -968,7 +967,6 @@ static void hvm_pirq_eoi(struct pirq *pirq,
      * since interrupt is still not EOIed
      */
     if ( --pirq_dpci->pending ||
-         (ent && ent->fields.mask) ||
          !pt_irq_need_timer(pirq_dpci->flags) )
         return;
 
@@ -977,19 +975,17 @@ static void hvm_pirq_eoi(struct pirq *pirq,
 }
 
 static void __hvm_dpci_eoi(struct domain *d,
-                           const struct hvm_girq_dpci_mapping *girq,
-                           const union vioapic_redir_entry *ent)
+                           const struct hvm_girq_dpci_mapping *girq)
 {
     struct pirq *pirq = pirq_info(d, girq->machine_gsi);
 
     if ( !hvm_domain_use_pirq(d, pirq) )
         hvm_pci_intx_deassert(d, girq->device, girq->intx);
 
-    hvm_pirq_eoi(pirq, ent);
+    hvm_pirq_eoi(pirq);
 }
 
-static void hvm_gsi_eoi(struct domain *d, unsigned int gsi,
-                        const union vioapic_redir_entry *ent)
+static void hvm_gsi_eoi(struct domain *d, unsigned int gsi)
 {
     struct pirq *pirq = pirq_info(d, gsi);
 
@@ -998,11 +994,10 @@ static void hvm_gsi_eoi(struct domain *d, unsigned int 
gsi,
         return;
 
     hvm_gsi_deassert(d, gsi);
-    hvm_pirq_eoi(pirq, ent);
+    hvm_pirq_eoi(pirq);
 }
 
-void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi,
-                  const union vioapic_redir_entry *ent)
+void hvm_dpci_eoi(struct domain *d, unsigned int guest_gsi)
 {
     const struct hvm_irq_dpci *hvm_irq_dpci;
     const struct hvm_girq_dpci_mapping *girq;
@@ -1013,7 +1008,7 @@ void hvm_dpci_eoi(struct domain *d, unsigned int 
guest_gsi,
     if ( is_hardware_domain(d) )
     {
         spin_lock(&d->event_lock);
-        hvm_gsi_eoi(d, guest_gsi, ent);
+        hvm_gsi_eoi(d, guest_gsi);
         goto unlock;
     }
 
@@ -1030,7 +1025,7 @@ void hvm_dpci_eoi(struct domain *d, unsigned int 
guest_gsi,
         goto unlock;
 
     list_for_each_entry ( girq, &hvm_irq_dpci->girq[guest_gsi], list )
-        __hvm_dpci_eoi(d, girq, ent);
+        __hvm_dpci_eoi(d, girq);
 
 unlock:
     spin_unlock(&d->event_lock);
diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h
index 558426b772..9453b9b2b7 100644
--- a/xen/include/asm-x86/hvm/io.h
+++ b/xen/include/asm-x86/hvm/io.h
@@ -118,8 +118,7 @@ bool handle_mmio_with_translation(unsigned long gla, 
unsigned long gpfn,
                                   struct npfec);
 bool handle_pio(uint16_t port, unsigned int size, int dir);
 void hvm_interrupt_post(struct vcpu *v, int vector, int type);
-void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq,
-                  const union vioapic_redir_entry *ent);
+void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq);
 void msix_write_completion(struct vcpu *);
 
 #ifdef CONFIG_HVM
-- 
2.29.2




 


Rackspace

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