From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH kernel] vfio-pci: Fix sparse capability when no parts of MSIX BAR can be mapped
Date: Wed, 29 Nov 2017 11:27:02 -0700 [thread overview]
Message-ID: <20171129112702.51d0a493@t450s.home> (raw)
In-Reply-To: <20171123045626.17542-1-aik@ozlabs.ru>
On Thu, 23 Nov 2017 15:56:26 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> It is currently possible to have a sparse capability with 1 areas which
> starts at 0 and 0 bytes long. One example is:
>
> Texas Instruments TUSB73x0 SuperSpeed USB 3.0 xHCI Host Controller
> [...]
> Region 0: Memory at 3fe280000000 (64-bit, non-prefetchable) [size=64K]
> Region 2: Memory at 3fe280010000 (64-bit, non-prefetchable) [size=8K]
> [...]
> Capabilities: [c0] MSI-X: Enable+ Count=8 Masked-
> Vector table: BAR=2 offset=00000000
> PBA: BAR=2 offset=00001000
>
> With PAGE_SIZE=64K, MSIX BAR occupies the entire BAR2 and cannot be
> mapped.
>
> This makes it explicit - if sparse->areas is empty, then advertise
> nr_areas as 0.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> QEMU gets it right as vfio_setup_region_sparse_mmaps() checks for size
> after QEMU's 24acf72b9a291ce "vfio: Handle zero-length sparse mmap ranges"
> but why not make it explicit in the first place?
>
>
> ---
> drivers/vfio/pci/vfio_pci.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index f041b1a..a201c45 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -597,6 +597,10 @@ static int msix_sparse_mmap_cap(struct vfio_pci_device *vdev,
> i++;
> }
>
> + /* With all alignments, there are no gaps left to mmap */
> + if (i == 0)
> + sparse->nr_areas = 0;
> +
Ok, but why does 0 become a special case? Shouldn't we set
sparse->nr_areas = i? Thanks,
Alex
> ret = vfio_info_add_capability(caps, VFIO_REGION_INFO_CAP_SPARSE_MMAP,
> sparse);
> kfree(sparse);
next prev parent reply other threads:[~2017-11-29 18:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-23 4:56 [RFC PATCH kernel] vfio-pci: Fix sparse capability when no parts of MSIX BAR can be mapped Alexey Kardashevskiy
2017-11-29 18:27 ` Alex Williamson [this message]
2017-11-30 6:00 ` Alexey Kardashevskiy
2017-11-30 15:47 ` Alex Williamson
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=20171129112702.51d0a493@t450s.home \
--to=alex.williamson@redhat.com \
--cc=aik@ozlabs.ru \
--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