[RFC PATCH v2 5/5] powerpc/syscalls: Allow none instead of sys_ni_syscall

Arnd Bergmann arnd at arndb.de
Thu Jan 17 00:53:32 AEDT 2019


On Wed, Jan 16, 2019 at 2:27 PM Michael Ellerman <mpe at ellerman.id.au> wrote:
>
> sys_ni_syscall is the "not-implemented" syscall syscall, which just
> returns -ENOSYS.
>
> But unless you know that it's not obvious what it does, and even if
> you do know what it means it doesn't stand out that well from other
> real syscalls.
>
> So teach the scripts to treat "none" as a synonym for
> "sys_ni_syscall". This makes the table more readable.

Hmm, this actually breaks the proposed script to find bugs
in the compat handling, i.e. detecting those that have no
compat handler but only a native one.

> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
> index c5907a2dbc86..988a7e29245f 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -24,28 +24,28 @@
>  14     common  mknod                           sys_mknod
>  15     common  chmod                           sys_chmod
>  16     common  lchown                          sys_lchown
> -17     common  break                           sys_ni_syscall
> -18     32      oldstat                         sys_stat                        sys_ni_syscall
> -18     64      oldstat                         sys_ni_syscall
> +17     common  break                           none
> +18     32      oldstat                         sys_stat                        none
> +18     64      oldstat                         none

The '64 oldstat' line can simply get dropped here, it has no value
(I failed to notice this earlier).

For break, i.e. a syscall number without any implementation,
we use a different syntax on x86 (leaving out the sys_* entirely),
and on s390 (using '-', which is visually better than 'none' IMHO).

We might also just remove those entirely across all architectures.
Some have already done this, and some have done it partially.
I can only see a couple of syscalls that got removed in the entire
git history (set_zone_reclaim, nfsservctl, vm86, timerfd), any other
ones are now literally pre-historic, and presumably nobody would
miss the macros when building a program that has no chance to
run on any kernel since at least 2.6.12.

For 32-bit oldstat, I'd argue that this should actually get fixed by adding
the compat syscall logic. I think this was discussed when Firoz
first posted his patches. Something like this:

diff --git a/arch/powerpc/include/asm/unistd.h
b/arch/powerpc/include/asm/unistd.h
index f44dbc65e38e..d954c2fc4e2f 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -41,9 +41,7 @@
 #define __ARCH_WANT_SYS_OLDUMOUNT
 #define __ARCH_WANT_SYS_SIGPENDING
 #define __ARCH_WANT_SYS_SIGPROCMASK
-#ifdef CONFIG_PPC32
 #define __ARCH_WANT_OLD_STAT
-#endif
 #ifdef CONFIG_PPC64
 #define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_SYS_UTIME
diff --git a/arch/powerpc/include/uapi/asm/stat.h
b/arch/powerpc/include/uapi/asm/stat.h
index afd25f2ff4e8..8331b350c12b 100644
--- a/arch/powerpc/include/uapi/asm/stat.h
+++ b/arch/powerpc/include/uapi/asm/stat.h
@@ -11,7 +11,7 @@

 #define STAT_HAVE_NSEC 1

-#ifndef __powerpc64__
+#if defined(__KERNEL__) || !defined(__powerpc64__)
 struct __old_kernel_stat {
        unsigned short st_dev;
        unsigned short st_ino;
@@ -25,7 +25,7 @@ struct __old_kernel_stat {
        unsigned long  st_mtime;
        unsigned long  st_ctime;
 };
-#endif /* !__powerpc64__ */
+#endif /* __KERNEL__ || !__powerpc64__ */

 struct stat {
        unsigned long   st_dev;
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
b/arch/powerpc/kernel/syscalls/syscall.tbl
index 740dc9dbf689..cd85718c7039 100644
--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -27,7 +27,7 @@
 15     common  chmod                           sys_chmod
 16     common  lchown                          sys_lchown
 17     common  break                           sys_ni_syscall
-18     32      oldstat                         sys_stat
         sys_ni_syscall
+18     32      oldstat                         sys_stat
 18     64      oldstat                         sys_ni_syscall
 18     spu     oldstat                         sys_ni_syscall
 19     common  lseek                           sys_lseek
         compat_sys_lseek
@@ -43,7 +43,7 @@
 25     spu     stime                           sys_stime
 26     nospu   ptrace                          sys_ptrace
         compat_sys_ptrace
 27     common  alarm                           sys_alarm
-28     32      oldfstat                        sys_fstat
         sys_ni_syscall
+28     32      oldfstat                        sys_fstat
 28     64      oldfstat                        sys_ni_syscall
 28     spu     oldfstat                        sys_ni_syscall
 29     nospu   pause                           sys_pause
@@ -114,7 +114,7 @@
 82     64      select                          sys_ni_syscall
 82     spu     select                          sys_ni_syscall
 83     common  symlink                         sys_symlink
-84     32      oldlstat                        sys_lstat
         sys_ni_syscall
+84     32      oldlstat                        sys_lstat
 84     64      oldlstat                        sys_ni_syscall
 84     spu     oldlstat                        sys_ni_syscall
 85     common  readlink                        sys_readlink


More information about the Linuxppc-dev mailing list