All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Xu <peterx@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org,
	cornelia.huck@de.ibm.com, alex.williamson@redhat.com,
	wexu@redhat.com, vkaplans@redhat.com, dgibson@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/3] memory: add iommu_notify_flag
Date: Tue, 6 Sep 2016 15:18:46 +1000	[thread overview]
Message-ID: <20160906051846.GD16479@voom.fritz.box> (raw)
In-Reply-To: <20160905083804.GB7761@pxdev.xzpeter.org>

[-- Attachment #1: Type: text/plain, Size: 2626 bytes --]

On Mon, Sep 05, 2016 at 04:38:04PM +0800, Peter Xu wrote:
> On Mon, Sep 05, 2016 at 10:04:42AM +0200, Paolo Bonzini wrote:
> > 
> > 
> > On 05/09/2016 09:21, Peter Xu wrote:
> > >  void memory_region_notify_iommu(MemoryRegion *mr,
> > > -                                IOMMUTLBEntry entry)
> > > +                                IOMMUTLBEntry entry, IOMMUAccessFlags flag)
> > >  {
> > >      assert(memory_region_is_iommu(mr));
> > > +    assert(flag == mr->iommu_notify_flag);
> > >      notifier_list_notify(&mr->iommu_notify, &entry);
> > >  }
> > 
> > Shouldn't it be possible to have IOMMU_RW and IOMMU_NONE on the same
> > IOMMU, if the IOMMU supports IOMMU_RW at all?
> 
> Yeah, this is a good point...
> 
> If we see IOMMU_NONE as a subset of IOMMU_RW, we should allow notify
> IOMMU_NONE even if the cached flag is IOMMU_RW.
> 
> However in this patch I was not meant to do that. I made it an
> exclusive flag to identify two different use cases. I don't know
> whether this is good, but at least for Intel IOMMU's current use case,
> these two types should be totally isolated from each other:

It's not good, it's horrible.  This makes a hideous interface that's
just a collection of separate use cases without any coherent
underlying semantics.

> - IOMMU_NONE notification is used by future DMAR-enabled vhost, it
>   should only be notified with device-IOTLB invalidations, this will
>   only require "Device IOTLB" capability for Intel IOMMUs, and be
>   notified in Device IOTLB invalidation handlers.
> 
> - IOMMU_RW notifications should only be used for vfio-pci, notified
>   with IOTLB invalidations. This will only require Cache Mode (CM=1)
>   capability, and will be notified in common IOTLB invalidations (no
>   matter whether it's an cache invalidation or not, we will all use
>   IOMMU_RW flag for this kind of notifies).
> 
> Maybe here naming the flags as IOMMU_{RW_NONE} is a little bit
> confusing (just to leverage existing access flags), but what I was
> trying to do is to make the two things not overlapped at all, since I
> didn't find a mixture use case.

Maybe not now, but a common use case is absolutely possible.  If you
had a single (guest) bus with a single IO address space, with vIOMMU
and both VFIO and vhost devices on it, the same vIOMMU would need to
send all notifications to VFIO and (at least) unmap notifications to
vhost.

-- 
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: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  parent reply	other threads:[~2016-09-06  5:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05  7:21 [Qemu-devel] [PATCH 0/3] memory: add IOMMU notifier type Peter Xu
2016-09-05  7:21 ` [Qemu-devel] [PATCH 1/3] memory: add one flag for IOMMU notifier Peter Xu
2016-09-05  7:21 ` [Qemu-devel] [PATCH 2/3] memory: add iommu_notify_flag Peter Xu
2016-09-05  8:04   ` Paolo Bonzini
2016-09-05  8:38     ` Peter Xu
2016-09-05  9:56       ` Paolo Bonzini
2016-09-06  5:27         ` Peter Xu
2016-09-06  7:51           ` Paolo Bonzini
2016-09-06  8:17             ` Peter Xu
2016-09-06  8:19               ` Paolo Bonzini
2016-09-06 10:31                 ` Peter Xu
2016-09-07  5:44                   ` David Gibson
2016-09-07  6:34                     ` Peter Xu
2016-09-07  6:41                       ` David Gibson
2016-09-08  9:07                         ` Peter Xu
2016-09-12  1:26                           ` David Gibson
2016-09-12  5:13                             ` Peter Xu
2016-09-14  4:00                               ` David Gibson
2016-09-14  5:43                                 ` Peter Xu
2016-09-06  5:18       ` David Gibson [this message]
2016-09-06  5:55         ` Peter Xu
2016-09-06  5:12   ` David Gibson
2016-09-06  5:33     ` Peter Xu
2016-09-05  7:21 ` [Qemu-devel] [PATCH 3/3] intel_iommu: allow IOMMU_NONE typed notifiers Peter Xu
2016-09-06  5:06 ` [Qemu-devel] [PATCH 0/3] memory: add IOMMU notifier type David Gibson
2016-09-06  5:49   ` Peter Xu
2016-09-06  6:26     ` Jason Wang
2016-09-07  4:38       ` 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=20160906051846.GD16479@voom.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=alex.williamson@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dgibson@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vkaplans@redhat.com \
    --cc=wexu@redhat.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 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.