Skip to content

Commit ad32fd7

Browse files
committed
Merge tag 'xtensa-20191017' of git://github.com/jcmvbkbc/linux-xtensa
Pull Xtensa fixes from Max Filippov: - fix {get,put}_user() for 64bit values - fix warning about static EXPORT_SYMBOL from modpost - fix PCI IO ports mapping for the virt board - fix pasto in change_bit for exclusive access option * tag 'xtensa-20191017' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: fix change_bit in exclusive access option xtensa: virt: fix PCI IO ports mapping xtensa: drop EXPORT_SYMBOL for outs*/ins* xtensa: fix type conversion in __get_user_[no]check xtensa: clean up assembly arguments in uaccess macros xtensa: fix {get,put}_user() for 64bit values
2 parents 6e8ba00 + 775fd6b commit ad32fd7

File tree

4 files changed

+55
-50
lines changed

4 files changed

+55
-50
lines changed

arch/xtensa/boot/dts/virt.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
reg = <0xf0100000 0x03f00000>;
5757

5858
// BUS_ADDRESS(3) CPU_PHYSICAL(1) SIZE(2)
59-
ranges = <0x01000000 0x0 0xf0000000 0xf0000000 0x0 0x00010000>,
59+
ranges = <0x01000000 0x0 0x00000000 0xf0000000 0x0 0x00010000>,
6060
<0x02000000 0x0 0xf4000000 0xf4000000 0x0 0x08000000>;
6161

6262
// PCI_DEVICE(3) INT#(1) CONTROLLER(PHANDLE) CONTROLLER_DATA(2)

arch/xtensa/include/asm/bitops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static inline void change_bit(unsigned int bit, volatile unsigned long *p)
148148
" getex %0\n"
149149
" beqz %0, 1b\n"
150150
: "=&a" (tmp)
151-
: "a" (~mask), "a" (p)
151+
: "a" (mask), "a" (p)
152152
: "memory");
153153
}
154154

arch/xtensa/include/asm/uaccess.h

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ do { \
100100
case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \
101101
case 8: { \
102102
__typeof__(*ptr) __v64 = x; \
103-
retval = __copy_to_user(ptr, &__v64, 8); \
103+
retval = __copy_to_user(ptr, &__v64, 8) ? -EFAULT : 0; \
104104
break; \
105105
} \
106106
default: __put_user_bad(); \
@@ -132,14 +132,14 @@ do { \
132132
#define __check_align_1 ""
133133

134134
#define __check_align_2 \
135-
" _bbci.l %3, 0, 1f \n" \
136-
" movi %0, %4 \n" \
135+
" _bbci.l %[addr], 0, 1f \n" \
136+
" movi %[err], %[efault] \n" \
137137
" _j 2f \n"
138138

139139
#define __check_align_4 \
140-
" _bbsi.l %3, 0, 0f \n" \
141-
" _bbci.l %3, 1, 1f \n" \
142-
"0: movi %0, %4 \n" \
140+
" _bbsi.l %[addr], 0, 0f \n" \
141+
" _bbci.l %[addr], 1, 1f \n" \
142+
"0: movi %[err], %[efault] \n" \
143143
" _j 2f \n"
144144

145145

@@ -151,40 +151,40 @@ do { \
151151
* WARNING: If you modify this macro at all, verify that the
152152
* __check_align_* macros still work.
153153
*/
154-
#define __put_user_asm(x, addr, err, align, insn, cb) \
154+
#define __put_user_asm(x_, addr_, err_, align, insn, cb)\
155155
__asm__ __volatile__( \
156156
__check_align_##align \
157-
"1: "insn" %2, %3, 0 \n" \
157+
"1: "insn" %[x], %[addr], 0 \n" \
158158
"2: \n" \
159159
" .section .fixup,\"ax\" \n" \
160160
" .align 4 \n" \
161161
" .literal_position \n" \
162162
"5: \n" \
163-
" movi %1, 2b \n" \
164-
" movi %0, %4 \n" \
165-
" jx %1 \n" \
163+
" movi %[tmp], 2b \n" \
164+
" movi %[err], %[efault] \n" \
165+
" jx %[tmp] \n" \
166166
" .previous \n" \
167167
" .section __ex_table,\"a\" \n" \
168168
" .long 1b, 5b \n" \
169169
" .previous" \
170-
:"=r" (err), "=r" (cb) \
171-
:"r" ((int)(x)), "r" (addr), "i" (-EFAULT), "0" (err))
170+
:[err] "+r"(err_), [tmp] "=r"(cb) \
171+
:[x] "r"(x_), [addr] "r"(addr_), [efault] "i"(-EFAULT))
172172

173173
#define __get_user_nocheck(x, ptr, size) \
174174
({ \
175-
long __gu_err, __gu_val; \
176-
__get_user_size(__gu_val, (ptr), (size), __gu_err); \
177-
(x) = (__force __typeof__(*(ptr)))__gu_val; \
175+
long __gu_err; \
176+
__get_user_size((x), (ptr), (size), __gu_err); \
178177
__gu_err; \
179178
})
180179

181180
#define __get_user_check(x, ptr, size) \
182181
({ \
183-
long __gu_err = -EFAULT, __gu_val = 0; \
182+
long __gu_err = -EFAULT; \
184183
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
185-
if (access_ok(__gu_addr, size)) \
186-
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
187-
(x) = (__force __typeof__(*(ptr)))__gu_val; \
184+
if (access_ok(__gu_addr, size)) \
185+
__get_user_size((x), __gu_addr, (size), __gu_err); \
186+
else \
187+
(x) = 0; \
188188
__gu_err; \
189189
})
190190

@@ -198,8 +198,17 @@ do { \
198198
case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb); break;\
199199
case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\
200200
case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb); break;\
201-
case 8: retval = __copy_from_user(&x, ptr, 8); break; \
202-
default: (x) = __get_user_bad(); \
201+
case 8: { \
202+
u64 __x; \
203+
if (unlikely(__copy_from_user(&__x, ptr, 8))) { \
204+
retval = -EFAULT; \
205+
(x) = 0; \
206+
} else { \
207+
(x) = *(__force __typeof__((ptr)))&__x; \
208+
} \
209+
break; \
210+
} \
211+
default: (x) = 0; __get_user_bad(); \
203212
} \
204213
} while (0)
205214

@@ -208,25 +217,28 @@ do { \
208217
* WARNING: If you modify this macro at all, verify that the
209218
* __check_align_* macros still work.
210219
*/
211-
#define __get_user_asm(x, addr, err, align, insn, cb) \
212-
__asm__ __volatile__( \
213-
__check_align_##align \
214-
"1: "insn" %2, %3, 0 \n" \
215-
"2: \n" \
216-
" .section .fixup,\"ax\" \n" \
217-
" .align 4 \n" \
218-
" .literal_position \n" \
219-
"5: \n" \
220-
" movi %1, 2b \n" \
221-
" movi %2, 0 \n" \
222-
" movi %0, %4 \n" \
223-
" jx %1 \n" \
224-
" .previous \n" \
225-
" .section __ex_table,\"a\" \n" \
226-
" .long 1b, 5b \n" \
227-
" .previous" \
228-
:"=r" (err), "=r" (cb), "=r" (x) \
229-
:"r" (addr), "i" (-EFAULT), "0" (err))
220+
#define __get_user_asm(x_, addr_, err_, align, insn, cb) \
221+
do { \
222+
u32 __x = 0; \
223+
__asm__ __volatile__( \
224+
__check_align_##align \
225+
"1: "insn" %[x], %[addr], 0 \n" \
226+
"2: \n" \
227+
" .section .fixup,\"ax\" \n" \
228+
" .align 4 \n" \
229+
" .literal_position \n" \
230+
"5: \n" \
231+
" movi %[tmp], 2b \n" \
232+
" movi %[err], %[efault] \n" \
233+
" jx %[tmp] \n" \
234+
" .previous \n" \
235+
" .section __ex_table,\"a\" \n" \
236+
" .long 1b, 5b \n" \
237+
" .previous" \
238+
:[err] "+r"(err_), [tmp] "=r"(cb), [x] "+r"(__x) \
239+
:[addr] "r"(addr_), [efault] "i"(-EFAULT)); \
240+
(x_) = (__force __typeof__(*(addr_)))__x; \
241+
} while (0)
230242

231243

232244
/*

arch/xtensa/kernel/xtensa_ksyms.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ EXPORT_SYMBOL(__invalidate_icache_range);
119119
// FIXME EXPORT_SYMBOL(screen_info);
120120
#endif
121121

122-
EXPORT_SYMBOL(outsb);
123-
EXPORT_SYMBOL(outsw);
124-
EXPORT_SYMBOL(outsl);
125-
EXPORT_SYMBOL(insb);
126-
EXPORT_SYMBOL(insw);
127-
EXPORT_SYMBOL(insl);
128-
129122
extern long common_exception_return;
130123
EXPORT_SYMBOL(common_exception_return);
131124

0 commit comments

Comments
 (0)