Thread (12 messages) 12 messages, 9 authors, 2017-03-09

Re: [PATCH 1/3] futex: remove duplicated code

From: "H. Peter Anvin" <hpa@zytor.com>
Date: 2017-03-09 05:08:00
Also in: linux-arch, linux-mips, linux-sh, lkml, sparclinux

[off-list ref],Thomas Gleixner [off-list ref],Ingo Molnar [off-list ref],Chris Zankel [off-list ref],Max Filippov [off-list ref],Arnd Bergmann [off-list ref],x86@kernel.org,linux-alpha@vger.kernel.org,linux-snps-arc@lists.infradead.org,linux-arm-kernel@lists.infradead.org,linux-hexagon@vger.kernel.org,linux-ia64@vger.kernel.org,linux-mips@linux-mips.org,openrisc@lists.librecores.org,linux-parisc@vger.kernel.org,linuxppc-dev@lists.ozlabs.org,linux-s390@vger.kernel.org,linux-sh@vger.kernel.org,sparclinux@vger.kernel.org,linux-xtensa@linux-xtensa.org,linux-arch@vger.kernel.org
From: hpa@zytor.com
Message-ID: [off-list ref]

On March 8, 2017 8:16:49 PM PST, Rob Landley <rob@landley=2Enet> wrote:
On 03/04/2017 07:05 AM, Russell King - ARM Linux wrote:
quoted
On Fri, Mar 03, 2017 at 01:27:10PM +0100, Jiri Slaby wrote:
quoted
diff --git a/kernel/futex=2Ec b/kernel/futex=2Ec
index b687cb22301c=2E=2Ec5ff9850952f 100644
--- a/kernel/futex=2Ec
+++ b/kernel/futex=2Ec
@@ -1457,6 +1457,42 @@ futex_wake(u32 __user *uaddr, unsigned int
flags, int nr_wake, u32 bitset)
quoted
quoted
 	return ret;
 }
=20
+static int futex_atomic_op_inuser(int encoded_op, u32 __user
*uaddr)
quoted
quoted
+{
+	int op =3D (encoded_op >> 28) & 7;
+	int cmp =3D (encoded_op >> 24) & 15;
+	int oparg =3D (encoded_op << 8) >> 20;
+	int cmparg =3D (encoded_op << 20) >> 20;
=20
Hmm=2E  oparg and cmparg look like they're doing these shifts to get
sign
quoted
extension of the 12-bit values by assuming that "int" is 32-bit -
probably worth a comment, or for safety, they should be "s32" so it's
not dependent on the bit-width of "int"=2E
I thought Linux depended on the LP64 standard for all architectures?

Standard: http://www=2Eunix=2Eorg/whitepapers/64bit=2Ehtml
Rationale: http://www=2Eunix=2Eorg/version2/whatsnew/lp64_wp=2Ehtml

So int has a defined bit width (32) on linux?

Rob
Linux is ILP32 on 32-bit architectures and LP64 on 64-bit architectures, b=
ut that doesn't inherently make this stuff clear=2E
--=20
Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help