x86/MSI: fail if no hardware support
authorJan Beulich <jbeulich@suse.com>
Wed, 16 Sep 2015 09:20:27 +0000 (11:20 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 16 Sep 2015 09:20:27 +0000 (11:20 +0200)
This is to guard against buggy callers (luckily Dom0 only) invoking
the respective hypercall for a device not being MSI-capable.

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

index 588305ab9f513387800f6eaf2517143aa66bf25b..3dbb84ddacda7173efea00e12a85c153fd7a9bfb 100644 (file)
@@ -696,6 +696,8 @@ static int msi_capability_init(struct pci_dev *dev,
 
     ASSERT(spin_is_locked(&pcidevs_lock));
     pos = pci_find_cap_offset(seg, bus, slot, func, PCI_CAP_ID_MSI);
+    if ( !pos )
+        return -ENODEV;
     control = pci_conf_read16(seg, bus, slot, func, msi_control_reg(pos));
     maxvec = multi_msi_capable(control);
     if ( nvec > maxvec )