All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Laszlo Ersek <lersek@redhat.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Mario Smarduch <m.smarduch@samsung.com>
Subject: Re: [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED
Date: Wed, 29 Apr 2015 13:19:36 +0200	[thread overview]
Message-ID: <20150429111936.GA2918@localhost.localdomain> (raw)
In-Reply-To: <CAFEAcA8782LF=m_L=iEqgkBAVThO2SxXOu74YaM3YQkvN_4owA@mail.gmail.com>

On Wed, Apr 29, 2015 at 10:19:55AM +0100, Peter Maydell wrote:
> On 29 April 2015 at 10:03, Alexander Graf <agraf@suse.de> wrote:
> >
> >
> > On 18.03.15 20:10, Andrew Jones wrote:
> >> Introduce a new memory region flag, KVM_MEM_UNCACHED, which
> >> is needed by ARM. This flag informs KVM that the given memory
> >> region is typically mapped by the guest as uncached. KVM for
> >> ARM then maps that region as uncached for userspace as well,
> >> in order to keep coherency.
> >
> > I finally managed to give this a spin and immediately ran into an
> > unaligned access trap:

Thanks! And err.. sorry it broke.

> >
> > [  116.509976] Unhandled fault: alignment fault (0x92000061) at
> > 0x000003ffb1300000
> >
> > Program received signal SIGBUS, Bus error.
> > [Switching to Thread 0x3ffb317ecb0 (LWP 1956)]
> > 0x000003ffb685ed68 in memset () from /lib64/libc.so.6
> > (gdb) bt
> > #0  0x000003ffb685ed68 in memset () from /lib64/libc.so.6
> > #1  0x000002aaaac013ec in memset (__len=<optimized out>, __ch=0,
> > __dest=<optimized out>) at /usr/include/bits/string3.h:90
> > #2  vbe_ioport_write_data (opaque=0x2aaabbd3600, addr=<optimized out>,
> > val=65) at /usr/src/debug/qemu-2.3.0-rc4/hw/display/vga.c:739
> > #3  0x000002aaaabe07dc in memory_region_write_accessor (mr=<optimized
> > out>, addr=<optimized out>, value=<optimized out>, size=<optimized out>,
> >     shift=<optimized out>, mask=<optimized out>) at
> > /usr/src/debug/qemu-2.3.0-rc4/memory.c:430
> > [...]
> 
> This appears to be because the KVM_MEM_UNCACHED flag
> confusingly isn't marking the memory as Normal-Noncacheable
> but as Device-nGnRnE (aka Strongly Ordered). You can't unalignedly
> access Device memory (and so you can't use the usual userspace
> memcpy, memset, etc).
> 
> Did we really want Device-nGnRnE memory here? If we did can
> we have a less confusing name for the flag?

I hadn't considered the other side-effects of going with device
vs. normal memory. I'll change patch 3/3 with

31c31
< +	pte = set_pte_bit(pte, L_PTE_MT_UNCACHED);
---
> +	pte = set_pte_bit(pte, L_PTE_MT_WRITEBACK);
166c166
< +	pte = set_pte_bit(pte, PTE_ATTRINDX(MT_DEVICE_nGnRnE));
---
> +	pte = set_pte_bit(pte, PTE_ATTRINDX(MT_NORMAL_NC));



I've left this on the backburner too long, but I can pick it back
up on Monday. I still haven't looked at Paolo's mmu notifier
suggestion yet either. I'll start looking at that as well.

Thanks,
drew


> 
> [for the non-ARM folk, nGnRnE == no gathering of accesses,
> no reordering, no early-write-acknowledgement.]
> 
> thanks
> -- PMM
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <drjones@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Alexander Graf <agraf@suse.de>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Laszlo Ersek <lersek@redhat.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Mario Smarduch <m.smarduch@samsung.com>
Subject: Re: [Qemu-devel] [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED
Date: Wed, 29 Apr 2015 13:19:36 +0200	[thread overview]
Message-ID: <20150429111936.GA2918@localhost.localdomain> (raw)
In-Reply-To: <CAFEAcA8782LF=m_L=iEqgkBAVThO2SxXOu74YaM3YQkvN_4owA@mail.gmail.com>

On Wed, Apr 29, 2015 at 10:19:55AM +0100, Peter Maydell wrote:
> On 29 April 2015 at 10:03, Alexander Graf <agraf@suse.de> wrote:
> >
> >
> > On 18.03.15 20:10, Andrew Jones wrote:
> >> Introduce a new memory region flag, KVM_MEM_UNCACHED, which
> >> is needed by ARM. This flag informs KVM that the given memory
> >> region is typically mapped by the guest as uncached. KVM for
> >> ARM then maps that region as uncached for userspace as well,
> >> in order to keep coherency.
> >
> > I finally managed to give this a spin and immediately ran into an
> > unaligned access trap:

Thanks! And err.. sorry it broke.

> >
> > [  116.509976] Unhandled fault: alignment fault (0x92000061) at
> > 0x000003ffb1300000
> >
> > Program received signal SIGBUS, Bus error.
> > [Switching to Thread 0x3ffb317ecb0 (LWP 1956)]
> > 0x000003ffb685ed68 in memset () from /lib64/libc.so.6
> > (gdb) bt
> > #0  0x000003ffb685ed68 in memset () from /lib64/libc.so.6
> > #1  0x000002aaaac013ec in memset (__len=<optimized out>, __ch=0,
> > __dest=<optimized out>) at /usr/include/bits/string3.h:90
> > #2  vbe_ioport_write_data (opaque=0x2aaabbd3600, addr=<optimized out>,
> > val=65) at /usr/src/debug/qemu-2.3.0-rc4/hw/display/vga.c:739
> > #3  0x000002aaaabe07dc in memory_region_write_accessor (mr=<optimized
> > out>, addr=<optimized out>, value=<optimized out>, size=<optimized out>,
> >     shift=<optimized out>, mask=<optimized out>) at
> > /usr/src/debug/qemu-2.3.0-rc4/memory.c:430
> > [...]
> 
> This appears to be because the KVM_MEM_UNCACHED flag
> confusingly isn't marking the memory as Normal-Noncacheable
> but as Device-nGnRnE (aka Strongly Ordered). You can't unalignedly
> access Device memory (and so you can't use the usual userspace
> memcpy, memset, etc).
> 
> Did we really want Device-nGnRnE memory here? If we did can
> we have a less confusing name for the flag?

I hadn't considered the other side-effects of going with device
vs. normal memory. I'll change patch 3/3 with

31c31
< +	pte = set_pte_bit(pte, L_PTE_MT_UNCACHED);
---
> +	pte = set_pte_bit(pte, L_PTE_MT_WRITEBACK);
166c166
< +	pte = set_pte_bit(pte, PTE_ATTRINDX(MT_DEVICE_nGnRnE));
---
> +	pte = set_pte_bit(pte, PTE_ATTRINDX(MT_NORMAL_NC));



I've left this on the backburner too long, but I can pick it back
up on Monday. I still haven't looked at Paolo's mmu notifier
suggestion yet either. I'll start looking at that as well.

Thanks,
drew


> 
> [for the non-ARM folk, nGnRnE == no gathering of accesses,
> no reordering, no early-write-acknowledgement.]
> 
> thanks
> -- PMM
> 
> 

  reply	other threads:[~2015-04-29 11:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18 19:08 the arm cache coherency cluster "v2" Andrew Jones
2015-03-18 19:08 ` [Qemu-devel] " Andrew Jones
2015-03-18 19:10 ` [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED Andrew Jones
2015-03-18 19:10   ` [Qemu-devel] " Andrew Jones
2015-03-18 19:10   ` [RFC PATCH 1/3] KVM: promote KVM_MEMSLOT_INCOHERENT to uapi Andrew Jones
2015-03-18 19:10     ` [Qemu-devel] " Andrew Jones
2015-04-20 15:26     ` Christoffer Dall
2015-04-20 15:26       ` [Qemu-devel] " Christoffer Dall
2015-03-18 19:10   ` [RFC PATCH 2/3] arm/arm64: KVM: decouple READONLY and UNCACHED Andrew Jones
2015-03-18 19:10     ` [Qemu-devel] " Andrew Jones
2015-03-18 19:10   ` [RFC PATCH 3/3] arm/arm64: KVM: implement KVM_MEM_UNCACHED Andrew Jones
2015-03-18 19:10     ` [Qemu-devel] " Andrew Jones
2015-03-19 16:56   ` [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED Paolo Bonzini
2015-03-19 16:56     ` [Qemu-devel] " Paolo Bonzini
2015-03-19 17:24     ` Andrew Jones
2015-03-19 17:24       ` [Qemu-devel] " Andrew Jones
2015-04-29  9:03   ` Alexander Graf
2015-04-29  9:03     ` Alexander Graf
2015-04-29  9:19     ` Peter Maydell
2015-04-29  9:19       ` Peter Maydell
2015-04-29 11:19       ` Andrew Jones [this message]
2015-04-29 11:19         ` Andrew Jones
2015-03-18 19:11 ` [RFC PATCH 0/4] support KVM_MEM_UNCACHED Andrew Jones
2015-03-18 19:11   ` [Qemu-devel] " Andrew Jones
2015-03-18 19:11   ` [RFC PATCH 1/4] kvm-all: put kvm_mem_flags to more work Andrew Jones
2015-03-18 19:11     ` [Qemu-devel] " Andrew Jones
2015-03-18 19:11   ` [RFC PATCH 2/4] HACK: linux header update Andrew Jones
2015-03-18 19:11     ` [Qemu-devel] " Andrew Jones
2015-03-18 19:11   ` [RFC PATCH 3/4] memory: add uncached flag Andrew Jones
2015-03-18 19:11     ` [Qemu-devel] " Andrew Jones
2015-03-18 19:11   ` [RFC PATCH 4/4] vga: flag vram as uncached Andrew Jones
2015-03-18 19:11     ` [Qemu-devel] " Andrew Jones
2015-03-18 19:18 ` the arm cache coherency cluster "v2" Andrew Jones
2015-03-18 19:18   ` [Qemu-devel] " Andrew Jones
2015-05-03 21:29   ` Alexander Graf
2015-05-03 21:29     ` [Qemu-devel] " Alexander Graf

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=20150429111936.GA2918@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=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 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.