Skip to content

Commit 592bbe9

Browse files
chleroympe
authored andcommitted
powerpc/uaccess: Don't use "m<>" constraint with GCC 4.9
GCC 4.9 sometimes fails to build with "m<>" constraint in inline assembly. CC lib/iov_iter.o In file included from ./arch/powerpc/include/asm/cmpxchg.h:6:0, from ./arch/powerpc/include/asm/atomic.h:11, from ./include/linux/atomic.h:7, from ./include/linux/crypto.h:15, from ./include/crypto/hash.h:11, from lib/iov_iter.c:2: lib/iov_iter.c: In function 'iovec_from_user.part.30': ./arch/powerpc/include/asm/uaccess.h:287:2: error: 'asm' operand has impossible constraints __asm__ __volatile__( \ ^ ./include/linux/compiler.h:78:42: note: in definition of macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ ./arch/powerpc/include/asm/uaccess.h:583:34: note: in expansion of macro 'unsafe_op_wrap' #define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e) ^ ./arch/powerpc/include/asm/uaccess.h:329:10: note: in expansion of macro '__get_user_asm' case 4: __get_user_asm(x, (u32 __user *)ptr, retval, "lwz"); break; \ ^ ./arch/powerpc/include/asm/uaccess.h:363:3: note: in expansion of macro '__get_user_size_allowed' __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ ^ ./arch/powerpc/include/asm/uaccess.h:100:2: note: in expansion of macro '__get_user_nocheck' __get_user_nocheck((x), (ptr), sizeof(*(ptr)), false) ^ ./arch/powerpc/include/asm/uaccess.h:583:49: note: in expansion of macro '__get_user_allowed' #define unsafe_get_user(x, p, e) unsafe_op_wrap(__get_user_allowed(x, p), e) ^ lib/iov_iter.c:1663:3: note: in expansion of macro 'unsafe_get_user' unsafe_get_user(len, &uiov[i].iov_len, uaccess_end); ^ make[1]: *** [scripts/Makefile.build:283: lib/iov_iter.o] Error 1 Define a UPD_CONSTR macro that is "<>" by default and only "" with GCC prior to GCC 5. Fixes: fcf1f26 ("powerpc/uaccess: Add pre-update addressing to __put_user_asm_goto()") Fixes: 2f279ee ("powerpc/uaccess: Add pre-update addressing to __get_user_asm() and __put_user_asm()") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Acked-by: Segher Boessenkool <segher@kernel.crashing.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/212d3bc4a52ca71523759517bb9c61f7e477c46a.1603179582.git.christophe.leroy@csgroup.eu
1 parent 99f6e97 commit 592bbe9

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

arch/powerpc/include/asm/asm-const.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,17 @@
1111
# define __ASM_CONST(x) x##UL
1212
# define ASM_CONST(x) __ASM_CONST(x)
1313
#endif
14+
15+
/*
16+
* Inline assembly memory constraint
17+
*
18+
* GCC 4.9 doesn't properly handle pre update memory constraint "m<>"
19+
*
20+
*/
21+
#if defined(GCC_VERSION) && GCC_VERSION < 50000
22+
#define UPD_CONSTR ""
23+
#else
24+
#define UPD_CONSTR "<>"
25+
#endif
26+
1427
#endif /* _ASM_POWERPC_ASM_CONST_H */

arch/powerpc/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ do { \
223223
"1: " op "%U1%X1 %0,%1 # put_user\n" \
224224
EX_TABLE(1b, %l2) \
225225
: \
226-
: "r" (x), "m<>" (*addr) \
226+
: "r" (x), "m"UPD_CONSTR (*addr) \
227227
: \
228228
: label)
229229

@@ -294,7 +294,7 @@ extern long __get_user_bad(void);
294294
".previous\n" \
295295
EX_TABLE(1b, 3b) \
296296
: "=r" (err), "=r" (x) \
297-
: "m<>" (*addr), "i" (-EFAULT), "0" (err))
297+
: "m"UPD_CONSTR (*addr), "i" (-EFAULT), "0" (err))
298298

299299
#ifdef __powerpc64__
300300
#define __get_user_asm2(x, addr, err) \

0 commit comments

Comments
 (0)