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

[Xen-changelog] [xen master] pass-through: adjust pIRQ migration



commit 782cf8ba467846b976db9365061298a81853a29f
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Nov 9 13:05:28 2018 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Nov 9 13:05:28 2018 +0100

    pass-through: adjust pIRQ migration
    
    For one it is quite pointless to iterate over all pIRQ-s the domain has
    when just one is being adjusted. Introduce hvm_migrate_pirq() as an
    externally accessible function.
    
    Additionally it is bogus to migrate the pIRQ to a vCPU different from
    the one the event is supposed to be posted to - if anything, it might be
    worth considering not to migrate the pIRQ at all in the posting case.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c        | 15 ++++++++++-----
 xen/drivers/passthrough/io.c  |  4 ++--
 xen/include/asm-x86/hvm/hvm.h |  1 +
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 7be9cf4454..90801bd828 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -462,10 +462,9 @@ void hvm_migrate_timers(struct vcpu *v)
     pt_migrate(v);
 }
 
-static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
-                            void *arg)
+void hvm_migrate_pirq(struct hvm_pirq_dpci *pirq_dpci, const struct vcpu *v)
 {
-    struct vcpu *v = arg;
+    ASSERT(iommu_enabled && hvm_domain_irq(v->domain)->dpci);
 
     if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) &&
          /* Needn't migrate pirq if this pirq is delivered to guest directly.*/
@@ -476,11 +475,17 @@ static int hvm_migrate_pirq(struct domain *d, struct 
hvm_pirq_dpci *pirq_dpci,
             pirq_spin_lock_irq_desc(dpci_pirq(pirq_dpci), NULL);
 
         if ( !desc )
-            return 0;
+            return;
         ASSERT(MSI_IRQ(desc - irq_desc));
         irq_set_affinity(desc, cpumask_of(v->processor));
         spin_unlock_irq(&desc->lock);
     }
+}
+
+static int migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
+                        void *arg)
+{
+    hvm_migrate_pirq(pirq_dpci, arg);
 
     return 0;
 }
@@ -493,7 +498,7 @@ void hvm_migrate_pirqs(struct vcpu *v)
        return;
 
     spin_lock(&d->event_lock);
-    pt_pirq_iterate(d, hvm_migrate_pirq, v);
+    pt_pirq_iterate(d, migrate_pirq, v);
     spin_unlock(&d->event_lock);
 }
 
diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c
index a5668e6495..a6eb8a4336 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -434,8 +434,8 @@ int pt_irq_create_bind(
             if ( vcpu )
                 pirq_dpci->gmsi.posted = true;
         }
-        if ( dest_vcpu_id >= 0 )
-            hvm_migrate_pirqs(d->vcpu[dest_vcpu_id]);
+        if ( vcpu && iommu_enabled )
+            hvm_migrate_pirq(pirq_dpci, vcpu);
 
         /* Use interrupt posting if it is supported. */
         if ( iommu_intpost )
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index cd8acd93e7..2a1acd8bfa 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -288,6 +288,7 @@ bool hvm_set_guest_bndcfgs(struct vcpu *v, u64 val);
 bool hvm_check_cpuid_faulting(struct vcpu *v);
 void hvm_migrate_timers(struct vcpu *v);
 void hvm_do_resume(struct vcpu *v);
+void hvm_migrate_pirq(struct hvm_pirq_dpci *pirq_dpci, const struct vcpu *v);
 void hvm_migrate_pirqs(struct vcpu *v);
 
 void hvm_inject_event(const struct x86_event *event);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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