From: Christian Borntraeger <borntraeger@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: "linux-arch@vger.kernel.org, linux-mips@linux-mips.org,
linux-x86_64@vger.kernel.org, linux-s390"@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
paulmck@linux.vnet.ibm.com, mingo@kernel.org,
torvalds@linux-foundation.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
David Howells <dhowells@redhat.com>,
Russell King <linux@arm.linux.org.uk>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCHv2 00/10] ACCESS_ONCE and non-scalar accesses
Date: Tue, 25 Nov 2014 13:38:27 +0100 [thread overview]
Message-ID: <1416919117-50652-1-git-send-email-borntraeger@de.ibm.com> (raw)
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(-)
next reply other threads:[~2014-11-25 12:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 12:38 Christian Borntraeger [this message]
2014-11-25 12:38 ` [PATCHv2 01/10] KVM: s390: Fix ipte locking Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 02/10] kernel: Provide READ_ONCE and ASSIGN_ONCE 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 ` [PATCHv2 05/10] x86: Replace ACCESS_ONCE in gup with READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 06/10] mips: " Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 07/10] arm64: Replace ACCESS_ONCE for spinlock code " Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 08/10] arm: " Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 09/10] tighten rules for ACCESS ONCE Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 10/10] KVM: s390: change ipte lock from barrier to READ_ONCE Christian Borntraeger
2014-11-26 19:20 ` [PATCHv3 00/10] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
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=1416919117-50652-1-git-send-email-borntraeger@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc="linux-arch@vger.kernel.org, linux-mips@linux-mips.org, linux-x86_64@vger.kernel.org, linux-s390"@vger.kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®