From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>,
qemu-devel@nongnu.org, peterx@redhat.com, eric.auger@redhat.com,
pbonzini@redhat.com, bbhushan2@marvell.com
Subject: Re: [PATCH v10 10/10] vfio: Don't issue full 2^64 unmap
Date: Fri, 30 Oct 2020 06:25:34 -0400 [thread overview]
Message-ID: <20201030062513-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20201008152214.3cb1425b@w520.home>
On Thu, Oct 08, 2020 at 03:22:14PM -0600, Alex Williamson wrote:
> On Thu, 8 Oct 2020 19:15:58 +0200
> Jean-Philippe Brucker <jean-philippe@linaro.org> wrote:
>
> > IOMMUs may declare memory regions spanning from 0 to UINT64_MAX. When
> > attempting to deal with such region, vfio_listener_region_del() passes a
> > size of 2^64 to int128_get64() which throws an assertion failure. Even
> > ignoring this, the VFIO_IOMMU_DMA_MAP ioctl cannot handle this size
> > since the size field is 64-bit. Split the request in two.
> >
> > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> > ---
> > For me this happens when memory_region_iommu_set_page_size_mask()
> > returns an error because a hotplugged endpoint uses an incompatible page
> > mask. vfio_connect_container() releases the memory listener which calls
> > region_del() with the 2^64 IOMMU region. There are probably other ways
> > to reach this.
> > ---
> > hw/vfio/common.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index e66054b02a7..e90a89c389e 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -797,6 +797,17 @@ static void vfio_listener_region_del(MemoryListener *listener,
> > }
> >
> > if (try_unmap) {
> > + if (llsize == int128_2_64()) {
> > + /* The unmap ioctl doesn't accept a full 64-bit span. */
> > + llsize = int128_rshift(llsize, 1);
> > + ret = vfio_dma_unmap(container, iova, int128_get64(llsize));
> > + if (ret) {
> > + error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
> > + "0x%"HWADDR_PRIx") = %d (%m)",
> > + container, iova, int128_get64(llsize), ret);
> > + }
> > + iova += int128_get64(llsize);
> > + }
> > ret = vfio_dma_unmap(container, iova, int128_get64(llsize));
> > if (ret) {
> > error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
>
> We're still susceptible that splitting the range in two could result in
> unmap calls that attempt to bisect a mapping that spans both ranges.
> Both unmap calls would fail in that case. I think we could solve this
> more completely with a high water marker, but this probably good enough
> for now.
>
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
Are you merging this then?
If yes
Acked-by: Michael S. Tsirkin <mst@redhat.com>
next prev parent reply other threads:[~2020-10-30 10:31 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 17:15 [PATCH v10 00/10] virtio-iommu: VFIO integration Jean-Philippe Brucker
2020-10-08 17:15 ` [PATCH v10 01/10] virtio-iommu: Fix virtio_iommu_mr() Jean-Philippe Brucker
2020-10-16 7:36 ` Auger Eric
2020-10-19 21:36 ` Peter Xu
2020-10-08 17:15 ` [PATCH v10 02/10] virtio-iommu: Store memory region in endpoint struct Jean-Philippe Brucker
2020-10-16 7:37 ` Auger Eric
2020-10-08 17:15 ` [PATCH v10 03/10] virtio-iommu: Add memory notifiers for map/unmap Jean-Philippe Brucker
2020-10-16 7:58 ` Auger Eric
2020-10-22 16:41 ` Jean-Philippe Brucker
2020-10-08 17:15 ` [PATCH v10 04/10] virtio-iommu: Call memory notifiers in attach/detach Jean-Philippe Brucker
2020-10-16 8:05 ` Auger Eric
2020-10-08 17:15 ` [PATCH v10 05/10] virtio-iommu: Add replay() memory region callback Jean-Philippe Brucker
2020-10-16 9:12 ` Auger Eric
2020-10-22 16:42 ` Jean-Philippe Brucker
2020-10-08 17:15 ` [PATCH v10 06/10] virtio-iommu: Add notify_flag_changed() " Jean-Philippe Brucker
2020-10-16 8:18 ` Auger Eric
2020-10-08 17:15 ` [PATCH v10 07/10] memory: Add interface to set iommu page size mask Jean-Philippe Brucker
2020-10-16 9:24 ` Auger Eric
2020-10-22 16:43 ` Jean-Philippe Brucker
2020-10-19 21:36 ` Peter Xu
2020-10-08 17:15 ` [PATCH v10 08/10] vfio: Set IOMMU page size as per host supported page size Jean-Philippe Brucker
2020-10-08 21:22 ` Alex Williamson
2020-10-30 10:26 ` Michael S. Tsirkin
2020-10-30 15:19 ` Jean-Philippe Brucker
2020-10-16 9:25 ` Auger Eric
2020-10-08 17:15 ` [PATCH v10 09/10] virtio-iommu: Set supported page size mask Jean-Philippe Brucker
2020-10-16 13:08 ` Auger Eric
2020-10-22 16:43 ` Jean-Philippe Brucker
2020-10-19 21:35 ` Peter Xu
2020-10-22 16:39 ` Jean-Philippe Brucker
2020-10-22 20:56 ` Peter Xu
2020-10-23 7:48 ` Jean-Philippe Brucker
2020-10-23 16:47 ` Peter Xu
2020-10-27 17:38 ` Jean-Philippe Brucker
2020-10-30 10:24 ` Michael S. Tsirkin
2020-10-08 17:15 ` [PATCH v10 10/10] vfio: Don't issue full 2^64 unmap Jean-Philippe Brucker
2020-10-08 21:22 ` Alex Williamson
2020-10-30 10:25 ` Michael S. Tsirkin [this message]
2020-10-30 17:26 ` Alex Williamson
2020-10-30 18:19 ` Paolo Bonzini
2020-11-02 17:37 ` Alex Williamson
2020-11-02 17:44 ` Paolo Bonzini
2020-11-02 18:00 ` Alex Williamson
2020-10-16 9:47 ` Auger Eric
2020-10-16 13:13 ` [PATCH v10 00/10] virtio-iommu: VFIO integration Auger Eric
2020-10-30 10:27 ` Michael S. Tsirkin
2020-10-30 10:48 ` Jean-Philippe Brucker
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=20201030062513-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=bbhushan2@marvell.com \
--cc=eric.auger@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.