@@ -34,6 +34,8 @@
#define MB2_SHADOW_OFFSET 0x2000
#define MB2_SHADOW_SIZE 16
+#define VMD_MIN_MSI_VECTOR_COUNT 64
+
enum vmd_features {
/*
* Device may contain registers which hint the physical location of the
@@ -807,13 +809,20 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
sd->node = pcibus_to_node(vmd->dev->bus);
+ vmd->msix_count = pci_msix_vec_count(vmd->dev);
+ if (vmd->msix_count < 0)
+ return -ENODEV;
+
/*
* Currently MSI remapping must be enabled in guest passthrough mode
* due to some missing interrupt remapping plumbing. This is probably
* acceptable because the guest is usually CPU-limited and MSI
* remapping doesn't become a performance bottleneck.
+ * Disable MSI remapping only if supported by VMD hardware and when
+ * VMD MSI count is less than or equal to minimum MSI count.
*/
if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||
+ vmd->msix_count > VMD_MIN_MSI_VECTOR_COUNT ||
offset[0] || offset[1]) {
ret = vmd_alloc_irqs(vmd);
if (ret)