Re: [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config

From: Petr Mladek

Date: Fri Apr 17 2026 - 11:15:11 EST


On Wed 2026-04-15 11:58:50, Miroslav Benes wrote:
> On Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
>
> > Older kernels that lack CONFIG_ARCH_HAS_SYSCALL_WRAPPER config don't
> > have any prefixes for their syscalls. The same applies to current
> > powerpc and loongarch, covering all currently supported architectures
> > that support livepatch.
> >
> > The other supported architectures have specific prefixes, so error out
> > when a new architecture adds livepatch support with wrappes but didn't
> > update the test to include it.
> >
> > --- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
> > @@ -12,15 +12,26 @@
> > #include <linux/slab.h>
> > #include <linux/livepatch.h>
> >
> > -#if defined(__x86_64__)
> > +/*
> > + * Before CONFIG_ARCH_HAS_SYSCALL_WRAPPER was introduced there were no
> > + * prefixes for system calls.
> > + * Both ppc and loongarch does not set prefixes for their system calls either.
> > + */
> > +#if !defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER) || defined(__powerpc__) || \
> > + defined(__loongarch__)
> > +#define FN_PREFIX
> > +#elif defined(__x86_64__)
> > #define FN_PREFIX __x64_
> > #elif defined(__s390x__)
> > #define FN_PREFIX __s390x_
> > #elif defined(__aarch64__)
> > #define FN_PREFIX __arm64_
> > -#else
> > -/* powerpc does not select ARCH_HAS_SYSCALL_WRAPPER */
> > +#elif defined(__powerpc__)
> > +#define FN_PREFIX
> > +#elif defined(__loongarch__)
> > #define FN_PREFIX
> > +#else
> > +#error "Missing syscall wrapper for the given architecture."
> > #endif
>
> I know that Sashiko commented on that already but even with that I wonder
> if it was cleaner to structure it differently...
>
> #if defined(CONFIG_ARCH_HAS_SYSCALL_WRAPPER)
> #if define(__x86_64__)
> ...
> #elif define(__powerpc__)
> #define FN_PREFIX
> #else
> #error
> #endif
> #elif
> #define FN_PREFIX
> #endif

Yeah, this looks better.

Best Regards,
Petr