summaryrefslogtreecommitdiffstats
path: root/drivers/vfio
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2013-09-04 12:58:52 -0400
committerAlex Williamson <alex.williamson@redhat.com>2013-09-04 12:58:52 -0400
commit17638db1b88184d8895f3f4551c936d7480a1d3f (patch)
tree7974ee39bc51997b86efb078f2502530884dc6dc /drivers/vfio
parent20e77457842f4cd253d093f08f0cce1a73afb7db (diff)
vfio-pci: Test for extended config space
Having PCIe/PCI-X capability isn't enough to assume that there are extended capabilities. Both specs define that the first capability header is all zero if there are no extended capabilities. Testing for this avoids an erroneous message about hiding capability 0x0 at offset 0x100. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r--drivers/vfio/pci/vfio_pci_config.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index affa34745be9..ffd0632c3cbc 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1012,6 +1012,7 @@ static int vfio_vc_cap_len(struct vfio_pci_device *vdev, u16 pos)
1012static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) 1012static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
1013{ 1013{
1014 struct pci_dev *pdev = vdev->pdev; 1014 struct pci_dev *pdev = vdev->pdev;
1015 u32 dword;
1015 u16 word; 1016 u16 word;
1016 u8 byte; 1017 u8 byte;
1017 int ret; 1018 int ret;
@@ -1025,7 +1026,9 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
1025 return pcibios_err_to_errno(ret); 1026 return pcibios_err_to_errno(ret);
1026 1027
1027 if (PCI_X_CMD_VERSION(word)) { 1028 if (PCI_X_CMD_VERSION(word)) {
1028 vdev->extended_caps = true; 1029 /* Test for extended capabilities */
1030 pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &dword);
1031 vdev->extended_caps = (dword != 0);
1029 return PCI_CAP_PCIX_SIZEOF_V2; 1032 return PCI_CAP_PCIX_SIZEOF_V2;
1030 } else 1033 } else
1031 return PCI_CAP_PCIX_SIZEOF_V0; 1034 return PCI_CAP_PCIX_SIZEOF_V0;
@@ -1037,9 +1040,11 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
1037 1040
1038 return byte; 1041 return byte;
1039 case PCI_CAP_ID_EXP: 1042 case PCI_CAP_ID_EXP:
1040 /* length based on version */ 1043 /* Test for extended capabilities */
1041 vdev->extended_caps = true; 1044 pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &dword);
1045 vdev->extended_caps = (dword != 0);
1042 1046
1047 /* length based on version */
1043 if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1) 1048 if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1)
1044 return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1; 1049 return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
1045 else 1050 else