From: Arnd Bergmann <arnd@arndb.de>
To: Russell King <linux@armlinux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Darren Hart <dvhart@infradead.org>
Cc: Mikael Pettersson <mikpelinux@gmail.com>,
Mikael Pettersson <mikpe@it.uu.se>, Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, Dave Martin <Dave.Martin@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable
Date: Thu, 7 Mar 2019 10:14:49 +0100 [thread overview]
Message-ID: <20190307091514.2489338-2-arnd@arndb.de> (raw)
In-Reply-To: <20190307091514.2489338-1-arnd@arndb.de>
Passing registers containing zero as both the address (NULL pointer)
and data into cmpxchg_futex_value_locked() leads clang to assign
the same register for both inputs on ARM, which triggers a warning
explaining that this instruction has unpredictable behavior on ARMv5.
/tmp/futex-7e740e.s: Assembler messages:
/tmp/futex-7e740e.s:12713: Warning: source register same as write-back base
This patch was suggested by Mikael Pettersson back in 2011 (!) with gcc-4.4,
as Mikael wrote:
"One way of fixing this is to make uaddr an input/output register, since
"that prevents it from overlapping any other input or output."
but then withdrawn as the warning was determined to be harmless, and it
apparently never showed up again with later gcc versions.
Now the same problem is back when compiling with clang, and we are trying
to get clang to build the kernel without warnings, as gcc normally does.
Cc: Mikael Pettersson <mikpe@it.uu.se>
Cc: Mikael Pettersson <mikpelinux@gmail.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Link: https://lore.kernel.org/linux-arm-kernel/20009.45690.158286.161591@pilspetsen.it.uu.se/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/include/asm/futex.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
index 0a46676b4245..79790912974e 100644
--- a/arch/arm/include/asm/futex.h
+++ b/arch/arm/include/asm/futex.h
@@ -110,13 +110,13 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
preempt_disable();
__ua_flags = uaccess_save_and_enable();
__asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
- "1: " TUSER(ldr) " %1, [%4]\n"
- " teq %1, %2\n"
+ "1: " TUSER(ldr) " %1, [%2]\n"
+ " teq %1, %3\n"
" it eq @ explicit IT needed for the 2b label\n"
- "2: " TUSER(streq) " %3, [%4]\n"
+ "2: " TUSER(streq) " %4, [%2]\n"
__futex_atomic_ex_table("%5")
- : "+r" (ret), "=&r" (val)
- : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
+ : "+&r" (ret), "=&r" (val), "+&r" (uaddr)
+ : "r" (oldval), "r" (newval), "Ir" (-EFAULT)
: "cc", "memory");
uaccess_restore(__ua_flags);
--
2.20.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next parent reply other threads:[~2019-03-07 9:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190307091514.2489338-1-arnd@arndb.de>
2019-03-07 9:14 ` Arnd Bergmann [this message]
2019-03-07 19:39 ` [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable Nick Desaulniers
2019-03-07 23:48 ` Russell King - ARM Linux admin
2019-03-08 0:04 ` Nick Desaulniers
2019-03-08 9:54 ` Russell King - ARM Linux admin
2019-03-08 8:57 ` Ard Biesheuvel
2019-03-08 9:53 ` Russell King - ARM Linux admin
2019-03-08 10:08 ` Ard Biesheuvel
2019-03-08 10:16 ` Ard Biesheuvel
2019-03-08 10:56 ` Russell King - ARM Linux admin
2019-03-08 10:34 ` Russell King - ARM Linux admin
2019-03-08 10:45 ` Ard Biesheuvel
2019-03-08 10:58 ` Russell King - ARM Linux admin
2019-03-08 11:55 ` Ard Biesheuvel
2019-03-11 14:34 ` Arnd Bergmann
2019-03-11 14:36 ` Ard Biesheuvel
2019-03-11 16:29 ` Arnd Bergmann
2019-03-11 16:36 ` Ard Biesheuvel
2019-03-11 20:58 ` Arnd Bergmann
2019-03-08 11:55 ` Dave Martin
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=20190307091514.2489338-2-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=Dave.Martin@arm.com \
--cc=dvhart@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mikpe@it.uu.se \
--cc=mikpelinux@gmail.com \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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