powerpc: system call table generation support
v3 cover powerpc: system call table generation support
The purpose of this patch series is, we can easily add/modify/delete system call table support by cha- nging entry in syscall.tbl file instead of manually changing many files. The other goal is to unify the system call table generation support implementation across all the architectures.
The system call tables are in different format in all architecture. It will be difficult to manually add, modify or delete the system calls in the resp- ective files manually. To make it easy by keeping a script and which'll generate uapi header file and syscall table file.
syscall.tbl contains the list of available system calls along with system call number and correspond- ing entry point. Add a new system call in this arch- itecture will be possible by adding new entry in the syscall.tbl file.
Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.
- Compat entry name, if required.
- spu entry name, if required.
ARM, s390 and x86 architecuture does exist the sim- ilar support. I leverage their implementation to come up with a generic solution.
I have done the same support for work for alpha, ia64, m68k, microblaze, mips, parisc, sh, sparc, and xtensa. Below mentioned git repository contains more details about the workflow.
https://github.com/frzkhn/system_call_table_generator/
Finally, this is the ground work to solve the Y2038 issue. We need to add two dozen of system calls to solve Y2038 issue. So this patch series will help to add new system calls easily by adding new entry in the syscall.tbl.
changes since v2:
- modified/optimized the syscall.tbl to avoid duplicate for the spu entries.
- updated the syscalltbl.sh to meet the above point.
changes since v1:
- optimized/updated the syscall table generation scripts.
- fixed all mixed indentation issues in syscall.tbl.
- added "comments" in syscall_*.tbl.
- changed from generic-y to generated-y in Kbuild.
Firoz Khan (4):
powerpc: add __NR_syscalls along with NR_syscalls
powerpc: move macro definition from asm/systbl.h
powerpc: add system call table generation support
powerpc: generate uapi header and system call table files
arch/powerpc/Makefile | 3 + arch/powerpc/include/asm/Kbuild | 4 + arch/powerpc/include/asm/systbl.h | 396 -------------------------- arch/powerpc/include/asm/unistd.h | 3 +- arch/powerpc/include/uapi/asm/Kbuild | 2 + arch/powerpc/include/uapi/asm/unistd.h | 389 +------------------------ arch/powerpc/kernel/Makefile | 10 - arch/powerpc/kernel/syscalls/Makefile | 63 ++++ arch/powerpc/kernel/syscalls/syscall.tbl | 427 ++++++++++++++++++++++++++++ arch/powerpc/kernel/syscalls/syscallhdr.sh | 36 +++ arch/powerpc/kernel/syscalls/syscalltbl.sh | 36 +++ arch/powerpc/kernel/systbl.S | 37 +-- arch/powerpc/kernel/systbl_chk.c | 60 ---- arch/powerpc/platforms/cell/spu_callbacks.c | 17 +- 14 files changed, 591 insertions(+), 892 deletions(-) delete mode 100644 arch/powerpc/include/asm/systbl.h create mode 100644 arch/powerpc/kernel/syscalls/Makefile create mode 100644 arch/powerpc/kernel/syscalls/syscall.tbl create mode 100644 arch/powerpc/kernel/syscalls/syscallhdr.sh create mode 100644 arch/powerpc/kernel/syscalls/syscalltbl.sh delete mode 100644 arch/powerpc/kernel/systbl_chk.c
Signature · 1 line
1.9.1
PATCH v3 1/4 powerpc: add __NR_syscalls along with NR_syscalls
NR_syscalls macro holds the number of system call exist in powerpc architecture. We have to change the value of NR_syscalls, if we add or delete a system call.
One of the patch in this patch series has a script which will generate a uapi header based on syscall.tbl file. The syscall.tbl file contains the number of system call information. So we have two option to update NR_syscalls value.
1. Update NR_syscalls in asm/unistd.h manually by count- ing the no.of system calls. No need to update NR_sys- calls until we either add a new system call or delete existing system call.
2. We can keep this feature in above mentioned script, that will count the number of syscalls and keep it in a generated file. In this case we don't need to expli- citly update NR_syscalls in asm/unistd.h file.
The 2nd option will be the recommended one. For that, I added the __NR_syscalls macro in uapi/asm/unistd.h along with NR_syscalls asm/unistd.h. The macro __NR_syscalls also added for making the name convention same across all architecture. While __NR_syscalls isn't strictly part of the uapi, having it as part of the generated header to simplifies the implementation. We also need to enclose this macro with #ifdef __KERNEL__ to avoid side effects.
--- arch/powerpc/include/asm/unistd.h | 3 +-- arch/powerpc/include/uapi/asm/unistd.h | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/unistd.h +1 -2
@@ -11,8 +11,7 @@#include <uapi/asm/unistd.h> - -#define NR_syscalls 389 +#define NR_syscalls __NR_syscalls#define __NR__exit __NR_exit
arch/powerpc/include/uapi/asm/unistd.h +4 -1
@@ -10,7 +10,6 @@#ifndef _UAPI_ASM_POWERPC_UNISTD_H_#define _UAPI_ASM_POWERPC_UNISTD_H_ -#define __NR_restart_syscall 0#define __NR_exit 1#define __NR_fork 2
@@ -401,4 +400,8 @@#define __NR_rseq 387#define __NR_io_pgetevents 388 +#ifdef __KERNEL__ +#define __NR_syscalls 389 +#endif +#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
Signature · 1 line
1.9.1
PATCH v3 2/4 powerpc: move macro definition from asm/systbl.h
In reply to Firoz KhanMove the macro definition for compat_sys_sigsuspend from asm/systbl.h to the file which it is getting included.
One of the patch in this patch series is generating uapi header and syscall table files. In order to come up with a common implimentation across all architecture, we need to do this change.
This change will simplify the implementation of system call table generation script and help to come up a common implementation across all architecture.
--- arch/powerpc/include/asm/systbl.h | 1 - arch/powerpc/kernel/systbl.S | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/systbl.h +0 -1
@@ -76,7 +76,6 @@ SYSCALL_SPU(ssetmask) SYSCALL_SPU(setreuid) SYSCALL_SPU(setregid) -#define compat_sys_sigsuspend sys_sigsuspend SYS32ONLY(sigsuspend) SYSX(sys_ni_syscall,compat_sys_sigpending,sys_sigpending) SYSCALL_SPU(sethostname)
arch/powerpc/kernel/systbl.S +1 -0
@@ -47,4 +47,5 @@ .globl sys_call_table sys_call_table: +#define compat_sys_sigsuspend sys_sigsuspend #include <asm/systbl.h>
Signature · 1 line
1.9.1
PATCH v3 3/4 powerpc: add system call table generation support
In reply to Firoz KhanThe system call tables are in different format in all architecture and it will be difficult to manually add or modify the system calls in the respective files. To make it easy by keeping a script and which will generate the uapi header and syscall table file. This change will also help to unify the implementation across all architectures.
The system call table generation script is added in syscalls directory which contain the script to generate both uapi header file and system call table files. The syscall.tbl file will be the input for the scripts.
syscall.tbl contains the list of available system calls along with system call number and corresponding entry point. Add a new system call in this architecture will be possible by adding new entry in the syscall.tbl file.
Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.
- Compat entry name, if required.
syscallhdr.sh and syscalltbl.sh will generate uapi header- unistd_32/64.h and syscall_table_32/64/c32/spu.h files respectively. File syscall_table_32/64/c32/spu.h is incl- uded by syscall.S - the real system call table. Both *.sh files will parse the content syscall.tbl to generate the header and table files.
ARM, s390 and x86 architecuture does have similar support. I leverage their implementation to come up with a generic solution.
--- arch/powerpc/kernel/syscalls/Makefile | 63 +++++ arch/powerpc/kernel/syscalls/syscall.tbl | 427 +++++++++++++++++++++++++++++ arch/powerpc/kernel/syscalls/syscallhdr.sh | 36 +++ arch/powerpc/kernel/syscalls/syscalltbl.sh | 36 +++ 4 files changed, 562 insertions(+) create mode 100644 arch/powerpc/kernel/syscalls/Makefile create mode 100644 arch/powerpc/kernel/syscalls/syscall.tbl create mode 100644 arch/powerpc/kernel/syscalls/syscallhdr.sh create mode 100644 arch/powerpc/kernel/syscalls/syscalltbl.sh
arch/powerpc/kernel/syscalls/Makefile new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: GPL-2.0 +kapi := arch/$(SRCARCH)/include/generated/asm +uapi := arch/$(SRCARCH)/include/generated/uapi/asm + +_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ + $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') + +syscall := $(srctree)/$(src)/syscall.tbl +syshdr := $(srctree)/$(src)/syscallhdr.sh +systbl := $(srctree)/$(src)/syscalltbl.sh + +quiet_cmd_syshdr = SYSHDR $@ + cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ + '$(syshdr_abis_$(basetarget))' \ + '$(syshdr_pfx_$(basetarget))' \ + '$(syshdr_offset_$(basetarget))' + +quiet_cmd_systbl = SYSTBL $@ + cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ + '$(systbl_abis_$(basetarget))' \ + '$(systbl_abi_$(basetarget))' \ + '$(systbl_offset_$(basetarget))' + +syshdr_abis_unistd_32 := common,nospu,32 +$(uapi)/unistd_32.h: $(syscall) $(syshdr) + $(call if_changed,syshdr) + +syshdr_abis_unistd_64 := common,nospu,64 +$(uapi)/unistd_64.h: $(syscall) $(syshdr) + $(call if_changed,syshdr) + +systbl_abis_syscall_table_32 := common,nospu,32 +systbl_abi_syscall_table_32 := 32 +$(kapi)/syscall_table_32.h: $(syscall) $(systbl) + $(call if_changed,systbl) + +systbl_abis_syscall_table_64 := common,nospu,64 +systbl_abi_syscall_table_64 := 64 +$(kapi)/syscall_table_64.h: $(syscall) $(systbl) + $(call if_changed,systbl) + +systbl_abis_syscall_table_c32 := common,nospu,32 +systbl_abi_syscall_table_c32 := c32 +$(kapi)/syscall_table_c32.h: $(syscall) $(systbl) + $(call if_changed,systbl) + +systbl_abis_syscall_table_spu := common,spu +systbl_abi_syscall_table_spu := spu +$(kapi)/syscall_table_spu.h: $(syscall) $(systbl) + $(call if_changed,systbl) + +uapisyshdr-y += unistd_32.h unistd_64.h +kapisyshdr-y += syscall_table_32.h \ + syscall_table_64.h \ + syscall_table_c32.h \ + syscall_table_spu.h + +targets += $(uapisyshdr-y) $(kapisyshdr-y) + +PHONY += all +all: $(addprefix $(uapi)/,$(uapisyshdr-y)) +all: $(addprefix $(kapi)/,$(kapisyshdr-y)) + @:
arch/powerpc/kernel/syscalls/syscall.tbl new file +427 -0
427 lines not on this page · raw message
arch/powerpc/kernel/syscalls/syscallhdr.sh new file +36 -0
@@ -0,0 +1,36 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +in="$1" +out="$2" +my_abis=`echo "($3)" | tr ',' '|'` +prefix="$4" +offset="$5" + +fileguard=_UAPI_ASM_POWERPC_`basename "$out" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( + printf "#ifndef %s\n" "${fileguard}" + printf "#define %s\n" "${fileguard}" + printf "\n" + + nxt=0 + while read nr abi name entry compat ; do + if [ -z "$offset" ]; then + printf "#define __NR_%s%s\t%s\n" \ + "${prefix}" "${name}" "${nr}" + else + printf "#define __NR_%s%s\t(%s + %s)\n" \ + "${prefix}" "${name}" "${offset}" "${nr}" + fi + nxt=$((nr+1)) + done + + printf "\n" + printf "#ifdef __KERNEL__\n" + printf "#define __NR_syscalls\t%s\n" "${nxt}" + printf "#endif\n" + printf "\n" + printf "#endif /* %s */" "${fileguard}" +) > "$out"
arch/powerpc/kernel/syscalls/syscalltbl.sh new file +36 -0
@@ -0,0 +1,36 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +in="$1" +out="$2" +my_abis=`echo "($3)" | tr ',' '|'` +my_abi="$4" +offset="$5" + +emit() { + t_nxt="$1" + t_nr="$2" + t_entry="$3" + + while [ $t_nxt -lt $t_nr ]; do + printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}" + t_nxt=$((t_nxt+1)) + done + printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}" +} + +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( + nxt=0 + if [ -z "$offset" ]; then + offset=0 + fi + + while read nr abi name entry compat ; do + if [ "$my_abi" = "c32" ] && [ ! -z "$compat" ]; then + emit $((nxt+offset)) $((nr+offset)) $compat + else + emit $((nxt+offset)) $((nr+offset)) $entry + fi + nxt=$((nr+1)) + done +) > "$out"
Signature · 1 line
1.9.1
PATCH v3 4/4 powerpc: generate uapi header and system call table files
In reply to Firoz KhanSystem call table generation script must be run to gener- ate unistd_32/64.h and syscall_table_32/64/c32/spu.h files. This patch will have changes which will invokes the script.
This patch will generate unistd_32/64.h and syscall_table- _32/64/c32/spu.h files by the syscall table generation script invoked by parisc/Makefile and the generated files against the removed files must be identical.
The generated uapi header file will be included in uapi/- asm/unistd.h and generated system call table header file will be included by kernel/systbl.S file.
--- arch/powerpc/Makefile | 3 + arch/powerpc/include/asm/Kbuild | 4 + arch/powerpc/include/asm/systbl.h | 395 ---------------------------- arch/powerpc/include/uapi/asm/Kbuild | 2 + arch/powerpc/include/uapi/asm/unistd.h | 392 +-------------------------- arch/powerpc/kernel/Makefile | 10 - arch/powerpc/kernel/systbl.S | 36 +-- arch/powerpc/kernel/systbl_chk.c | 60 ----- arch/powerpc/platforms/cell/spu_callbacks.c | 17 +- 9 files changed, 27 insertions(+), 892 deletions(-) delete mode 100644 arch/powerpc/include/asm/systbl.h delete mode 100644 arch/powerpc/kernel/systbl_chk.c
arch/powerpc/Makefile +3 -0
@@ -402,6 +402,9 @@ archclean: archprepare: checkbin +archheaders: + $(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all + ifdef CONFIG_STACKPROTECTOR prepare: stack_protector_prepare
arch/powerpc/include/asm/Kbuild +4 -0
@@ -1,3 +1,7 @@ +generated-y += syscall_table_32.h +generated-y += syscall_table_64.h +generated-y += syscall_table_c32.h +generated-y += syscall_table_spu.h generic-y += div64.h generic-y += export.h generic-y += irq_regs.h
arch/powerpc/include/asm/systbl.h deleted +0 -395
395 lines not on this page · raw message
arch/powerpc/include/uapi/asm/Kbuild +2 -0
@@ -1,6 +1,8 @@ # UAPI Header export list include include/uapi/asm-generic/Kbuild.asm +generated-y += unistd_32.h +generated-y += unistd_64.h generic-y += bpf_perf_event.h generic-y += param.h generic-y += poll.h
arch/powerpc/include/uapi/asm/unistd.h +2 -390
400 lines not on this page · raw message
arch/powerpc/kernel/Makefile +0 -10
@@ -160,16 +160,6 @@ extra-$(CONFIG_ALTIVEC) += vector.o extra-$(CONFIG_PPC64) += entry_64.o extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o -extra-y += systbl_chk.i -$(obj)/systbl.o: systbl_chk - -quiet_cmd_systbl_chk = CALL $< - cmd_systbl_chk = $(CONFIG_SHELL) $< $(obj)/systbl_chk.i - -PHONY += systbl_chk -systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i - $(call cmd,systbl_chk) - ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE $(obj)/built-in.a: prom_init_check
arch/powerpc/kernel/systbl.S +13 -23
@@ -16,28 +16,6 @@ #include <asm/ppc_asm.h> -#ifdef CONFIG_PPC64 -#define SYSCALL(func) .8byte DOTSYM(sys_##func),DOTSYM(sys_##func) -#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func),DOTSYM(compat_sys_##func) -#define PPC_SYS(func) .8byte DOTSYM(ppc_##func),DOTSYM(ppc_##func) -#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall) -#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func) -#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall) -#define SYSX(f, f3264, f32) .8byte DOTSYM(f),DOTSYM(f3264) -#else -#define SYSCALL(func) .long sys_##func -#define COMPAT_SYS(func) .long sys_##func -#define PPC_SYS(func) .long ppc_##func -#define OLDSYS(func) .long sys_##func -#define SYS32ONLY(func) .long sys_##func -#define PPC64ONLY(func) .long sys_ni_syscall -#define SYSX(f, f3264, f32) .long f32 -#endif -#define SYSCALL_SPU(func) SYSCALL(func) -#define COMPAT_SYS_SPU(func) COMPAT_SYS(func) -#define COMPAT_SPU_NEW(func) COMPAT_SYS(func) -#define SYSX_SPU(f, f3264, f32) SYSX(f, f3264, f32) - .section .rodata,"a" #ifdef CONFIG_PPC64
@@ -47,5 +25,17 @@ .globl sys_call_table sys_call_table: +#if defined CONFIG_PPC64 && defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry #define compat_sys_sigsuspend sys_sigsuspend -#include <asm/systbl.h> +#include <asm/syscall_table_c32.h> +#undef __SYSCALL +#elif defined CONFIG_PPC64 && !defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry +#include <asm/syscall_table_64.h> +#undef __SYSCALL +#else +#define __SYSCALL(nr, entry, nargs) .long entry +#include <asm/syscall_table_32.h> +#undef __SYSCALL +#endif
arch/powerpc/kernel/systbl_chk.c deleted +0 -60
60 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_callbacks.c +3 -14
@@ -34,20 +34,9 @@*/ static void *spu_syscall_table[] = { -#define SYSCALL(func) sys_ni_syscall, -#define COMPAT_SYS(func) sys_ni_syscall, -#define PPC_SYS(func) sys_ni_syscall, -#define OLDSYS(func) sys_ni_syscall, -#define SYS32ONLY(func) sys_ni_syscall, -#define PPC64ONLY(func) sys_ni_syscall, -#define SYSX(f, f3264, f32) sys_ni_syscall, - -#define SYSCALL_SPU(func) sys_##func, -#define COMPAT_SYS_SPU(func) sys_##func, -#define COMPAT_SPU_NEW(func) sys_##func, -#define SYSX_SPU(f, f3264, f32) f, - -#include <asm/systbl.h> +#define __SYSCALL(nr, entry, nargs) entry, +#include <asm/syscall_table_spu.h> +#undef __SYSCALL };long spu_sys_callback (struct spu_syscall_block *s)
Signature · 1 line
1.9.1
Arnd Bergmann
maintainerRe: [PATCH v3 4/4] powerpc: generate uapi header and system call table files
Quoted 10 lines
arch/powerpc/kernel/systbl.S +0
-0#ifdef CONFIG_PPC64@@ -47,5 +25,17 @@ .globl sys_call_table sys_call_table:
arch/powerpc/kernel/systbl.S line 36
Quoted 10 lines
arch/powerpc/kernel/systbl.S +8
-1+#if defined CONFIG_PPC64 && defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry #define compat_sys_sigsuspend sys_sigsuspend -#include <asm/systbl.h> +#include <asm/syscall_table_c32.h> +#undef __SYSCALL +#elif defined CONFIG_PPC64 && !defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry +#include <asm/syscall_table_64.h> +#undef __SYSCALL
This part looks wrong: where the old sys_call_table contained both the native and compat calls side by side, the new table contains only the compat versions (note that CONFIG_COMPAT is always set on PPC64). I think you copy-pasted this incorrectly from one of the other architectures that uses a different layout for the compat calls.
The way I think this could work best is if you add a preparation patch that splits out the 64-bit table into two separate ones (and make sure that works). After that, you can add your existing patch, rebased to use the two generated tables instead of the old-style tables. I'll follow up with an untested patch for illustration.
Arnd
Arnd Bergmann
maintainerPATCH 1/1 powerpc: split compat syscall table out from native table
PowerPC uses a syscall table with native and compat calls interleaved, which is a slightly simpler way to define two matching tables.
As we move to having the tables generated, that advantage is no longer important, but the interleaved table gets in the way of using the same scripts as on the other architectures.
Split out a new compat_sys_call_table symbol that contains all the compat calls, and leave the main table for the native calls, to more closely match the method we use everywhere else.
---
This is completely untested, it's just for illustration and to get comments about whether this is a good idea.
Firoz, can you try to get this working?
--- arch/powerpc/include/asm/syscall.h | 3 +-- arch/powerpc/kernel/entry_64.S | 7 ++++-- arch/powerpc/kernel/systbl.S | 37 ++++++++++++++++++++++++------ arch/powerpc/kernel/vdso.c | 7 ++++-- 4 files changed, 41 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/syscall.h +1 -2
@@ -18,9 +18,8 @@#include <linux/thread_info.h> /* ftrace syscalls requires exporting the sys_call_table */ -#ifdef CONFIG_FTRACE_SYSCALLS extern const unsigned long sys_call_table[]; -#endif /* CONFIG_FTRACE_SYSCALLS */ +extern const unsigned long compat_sys_call_table[];static inline int syscall_get_nr (struct task_struct *task,struct pt_regs *regs) {
arch/powerpc/kernel/entry_64.S +5 -2
@@ -54,6 +54,9 @@ SYS_CALL_TABLE: .tc sys_call_table[TC],sys_call_table +COMPAT_SYS_CALL_TABLE: + .tc compat_sys_call_table[TC],compat_sys_call_table + /* This value is used to mark exception frames on the stack. */ exception_marker: .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER
@@ -173,7 +176,7 @@ system_call: /* label this so stack traces look sane */ ld r11,SYS_CALL_TABLE@toc(2) andis. r10,r10,_TIF_32BIT@h beq 15f - addi r11,r11,8 /* use 32-bit syscall entries */ + ld r11,COMPAT_SYS_CALL_TABLE@toc(2) clrldi r3,r3,32 clrldi r4,r4,32 clrldi r5,r5,32
@@ -181,7 +184,7 @@ system_call: /* label this so stack traces look sane */ clrldi r7,r7,32 clrldi r8,r8,32 15: - slwi r0,r0,4 + slwi r0,r0,3 barrier_nospec_asm /*
arch/powerpc/kernel/systbl.S +30 -7
@@ -17,13 +17,13 @@ #include <asm/ppc_asm.h> #ifdef CONFIG_PPC64 -#define SYSCALL(func) .8byte DOTSYM(sys_##func),DOTSYM(sys_##func) -#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func),DOTSYM(compat_sys_##func) -#define PPC_SYS(func) .8byte DOTSYM(ppc_##func),DOTSYM(ppc_##func) -#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall) -#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func) -#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall) -#define SYSX(f, f3264, f32) .8byte DOTSYM(f),DOTSYM(f3264) +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f) #else #define SYSCALL(func) .long sys_##func #define COMPAT_SYS(func) .long sys_##func
@@ -48,3 +48,26 @@ sys_call_table: #include <asm/systbl.h> + +#undef SYSCALL +#undef COMPAT_SYS +#undef PPC_SYS +#undef OLDSYS +#undef SYS32ONLY +#undef PPC64ONLY +#undef SYSX + +#ifdef CONFIG_COMPAT +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(compat_sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(compat_sys_##func) +#define PPC64ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f3264) + +.globl compat_sys_call_table +compat_sys_call_table: + +#include <asm/systbl.h> +#endif
arch/powerpc/kernel/vdso.c +5 -2
@@ -671,15 +671,18 @@ static void __init vdso_setup_syscall_map(void) {unsigned int i;extern unsigned long *sys_call_table; +#ifdef CONFIG_PPC64 +extern unsigned long *compat_sys_call_table; +#endif extern unsigned long sys_ni_syscall;for (i =0 ; i < NR_syscalls; i++) {#ifdef CONFIG_PPC64 -if (sys_call_table[i*2 ] != sys_ni_syscall) +if (sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_64[i >>5 ] |=0x80000000UL >> (i &0x1f ); -if (sys_call_table[i*2 +1 ] != sys_ni_syscall) +if (compat_sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_32[i >>5 ] |=0x80000000UL >> (i &0x1f );#else /* CONFIG_PPC64 */
Signature · 1 line
2.18.0
Michael Ellerman
reviewerRe: [PATCH] powerpc: split compat syscall table out from native table
Quoted 7 lines · Arnd Bergmann
PowerPC uses a syscall table with native and compat calls interleaved, which is a slightly simpler way to define two matching tables.
As we move to having the tables generated, that advantage is no longer important, but the interleaved table gets in the way of using the same scripts as on the other architectures.
Quoted 8 lines
Split out a new
compat_sys_call_tablesymbol that contains all the compat calls, and leave the main table for the native calls, to more closely match the method we use everywhere else.Signed-off-by Arnd Bergmann <[email protected]>---
This is completely untested, it's just for illustration and to get comments about whether this is a good idea.
Seems like a good idea to me.
The code's not much more complicated, in fact it's probably clearer except for the extra macros.
It's more cache efficient too, though it probably doesn't really matter.
cheers
Quoted 134 lines
Firoz, can you try to get this working?
--- arch/powerpc/include/asm/syscall.h | 3 +-- arch/powerpc/kernel/entry_64.S | 7 ++++-- arch/powerpc/kernel/systbl.S | 37 ++++++++++++++++++++++++------ arch/powerpc/kernel/vdso.c | 7 ++++-- 4 files changed, 41 insertions(+), 13 deletions(-)arch/powerpc/include/asm/syscall.h +1
-2@@ -18,9 +18,8 @@#include <linux/thread_info.h> /* ftrace syscalls requires exporting the sys_call_table */ -#ifdef CONFIG_FTRACE_SYSCALLS extern const unsigned long sys_call_table[]; -#endif /* CONFIG_FTRACE_SYSCALLS */ +extern const unsigned long compat_sys_call_table[];static inline int syscall_get_nr (struct task_struct *task,struct pt_regs *regs) {arch/powerpc/kernel/entry_64.S +5
-2@@ -54,6 +54,9 @@ SYS_CALL_TABLE: .tc sys_call_table[TC],sys_call_table +COMPAT_SYS_CALL_TABLE: + .tc compat_sys_call_table[TC],compat_sys_call_table + /* This value is used to mark exception frames on the stack. */ exception_marker: .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER@@ -173,7 +176,7 @@ system_call: /* label this so stack traces look sane */ ld r11,SYS_CALL_TABLE@toc(2) andis. r10,r10,_TIF_32BIT@h beq 15f - addi r11,r11,8 /* use 32-bit syscall entries */ + ld r11,COMPAT_SYS_CALL_TABLE@toc(2) clrldi r3,r3,32 clrldi r4,r4,32 clrldi r5,r5,32@@ -181,7 +184,7 @@ system_call: /* label this so stack traces look sane */ clrldi r7,r7,32 clrldi r8,r8,32 15: - slwi r0,r0,4 + slwi r0,r0,3 barrier_nospec_asm /*arch/powerpc/kernel/systbl.S +30
-7@@ -17,13 +17,13 @@ #include <asm/ppc_asm.h> #ifdef CONFIG_PPC64 -#define SYSCALL(func) .8byte DOTSYM(sys_##func),DOTSYM(sys_##func) -#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func),DOTSYM(compat_sys_##func) -#define PPC_SYS(func) .8byte DOTSYM(ppc_##func),DOTSYM(ppc_##func) -#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall) -#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func) -#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall) -#define SYSX(f, f3264, f32) .8byte DOTSYM(f),DOTSYM(f3264) +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define PPC64ONLY(func) .8byte DOTSYM(ppc_##func) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f) #else #define SYSCALL(func) .long sys_##func #define COMPAT_SYS(func) .long sys_##func@@ -48,3 +48,26 @@ sys_call_table: #include <asm/systbl.h> + +#undef SYSCALL +#undef COMPAT_SYS +#undef PPC_SYS +#undef OLDSYS +#undef SYS32ONLY +#undef PPC64ONLY +#undef SYSX + +#ifdef CONFIG_COMPAT +#define SYSCALL(func) .8byte DOTSYM(sys_##func) +#define COMPAT_SYS(func) .8byte DOTSYM(compat_sys_##func) +#define PPC_SYS(func) .8byte DOTSYM(ppc_##func) +#define OLDSYS(func) .8byte DOTSYM(sys_ni_syscall) +#define SYS32ONLY(func) .8byte DOTSYM(compat_sys_##func) +#define PPC64ONLY(func) .8byte DOTSYM(sys_ni_syscall) +#define SYSX(f, f3264, f32) .8byte DOTSYM(f3264) + +.globl compat_sys_call_table +compat_sys_call_table: + +#include <asm/systbl.h> +#endifarch/powerpc/kernel/vdso.c +5
-2@@ -671,15 +671,18 @@ static void __init vdso_setup_syscall_map(void) {unsigned int i;extern unsigned long *sys_call_table; +#ifdef CONFIG_PPC64 +extern unsigned long *compat_sys_call_table; +#endif extern unsigned long sys_ni_syscall;for (i =0 ; i < NR_syscalls; i++) {#ifdef CONFIG_PPC64 -if (sys_call_table[i*2 ] != sys_ni_syscall) +if (sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_64[i >>5 ] |=0x80000000UL >> (i &0x1f ); -if (sys_call_table[i*2 +1 ] != sys_ni_syscall) +if (compat_sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_32[i >>5 ] |=0x80000000UL >> (i &0x1f );#else /* CONFIG_PPC64 */ Signature · 1 line
2.18.0
Arnd Bergmann
maintainerRe: [PATCH v3 4/4] powerpc: generate uapi header and system call table files
In reply to Arnd BergmannQuoted 29 lines · Arnd Bergmann
Quoted 11 lines
arch/powerpc/kernel/systbl.S +0
-0#ifdef CONFIG_PPC64@@ -47,5 +25,17 @@ .globl sys_call_table sys_call_table:arch/powerpc/kernel/systbl.S line 36
Quoted 10 lines
arch/powerpc/kernel/systbl.S +8
-1+#if defined CONFIG_PPC64 && defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry #define compat_sys_sigsuspend sys_sigsuspend -#include <asm/systbl.h> +#include <asm/syscall_table_c32.h> +#undef __SYSCALL +#elif defined CONFIG_PPC64 && !defined(CONFIG_COMPAT) +#define __SYSCALL(nr, entry, nargs) .8byte entry +#include <asm/syscall_table_64.h> +#undef __SYSCALLThis part looks wrong: where the old
sys_call_tablecontained both the native and compat calls side by side, the new table contains only the compat versions (note thatCONFIG_COMPATis always set on PPC64). I think you copy-pasted this incorrectly from one of the other architectures that uses a different layout for the compat calls.
Quoted 6 lines
The way I think this could work best is if you add a preparation patch that splits out the 64-bit table into two separate ones (and make sure that works). After that, you can add your existing patch, rebased to use the two generated tables instead of the old-style tables. I'll follow up with an untested patch for illustration.
One more thing I noticed while writing up that patch: you also need to use the DOTSYM() macro in __SYSCALL() to generate the correct symbol name for the old ELF ABI (when PPC64_ELF_ABI_v2 is not set).
Arnd
Quoted 89 lines · Firoz Khan
The purpose of this patch series is, we can easily add/modify/delete system call table support by cha- nging entry in syscall.tbl file instead of manually changing many files. The other goal is to unify the system call table generation support implementation across all the architectures.
The system call tables are in different format in all architecture. It will be difficult to manually add, modify or delete the system calls in the resp- ective files manually. To make it easy by keeping a script and which'll generate uapi header file and syscall table file.
syscall.tbl contains the list of available system calls along with system call number and correspond- ing entry point. Add a new system call in this arch- itecture will be possible by adding new entry in the syscall.tbl file.
Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.
- Compat entry name, if required.
- spu entry name, if required.ARM, s390 and x86 architecuture does exist the sim- ilar support. I leverage their implementation to come up with a generic solution.
I have done the same support for work for alpha, ia64, m68k, microblaze, mips, parisc, sh, sparc, and xtensa. Below mentioned git repository contains more details about the workflow.
https://github.com/frzkhn/system_call_table_generator/
Finally, this is the ground work to solve the Y2038 issue. We need to add two dozen of system calls to solve Y2038 issue. So this patch series will help to add new system calls easily by adding new entry in the syscall.tbl.
changes since v2:
- modified/optimized the syscall.tbl to avoid duplicate for the spu entries.
- updated thesyscalltbl.shto meet the above point.changes since v1:
- optimized/updated the syscall table generation scripts.
- fixed all mixed indentation issues in syscall.tbl.
- added "comments" in syscall_*.tbl.
- changed from generic-y to generated-y inKbuild.Firoz Khan (4):
powerpc: add__NR_syscallsalong withNR_syscalls
powerpc: move macro definition fromasm/systbl.h
powerpc: add system call table generation support
powerpc: generate uapi header and system call table filesarch/powerpc/Makefile | 3 + arch/powerpc/include/asm/Kbuild | 4 + arch/powerpc/include/asm/systbl.h | 396 -------------------------- arch/powerpc/include/asm/unistd.h | 3 +- arch/powerpc/include/uapi/asm/Kbuild | 2 + arch/powerpc/include/uapi/asm/unistd.h | 389 +------------------------ arch/powerpc/kernel/Makefile | 10 - arch/powerpc/kernel/syscalls/Makefile | 63 ++++ arch/powerpc/kernel/syscalls/syscall.tbl | 427 ++++++++++++++++++++++++++++ arch/powerpc/kernel/syscalls/syscallhdr.sh | 36 +++ arch/powerpc/kernel/syscalls/syscalltbl.sh | 36 +++ arch/powerpc/kernel/systbl.S | 37 +-- arch/powerpc/kernel/systbl_chk.c | 60 ---- arch/powerpc/platforms/cell/spu_callbacks.c | 17 +- 14 files changed, 591 insertions(+), 892 deletions(-) delete mode 100644 arch/powerpc/include/asm/systbl.h create mode 100644 arch/powerpc/kernel/syscalls/Makefile create mode 100644 arch/powerpc/kernel/syscalls/syscall.tbl create mode 100644 arch/powerpc/kernel/syscalls/syscallhdr.sh create mode 100644 arch/powerpc/kernel/syscalls/syscalltbl.sh delete mode 100644 arch/powerpc/kernel/systbl_chk.c--
1.9.1