public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Fix version2 RC endpoint PCIe capability size
@ 2017-08-11 10:03 Andrew Jones
  2017-08-11 14:13 ` Alex Williamson
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Jones @ 2017-08-11 10:03 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, eric.auger

Fix a typo which resulted in returning the same value for the length
of version 2 root complex integrated endpoints as other version 2
devices, even though RC's don't have a link.

Signed-off-by: Andrew Jones <drjones@redhat.com>

---

The issue was only found by review, so I've only compile-tested the fix.
Actually, TBH, I don't know anything about PCI or RC config space, so I'm
just assuming link-size-v2 == link-size-v1 and that link-size-v1 is 8,
since the code was using 0xc == PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 - 8 for it.

 drivers/vfio/pci/vfio_pci_config.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 5628fe114347..afe29cd88f1f 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1244,15 +1244,15 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
 		}
 
 		/* length based on version and type */
-		if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1) {
-			if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
-				return 0xc; /* "All Devices" only, no link */
-			return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
-		} else {
-			if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
-				return 0x2c; /* No link */
-			return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
-		}
+		if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1)
+			ret = PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
+		else
+			ret = PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
+
+		if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
+			ret -= 8; /* "All Devices" only, no link */
+
+		return ret;
 	case PCI_CAP_ID_HT:
 		ret = pci_read_config_byte(pdev, pos + 3, &byte);
 		if (ret)
-- 
2.13.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-11 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 10:03 [PATCH] vfio/pci: Fix version2 RC endpoint PCIe capability size Andrew Jones
2017-08-11 14:13 ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox