From: Alex Williamson <alex.williamson@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, eric.auger@redhat.com
Subject: Re: [PATCH] vfio/pci: Fix version2 RC endpoint PCIe capability size
Date: Fri, 11 Aug 2017 08:13:51 -0600 [thread overview]
Message-ID: <20170811081351.2af53873@w520.home> (raw)
In-Reply-To: <20170811100335.22716-1-drjones@redhat.com>
On Fri, 11 Aug 2017 12:03:35 +0200
Andrew Jones <drjones@redhat.com> wrote:
> 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.
It seems this fixes the wrong bug. The bug is in the definition of
PCI_CAP_EXP_ENDPOINT_SIZEOF_V2, which does not include the v2 link
information. This is why they're the same size currently. I've posted
this patch which resolves that issue:
http://www.spinics.net/lists/linux-pci/msg63762.html
Once accepted we can incorporate the new macros rather than the
hard coded values used here, but the existing code will automatically
start using the correct offsets. The proposal below is wrong
without the patch above, making the v2 RC endpoint too short. Thanks,
Alex
> 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)
prev parent reply other threads:[~2017-08-11 14:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170811081351.2af53873@w520.home \
--to=alex.williamson@redhat.com \
--cc=drjones@redhat.com \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox