2019-10-09 10:06:54

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH] MIPS: include: Mark __xchg as __always_inline

Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
forcibly") allows compiler to uninline functions marked as 'inline'.
In cace of __xchg this would cause to reference function
__xchg_called_with_bad_pointer, which is an error case
for catching bugs and will not happen for correct code, if
__xchg is inlined.

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
arch/mips/include/asm/cmpxchg.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
index 012dcf7046ad..f6136871561d 100644
--- a/arch/mips/include/asm/cmpxchg.h
+++ b/arch/mips/include/asm/cmpxchg.h
@@ -77,8 +77,8 @@ extern unsigned long __xchg_called_with_bad_pointer(void)
extern unsigned long __xchg_small(volatile void *ptr, unsigned long val,
unsigned int size);

-static inline unsigned long __xchg(volatile void *ptr, unsigned long x,
- int size)
+static __always_inline
+unsigned long __xchg(volatile void *ptr, unsigned long x, int size)
{
switch (size) {
case 1:
--
2.16.4


2019-10-09 12:46:31

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH] MIPS: include: Mark __xchg as __always_inline

On 10/9/19 12:06 PM, Thomas Bogendoerfer wrote:
> Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
> forcibly") allows compiler to uninline functions marked as 'inline'.
> In cace of __xchg this would cause to reference function

Typo: "in case of"

> __xchg_called_with_bad_pointer, which is an error case
> for catching bugs and will not happen for correct code, if
> __xchg is inlined.
>

Ah, this is the equivalent of ARM commit 920fdab7b3c.

Maybe add:

Fixes: ac7c3e4ff401

> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> ---
> arch/mips/include/asm/cmpxchg.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
> index 012dcf7046ad..f6136871561d 100644
> --- a/arch/mips/include/asm/cmpxchg.h
> +++ b/arch/mips/include/asm/cmpxchg.h
> @@ -77,8 +77,8 @@ extern unsigned long __xchg_called_with_bad_pointer(void)
> extern unsigned long __xchg_small(volatile void *ptr, unsigned long val,
> unsigned int size);
>
> -static inline unsigned long __xchg(volatile void *ptr, unsigned long x,
> - int size)
> +static __always_inline
> +unsigned long __xchg(volatile void *ptr, unsigned long x, int size)
> {
> switch (size) {
> case 1:
>

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

2019-10-09 21:58:49

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH] MIPS: include: Mark __xchg as __always_inline

Hello,

Thomas Bogendoerfer wrote:
> Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
> forcibly") allows compiler to uninline functions marked as 'inline'.
> In cace of __xchg this would cause to reference function
> __xchg_called_with_bad_pointer, which is an error case
> for catching bugs and will not happen for correct code, if
> __xchg is inlined.

Applied to mips-fixes.

> commit 46f1619500d0
> https://git.kernel.org/mips/c/46f1619500d0
>
> Signed-off-by: Thomas Bogendoerfer <[email protected]>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>

Thanks,
Paul

[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]