Check the device negotiated TPH support status before parsing the TPH extended capability. Return zero length to hide the capability from userspace if TPH is disabled during topology negotiation. Signed-off-by: Chengwen Feng --- drivers/vfio/pci/vfio_pci_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index a10ed733f0e3..5c6ab172df6c 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1450,6 +1451,8 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo byte &= PCI_DPA_CAP_SUBSTATE_MASK; return PCI_DPA_BASE_SIZEOF + byte + 1; case PCI_EXT_CAP_ID_TPH: + if (!pcie_tph_supported(pdev, false)) + return 0; ret = pci_read_config_dword(pdev, epos + PCI_TPH_CAP, &dword); if (ret) return pcibios_err_to_errno(ret); -- 2.17.1