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: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com,
	vkaplans@redhat.com, alex.williamson@redhat.com, wexu@redhat.com,
	pbonzini@redhat.com, cornelia.huck@de.ibm.com,
	dgibson@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 2/3] memory: introduce IOMMUOps.notify_flag_changed
Date: Wed, 14 Sep 2016 20:37:34 +1000	[thread overview]
Message-ID: <20160914103734.GQ15077@voom.fritz.box> (raw)
In-Reply-To: <20160914074941.GO3776@pxdev.xzpeter.org>

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

On Wed, Sep 14, 2016 at 03:49:41PM +0800, Peter Xu wrote:
> On Wed, Sep 14, 2016 at 05:22:40PM +1000, David Gibson wrote:
> > On Wed, Sep 14, 2016 at 03:12:43PM +0800, Peter Xu wrote:
> > > On Wed, Sep 14, 2016 at 03:55:28PM +1000, David Gibson wrote:
> > > 
> > > [...]
> > > 
> > > > > -static void vtd_iommu_notify_started(MemoryRegion *iommu)
> > > > > +static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
> > > > > +                                          IOMMUNotifierFlag old,
> > > > > +                                          IOMMUNotifierFlag new)
> > > > >  {
> > > > >      VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
> > > > 
> > > > Shouldn't this have a sanity check that the new flags doesn't include
> > > > MAP actions?
> > > 
> > > See your r-b for patch 3, thanks! So skipping this one.
> > > 
> > > [...]
> > > 
> > > > > +static void spapr_tce_notify_flag_changed(MemoryRegion *iommu,
> > > > > +                                          IOMMUNotifierFlag old,
> > > > > +                                          IOMMUNotifierFlag new)
> > > > > +{
> > > > > +    if (old == IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_ALL) {
> > > > > +        spapr_tce_notify_started(iommu);
> > > > > +    } else if (old == IOMMU_NOTIFIER_ALL && new == IOMMU_NOTIFIER_NONE) {
> > > > > +        spapr_tce_notify_stopped(iommu);
> > > > > +    }
> > > > 
> > > > This is wrong.  We need to do the notify_start and stop actions if
> > > > *any* bits are set in the new/old flags, not just if all of them are
> > > > set.
> > > 
> > > Power should need both, right? I can switch all
> > > 
> > >   "== IOMMU_NOTIFIER_ALL"
> > > 
> > > into:
> > > 
> > >   "!= IOMMU_NOTIFIER_NONE"
> > 
> > Yes, that should be right.
> > 
> > > in the next version if you like, but AFAICT they are totally the
> > > same.
> > 
> > Again, only if you assume things about how the notifiers will be used,
> > which is not a good look when designing an interface.
> 
> This should not be related to the interface at all?
> 
> I was based on the assumption that "Power cannot support either one of
> MAP/UNMAP, but only if both exist".

Huh? I have no idea what you mean by that.

Power can support notifying both map and unmap events just fine - but
in order to provide *any* notifications, it has to disable KVM
acceleration of the guest-side IOMMU (otherwise qemu won't know about
any changes to the IOMMU state).

So the change you you suggested before to != IOMMU_NOTIFIER_NONE is
exactly correct, anything else is not.

> To be more specific, we possibly
> can have this at the beginning of flags_changed():
> 
>   assert(old == IOMMU_NOTIFIER_NONE || old == IOMMU_NOTIFIER_ALL);
>   assert(new == IOMMU_NOTIFIER_NONE || new == IOMMU_NOTIFIER_ALL);
> 
> To make sure nothing will go wrong.

Hmm.. I really get the feeling you're confusing constraints of the
guest side with constraints of the host side.

-- 
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 --]

  reply	other threads:[~2016-09-14 10:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09  2:57 [Qemu-devel] [PATCH v4 0/3] Introduce IOMMUNotifier struct Peter Xu
2016-09-09  2:57 ` [Qemu-devel] [PATCH v4 1/3] memory: introduce IOMMUNotifier and its caps Peter Xu
2016-09-14  5:48   ` David Gibson
2016-09-14  7:15     ` David Gibson
2016-09-14  7:40       ` Peter Xu
2016-09-14 10:47         ` David Gibson
2016-09-14  8:17       ` Peter Xu
2016-09-14 10:50         ` David Gibson
2016-09-09  2:57 ` [Qemu-devel] [PATCH v4 2/3] memory: introduce IOMMUOps.notify_flag_changed Peter Xu
2016-09-14  5:55   ` David Gibson
2016-09-14  7:12     ` Peter Xu
2016-09-14  7:22       ` David Gibson
2016-09-14  7:49         ` Peter Xu
2016-09-14 10:37           ` David Gibson [this message]
2016-09-14 11:25             ` Peter Xu
2016-09-09  2:57 ` [Qemu-devel] [PATCH v4 3/3] intel_iommu: allow UNMAP notifiers Peter Xu
2016-09-14  5:56   ` David Gibson
2016-09-09  4:05 ` [Qemu-devel] [PATCH v4 0/3] Introduce IOMMUNotifier struct no-reply
2016-09-09  6:41   ` 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=20160914103734.GQ15077@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.