Skip to content

Commit

Permalink
ARM: use __inttype() in get_user()
Browse files Browse the repository at this point in the history
Borrow the x86 implementation of __inttype() to use in get_user() to
select an integer type suitable to temporarily hold the result value.
This is necessary to avoid propagating the volatile nature of the
result argument, which can cause the following warning:

lib/iov_iter.c:413:5: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var]

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
  • Loading branch information
Russell King committed Aug 2, 2018
1 parent 8c8484a commit d09fbb3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion arch/arm/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ static inline void set_fs(mm_segment_t fs)
: "cc"); \
flag; })

/*
* This is a type: either unsigned long, if the argument fits into
* that type, or otherwise unsigned long long.
*/
#define __inttype(x) \
__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))

/*
* Single-value transfer routines. They automatically use the right
* size if we just have the right pointer type. Note that the functions
Expand Down Expand Up @@ -153,7 +160,7 @@ extern int __get_user_64t_4(void *);
({ \
unsigned long __limit = current_thread_info()->addr_limit - 1; \
register const typeof(*(p)) __user *__p asm("r0") = (p);\
register typeof(x) __r2 asm("r2"); \
register __inttype(x) __r2 asm("r2"); \
register unsigned long __l asm("r1") = __limit; \
register int __e asm("r0"); \
unsigned int __ua_flags = uaccess_save_and_enable(); \
Expand Down

0 comments on commit d09fbb3

Please sign in to comment.