sparc: mark __arch_xchg() as __always_inline
PATCH 1/1 sparc: mark __arch_xchg() as __always_inline
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc __arch_xchg() function, which is calls __xchg_called_with_bad_pointer() when its arguments are unknown at compile time:
ERROR: modpost: "__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as __always_inline to force the compiler to do the right thing here.
--- arch/sparc/include/asm/cmpxchg_32.h | 2 +- arch/sparc/include/asm/cmpxchg_64.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/sparc/include/asm/cmpxchg_32.h +1 -1
@@ -15,7 +15,7 @@unsigned long __xchg_u32 (volatile u32 *m,u32 new);void __xchg_called_with_bad_pointer (void ); -static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {case 4 :
arch/sparc/include/asm/cmpxchg_64.h +1 -1
@@ -87,7 +87,7 @@ xchg16(__volatile__ unsigned short *m, unsigned short val)return (load32 & mask) >> bit_shift; } -static inline unsigned long +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {
Signature · 1 line
2.39.2
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!
Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>
Aha; you saved me writing a patch! :)
We should probably do likewise for all the other bits like __cmpxchg(), but either way:
Mark.
Quoted 34 lines
--- arch/sparc/include/asm/cmpxchg_32.h | 2 +- arch/sparc/include/asm/cmpxchg_64.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/sparc/include/asm/cmpxchg_32.h +1
-1@@ -15,7 +15,7 @@unsigned long __xchg_u32 (volatile u32 *m,u32 new);void __xchg_called_with_bad_pointer (void ); -static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {case 4 :arch/sparc/include/asm/cmpxchg_64.h +1
-1@@ -87,7 +87,7 @@ xchg16(__volatile__ unsigned short *m, unsigned short val)return (load32 & mask) >> bit_shift; } -static inline unsigned long +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {Signature · 1 line
2.39.2
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!
Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>
Nice catch.
Quoted 31 lines
--- arch/sparc/include/asm/cmpxchg_32.h | 2 +- arch/sparc/include/asm/cmpxchg_64.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/sparc/include/asm/cmpxchg_32.h +1
-1@@ -15,7 +15,7 @@unsigned long __xchg_u32 (volatile u32 *m,u32 new);void __xchg_called_with_bad_pointer (void ); -static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {case 4 :arch/sparc/include/asm/cmpxchg_64.h +1
-1@@ -87,7 +87,7 @@ xchg16(__volatile__ unsigned short *m, unsigned short val)return (load32 & mask) >> bit_shift; } -static inline unsigned long +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!
Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>
I assume you will find a way to apply the patch.
Sam
Hi Arnd,
Quoted 7 lines
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!
Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>
Thanks,
Andi
Quoted 14 lines · Sam Ravnborg
Quoted 13 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.
Quoted 7 lines
Quoted 4 lines
Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>Reviewed-by Sam Ravnborg <[email protected]>I assume you will find a way to apply the patch.
Hmmm, looks to me like this patch is sitting here for two weeks now without having made any progress. From a quick search on lore it also looks like Dave is not very active currently. Hence:
Arnd, is that maybe something that is worth sending straight to Linus?
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.
Palmer Dabbelt
Acked-byQuoted 19 lines · Mark Rutland
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 6 lines
Aha; you saved me writing a patch! :)
We should probably do likewise for all the other bits like
__cmpxchg(), but either way:Acked-by Mark Rutland <[email protected]>
Though I'm not sure that means a whole lot over here ;)
Quoted 36 lines
Mark.
Quoted 34 lines
--- arch/sparc/include/asm/cmpxchg_32.h | 2 +- arch/sparc/include/asm/cmpxchg_64.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/sparc/include/asm/cmpxchg_32.h +1
-1@@ -15,7 +15,7 @@unsigned long __xchg_u32 (volatile u32 *m,u32 new);void __xchg_called_with_bad_pointer (void ); -static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) {case 4 :arch/sparc/include/asm/cmpxchg_64.h +1
-2@@ -87,7 +87,7 @@ xchg16(__volatile__ unsigned short *m, unsigned short val)return (load32 & mask) >> bit_shift; } -static inline unsigned long +static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) {switch (size) { --2.39.2
Quoted 22 lines · Palmer Dabbelt
Quoted 21 lines · Mark Rutland
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined!Quoted 8 lines
This now happens because gcc determines that it's better to not inline the function. Avoid this by just marking the function as
__always_inlineto force the compiler to do the right thing here.Reported-by Guenter Roeck <[email protected]>Fixes d12157efc8e08 ("locking/atomic: make atomic*_{cmp,}xchg optional")Signed-off-by Arnd Bergmann <[email protected]>Aha; you saved me writing a patch! :)
Quoted 8 lines
Quoted 4 lines
We should probably do likewise for all the other bits like
__cmpxchg(), but either way:Acked-by Mark Rutland <[email protected]>Acked-by Palmer Dabbelt <[email protected]>Though I'm not sure that means a whole lot over here ;)
I've carried some other sparc stuff before. I can send this to Linus with other fixes.
Signature · 1 line
Kees Cook
Kees Cook
AppliedQuoted 8 lines · Arnd Bergmann
An otherwise correct change to the atomic operations uncovered an existing bug in the sparc
__arch_xchg()function, which is calls__xchg_called_with_bad_pointer()when its arguments are unknown at compile time:ERROR: modpost: "
__xchg_called_with_bad_pointer" [lib/atomic64_test.ko] undefined![...]
Applied, thanks!
[1/1] sparc: mark __arch_xchg() as __always_inline
https://git.kernel.org/kees/c/ec7633de404e
Best regards,
Signature · 1 line
Kees Cook