]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: config-create: Filter out invalid MSI-X capabilities
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 12 May 2015 06:24:17 +0000 (08:24 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Wed, 13 May 2015 06:52:24 +0000 (08:52 +0200)
Avoid passing zero as MSI-X address to the hypervisor, it will only
crash. Rather disable this capability by leaving related fields cleared.

See also http://thread.gmane.org/gmane.linux.jailhouse/3056.

Reported-by: Yijun Zhu <zhuyijun@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/jailhouse-config-create

index 15506b3294374b74b1b282e77599b51d60407dc2..d489113a6629dbdd5462b210509fe1a0d448d25f 100755 (executable)
@@ -249,10 +249,14 @@ class PCIDevice:
                     self.num_msi_vectors = 1 << ((msg_ctrl >> 1) & 0x7)
                     self.msi_64bits = (msg_ctrl >> 7) & 1
                 else:  # MSI-X
-                    vectors = (msg_ctrl & 0x7ff) + 1
-                    self.num_msix_vectors = vectors
-                    self.msix_region_size = (vectors * 16 + 0xfff) & 0xf000
-                    self.msix_address = c.msix_address
+                    if c.msix_address != 0:
+                        vectors = (msg_ctrl & 0x7ff) + 1
+                        self.num_msix_vectors = vectors
+                        self.msix_region_size = (vectors * 16 + 0xfff) & 0xf000
+                        self.msix_address = c.msix_address
+                    else:
+                        print('WARNING: Ignoring invalid MSI-X configuration'
+                              ' of device %02x:%02x.%x' % (bus, dev, fn))
 
     def __str__(self):
         return 'PCIDevice: %02x:%02x.%x' % (self.bus, self.dev, self.fn)