Skip to contentSkip to conversation

x86/percpu: Fix assembly in variable_test_bit

PATCH New Keno Fischer 1 participant 1 message Mar 18, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/percpu: Fix assembly in variable_test_bit

I was trying to compile the kernel with -Og for a better debugging experience. One side effect of this that the compiler will no longer do as aggressive dead code elimination, so assembly blocks that were previously dce'd remained in the final assembly. There's quite a number of places in the kernel that rely on this dce happening, so it's not clear that this should be a supported configuration. Nevertheless, in this particular instance, I believe it found a real issue. In particular, I believe the __percpu_arg macro should be on the memory operand rather than the immediate. As far as I can tell, this was never correct, but just happened to be always dce'd out because the cpu_test macro is generally only used with constant nr arguments.

Fixes 349c004e3d31 ("x86: A fast way to check capabilities of the current cpu")
---
 arch/x86/include/asm/percpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/percpu.h +1 -1
index 2278797c769d..17c7677e6cdd 100644
@@ -539,7 +539,7 @@ static inline bool x86_this_cpu_variable_test_bit(int nr,
 {
 	bool oldbit;
 
-	asm volatile("btl "__percpu_arg(2)",%1"
+	asm volatile("btl %2,"__percpu_arg(1)"\n\t"
 			CC_SET(c)
 			: CC_OUT(c) (oldbit)
 			: "m" (*(unsigned long __percpu *)addr), "Ir" (nr));
Signature · 1 line
2.24.0