Skip to content

Commit 890f0b0

Browse files
committed
x86: start using named parameters for low-level uaccess asms
This is partly for readability - using named arguments instead of numbered ones makes it muchmore obvious just what is going on. Using "%[efault]" instead of "%4" for the special -EFAULT constant just means that you don't have to count the arguments to see what's up. But the motivation for all this cleanup is that when we'll start to conditionally use "asm goto" even for the __get_user_asm() case, the argument numbers will depend on whether we have an error output, or an error label we can just directly jump to. So this moves us towards named arguments for the same reason that we have to use named arguments for the asms that use SET_CC(): numbering will eventually become similarly unreliable and depends on whether we can use particular compiler features or not. Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7da63b3 commit 890f0b0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

arch/x86/include/asm/uaccess.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,22 @@ do { \
289289
({ \
290290
__typeof__(ptr) __ptr = (ptr); \
291291
asm volatile("\n" \
292-
"1: movl %2,%%eax\n" \
293-
"2: movl %3,%%edx\n" \
292+
"1: movl %[lowbits],%%eax\n" \
293+
"2: movl %[highbits],%%edx\n" \
294294
"3:\n" \
295295
".section .fixup,\"ax\"\n" \
296-
"4: mov %4,%0\n" \
296+
"4: mov %[efault],%[errout]\n" \
297297
" xorl %%eax,%%eax\n" \
298298
" xorl %%edx,%%edx\n" \
299299
" jmp 3b\n" \
300300
".previous\n" \
301301
_ASM_EXTABLE_UA(1b, 4b) \
302302
_ASM_EXTABLE_UA(2b, 4b) \
303-
: "=r" (retval), "=&A"(x) \
304-
: "m" (__m(__ptr)), "m" __m(((u32 __user *)(__ptr)) + 1), \
305-
"i" (-EFAULT), "0" (retval)); \
303+
: [errout] "=r" (retval), \
304+
[output] "=&A"(x) \
305+
: [lowbits] "m" (__m(__ptr)), \
306+
[highbits] "m" __m(((u32 __user *)(__ptr)) + 1), \
307+
[efault] "i" (-EFAULT), "0" (retval)); \
306308
})
307309

308310
#else
@@ -334,16 +336,18 @@ do { \
334336

335337
#define __get_user_asm(x, addr, err, itype, ltype) \
336338
asm volatile("\n" \
337-
"1: mov"itype" %2,%1\n" \
339+
"1: mov"itype" %[umem],%[output]\n" \
338340
"2:\n" \
339341
".section .fixup,\"ax\"\n" \
340-
"3: mov %3,%0\n" \
341-
" xor"itype" %1,%1\n" \
342+
"3: mov %[efault],%[errout]\n" \
343+
" xor"itype" %[output],%[output]\n" \
342344
" jmp 2b\n" \
343345
".previous\n" \
344346
_ASM_EXTABLE_UA(1b, 3b) \
345-
: "=r" (err), ltype(x) \
346-
: "m" (__m(addr)), "i" (-EFAULT), "0" (err))
347+
: [errout] "=r" (err), \
348+
[output] ltype(x) \
349+
: [umem] "m" (__m(addr)), \
350+
[efault] "i" (-EFAULT), "0" (err))
347351

348352
#define __put_user_nocheck(x, ptr, size) \
349353
({ \

0 commit comments

Comments
 (0)