qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: peter.maydell@linaro.org, ard.biesheuvel@linaro.org,
	marc.zyngier@arm.com, catalin.marinas@arm.com,
	qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com,
	j.fanguede@virtualopensystems.com, lersek@redhat.com,
	kvmarm@lists.cs.columbia.edu, m.smarduch@samsung.com
Subject: Re: [Qemu-devel] [RFC/RFT PATCH v2 3/3] arm/arm64: KVM: implement 'uncached' mem coherency
Date: Fri, 15 May 2015 19:04:37 +0200	[thread overview]
Message-ID: <20150515170437.GA2951@localhost.localdomain> (raw)
In-Reply-To: <20150515145921.GB14144@lvm>

On Fri, May 15, 2015 at 08:02:59AM -0700, Christoffer Dall wrote:
> On Thu, May 14, 2015 at 03:32:13PM +0200, Andrew Jones wrote:
> > On Thu, May 14, 2015 at 12:55:49PM +0200, Christoffer Dall wrote:
> > > On Wed, May 13, 2015 at 01:31:54PM +0200, Andrew Jones wrote:
> > > > When S1 and S2 memory attributes combine wrt to caching policy,
> > > > non-cacheable types take precedence. If a guest maps a region as
> > > > device memory, which KVM userspace is using to emulate the device
> > > > using normal, cacheable memory, then we lose coherency. With
> > > > KVM_MEM_UNCACHED, KVM userspace can now hint to KVM which memory
> > > > regions are likely to be problematic. With this patch, as pages
> > > > of these types of regions are faulted into the guest, not only do
> > > > we flush the page's dcache, but we also change userspace's
> > > > mapping to NC in order to maintain coherency.
> > > > 
> > > > What if the guest doesn't do what we expect? While we can't
> > > > force a guest to use cacheable memory, we can take advantage of
> > > > the non-cacheable precedence, and force it to use non-cacheable.
> > > > So, this patch also introduces PAGE_S2_NORMAL_NC, and uses it on
> > > > KVM_MEM_UNCACHED regions to force them to NC.
> > > > 
> > > > We now have both guest and userspace on the same page (pun intended)
> > > 
> > > I'd like to revisit the overall approach here.  Is doing non-cached
> > > accesses in both the guest and host really the right thing to do here?
> > 
> > I think so, but all ideas/approaches are still on the table. This is
> > still an RFC.
> > 
> > > 
> > > The semantics of the device becomes that it is cache coherent (because
> > > QEMU is), and I think Marc argued that Linux/UEFI should simply be
> > > adapted to handle whatever emulated devices we have as coherent.  I also
> > > remember someone arguing that would be wrong (Peter?).
> > 
> > I'm not really for quirking all devices in all guest types (AAVMF, Linux,
> > other bootloaders, other OSes). Windows is unlikely to apply any quirks.
> > 
> 
> Well my point was that if we're emulating a platform with coherent IO
> memory for PCI devices that is something that the guest should work with
> as such, but as Paolo explained it should always be safe for a guest to
> assume non-coherent, so that doesn't work.
> 
> > > 
> > > Finally, does this address all cache coherency issues with emulated
> > > devices?  Some VOS guys had seen things still not working with this
> > > approach, unsure why...  I'd like to avoid us merging this only to merge
> > > a more complete solution in a few weeks which reverts this solution...
> > 
> > I'm not sure (this is still an RFT too :-) We definitely would need to
> > scatter some more memory_region_set_uncached() calls around QEMU first.
> > 
> 
> It would be good if you could sync with the VOS guys and make sure your
> patch set addresses their issues with the appropriate
> memory_region_set_uncached() added to QEMU, and if it does not, some
> vague idea why that falls outside of the scope of this patch set.  After
> all, adding a USB controller to a VM is not that an esoteric use case,
> is it?

I'll pull together a new version addressing all your comments, and also
put some more time into making sure it'll work...

Jeremy, can you give me the qemu command line you're using for your tests?
I'll do some experimenting with it.

Thanks,
drew

  reply	other threads:[~2015-05-15 17:05 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 11:31 [Qemu-devel] [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Andrew Jones
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc Andrew Jones
2015-05-14 11:05   ` Christoffer Dall
2015-05-14 13:46     ` Andrew Jones
2015-05-15 14:51       ` Christoffer Dall
2015-05-18 15:53       ` Catalin Marinas
2015-05-19 10:03         ` Andrew Jones
2015-05-19 11:18           ` Catalin Marinas
2015-05-19 11:38             ` Andrew Jones
2015-05-20 10:01             ` Christoffer Dall
2015-05-20 11:24               ` Catalin Marinas
2015-05-23  1:08         ` Mario Smarduch
2015-05-25 17:11           ` Andrew Jones
2015-05-27  1:08             ` Mario Smarduch
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 2/3] KVM: promote KVM_MEMSLOT_INCOHERENT to uapi Andrew Jones
2015-05-14 10:12   ` Paolo Bonzini
2015-05-14 10:34   ` Christoffer Dall
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 3/3] arm/arm64: KVM: implement 'uncached' mem coherency Andrew Jones
2015-05-14 10:55   ` Christoffer Dall
2015-05-14 13:32     ` Andrew Jones
2015-05-15 15:02       ` Christoffer Dall
2015-05-15 17:04         ` Andrew Jones [this message]
2015-05-15 20:16           ` Jérémy Fanguède
2015-05-21  2:29           ` Mario Smarduch
2015-05-21 16:50             ` Andrew Jones
2015-05-14 10:30 ` [Qemu-devel] [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Christoffer Dall
2015-05-14 11:09   ` Laszlo Ersek
2015-05-14 11:29     ` Christoffer Dall
2015-05-14 11:31       ` Paolo Bonzini
2015-05-14 11:36         ` Christoffer Dall
2015-05-14 11:38           ` Paolo Bonzini
2015-05-14 12:00             ` Christoffer Dall
2015-05-14 12:08               ` Paolo Bonzini
2015-05-14 12:24                 ` Christoffer Dall
2015-05-14 12:28                   ` Paolo Bonzini
2015-05-14 12:34                     ` Christoffer Dall
2015-05-14 13:01                       ` Laszlo Ersek
2015-05-14 12:38                     ` Peter Maydell
2015-05-14 13:00                       ` Andrew Jones
2015-05-14 13:32                         ` Laszlo Ersek
2015-05-14 13:48                           ` Michael S. Tsirkin
2015-05-14 14:19                             ` Laszlo Ersek
2015-05-14 14:41                               ` Michael S. Tsirkin
2015-05-15  9:00                                 ` Ard Biesheuvel
2015-05-14 10:31 ` Andrew Jones
2015-05-14 10:37   ` Peter Maydell
2015-05-14 13:03     ` Andrew Jones
2015-05-14 13:11       ` Peter Maydell
2015-05-14 13:33         ` Laszlo Ersek
2015-05-14 13:36         ` Andrew Jones
2015-05-15 15:09           ` Christoffer Dall

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=20150515170437.GA2951@localhost.localdomain \
    --to=drjones@redhat.com \
    --cc=agraf@suse.de \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=j.fanguede@virtualopensystems.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=lersek@redhat.com \
    --cc=m.smarduch@samsung.com \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).