All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Smarduch <m.smarduch@samsung.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "ard.biesheuvel@linaro.org" <ard.biesheuvel@linaro.org>,
	Marc Zyngier <Marc.Zyngier@arm.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"lersek@redhat.com" <lersek@redhat.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc
Date: Fri, 22 May 2015 18:08:30 -0700	[thread overview]
Message-ID: <555FD30E.6050507@samsung.com> (raw)
In-Reply-To: <20150518155303.GF21251@e104818-lin.cambridge.arm.com>

On 05/18/2015 08:53 AM, Catalin Marinas wrote:
> On Thu, May 14, 2015 at 02:46:44PM +0100, Andrew Jones wrote:
>> On Thu, May 14, 2015 at 01:05:09PM +0200, Christoffer Dall wrote:
>>> On Wed, May 13, 2015 at 01:31:52PM +0200, Andrew Jones wrote:
>>>> Provide a method to change normal, cacheable memory to non-cacheable.
>>>> KVM will make use of this to keep emulated device memory regions
>>>> coherent with the guest.
>>>>
>>>> Signed-off-by: Andrew Jones <drjones@redhat.com>
>>>
>>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>>
>>> But you obviously need Russell and Will/Catalin to ack/merge this.
>>
>> I guess this patch is going to go away in the next round. You've
>> pointed out that I screwed stuff up royally with my over eagerness
>> to reuse code. I need to reimplement change_memory_common, but a
>> version that takes an mm, which is more or less what I did in the
>> last version of this series, back when I was pinning pages.
> 
> I kept wondering what this patch and the next one are doing with
> set_memory_nc(). Basically you were trying to set the cache attributes
> for the kernel linear mapping or kmap address (in the 32-bit arm case,
> which is removed anyway on kunmap).
> 
> What you need is changing the attributes of the user mapping as accessed
> by Qemu but I don't think simply re-implementing change_memory_common()
> would work, you probably need to pin the pages in memory as well.
> Otherwise, the kernel may remove such pages and, when bringing them
> back, would set the default cacheability attributes.
> 
> 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.
> 
> 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 think this option with a basic loadable driver
that allocates non-cachable/pinned pages for QEMU to mmap()
may provide a reference point to build on. If that covers
all the cases then perhaps move to more generic solution. This
should be quicker to implement and test.

I wonder if kernel mm will ever have a reason
to create a cacheable mapping even if the pages are pinned?
Like reading /dev/mem although that's not a likely case here.

- Mario

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

WARNING: multiple messages have this Message-ID (diff)
From: Mario Smarduch <m.smarduch@samsung.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	Andrew Jones <drjones@redhat.com>,
	"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>
Subject: Re: [Qemu-devel] [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc
Date: Fri, 22 May 2015 18:08:30 -0700	[thread overview]
Message-ID: <555FD30E.6050507@samsung.com> (raw)
In-Reply-To: <20150518155303.GF21251@e104818-lin.cambridge.arm.com>

On 05/18/2015 08:53 AM, Catalin Marinas wrote:
> On Thu, May 14, 2015 at 02:46:44PM +0100, Andrew Jones wrote:
>> On Thu, May 14, 2015 at 01:05:09PM +0200, Christoffer Dall wrote:
>>> On Wed, May 13, 2015 at 01:31:52PM +0200, Andrew Jones wrote:
>>>> Provide a method to change normal, cacheable memory to non-cacheable.
>>>> KVM will make use of this to keep emulated device memory regions
>>>> coherent with the guest.
>>>>
>>>> Signed-off-by: Andrew Jones <drjones@redhat.com>
>>>
>>> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
>>>
>>> But you obviously need Russell and Will/Catalin to ack/merge this.
>>
>> I guess this patch is going to go away in the next round. You've
>> pointed out that I screwed stuff up royally with my over eagerness
>> to reuse code. I need to reimplement change_memory_common, but a
>> version that takes an mm, which is more or less what I did in the
>> last version of this series, back when I was pinning pages.
> 
> I kept wondering what this patch and the next one are doing with
> set_memory_nc(). Basically you were trying to set the cache attributes
> for the kernel linear mapping or kmap address (in the 32-bit arm case,
> which is removed anyway on kunmap).
> 
> What you need is changing the attributes of the user mapping as accessed
> by Qemu but I don't think simply re-implementing change_memory_common()
> would work, you probably need to pin the pages in memory as well.
> Otherwise, the kernel may remove such pages and, when bringing them
> back, would set the default cacheability attributes.
> 
> 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.
> 
> 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 think this option with a basic loadable driver
that allocates non-cachable/pinned pages for QEMU to mmap()
may provide a reference point to build on. If that covers
all the cases then perhaps move to more generic solution. This
should be quicker to implement and test.

I wonder if kernel mm will ever have a reason
to create a cacheable mapping even if the pages are pinned?
Like reading /dev/mem although that's not a likely case here.

- Mario

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

  parent reply	other threads:[~2015-05-23  0:59 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 11:31 [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Andrew Jones
2015-05-13 11:31 ` [Qemu-devel] " Andrew Jones
2015-05-13 11:31 ` [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc Andrew Jones
2015-05-13 11:31   ` [Qemu-devel] " Andrew Jones
2015-05-14 11:05   ` Christoffer Dall
2015-05-14 11:05     ` [Qemu-devel] " Christoffer Dall
2015-05-14 13:46     ` Andrew Jones
2015-05-14 13:46       ` [Qemu-devel] " Andrew Jones
2015-05-15 14:51       ` Christoffer Dall
2015-05-15 14:51         ` [Qemu-devel] " Christoffer Dall
2015-05-18 15:53       ` Catalin Marinas
2015-05-18 15:53         ` [Qemu-devel] " Catalin Marinas
2015-05-19 10:03         ` Andrew Jones
2015-05-19 10:03           ` [Qemu-devel] " Andrew Jones
2015-05-19 11:18           ` Catalin Marinas
2015-05-19 11:18             ` [Qemu-devel] " Catalin Marinas
2015-05-19 11:38             ` Andrew Jones
2015-05-19 11:38               ` [Qemu-devel] " Andrew Jones
2015-05-20 10:01             ` Christoffer Dall
2015-05-20 10:01               ` [Qemu-devel] " Christoffer Dall
2015-05-20 11:24               ` Catalin Marinas
2015-05-20 11:24                 ` [Qemu-devel] " Catalin Marinas
2015-05-23  1:08         ` Mario Smarduch [this message]
2015-05-23  1:08           ` Mario Smarduch
2015-05-25 17:11           ` Andrew Jones
2015-05-25 17:11             ` Andrew Jones
2015-05-27  1:08             ` Mario Smarduch
2015-05-27  1:08               ` Mario Smarduch
2015-05-13 11:31 ` [RFC/RFT PATCH v2 2/3] KVM: promote KVM_MEMSLOT_INCOHERENT to uapi Andrew Jones
2015-05-13 11:31   ` [Qemu-devel] " Andrew Jones
2015-05-14 10:12   ` Paolo Bonzini
2015-05-14 10:12     ` [Qemu-devel] " Paolo Bonzini
2015-05-14 10:34   ` Christoffer Dall
2015-05-14 10:34     ` [Qemu-devel] " Christoffer Dall
2015-05-13 11:31 ` [RFC/RFT PATCH v2 3/3] arm/arm64: KVM: implement 'uncached' mem coherency Andrew Jones
2015-05-13 11:31   ` [Qemu-devel] " Andrew Jones
2015-05-14 10:55   ` Christoffer Dall
2015-05-14 10:55     ` [Qemu-devel] " Christoffer Dall
2015-05-14 13:32     ` Andrew Jones
2015-05-14 13:32       ` Andrew Jones
2015-05-15 15:02       ` Christoffer Dall
2015-05-15 15:02         ` Christoffer Dall
2015-05-15 17:04         ` Andrew Jones
2015-05-15 17:04           ` Andrew Jones
2015-05-15 20:16           ` Jérémy Fanguède
2015-05-15 20:16             ` Jérémy Fanguède
2015-05-21  2:29           ` Mario Smarduch
2015-05-21  2:29             ` Mario Smarduch
2015-05-21 16:50             ` Andrew Jones
2015-05-21 16:50               ` Andrew Jones
2015-05-14 10:30 ` [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Christoffer Dall
2015-05-14 10:30   ` [Qemu-devel] " Christoffer Dall
2015-05-14 11:09   ` Laszlo Ersek
2015-05-14 11:09     ` [Qemu-devel] " Laszlo Ersek
2015-05-14 11:29     ` Christoffer Dall
2015-05-14 11:29       ` [Qemu-devel] " Christoffer Dall
2015-05-14 11:31       ` Paolo Bonzini
2015-05-14 11:31         ` [Qemu-devel] " Paolo Bonzini
2015-05-14 11:36         ` Christoffer Dall
2015-05-14 11:36           ` [Qemu-devel] " Christoffer Dall
2015-05-14 11:38           ` Paolo Bonzini
2015-05-14 11:38             ` [Qemu-devel] " Paolo Bonzini
2015-05-14 12:00             ` Christoffer Dall
2015-05-14 12:00               ` [Qemu-devel] " Christoffer Dall
2015-05-14 12:08               ` Paolo Bonzini
2015-05-14 12:08                 ` [Qemu-devel] " Paolo Bonzini
2015-05-14 12:24                 ` Christoffer Dall
2015-05-14 12:24                   ` [Qemu-devel] " Christoffer Dall
2015-05-14 12:28                   ` Paolo Bonzini
2015-05-14 12:28                     ` [Qemu-devel] " Paolo Bonzini
2015-05-14 12:34                     ` Christoffer Dall
2015-05-14 12:34                       ` [Qemu-devel] " Christoffer Dall
2015-05-14 13:01                       ` Laszlo Ersek
2015-05-14 13:01                         ` [Qemu-devel] " Laszlo Ersek
2015-05-14 12:38                     ` Peter Maydell
2015-05-14 12:38                       ` [Qemu-devel] " Peter Maydell
2015-05-14 13:00                       ` Andrew Jones
2015-05-14 13:00                         ` Andrew Jones
2015-05-14 13:32                         ` Laszlo Ersek
2015-05-14 13:32                           ` Laszlo Ersek
2015-05-14 13:48                           ` Michael S. Tsirkin
2015-05-14 13:48                             ` Michael S. Tsirkin
2015-05-14 14:19                             ` Laszlo Ersek
2015-05-14 14:19                               ` Laszlo Ersek
2015-05-14 14:41                               ` Michael S. Tsirkin
2015-05-14 14:41                                 ` Michael S. Tsirkin
2015-05-15  9:00                                 ` Ard Biesheuvel
2015-05-15  9:00                                   ` Ard Biesheuvel
2015-05-14 10:31 ` Andrew Jones
2015-05-14 10:31   ` [Qemu-devel] " Andrew Jones
2015-05-14 10:37   ` Peter Maydell
2015-05-14 10:37     ` [Qemu-devel] " Peter Maydell
2015-05-14 13:03     ` Andrew Jones
2015-05-14 13:03       ` [Qemu-devel] " Andrew Jones
2015-05-14 13:11       ` Peter Maydell
2015-05-14 13:11         ` [Qemu-devel] " Peter Maydell
2015-05-14 13:33         ` Laszlo Ersek
2015-05-14 13:33           ` [Qemu-devel] " Laszlo Ersek
2015-05-14 13:36         ` Andrew Jones
2015-05-14 13:36           ` Andrew Jones
2015-05-15 15:09           ` Christoffer Dall
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=555FD30E.6050507@samsung.com \
    --to=m.smarduch@samsung.com \
    --cc=Marc.Zyngier@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=lersek@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 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.