2024-03-26 15:41:36

by Sami Tolvanen

[permalink] [raw]
Subject: [PATCH] riscv: Mark __se_sys_* functions __used

Clang doesn't think ___se_sys_* functions used even though they are
aliased to __se_sys_*, resulting in -Wunused-function warnings when
building rv32. For example:

mm/oom_kill.c:1195:1: warning: unused function '___se_sys_process_mrelease' [-Wunused-function]
1195 | SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE2'
221 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/syscalls.h:231:2: note: expanded from macro 'SYSCALL_DEFINEx'
231 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/syscall_wrapper.h:81:2: note: expanded from macro '__SYSCALL_DEFINEx'
81 | __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/include/asm/syscall_wrapper.h:40:14: note: expanded from macro '__SYSCALL_SE_DEFINEx'
40 | static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
| ^~~~~~~~~~~~~~~~~~~~
<scratch space>:30:1: note: expanded from here
30 | ___se_sys_process_mrelease
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Mark the functions __used explicitly to fix the Clang warnings.

Fixes: a9ad73295cc1 ("riscv: Fix syscall wrapper for >word-size arguments")
Reported-by: Linux Kernel Functional Testing <[email protected]>
Tested-by: Linux Kernel Functional Testing <[email protected]>
Signed-off-by: Sami Tolvanen <[email protected]>
---
arch/riscv/include/asm/syscall_wrapper.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/syscall_wrapper.h b/arch/riscv/include/asm/syscall_wrapper.h
index 980094c2e976..ac80216549ff 100644
--- a/arch/riscv/include/asm/syscall_wrapper.h
+++ b/arch/riscv/include/asm/syscall_wrapper.h
@@ -36,7 +36,8 @@ asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);
ulong) \
__attribute__((alias(__stringify(___se_##prefix##name)))); \
__diag_pop(); \
- static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
+ static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
+ __used; \
static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))

#define SC_RISCV_REGS_TO_ARGS(x, ...) \

base-commit: 4cece764965020c22cff7665b18a012006359095
--
2.44.0.396.g6e790dbe36-goog



2024-03-26 18:43:51

by Alexandre Ghiti

[permalink] [raw]
Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

Hi Sami,

On 26/03/2024 16:37, Sami Tolvanen wrote:
> Clang doesn't think ___se_sys_* functions used even though they are
> aliased to __se_sys_*, resulting in -Wunused-function warnings when
> building rv32. For example:
>
> mm/oom_kill.c:1195:1: warning: unused function '___se_sys_process_mrelease' [-Wunused-function]
> 1195 | SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE2'
> 221 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:231:2: note: expanded from macro 'SYSCALL_DEFINEx'
> 231 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:81:2: note: expanded from macro '__SYSCALL_DEFINEx'
> 81 | __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__) \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:40:14: note: expanded from macro '__SYSCALL_SE_DEFINEx'
> 40 | static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
> | ^~~~~~~~~~~~~~~~~~~~
> <scratch space>:30:1: note: expanded from here
> 30 | ___se_sys_process_mrelease
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 warning generated.
>
> Mark the functions __used explicitly to fix the Clang warnings.
>
> Fixes: a9ad73295cc1 ("riscv: Fix syscall wrapper for >word-size arguments")
> Reported-by: Linux Kernel Functional Testing <[email protected]>


Do you have the link of the report? So we can add a Closes tag.


> Tested-by: Linux Kernel Functional Testing <[email protected]>
> Signed-off-by: Sami Tolvanen <[email protected]>
> ---
> arch/riscv/include/asm/syscall_wrapper.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/syscall_wrapper.h b/arch/riscv/include/asm/syscall_wrapper.h
> index 980094c2e976..ac80216549ff 100644
> --- a/arch/riscv/include/asm/syscall_wrapper.h
> +++ b/arch/riscv/include/asm/syscall_wrapper.h
> @@ -36,7 +36,8 @@ asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);
> ulong) \
> __attribute__((alias(__stringify(___se_##prefix##name)))); \
> __diag_pop(); \
> - static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
> + static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
> + __used; \
> static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
>
> #define SC_RISCV_REGS_TO_ARGS(x, ...) \
>
> base-commit: 4cece764965020c22cff7665b18a012006359095


You can add:

Reviewed-by: Alexandre Ghiti <[email protected]>

As the commit fixed here was merged in 6.9, this should go into fixes.

Thanks,

Alex


2024-03-26 18:53:11

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

On Tue, Mar 26, 2024 at 03:37:13PM +0000, Sami Tolvanen wrote:
> Clang doesn't think ___se_sys_* functions used even though they are
> aliased to __se_sys_*, resulting in -Wunused-function warnings when
> building rv32. For example:
>
> mm/oom_kill.c:1195:1: warning: unused function '___se_sys_process_mrelease' [-Wunused-function]
> 1195 | SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE2'
> 221 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:231:2: note: expanded from macro 'SYSCALL_DEFINEx'
> 231 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:81:2: note: expanded from macro '__SYSCALL_DEFINEx'
> 81 | __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__) \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:40:14: note: expanded from macro '__SYSCALL_SE_DEFINEx'
> 40 | static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
> | ^~~~~~~~~~~~~~~~~~~~
> <scratch space>:30:1: note: expanded from here
> 30 | ___se_sys_process_mrelease
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 warning generated.
>
> Mark the functions __used explicitly to fix the Clang warnings.
>
> Fixes: a9ad73295cc1 ("riscv: Fix syscall wrapper for >word-size arguments")
> Reported-by: Linux Kernel Functional Testing <[email protected]>
> Tested-by: Linux Kernel Functional Testing <[email protected]>
> Signed-off-by: Sami Tolvanen <[email protected]>

Oh neat, thanks. This was generating a shed load of noise in CI :)
Tested-by: Conor Dooley <[email protected]>

Thanks,
Conor.

> ---
> arch/riscv/include/asm/syscall_wrapper.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/syscall_wrapper.h b/arch/riscv/include/asm/syscall_wrapper.h
> index 980094c2e976..ac80216549ff 100644
> --- a/arch/riscv/include/asm/syscall_wrapper.h
> +++ b/arch/riscv/include/asm/syscall_wrapper.h
> @@ -36,7 +36,8 @@ asmlinkage long __riscv_sys_ni_syscall(const struct pt_regs *);
> ulong) \
> __attribute__((alias(__stringify(___se_##prefix##name)))); \
> __diag_pop(); \
> - static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
> + static long noinline ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
> + __used; \
> static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
>
> #define SC_RISCV_REGS_TO_ARGS(x, ...) \
>
> base-commit: 4cece764965020c22cff7665b18a012006359095
> --
> 2.44.0.396.g6e790dbe36-goog
>
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv


Attachments:
(No filename) (3.21 kB)
signature.asc (235.00 B)
Download all attachments

2024-03-26 19:03:29

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

On Tue, Mar 26, 2024 at 6:43 PM Alexandre Ghiti <[email protected]> wrote:
>
> Do you have the link of the report? So we can add a Closes tag.

Sure, this was reported here:

https://lore.kernel.org/lkml/[email protected]/

Sami

2024-03-26 20:02:21

by Alexandre Ghiti

[permalink] [raw]
Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

On 26/03/2024 19:55, Sami Tolvanen wrote:
> On Tue, Mar 26, 2024 at 6:43 PM Alexandre Ghiti <[email protected]> wrote:
>> Do you have the link of the report? So we can add a Closes tag.
> Sure, this was reported here:
>
> https://lore.kernel.org/lkml/[email protected]/


For b4:

Closes:
https://lore.kernel.org/lkml/[email protected]/

I was expecting the "direct" lkft link though, @Daniel do you have any?

Thanks,

Alex


>
> Sami
>
> _______________________________________________
> linux-riscv mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-riscv

2024-03-27 14:29:37

by Daniel Díaz

[permalink] [raw]
Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

Hello!

On Tue, 26 Mar 2024 at 13:56, Alexandre Ghiti <[email protected]> wrote:
> On 26/03/2024 19:55, Sami Tolvanen wrote:
> > On Tue, Mar 26, 2024 at 6:43 PM Alexandre Ghiti <[email protected]> wrote:
> >> Do you have the link of the report? So we can add a Closes tag.
> > Sure, this was reported here:
> >
> > https://lore.kernel.org/lkml/[email protected]/
>
> For b4:
>
> Closes:
> https://lore.kernel.org/lkml/[email protected]/
>
> I was expecting the "direct" lkft link though, @Daniel do you have any?

No, that's the extent of that report.

Greetings!

Daniel Díaz
[email protected]

Subject: Re: [PATCH] riscv: Mark __se_sys_* functions __used

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <[email protected]>:

On Tue, 26 Mar 2024 15:37:13 +0000 you wrote:
> Clang doesn't think ___se_sys_* functions used even though they are
> aliased to __se_sys_*, resulting in -Wunused-function warnings when
> building rv32. For example:
>
> mm/oom_kill.c:1195:1: warning: unused function '___se_sys_process_mrelease' [-Wunused-function]
> 1195 | SYSCALL_DEFINE2(process_mrelease, int, pidfd, unsigned int, flags)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE2'
> 221 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/syscalls.h:231:2: note: expanded from macro 'SYSCALL_DEFINEx'
> 231 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:81:2: note: expanded from macro '__SYSCALL_DEFINEx'
> 81 | __SYSCALL_SE_DEFINEx(x, sys, name, __VA_ARGS__) \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/riscv/include/asm/syscall_wrapper.h:40:14: note: expanded from macro '__SYSCALL_SE_DEFINEx'
> 40 | static long ___se_##prefix##name(__MAP(x,__SC_LONG,__VA_ARGS__))
> | ^~~~~~~~~~~~~~~~~~~~
> <scratch space>:30:1: note: expanded from here
> 30 | ___se_sys_process_mrelease
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 warning generated.
>
> [...]

Here is the summary with links:
- riscv: Mark __se_sys_* functions __used
https://git.kernel.org/riscv/c/653650c468be

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html