]> xenbits.xensource.com Git - people/larsk/xen.git/commitdiff
vpci: honor read-only devices
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 17 Sep 2019 14:13:39 +0000 (16:13 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 17 Sep 2019 14:13:39 +0000 (16:13 +0200)
Don't allow the hardware domain write access the PCI config space of
devices marked as read-only.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/tests/vpci/emul.h
xen/drivers/vpci/vpci.c

index 5d47544bf72ecc1b76dbbb93125e95e7fabd8c6b..2e1d3057c9d896e7ed6702fa68fe9ba922d715c1 100644 (file)
@@ -92,6 +92,9 @@ typedef union {
 #define xfree(p) free(p)
 
 #define pci_get_pdev_by_domain(...) &test_pdev
+#define pci_get_ro_map(...) NULL
+
+#define test_bit(...) false
 
 /* Dummy native helpers. Writes are ignored, reads return 1's. */
 #define pci_conf_read8(...)     0xff
index 758d9420e79bc8a600c88e049a5b80c334fbf1c8..cbd1bac7fc335a75fc662a9940038ad063c833ed 100644 (file)
@@ -411,6 +411,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
     const struct pci_dev *pdev;
     const struct vpci_register *r;
     unsigned int data_offset = 0;
+    const unsigned long *ro_map = pci_get_ro_map(sbdf.seg);
 
     if ( !size )
     {
@@ -418,6 +419,10 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         return;
     }
 
+    if ( ro_map && test_bit(sbdf.bdf, ro_map) )
+        /* Ignore writes to read-only devices. */
+        return;
+
     /*
      * Find the PCI dev matching the address.
      * Passthrough everything that's not trapped.