[PATCH] vfio/pci: Add DVSEC PCI Extended Config Capability to user visible list.

From: K V P, Satyanarayana
Date: Fri Mar 03 2023 - 00:55:45 EST


Intel Platform Monitoring Technology (PMT) support is indicated by presence
of an Intel defined PCIe Designated Vendor Specific Extended Capabilities
(DVSEC) structure with a PMT specific ID.However DVSEC structures may also
be used by Intel to indicate support for other features. The Out Of Band Management
Services Module (OOBMSM) uses DVSEC to enumerate several features, including PMT.

The current VFIO driver does not pass DVSEC capabilities to virtual machine (VM)
which makes intel_vsec driver not to work in the VM. This series adds DVSEC
capability to user visible list to allow its use with VFIO.

Signed-off-by: K V P Satyanarayana <satyanarayana.k.v.p@xxxxxxxxx>
---
drivers/vfio/pci/vfio_pci_config.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 523e0144c86f..d984c0dd6cca 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -96,6 +96,7 @@ static const u16 pci_ext_cap_length[PCI_EXT_CAP_ID_MAX + 1] = {
[PCI_EXT_CAP_ID_SECPCI] = 0, /* not yet */
[PCI_EXT_CAP_ID_PMUX] = 0, /* not yet */
[PCI_EXT_CAP_ID_PASID] = 0, /* not yet */
+ [PCI_EXT_CAP_ID_DVSEC] = 0xFF,
};

/*
@@ -1440,6 +1441,13 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo
return PCI_TPH_BASE_SIZEOF + (sts * 2) + 2;
}
return PCI_TPH_BASE_SIZEOF;
+ case PCI_EXT_CAP_ID_DVSEC:
+ ret = pci_read_config_dword(pdev, epos + PCI_DVSEC_HEADER1, &dword);
+ if (ret)
+ return pcibios_err_to_errno(ret);
+
+ return PCI_DVSEC_HEADER1_LEN(dword);
+
default:
pci_warn(pdev, "%s: unknown length for PCI ecap %#x@%#x\n",
__func__, ecap, epos);
--
2.34.1