All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 00/10] ACCESS_ONCE and non-scalar accesses
@ 2014-11-25 12:38 Christian Borntraeger
  2014-11-25 12:38 ` [PATCHv2 01/10] KVM: s390: Fix ipte locking Christian Borntraeger
                   ` (19 more replies)
  0 siblings, 20 replies; 26+ messages in thread
From: Christian Borntraeger @ 2014-11-25 12:38 UTC (permalink / raw)
  To: linux-kernel
  Cc: "linux-arch, Paolo Bonzini, paulmck, mingo, torvalds,
	Catalin Marinas, Will Deacon, Alexei Starovoitov, David Howells,
	Russell King, Christian Borntraeger

As discussed on LKML http://marc.info/?i=54611D86.4040306%40de.ibm.com
ACCESS_ONCE might fail with specific compiler for non-scalar accesses.

Here is a set of patches to tackle that problem.

The first patch is already in kvm/next and this series is against rc3 (as
kvm/next so that we can avoid a merge conflict as soon as this series
has stabilized).
The 2nd patch introduces READ_ONCE/ASSIGN_ONCE as suggested by Linus.
The 2nd to last patch will force ACCESS_ONCE to error-out if it is used
on non-scalar accesses.

I have cross-compiled the resulting kernel with defconfig for
microblaze, m68k, alpha, s390,x86_64, i686, sparc, sparc64, mips,
ia64, arm and arm64.
Will Deacon pointed me to the right defconfig for arm32 to also trigger
a finding here.
Runtime testing was only done on s390x.

There is a small problem left with sparc (32bit) and m68k:

mm/rmap.c: In function 'mm_find_pmd':
include/linux/compiler.h:220:72: warning: '__val' may be used uninitialized in this function [-Wmaybe-uninitialized]
       ({ typeof(p) __val; __read_once_size(&p, &__val, sizeof(__val)); __val; })
                                                                        ^
include/linux/compiler.h:220:20: note: '__val' was declared here
       ({ typeof(p) __val; __read_once_size(&p, &__val, sizeof(__val)); __val; })
                    ^
mm/rmap.c:584:9: note: in expansion of macro 'READ_ONCE'
  pmde = READ_ONCE(*pmd);

Reason is that for both architectures pmd_t is long[16]. WTF?

So the next spin will either fix m68k/sparc or use a barrier + ACCESS_ONCE.

Comments?

Christian Borntraeger (10):
  KVM: s390: Fix ipte locking
  kernel: Provide READ_ONCE and ASSIGN_ONCE
  mm: replace ACCESS_ONCE with READ_ONCE
  x86/spinlock: Replace ACCESS_ONCE with READ_ONCE/ASSIGN_ONCE
  x86: Replace ACCESS_ONCE in gup with READ_ONCE
  mips: Replace ACCESS_ONCE in gup with READ_ONCE
  arm64: Replace ACCESS_ONCE for spinlock code with READ_ONCE
  arm: Replace ACCESS_ONCE for spinlock code with READ_ONCE
  tighten rules for ACCESS ONCE
  KVM: s390: change ipte lock from barrier to READ_ONCE

 arch/arm/include/asm/spinlock.h   |  4 ++--
 arch/arm64/include/asm/spinlock.h |  4 ++--
 arch/mips/mm/gup.c                |  2 +-
 arch/s390/kvm/gaccess.c           | 14 +++++++------
 arch/x86/include/asm/spinlock.h   |  8 +++----
 arch/x86/mm/gup.c                 |  2 +-
 include/linux/compiler.h          | 44 ++++++++++++++++++++++++++++++++++++++-
 mm/gup.c                          |  2 +-
 mm/memory.c                       |  2 +-
 mm/rmap.c                         |  2 +-
 10 files changed, 64 insertions(+), 20 deletions(-)



^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2014-11-26 19:20 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-25 12:38 [PATCHv2 00/10] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 01/10] KVM: s390: Fix ipte locking Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 02/10] kernel: Provide READ_ONCE and ASSIGN_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 15:59   ` Paul E. McKenney
2014-11-25 17:28     ` Linus Torvalds
2014-11-25 17:50       ` Paul E. McKenney
2014-11-25 19:35     ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 03/10] mm: replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 04/10] x86/spinlock: Replace ACCESS_ONCE with READ_ONCE/ASSIGN_ONCE Christian Borntraeger
2014-11-25 20:29   ` Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 05/10] x86: Replace ACCESS_ONCE in gup with READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 06/10] mips: " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 07/10] arm64: Replace ACCESS_ONCE for spinlock code " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 08/10] arm: " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 09/10] tighten rules for ACCESS ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 10/10] KVM: s390: change ipte lock from barrier to READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-26 19:20 ` [PATCHv3 00/10] ACCESS_ONCE and non-scalar accesses Christian Borntraeger

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.