x86/vMSI-X: defer intercept handler registration
authorJan Beulich <jbeulich@suse.com>
Wed, 22 Jun 2016 09:58:31 +0000 (11:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 22 Jun 2016 09:58:31 +0000 (11:58 +0200)
There's no point in registering the internal MSI-X table intercept
functions on all domains - it is sufficient to do so once a domain gets
an MSI-X capable device assigned.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/vmsi.c
xen/drivers/passthrough/pci.c

index ffc3395ccc4d57dc0e854bd6b259fbc4742528b5..5d6b9218211d303c6d9c289e1ea5a23ef26c765e 100644 (file)
@@ -644,8 +644,6 @@ int hvm_domain_initialise(struct domain *d)
 
     rtc_init(d);
 
-    msixtbl_init(d);
-
     register_portio_handler(d, 0xe9, 1, hvm_print_line);
 
     if ( hvm_tsc_scaling_supported )
index 0066be565c2a3c1a5d8ef50b22cbf50fa349590c..81e45c8b7af05d120f1a399de5fd44f4ca587550 100644 (file)
@@ -553,7 +553,8 @@ found:
 
 void msixtbl_init(struct domain *d)
 {
-    if ( !has_vlapic(d) )
+    if ( !has_hvm_container_domain(d) || !has_vlapic(d) ||
+         d->arch.hvm_domain.msixtbl_list.next )
         return;
 
     INIT_LIST_HEAD(&d->arch.hvm_domain.msixtbl_list);
@@ -567,7 +568,7 @@ void msixtbl_pt_cleanup(struct domain *d)
     struct msixtbl_entry *entry, *temp;
     unsigned long flags;
 
-    if ( !has_vlapic(d) )
+    if ( !d->arch.hvm_domain.msixtbl_list.next )
         return;
 
     /* msixtbl_list_lock must be acquired with irq_disabled for check_lock() */
index 98936f55cbb08c6e8a6c0ad57eeb3e3834382f49..bb5f344878410063f09d881b1824b22d6c3729fd 100644 (file)
@@ -1380,6 +1380,9 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
         goto done;
     }
 
+    if ( pdev->msix )
+        msixtbl_init(d);
+
     pdev->fault.count = 0;
 
     if ( (rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev), flag)) )