linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] vfio-pci: Mask cap zero
@ 2020-05-05 22:27 Alex Williamson
  2020-05-06 11:26 ` Cornelia Huck
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Williamson @ 2020-05-05 22:27 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, cohuck, cjia

The PCI Code and ID Assignment Specification changed capability ID 0
from reserved to a NULL capability in the v1.1 revision.  The NULL
capability is defined to include only the 16-bit capability header,
ie. only the ID and next pointer.  Unfortunately vfio-pci creates a
map of config space, where ID 0 is used to reserve the standard type
0 header.  Finding an actual capability with this ID therefore results
in a bogus range marked in that map and conflicts with subsequent
capabilities.  As this seems to be a dummy capability anyway and we
already support dropping capabilities, let's hide this one rather than
delving into the potentially subtle dependencies within our map.

Seen on an NVIDIA Tesla T4.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/pci/vfio_pci_config.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 3dcddbd572e6..0d110e268094 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1486,7 +1486,12 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
 		if (ret)
 			return ret;
 
-		if (cap <= PCI_CAP_ID_MAX) {
+		/*
+		 * ID 0 is a NULL capability, conflicting with our fake
+		 * PCI_CAP_ID_BASIC.  As it has no content, consider it
+		 * hidden for now.
+		 */
+		if (cap && cap <= PCI_CAP_ID_MAX) {
 			len = pci_cap_length[cap];
 			if (len == 0xFF) { /* Variable length */
 				len = vfio_cap_len(vdev, cap, pos);


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

* Re: [PATCH v2] vfio-pci: Mask cap zero
  2020-05-05 22:27 [PATCH v2] vfio-pci: Mask cap zero Alex Williamson
@ 2020-05-06 11:26 ` Cornelia Huck
  0 siblings, 0 replies; 2+ messages in thread
From: Cornelia Huck @ 2020-05-06 11:26 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, linux-kernel, cjia

On Tue, 05 May 2020 16:27:01 -0600
Alex Williamson <alex.williamson@redhat.com> wrote:

> The PCI Code and ID Assignment Specification changed capability ID 0
> from reserved to a NULL capability in the v1.1 revision.  The NULL
> capability is defined to include only the 16-bit capability header,
> ie. only the ID and next pointer.  Unfortunately vfio-pci creates a
> map of config space, where ID 0 is used to reserve the standard type
> 0 header.  Finding an actual capability with this ID therefore results
> in a bogus range marked in that map and conflicts with subsequent
> capabilities.  As this seems to be a dummy capability anyway and we
> already support dropping capabilities, let's hide this one rather than
> delving into the potentially subtle dependencies within our map.
> 
> Seen on an NVIDIA Tesla T4.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>  drivers/vfio/pci/vfio_pci_config.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


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

end of thread, other threads:[~2020-05-06 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 22:27 [PATCH v2] vfio-pci: Mask cap zero Alex Williamson
2020-05-06 11:26 ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).