Commit c53aeca059c4d2108335810fba6ba89ab6a944dd

Authored by Sam Ravnborg
1 parent ded2e1640f

kbuild: complain about missing system calls

Most system calls seems to get added to i386 first. This patch
automatically generates a warning for any new system call which is
implemented on i386 but not the architecture currently being compiled.
On PowerPC at the moment, for example, it results in these warnings:
init/missing_syscalls.h:935:3: warning: #warning syscall sync_file_range not implemented
init/missing_syscalls.h:947:3: warning: #warning syscall getcpu not implemented
init/missing_syscalls.h:950:3: warning: #warning syscall epoll_pwait not implemented

The file scripts/checksyscalls.sh list a number of legacy system calls
that are ignored because they only makes sense on i386 systems.

Other contributors to this patch are Russell King <rmk+lkml@arm.linux.org.uk>
and St├ęphane Jourdois <kwisatz@rubis.org>

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 3 changed files with 130 additions and 0 deletions Side-by-side Diff

... ... @@ -2,6 +2,7 @@
2 2 # Kbuild for top-level directory of the kernel
3 3 # This file takes care of the following:
4 4 # 1) Generate asm-offsets.h
  5 +# 2) Check for missing system calls
5 6  
6 7 #####
7 8 # 1) Generate asm-offsets.h
... ... @@ -45,4 +46,15 @@
45 46 $(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
46 47 $(Q)mkdir -p $(dir $@)
47 48 $(call cmd,offsets)
  49 +
  50 +#####
  51 +# 2) Check for missing system calls
  52 +#
  53 +
  54 +quiet_cmd_syscalls = CALL $<
  55 + cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags)
  56 +
  57 +PHONY += missing-syscalls
  58 +missing-syscalls: scripts/checksyscalls.sh FORCE
  59 + $(call cmd,syscalls)
... ... @@ -856,6 +856,7 @@
856 856  
857 857 prepare0: archprepare FORCE
858 858 $(Q)$(MAKE) $(build)=.
  859 + $(Q)$(MAKE) $(build)=. missing-syscalls
859 860  
860 861 # All the preparing..
861 862 prepare: prepare0
scripts/checksyscalls.sh
  1 +#!/bin/sh
  2 +#
  3 +# Check if current architecture are missing any function calls compared
  4 +# to i386.
  5 +# i386 define a number of legacy system calls that are i386 specific
  6 +# and listed below so they are ignored.
  7 +#
  8 +# Usage:
  9 +# syscallchk gcc gcc-options
  10 +#
  11 +
  12 +ignore_list() {
  13 +cat << EOF
  14 +#include <asm/types.h>
  15 +#include <asm/unistd.h>
  16 +
  17 +/* System calls for 32-bit kernels only */
  18 +#if BITS_PER_LONG == 64
  19 +#define __IGNORE_sendfile64
  20 +#define __IGNORE_ftruncate64
  21 +#define __IGNORE_truncate64
  22 +#define __IGNORE_stat64
  23 +#define __IGNORE_lstat64
  24 +#define __IGNORE_fstat64
  25 +#define __IGNORE_fcntl64
  26 +#define __IGNORE_fadvise64_64
  27 +#define __IGNORE_fstatat64
  28 +#define __IGNORE_fstatfs64
  29 +#define __IGNORE_statfs64
  30 +#endif
  31 +
  32 +/* i386-specific or historical system calls */
  33 +#define __IGNORE_break
  34 +#define __IGNORE_stty
  35 +#define __IGNORE_gtty
  36 +#define __IGNORE_ftime
  37 +#define __IGNORE_prof
  38 +#define __IGNORE_lock
  39 +#define __IGNORE_mpx
  40 +#define __IGNORE_ulimit
  41 +#define __IGNORE_profil
  42 +#define __IGNORE_ioperm
  43 +#define __IGNORE_iopl
  44 +#define __IGNORE_idle
  45 +#define __IGNORE_modify_ldt
  46 +#define __IGNORE_ugetrlimit
  47 +#define __IGNORE_mmap2
  48 +#define __IGNORE_vm86
  49 +#define __IGNORE_vm86old
  50 +#define __IGNORE_set_thread_area
  51 +#define __IGNORE_get_thread_area
  52 +#define __IGNORE_madvise1
  53 +#define __IGNORE_oldstat
  54 +#define __IGNORE_oldfstat
  55 +#define __IGNORE_oldlstat
  56 +#define __IGNORE_oldolduname
  57 +#define __IGNORE_olduname
  58 +#define __IGNORE_umount2
  59 +#define __IGNORE_umount
  60 +#define __IGNORE_waitpid
  61 +#define __IGNORE_stime
  62 +#define __IGNORE_nice
  63 +#define __IGNORE_signal
  64 +#define __IGNORE_sigaction
  65 +#define __IGNORE_sgetmask
  66 +#define __IGNORE_sigsuspend
  67 +#define __IGNORE_sigpending
  68 +#define __IGNORE_ssetmask
  69 +#define __IGNORE_readdir
  70 +#define __IGNORE_socketcall
  71 +#define __IGNORE_ipc
  72 +#define __IGNORE_sigreturn
  73 +#define __IGNORE_sigprocmask
  74 +#define __IGNORE_bdflush
  75 +#define __IGNORE__llseek
  76 +#define __IGNORE__newselect
  77 +#define __IGNORE_create_module
  78 +#define __IGNORE_delete_module
  79 +#define __IGNORE_query_module
  80 +#define __IGNORE_get_kernel_syms
  81 +/* ... including the "new" 32-bit uid syscalls */
  82 +#define __IGNORE_lchown32
  83 +#define __IGNORE_getuid32
  84 +#define __IGNORE_getgid32
  85 +#define __IGNORE_geteuid32
  86 +#define __IGNORE_getegid32
  87 +#define __IGNORE_setreuid32
  88 +#define __IGNORE_setregid32
  89 +#define __IGNORE_getgroups32
  90 +#define __IGNORE_setgroups32
  91 +#define __IGNORE_fchown32
  92 +#define __IGNORE_setresuid32
  93 +#define __IGNORE_getresuid32
  94 +#define __IGNORE_setresgid32
  95 +#define __IGNORE_getresgid32
  96 +#define __IGNORE_chown32
  97 +#define __IGNORE_setuid32
  98 +#define __IGNORE_setgid32
  99 +#define __IGNORE_setfsuid32
  100 +#define __IGNORE_setfsgid32
  101 +
  102 +/* Unmerged syscalls for AFS, STREAMS, etc. */
  103 +#define __IGNORE_afs_syscall
  104 +#define __IGNORE_getpmsg
  105 +#define __IGNORE_putpmsg
  106 +#define __IGNORE_vserver
  107 +EOF
  108 +}
  109 +
  110 +syscall_list() {
  111 +sed -n -e '/^\#define/ { s/[^_]*__NR_\([^[:space:]]*\).*/\
  112 +\#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\
  113 +\#warning syscall \1 not implemented\
  114 +\#endif/p }' $1
  115 +}
  116 +
  117 +(ignore_list && syscall_list ${srctree}/include/asm-i386/unistd.h) | \
  118 +$* -E -x c - > /dev/null