Skip to contentSkip to conversation

parisc: Add compile-time check when adding new syscalls

PATCH In review Helge Deller 1 participant 2 messages Mar 14, 2015 – Mar 15, 2015 PA-RISC architecture

lore
Share & tools
lore

Helge Deller

author maintainer
#0 lore raw

PATCH 1/1 parisc: Add compile-time check when adding new syscalls

arch/parisc/kernel/syscall_table.S +18 -0
index 5a8997d..802f807 100644
@@ -41,20 +41,25 @@
 #define ENTRY_UHOH(_name_) .dword sys32_##unimplemented
 #define ENTRY_OURS(_name_) .dword parisc_##_name_
 #define ENTRY_COMP(_name_) .dword compat_sys_##_name_
+#define SYSCALLTABLE_NAME  syscall_table_compat
 #elif defined(CONFIG_64BIT) && defined(SYSCALL_TABLE_64BIT)
 #define ENTRY_SAME(_name_) .dword sys_##_name_
 #define ENTRY_DIFF(_name_) .dword sys_##_name_
 #define ENTRY_UHOH(_name_) .dword sys_##_name_
 #define ENTRY_OURS(_name_) .dword sys_##_name_
 #define ENTRY_COMP(_name_) .dword sys_##_name_
+#define SYSCALLTABLE_NAME  syscall_table_64bit
 #else
 #define ENTRY_SAME(_name_) .word sys_##_name_
 #define ENTRY_DIFF(_name_) .word sys_##_name_
 #define ENTRY_UHOH(_name_) .word sys_##_name_
 #define ENTRY_OURS(_name_) .word parisc_##_name_
 #define ENTRY_COMP(_name_) .word sys_##_name_
+#define SYSCALLTABLE_NAME  syscall_table_32bit
 #endif
 
+        .local SYSCALLTABLE_NAME
+SYSCALLTABLE_NAME:
 	ENTRY_SAME(restart_syscall)	/* 0 */
 	ENTRY_SAME(exit)
 	ENTRY_SAME(fork_wrapper)
@@ -439,8 +444,21 @@
 	ENTRY_SAME(bpf)
 	ENTRY_COMP(execveat)
 
+
+        .size SYSCALLTABLE_NAME, . - SYSCALLTABLE_NAME
+        .type SYSCALLTABLE_NAME, @object
+
+#if defined(CONFIG_64BIT)
+.ifne (. - SYSCALLTABLE_NAME) - (__NR_Linux_syscalls * 8)
+#else /* !defined(CONFIG_64BIT) */
+.ifne (. - SYSCALLTABLE_NAME) - (__NR_Linux_syscalls * 4)
+#endif
+.error "syscall table not in sync with value of __NR_Linux_syscalls"
+.endif
+
 	/* Nothing yet */
 
+#undef SYSCALLTABLE_NAME
 #undef ENTRY_SAME
 #undef ENTRY_DIFF
 #undef ENTRY_UHOH
author maintainer
#1 lore raw
arch/parisc/kernel/syscall_table.S +10 -0
index 5a8997d..0959fcc 100644
@@ -55,6 +55,7 @@
 #define ENTRY_COMP(_name_) .word sys_##_name_
 #endif
 
+99:
 	ENTRY_SAME(restart_syscall)	/* 0 */
 	ENTRY_SAME(exit)
 	ENTRY_SAME(fork_wrapper)
@@ -439,6 +440,15 @@
 	ENTRY_SAME(bpf)
 	ENTRY_COMP(execveat)
 
+
+#if defined(CONFIG_64BIT)
+.ifne (. - 99b) - (__NR_Linux_syscalls * 8)
+#else /* !defined(CONFIG_64BIT) */
+.ifne (. - 99b) - (__NR_Linux_syscalls * 4)
+#endif
+.error "size of syscall table does not fit value of __NR_Linux_syscalls"
+.endif
+
 	/* Nothing yet */
 
 #undef ENTRY_SAME