x86/percpu: Fix and improve x86_this_cpu_test_bit() and friends
Subsystems (3)
PATCH 1/1 x86/percpu: Fix and improve x86_this_cpu_test_bit() and friends
Fix x86_this_cpu_variable_test_bit(), which is implemented with wrong asm template, where argument 2 (count argument) is considered as percpu variable. However, x86_this_cpu_test_bit() is currently used exclusively with constant bit number argument, so the called x86_this_cpu_variable_test_bit() function is never instantiated. The fix introduces named assembler operands to prevent this kind of errors.
Also rewrite the whole family of x86_this_cpu_test_bit() functions as macros, so standard __my_cpu_var() and raw_cpu_read() macros can be used on percpu variables. This approach considerably simplifies implementation of functions and also introduces standard checks on accessed percpu variables.
No functional changes intended.
--- arch/um/include/asm/cpufeature.h | 3 +- arch/x86/include/asm/cpufeature.h | 3 +- arch/x86/include/asm/percpu.h | 51 +++++++++++++------------------ 3 files changed, 24 insertions(+), 33 deletions(-)
arch/um/include/asm/cpufeature.h +1 -2
@@ -38,8 +38,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];#define this_cpu_has (bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ - x86_this_cpu_test_bit(bit, \ - (unsigned long __percpu *)&cpu_info.x86_capability)) + x86_this_cpu_test_bit(bit, cpu_info.x86_capability))/* * This macro is for detection of features which need kernel
arch/x86/include/asm/cpufeature.h +1 -2
@@ -127,8 +127,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];#define this_cpu_has (bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ - x86_this_cpu_test_bit(bit, \ - (unsigned long __percpu *)&cpu_info.x86_capability)) + x86_this_cpu_test_bit(bit, cpu_info.x86_capability))/* * This macro is for detection of features which need kernel
arch/x86/include/asm/percpu.h +22 -29
65 lines not on this page · raw message
Signature · 1 line
2.42.0
Quoted 8 lines · Uros Bizjak
Fix
x86_this_cpu_variable_test_bit(), which is implemented with wrong asm template, where argument 2 (count argument) is considered as percpu variable. However,x86_this_cpu_test_bit()is currently used exclusively with constant bit number argument, so the calledx86_this_cpu_variable_test_bit()function is never instantiated. The fix introduces named assembler operands to prevent this kind of errors.
Quoted 7 lines
Also rewrite the whole family of
x86_this_cpu_test_bit()functions as macros, so standard__my_cpu_var()andraw_cpu_read()macros can be used on percpu variables. This approach considerably simplifies implementation of functions and also introduces standard checks on accessed percpu variables.No functional changes intended.
Could you please split this into at least two patches?
Hint: 'also' in a changelog paragraph is an indicator of a new patch being justified, in like 80% of the cases. :-)
Thanks,
Ingo