From: Andrew Jones <drjones@redhat.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
"ard.biesheuvel@linaro.org" <ard.biesheuvel@linaro.org>,
Marc Zyngier <Marc.Zyngier@arm.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"agraf@suse.de" <agraf@suse.de>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"j.fanguede@virtualopensystems.com"
<j.fanguede@virtualopensystems.com>,
"lersek@redhat.com" <lersek@redhat.com>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
Christoffer Dall <christoffer.dall@linaro.org>,
"m.smarduch@samsung.com" <m.smarduch@samsung.com>
Subject: Re: [Qemu-devel] [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc
Date: Tue, 19 May 2015 13:38:42 +0200 [thread overview]
Message-ID: <20150519113842.GE2815@localhost.localdomain> (raw)
In-Reply-To: <20150519111854.GA14109@localhost>
On Tue, May 19, 2015 at 12:18:54PM +0100, Catalin Marinas wrote:
> On Tue, May 19, 2015 at 11:03:22AM +0100, Andrew Jones wrote:
> > On Mon, May 18, 2015 at 04:53:03PM +0100, Catalin Marinas wrote:
> > > Another way would be to split the vma containing the non-cacheable
> > > memory so that you get a single vma with the vm_page_prot as
> > > Non-cacheable.
> >
> > This sounds interesting. Actually, it even crossed my mind once when I
> > first saw that the vma would overwrite the attributes, but then, sigh,
> > I let my brain take a stupidity bath.
> >
> > >
> > > Yet another approach could be for KVM to mmap the necessary memory for
> > > Qemu via a file_operations.mmap call (but that's only for ranges outside
> > > the guest "RAM").
> >
> > I guess I prefer the vma splitting, rather than this (the vma creating
> > with mmap), as it keeps the KVM interface from changing (as you point out
> > below). Well, unless there are other advantages to this that are worth
> > considering?
>
> The advantage is that you don't need to deal with the mm internals in
> the KVM code.
>
> But you can probably add such code directly to mm/ and reuse some of the
> existing code in there already as part of change_protection(),
> mprotect_fixup(), sys_mprotect(). Actually, once you split the vma and
> set the new protection (something similar to mprotect_fixup), it looks
> to me like you can just call change_protection(vma->vm_page_prot).
I'll start playing around with this today.
>
> > > I didn't have time to follow these threads in details, but just to
> > > recap my understanding, we have two main use-cases:
> > >
> > > 1. Qemu handling guest I/O to device (e.g. PCIe BARs)
> > > 2. Qemu emulating device DMA
> > >
> > > For (1), I guess Qemu uses an anonymous mmap() and then tells KVM about
> > > this memory slot. The memory attributes in this case could be Device
> > > because that's how the guest would normally map it. The
> > > file_operations.mmap trick would work in this case but this means
> > > expanding the KVM ABI beyond just an ioctl().
> > >
> > > For (2), since Qemu is writing to the guest "RAM" (e.g. video
> > > framebuffer allocated by the guest), I still think the simplest is to
> > > tell the guest (via DT) that such device is cache coherent rather than
> > > trying to remap the Qemu mapping as non-cacheable.
> >
> > If we need a solution for (1), then I'd prefer that it work and be
> > applied to (2) as well. Anyway, I'm still not 100% sure we can count on
> > all guest types (booloaders, different OSes) to listen to us. They may
> > assume non-cacheable is typical and safe, and thus just do that always.
> > We can certainly change some of those bootloaders and OSes, but probably
> > not all of them.
>
> That's fine by me. Once you get the vma splitting and attributes
> changing done, I think you get the second one for free.
>
> Do we want to differentiate between Device and Normal Non-cacheable
> memory? Something like KVM_MEMSLOT_DEVICE?
>
> Nitpick: I'm not sure whether "uncached" is clear enough. In Linux,
> pgprot_noncached() returns Strongly Ordered memory. For Normal
> Non-cachable we used pgprot_writecombine (e.g. a video framebuffer).
>
> Maybe something like KVM_MEMSLOT_COHERENT meaning a request to KVM to
Sounds good to me. I'll rename for the next round.
> ensure that guest and host access it coherently (which would mean
> writecombine for ARM). That's similar naming to functions like
> dma_alloc_coherent() that return cacheable or non-cacheable memory based
> on what the device supports. Anyway, I'm not to bothered with the
> naming.
>
Thanks for your help!
drew
next prev parent reply other threads:[~2015-05-19 11:39 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 [this message]
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
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=20150519113842.GE2815@localhost.localdomain \
--to=drjones@redhat.com \
--cc=Marc.Zyngier@arm.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=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).