From: Alex Williamson <alex.williamson@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC 0/3] vfio: allow to notify unmap for very big region
Date: Thu, 19 Jan 2017 10:54:37 -0700 [thread overview]
Message-ID: <20170119105437.5b17d979@t450s.home> (raw)
In-Reply-To: <1484817932-14452-1-git-send-email-peterx@redhat.com>
On Thu, 19 Jan 2017 17:25:29 +0800
Peter Xu <peterx@redhat.com> wrote:
> This requirement originates from the VT-d vfio series:
>
> https://lists.nongnu.org/archive/html/qemu-devel/2017-01/msg03495.html
>
> The goal of this series is to allow IOMMU to notify unmap with very
> big IOTLB range, for example, with base=0 and size=2^63-1 (to unmap
> the whole address space).
>
> The first patch is a good to have, for traces.
>
> The second one is a cleanup of existing code, only.
Sort of, it does add some overhead to the unmap path, but you remove
that and more in the third patch.
> The third one moves the further RAM translation and check into map
> operation logic, so that it'll free unmap operations.
>
> The series is marked as RFC since I am not sure whether this is a
> workable way. Anyway, please review to help confirm it.
It seems reasonable to me, except for the example here of using 2^63-1,
which I expect is to work around the vfio {un}map API bug as we
discussed on irc. For everyone, the root of the problem is that the
ioctls use:
__u64 iova; /* IO virtual address */
__u64 size; /* Size of mapping (bytes) */
So we can only express a size of 2^64-1 and we have an off-by-one error
trying to perform a map/unmap of an entire 64-bit space. Note when
designing an API, use start/end rather than base/size to avoid this.
What I don't want to see is for this API bug to leak out into the rest
of the QEMU code such that intel_iommu code, or iommu code in general
subtly avoids it by artificially using a smaller range. VT-d hardware
has an actual physical address space of either 2^39 or 2^48 bits, so if
you want to make the iommu address space match the device we're trying
to emulate, that's perfectly fine. AIUI, AMD-Vi does actually have a
64-bit address space on the IOMMU, so to handle that case I'd expect
the simplest solution would be to track the and mapped iova high water
mark per container in vfio and truncate unmaps to that high water end
address. Realistically we're probably not going to see iovas at the end
of the 64-bit address space, but we can come up with some other
workaround in the vfio code or update the kernel API if we do. Thanks,
Alex
next prev parent reply other threads:[~2017-01-19 17:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 9:25 [Qemu-devel] [PATCH RFC 0/3] vfio: allow to notify unmap for very big region Peter Xu
2017-01-19 9:25 ` [Qemu-devel] [PATCH RFC 1/3] vfio: trace map/unmap for notify as well Peter Xu
2017-01-19 9:25 ` [Qemu-devel] [PATCH RFC 2/3] vfio: introduce vfio_get_vaddr() Peter Xu
2017-01-19 9:25 ` [Qemu-devel] [PATCH RFC 3/3] vfio: allow to notify unmap for very large region Peter Xu
2017-01-19 17:54 ` Alex Williamson [this message]
2017-01-20 3:43 ` [Qemu-devel] [PATCH RFC 0/3] vfio: allow to notify unmap for very big region Peter Xu
2017-01-20 4:21 ` Alex Williamson
2017-01-20 4:45 ` Peter Xu
2017-01-20 12:27 ` Peter Xu
2017-01-20 17:14 ` Alex Williamson
2017-01-22 2:59 ` Peter Xu
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=20170119105437.5b17d979@t450s.home \
--to=alex.williamson@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 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).