From: "Michael S. Tsirkin" <mst@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, linux-kernel@vger.kernel.org,
pbonzini@redhat.com, peterx@redhat.com, cornelia.huck@de.ibm.com,
Kevin Wolf <kwolf@redhat.com>, Amit Shah <amit.shah@redhat.com>,
qemu-block@nongnu.org, Jason Wang <jasowang@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Andy Lutomirski <luto@kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Wei Liu <wei.liu2@citrix.com>,
David Woodhouse <dwmw2@infradead.org>,
virtualization@lists.linux-foundation.org, kvm@vger.kernel.org
Subject: Re: [PATCH V2 RFC] fixup! virtio: convert to use DMA api
Date: Thu, 21 Apr 2016 18:11:40 +0300 [thread overview]
Message-ID: <20160421181102-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20160421145653.GB11814@stefanha-x1.localdomain>
On Thu, Apr 21, 2016 at 03:56:53PM +0100, Stefan Hajnoczi wrote:
> On Thu, Apr 21, 2016 at 04:43:45PM +0300, Michael S. Tsirkin wrote:
> > This adds a flag to enable/disable bypassing the IOMMU by
> > virtio devices.
> >
> > This is on top of patch
> > http://article.gmane.org/gmane.comp.emulators.qemu/403467
> > virtio: convert to use DMA api
> >
> > Tested with patchset
> > http://article.gmane.org/gmane.linux.kernel.virtualization/27545
> > virtio-pci: iommu support (note: bit number has been kept at 34
> > intentionally to match posted guest code. a non-RFC version will
> > renumber bits to be contigious).
> >
> > changes from v1:
> > drop PASSTHROUGH flag
> >
> > The interaction between virtio and DMA API is messy.
> >
> > On most systems with virtio, physical addresses match bus addresses,
> > and it doesn't particularly matter whether we use the DMA API.
> >
> > On some systems, including Xen and any system with a physical device
> > that speaks virtio behind a physical IOMMU, we must use the DMA API
> > for virtio DMA to work at all.
> >
> > Add a feature bit to detect that: VIRTIO_F_IOMMU_PLATFORM.
> >
> > If not there, we preserve historic behavior and bypass the DMA
> > API unless within Xen guest. This is actually required for
> > systems, including SPARC and PPC64, where virtio-pci devices are
> > enumerated as though they are behind an IOMMU, but the virtio host
> > ignores the IOMMU, so we must either pretend that the IOMMU isn't
> > there or somehow map everything as the identity.
> >
> > Re: non-virtio devices.
> >
> > It turns out that on old QEMU hosts, only emulated devices which were
> > part of QEMU use the IOMMU. Should we want to bypass the IOMMU for such
> > devices *only*, it would be rather easy to detect them by looking at
> > subsystem vendor and device ID. Thus, no new interfaces are required
> > except for virtio which always uses the same subsystem vendor and device ID.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > include/hw/virtio/virtio-access.h | 3 ++-
> > include/hw/virtio/virtio.h | 4 +++-
> > include/standard-headers/linux/virtio_config.h | 2 ++
> > 3 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
> > index 967cc75..bb6f34e 100644
> > --- a/include/hw/virtio/virtio-access.h
> > +++ b/include/hw/virtio/virtio-access.h
> > @@ -23,7 +23,8 @@ static inline AddressSpace *virtio_get_dma_as(VirtIODevice *vdev)
> > BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
> > VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
> >
> > - if (k->get_dma_as) {
> > + if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM) &&
> > + k->get_dma_as) {
> > return k->get_dma_as(qbus->parent);
> > }
> > return &address_space_memory;
> > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> > index b12faa9..44f3788 100644
> > --- a/include/hw/virtio/virtio.h
> > +++ b/include/hw/virtio/virtio.h
> > @@ -228,7 +228,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;
> > DEFINE_PROP_BIT64("notify_on_empty", _state, _field, \
> > VIRTIO_F_NOTIFY_ON_EMPTY, true), \
> > DEFINE_PROP_BIT64("any_layout", _state, _field, \
> > - VIRTIO_F_ANY_LAYOUT, true)
> > + VIRTIO_F_ANY_LAYOUT, true), \
> > + DEFINE_PROP_BIT64("iommu_platform", _state, _field, \
> > + VIRTIO_F_IOMMU_PLATFORM, false)
>
> Looks like the impact of this patch is that users who relied on
> k->get_dma_as today may now have to explicitly add iommu_platform=on.
> Are there any such users (e.g. Xen)?
No because upstream this is ignored. This is an incremental patch
on top of Jason's one.
> Instead of breaking the command-line for these users you could invert
> the flag's meaning ("iommu_bypass=on") and set it in the SPARC/PPC
> machine types.
>
> Stefan
I hope I made it clear that there are no such users.
next prev parent reply other threads:[~2016-04-21 15:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 13:43 [PATCH V2 RFC] fixup! virtio: convert to use DMA api Michael S. Tsirkin
2016-04-21 13:54 ` Wei Liu
2016-04-27 12:18 ` David Woodhouse
2016-04-27 13:37 ` Michael S. Tsirkin
2016-04-27 14:23 ` Joerg Roedel
2016-04-27 14:31 ` Andy Lutomirski
2016-04-27 14:38 ` Michael S. Tsirkin
2016-04-27 14:43 ` Andy Lutomirski
2016-04-27 14:54 ` Michael S. Tsirkin
2016-04-27 14:58 ` Joerg Roedel
2016-04-27 15:09 ` Michael S. Tsirkin
2016-04-27 15:10 ` Andy Lutomirski
2016-04-27 14:34 ` Michael S. Tsirkin
2016-04-27 14:56 ` Joerg Roedel
2016-04-27 15:05 ` Michael S. Tsirkin
2016-04-27 15:15 ` David Woodhouse
2016-04-27 18:17 ` Michael S. Tsirkin
2016-04-27 19:16 ` David Woodhouse
2016-04-28 14:34 ` Michael S. Tsirkin
2016-04-28 15:11 ` David Woodhouse
2016-04-28 15:37 ` Michael S. Tsirkin
2016-04-28 15:48 ` David Woodhouse
2016-05-01 10:37 ` Michael S. Tsirkin
2016-05-09 11:09 ` Paolo Bonzini
2016-04-21 14:56 ` Stefan Hajnoczi
2016-04-21 15:11 ` Michael S. Tsirkin [this message]
2016-04-22 9:33 ` Stefan Hajnoczi
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=20160421181102-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=amit.shah@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dwmw2@infradead.org \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.liu2@citrix.com \
/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).