Skip to content

Commit 4630535

Browse files
ubizjaksuryasaimadhu
authored andcommitted
x86/uaccess: Improve __try_cmpxchg64_user_asm() for x86_32
Improve __try_cmpxcgh64_user_asm() for !CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT by relaxing the output register constraint from "c" to "q" constraint, which allows the compiler to choose between %ecx or %ebx register. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220628161612.7993-1-ubizjak@gmail.com
1 parent 3163600 commit 4630535

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/x86/include/asm/uaccess.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ do { \
448448

449449
#ifdef CONFIG_X86_32
450450
/*
451-
* Unlike the normal CMPXCHG, hardcode ECX for both success/fail and error.
451+
* Unlike the normal CMPXCHG, use output GPR for both success/fail and error.
452452
* There are only six GPRs available and four (EAX, EBX, ECX, and EDX) are
453453
* hardcoded by CMPXCHG8B, leaving only ESI and EDI. If the compiler uses
454454
* both ESI and EDI for the memory operand, compilation will fail if the error
@@ -461,11 +461,12 @@ do { \
461461
__typeof__(*(_ptr)) __new = (_new); \
462462
asm volatile("\n" \
463463
"1: " LOCK_PREFIX "cmpxchg8b %[ptr]\n" \
464-
"mov $0, %%ecx\n\t" \
465-
"setz %%cl\n" \
464+
"mov $0, %[result]\n\t" \
465+
"setz %b[result]\n" \
466466
"2:\n" \
467-
_ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, %%ecx) \
468-
: [result]"=c" (__result), \
467+
_ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG, \
468+
%[result]) \
469+
: [result] "=q" (__result), \
469470
"+A" (__old), \
470471
[ptr] "+m" (*_ptr) \
471472
: "b" ((u32)__new), \

0 commit comments

Comments
 (0)