Skip to contentSkip to conversation

x86: drop bogus "cc" clobber from __try_cmpxchg_user_asm()

PATCH Applied Jan Beulich 2 participants 2 messages Jun 7, 2022 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: drop bogus "cc" clobber from __try_cmpxchg_user_asm()

As noted (and fixed) a couple of times in the past, "=@cc<cond>" outputs and clobbering of "cc" don't work well together. The compiler appears to mean to reject such, but doesn't - in its upstream form - quite manage to yet for "cc". Furthermore two similar macros don't clobber "cc", and clobbering "cc" is pointless in asm()-s for x86 anyway - the compiler always assumes status flags to be clobbered there.

Fixes 989b5db215a2 ("x86/uaccess: Implement macros for CMPXCHG on user addresses")

---
The change I continue to carry locally actually allows specifying that "cc" is _not_ clobbered; it only happens to improve detection of bad situations like the one here.

arch/x86/include/asm/uaccess.h +1 -1
@@ -439,7 +439,7 @@ do {									\
 		       [ptr] "+m" (*_ptr),				\
 		       [old] "+a" (__old)				\
 		     : [new] ltype (__new)				\
-		     : "memory", "cc");					\
+		     : "memory");					\
 	if (unlikely(__err))						\
 		goto label;						\
 	if (unlikely(!success))						\
#1 lore raw
Quoted 18 lines · Jan Beulich

As noted (and fixed) a couple of times in the past, "=@cc<cond>" outputs and clobbering of "cc" don't work well together. The compiler appears to mean to reject such, but doesn't - in its upstream form - quite manage to yet for "cc". Furthermore two similar macros don't clobber "cc", and clobbering "cc" is pointless in asm()-s for x86 anyway - the compiler always assumes status flags to be clobbered there.

Fixes 989b5db215a2 ("x86/uaccess: Implement macros for CMPXCHG on user addresses")

---
The change I continue to carry locally actually allows specifying that "cc" is _not_ clobbered; it only happens to improve detection of bad situations like the one here.

arch/x86/include/asm/uaccess.h do { \ · line 445

Quoted 8 lines
arch/x86/include/asm/uaccess.h +1 -1
@@ -439,7 +439,7 @@ do {									\
  		       [ptr] "+m" (*_ptr),				\
  		       [old] "+a" (__old)				\
  		     : [new] ltype (__new)				\
-		     : "memory", "cc");					\
+		     : "memory");					\
  	if (unlikely(__err))						\
  		goto label;						\
  	if (unlikely(!success))						\

Queued, thanks.

Paolo