Re: [PATCH v5 1/3] x86/syscall: Mark exit[_group] syscall handlers __noreturn

From: Josh Poimboeuf
Date: Wed Jun 26 2024 - 01:21:27 EST


On Mon, May 27, 2024 at 02:15:57PM +0300, Nikolay Borisov wrote:
>
>
> On 7.05.24 г. 8:30 ч., Josh Poimboeuf wrote:
> > The direct-call syscall dispatch function doesn't know that the exit()
> > and exit_group() syscall handlers don't return, so the call sites aren't
> > optimized accordingly.
> >
> > Fix that by marking those exit syscall declarations __noreturn.
> >
> > Fixes the following warnings:
> >
> > vmlinux.o: warning: objtool: x64_sys_call+0x2804: __x64_sys_exit() is missing a __noreturn annotation
> > vmlinux.o: warning: objtool: ia32_sys_call+0x29b6: __ia32_sys_exit_group() is missing a __noreturn annotation
> >
> > Fixes: 7390db8aea0d ("x86/bhi: Add support for clearing branch history at syscall entry")
> > Reported-by: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
> > Closes: https://lkml.kernel.org/lkml/6dba9b32-db2c-4e6d-9500-7a08852f17a3@paulmck-laptop
> > Tested-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > ---
> > arch/x86/entry/syscall_32.c | 10 ++++++----
> > arch/x86/entry/syscall_64.c | 9 ++++++---
> > arch/x86/entry/syscall_x32.c | 7 +++++--
> > arch/x86/entry/syscalls/syscall_32.tbl | 6 +++---
> > arch/x86/entry/syscalls/syscall_64.tbl | 6 +++---
> > arch/x86/um/sys_call_table_32.c | 10 ++++++----
> > arch/x86/um/sys_call_table_64.c | 11 +++++++----
> > scripts/syscalltbl.sh | 18 ++++++++++++++++--
> > tools/objtool/noreturns.h | 4 ++++
> > 9 files changed, 56 insertions(+), 25 deletions(-)
> >
> > diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
> > index c2235bae17ef..8cc9950d7104 100644
> > --- a/arch/x86/entry/syscall_32.c
> > +++ b/arch/x86/entry/syscall_32.c
> > @@ -14,9 +14,12 @@
> > #endif
> > #define __SYSCALL(nr, sym) extern long __ia32_##sym(const struct pt_regs *);
> > -
> > +#define __SYSCALL_NORETURN(nr, sym) extern long __noreturn __ia32_##sym(const struct pt_regs *);
> > #include <asm/syscalls_32.h>
> > -#undef __SYSCALL
> > +#undef __SYSCALL
> > +
> > +#undef __SYSCALL_NORETURN
> > +#define __SYSCALL_NORETURN __SYSCALL
> > /*
> > * The sys_call_table[] is no longer used for system calls, but
> > @@ -28,11 +31,10 @@
> > const sys_call_ptr_t sys_call_table[] = {
> > #include <asm/syscalls_32.h>
> > };
> > -#undef __SYSCALL
> > +#undef __SYSCALL
>
> nit: Am I blind or all the __SYSCALL lines have an extra whitespace?
>
> <snip>

That was a small readability tweak to make '__SYSCALL' vertically aligned:

#define __SYSCALL(nr, sym) extern long __ia32_##sym(const struct pt_regs *);
#define __SYSCALL_NORETURN(nr, sym) extern long __noreturn __ia32_##sym(const struct pt_regs *);
#include <asm/syscalls_32.h>
#undef __SYSCALL

--
Josh