diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-07-09 10:22:45 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2018-08-02 12:41:38 -0400 |
commit | d09fbb327d670737ab40fd8bbb0765ae06b8b739 (patch) | |
tree | 4a379d3b12129b5f902337e56834eeeb7eef6b22 | |
parent | 8c8484a1c18e3231648f5ba7cc5ffb7fd70b3ca4 (diff) |
ARM: use __inttype() in get_user()
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>
-rw-r--r-- | arch/arm/include/asm/uaccess.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 0bf2347495f1..29fa6f3ea25a 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h | |||
@@ -85,6 +85,13 @@ static inline void set_fs(mm_segment_t fs) | |||
85 | flag; }) | 85 | flag; }) |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * This is a type: either unsigned long, if the argument fits into | ||
89 | * that type, or otherwise unsigned long long. | ||
90 | */ | ||
91 | #define __inttype(x) \ | ||
92 | __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) | ||
93 | |||
94 | /* | ||
88 | * Single-value transfer routines. They automatically use the right | 95 | * Single-value transfer routines. They automatically use the right |
89 | * size if we just have the right pointer type. Note that the functions | 96 | * size if we just have the right pointer type. Note that the functions |
90 | * which read from user space (*get_*) need to take care not to leak | 97 | * which read from user space (*get_*) need to take care not to leak |
@@ -153,7 +160,7 @@ extern int __get_user_64t_4(void *); | |||
153 | ({ \ | 160 | ({ \ |
154 | unsigned long __limit = current_thread_info()->addr_limit - 1; \ | 161 | unsigned long __limit = current_thread_info()->addr_limit - 1; \ |
155 | register const typeof(*(p)) __user *__p asm("r0") = (p);\ | 162 | register const typeof(*(p)) __user *__p asm("r0") = (p);\ |
156 | register typeof(x) __r2 asm("r2"); \ | 163 | register __inttype(x) __r2 asm("r2"); \ |
157 | register unsigned long __l asm("r1") = __limit; \ | 164 | register unsigned long __l asm("r1") = __limit; \ |
158 | register int __e asm("r0"); \ | 165 | register int __e asm("r0"); \ |
159 | unsigned int __ua_flags = uaccess_save_and_enable(); \ | 166 | unsigned int __ua_flags = uaccess_save_and_enable(); \ |