From: David Gibson <david@gibson.dropbear.id.au>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: aik@ozlabs.ru, alex.williamson@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/4] vfio: Move container list to iommu MemoryRegion
Date: Tue, 30 Apr 2013 12:05:39 +1000 [thread overview]
Message-ID: <20130430020539.GT20202@truffula.fritz.box> (raw)
In-Reply-To: <517E794B.1060307@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3034 bytes --]
On Mon, Apr 29, 2013 at 03:44:43PM +0200, Paolo Bonzini wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Il 29/04/2013 13:56, David Gibson ha scritto:
> >> Why should VFIO be any special in this? It is reassuring to me
> >> that the VFIO maintainer thinks the same. :)
> >
> > Because device passthrough is a sufficiently special case, IMO.
> > It introduces requirements that are fundamentally different from
> > any emulated device.
> >
> >>> It does also require making sure the lifetime handling is
> >>> correct. The entry from the hash table must be removed before
> >>> the corresponding MemoryRegion is free()ed; otherwise we could
> >>> end up using the same pointer for a newly constructed
> >>> MemoryRegion, and get a false lookup in the hash. Whether that
> >>> happens essentially never, or almost immediately in practice
> >>> depends on the malloc() implementation, of course.
> >>
> >> There is only one MemoryRegion per PCI host bridge, and the PCI
> >> host
> >
> > That's true for existing examples, but it need not be true. For
> > example the Intel IOMMU supports multiple "iommu domains" which
> > are different address spaces on the same host bridge. When one of
> > those domains is reconfigured, we will again need to call into vfio
> > by some mechanism to readjust the host side iommu configuration
> > accordingly.
> >
> >> bridge cannot disappear before the VFIO devices on it are torn
> >> down. So the lifetime should not be a problem.
> >
> > I think it is very risky to assume that existing constraints
> > control the lifetime for us, since we don't know what variety of
> > iommus we may have in future. I really think we should have an
> > explicit hook which allows us to call vfio side cleanup code when a
> > guest side iommu region is destroyed. Personally, I still think a
> > special-purpose vfio hook is the simplest way to do that, but a
> > more general use Notifier list or something in the right place
> > could do the job too.
>
> I think this is a different problem. Basically the question is "what
> happens if a MemoryRegion 'disappears' while an AddressSpace is still
> referring to it", and the answer right now is "badness".
Well.. no. The same problem may well exist for AddressSpace objects,
but in this case it's for the VFIO private per-address-space object.
> We should look at generic fixes before dropping hooks in the code. At
> the very least an "assert(mr->parent == NULL);" is missing in
> memory_region_destroy.
Well, sure that's probably also a good idea. But the whole point here
is you're insisting that the MemoryRegion code doesn't know about the
vfio private data, even as an opaque handle, and so there's no
possible assert we can put there to check it has been destroyed.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-04-30 2:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 6:02 [Qemu-devel] [0/4] RFC: Preparations for VFIO and guest IOMMUs (v2) David Gibson
2013-04-26 6:02 ` [Qemu-devel] [PATCH 1/4] Fix vmw_pvscsi.c for iommu support changes David Gibson
2013-04-26 8:19 ` Paolo Bonzini
2013-04-26 11:04 ` David Gibson
2013-04-26 6:02 ` [Qemu-devel] [PATCH 2/4] vfio: Associate VFIO groups with (guest) IOMMU address spaces David Gibson
2013-04-26 6:02 ` [Qemu-devel] [PATCH 3/4] vfio: Move container list to iommu MemoryRegion David Gibson
2013-04-26 8:23 ` Paolo Bonzini
2013-04-26 11:31 ` David Gibson
2013-04-26 13:40 ` Paolo Bonzini
2013-04-27 9:49 ` David Gibson
2013-04-27 12:17 ` Paolo Bonzini
2013-04-28 1:58 ` David Gibson
2013-04-29 8:11 ` Paolo Bonzini
2013-04-29 11:00 ` David Gibson
2013-04-29 11:38 ` Paolo Bonzini
2013-04-29 11:56 ` David Gibson
2013-04-29 13:44 ` Paolo Bonzini
2013-04-30 2:05 ` David Gibson [this message]
2013-04-30 2:23 ` David Gibson
2013-04-30 7:30 ` Paolo Bonzini
2013-04-30 7:54 ` David Gibson
2013-04-29 2:11 ` [Qemu-devel] [PATCH] memory: give name every AddressSpace Alexey Kardashevskiy
2013-04-29 8:16 ` Paolo Bonzini
2013-04-29 8:21 ` Alexey Kardashevskiy
2013-04-29 9:25 ` Paolo Bonzini
2013-04-29 11:09 ` David Gibson
2013-04-30 2:14 ` Alexey Kardashevskiy
2013-04-26 6:02 ` [Qemu-devel] [PATCH 4/4] vfio: Only use memory listeners when appropriate David Gibson
2013-04-26 15:42 ` [Qemu-devel] [0/4] RFC: Preparations for VFIO and guest IOMMUs (v2) Alex Williamson
2013-04-27 9:51 ` David Gibson
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=20130430020539.GT20202@truffula.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=pbonzini@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).