aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2008-01-07 00:12:44 -0500
committerPaul Mackerras <paulus@samba.org>2008-01-16 22:57:38 -0500
commit0a4690cf751db6adb28b9275a6ecbaa6549a9ea8 (patch)
treeab0076ed230dde1e688ed92a09685e3a7bf0cc7e /arch/powerpc/kernel
parent4ec161cf73bc0b4e5c36843638ef9171896fc0b9 (diff)
[POWERPC] Check that the syscall table matches the syscall numbers
Also check that __NR_syscalls has been updated appropriately. Hopefully this will catch any out of order additions to the table in the future. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile10
-rw-r--r--arch/powerpc/kernel/systbl_chk.c58
-rw-r--r--arch/powerpc/kernel/systbl_chk.sh33
3 files changed, 101 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 9374bc9a2dd1..d9b377070caa 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -91,3 +91,13 @@ obj-$(CONFIG_PPC64) += $(obj64-y)
91 91
92extra-$(CONFIG_PPC_FPU) += fpu.o 92extra-$(CONFIG_PPC_FPU) += fpu.o
93extra-$(CONFIG_PPC64) += entry_64.o 93extra-$(CONFIG_PPC64) += entry_64.o
94
95extra-y += systbl_chk.i
96$(obj)/systbl.o: systbl_chk
97
98quiet_cmd_systbl_chk = CALL $<
99 cmd_systbl_chk = $(CONFIG_SHELL) $< $(obj)/systbl_chk.i
100
101PHONY += systbl_chk
102systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
103 $(call cmd,systbl_chk)
diff --git a/arch/powerpc/kernel/systbl_chk.c b/arch/powerpc/kernel/systbl_chk.c
new file mode 100644
index 000000000000..77824d1cb150
--- /dev/null
+++ b/arch/powerpc/kernel/systbl_chk.c
@@ -0,0 +1,58 @@
1/*
2 * This file, when run through CPP produces a list of syscall numbers
3 * in the order of systbl.h. That way we can check for gaps and syscalls
4 * that are out of order.
5 *
6 * Unfortunately, we cannot check for the correct ordering of entries
7 * using SYSX().
8 *
9 * Copyright © IBM Corporation
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#include <asm/unistd.h>
17
18#define SYSCALL(func) __NR_##func
19#define COMPAT_SYS(func) __NR_##func
20#define PPC_SYS(func) __NR_##func
21#ifdef CONFIG_PPC64
22#define OLDSYS(func) -1
23#define SYS32ONLY(func) -1
24#else
25#define OLDSYS(func) __NR_old##func
26#define SYS32ONLY(func) __NR_##func
27#endif
28#define SYSX(f, f3264, f32) -1
29
30#define SYSCALL_SPU(func) SYSCALL(func)
31#define COMPAT_SYS_SPU(func) COMPAT_SYS(func)
32#define PPC_SYS_SPU(func) PPC_SYS(func)
33#define SYSX_SPU(f, f3264, f32) SYSX(f, f3264, f32)
34
35/* Just insert a marker for ni_syscalls */
36#define __NR_ni_syscall -1
37
38/*
39 * These are the known exceptions.
40 * Hopefully, there will be no more.
41 */
42#define __NR_llseek __NR__llseek
43#undef __NR_umount
44#define __NR_umount __NR_umount2
45#define __NR_old_getrlimit __NR_getrlimit
46#define __NR_newstat __NR_stat
47#define __NR_newlstat __NR_lstat
48#define __NR_newfstat __NR_fstat
49#define __NR_newuname __NR_uname
50#define __NR_sysctl __NR__sysctl
51#define __NR_olddebug_setcontext __NR_sys_debug_setcontext
52
53/* We call sys_ugetrlimit for syscall number __NR_getrlimit */
54#define getrlimit ugetrlimit
55
56START_TABLE
57#include <asm/systbl.h>
58END_TABLE __NR_syscalls
diff --git a/arch/powerpc/kernel/systbl_chk.sh b/arch/powerpc/kernel/systbl_chk.sh
new file mode 100644
index 000000000000..367d208301d2
--- /dev/null
+++ b/arch/powerpc/kernel/systbl_chk.sh
@@ -0,0 +1,33 @@
1#!/bin/sh
2#
3# Just process the CPP output from systbl_chk.c and complain
4# if anything is out of order.
5#
6# Copyright © 2008 IBM Corporation
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version
11# 2 of the License, or (at your option) any later version.
12
13awk 'BEGIN { num = -1; } # Ignore the beginning of the file
14 /^#/ { next; }
15 /^[ \t]*$/ { next; }
16 /^START_TABLE/ { num = 0; next; }
17 /^END_TABLE/ {
18 if (num != $2) {
19 printf "__NR_syscalls (%s) is not one more than the last syscall (%s)\n",
20 $2, num - 1;
21 exit(1);
22 }
23 num = -1; # Ignore the rest of the file
24 }
25 {
26 if (num == -1) next;
27 if (($1 != -1) && ($1 != num)) {
28 printf "Syscall %s out of order (expected %s)\n",
29 $1, num;
30 exit(1);
31 };
32 num++;
33 }' "$1"