Skip to content

Commit 6218d0f

Browse files
masahir0yKAGA-KOKO
authored andcommitted
x86/syscalls: Switch to generic syscalltbl.sh
Many architectures duplicate similar shell scripts. Convert x86 and UML to use scripts/syscalltbl.sh. The generic script generates seperate headers for x86/64 and x86/x32 syscalls, while the x86 specific script coalesced them into one. Adjust the code accordingly. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20210517073815.97426-3-masahiroy@kernel.org
1 parent 2e958a8 commit 6218d0f

8 files changed

Lines changed: 34 additions & 76 deletions

File tree

arch/x86/entry/syscall_32.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
#include <asm/unistd.h>
99
#include <asm/syscall.h>
1010

11-
#define __SYSCALL_I386(nr, sym) extern long __ia32_##sym(const struct pt_regs *);
11+
#ifdef CONFIG_IA32_EMULATION
12+
#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat)
13+
#else
14+
#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
15+
#endif
16+
17+
#define __SYSCALL(nr, sym) extern long __ia32_##sym(const struct pt_regs *);
1218

1319
#include <asm/syscalls_32.h>
14-
#undef __SYSCALL_I386
20+
#undef __SYSCALL
1521

16-
#define __SYSCALL_I386(nr, sym) [nr] = __ia32_##sym,
22+
#define __SYSCALL(nr, sym) [nr] = __ia32_##sym,
1723

1824
__visible const sys_call_ptr_t ia32_sys_call_table[__NR_ia32_syscall_max+1] = {
1925
/*

arch/x86/entry/syscall_64.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
#include <asm/unistd.h>
99
#include <asm/syscall.h>
1010

11-
#define __SYSCALL_X32(nr, sym)
12-
#define __SYSCALL_COMMON(nr, sym) __SYSCALL_64(nr, sym)
13-
14-
#define __SYSCALL_64(nr, sym) extern long __x64_##sym(const struct pt_regs *);
11+
#define __SYSCALL(nr, sym) extern long __x64_##sym(const struct pt_regs *);
1512
#include <asm/syscalls_64.h>
16-
#undef __SYSCALL_64
13+
#undef __SYSCALL
1714

18-
#define __SYSCALL_64(nr, sym) [nr] = __x64_##sym,
15+
#define __SYSCALL(nr, sym) [nr] = __x64_##sym,
1916

2017
asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
2118
/*

arch/x86/entry/syscall_x32.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@
88
#include <asm/unistd.h>
99
#include <asm/syscall.h>
1010

11-
#define __SYSCALL_64(nr, sym)
11+
#define __SYSCALL(nr, sym) extern long __x64_##sym(const struct pt_regs *);
12+
#include <asm/syscalls_x32.h>
13+
#undef __SYSCALL
1214

13-
#define __SYSCALL_X32(nr, sym) extern long __x64_##sym(const struct pt_regs *);
14-
#define __SYSCALL_COMMON(nr, sym) extern long __x64_##sym(const struct pt_regs *);
15-
#include <asm/syscalls_64.h>
16-
#undef __SYSCALL_X32
17-
#undef __SYSCALL_COMMON
18-
19-
#define __SYSCALL_X32(nr, sym) [nr] = __x64_##sym,
20-
#define __SYSCALL_COMMON(nr, sym) [nr] = __x64_##sym,
15+
#define __SYSCALL(nr, sym) [nr] = __x64_##sym,
2116

2217
asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_x32_syscall_max+1] = {
2318
/*
2419
* Smells like a compiler bug -- it doesn't work
2520
* when the & below is removed.
2621
*/
2722
[0 ... __NR_x32_syscall_max] = &__x64_sys_ni_syscall,
28-
#include <asm/syscalls_64.h>
23+
#include <asm/syscalls_x32.h>
2924
};

arch/x86/entry/syscalls/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ syscall32 := $(src)/syscall_32.tbl
1010
syscall64 := $(src)/syscall_64.tbl
1111

1212
syshdr := $(srctree)/$(src)/syscallhdr.sh
13-
systbl := $(srctree)/$(src)/syscalltbl.sh
13+
systbl := $(srctree)/scripts/syscalltbl.sh
1414

1515
quiet_cmd_syshdr = SYSHDR $@
1616
cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \
1717
'$(syshdr_abi_$(basetarget))' \
1818
'$(syshdr_pfx_$(basetarget))' \
1919
'$(syshdr_offset_$(basetarget))'
2020
quiet_cmd_systbl = SYSTBL $@
21-
cmd_systbl = $(CONFIG_SHELL) '$(systbl)' $< $@
21+
cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@
2222

2323
quiet_cmd_hypercalls = HYPERCALLS $@
2424
cmd_hypercalls = $(CONFIG_SHELL) '$<' $@ $(filter-out $<, $(real-prereqs))
@@ -46,10 +46,15 @@ syshdr_pfx_unistd_64_x32 := x32_
4646
$(out)/unistd_64_x32.h: $(syscall64) $(syshdr) FORCE
4747
$(call if_changed,syshdr)
4848

49+
$(out)/syscalls_32.h: abis := i386
4950
$(out)/syscalls_32.h: $(syscall32) $(systbl) FORCE
5051
$(call if_changed,systbl)
52+
$(out)/syscalls_64.h: abis := common,64
5153
$(out)/syscalls_64.h: $(syscall64) $(systbl) FORCE
5254
$(call if_changed,systbl)
55+
$(out)/syscalls_x32.h: abis := common,x32
56+
$(out)/syscalls_x32.h: $(syscall64) $(systbl) FORCE
57+
$(call if_changed,systbl)
5358

5459
$(out)/xen-hypercalls.h: $(srctree)/scripts/xen-hypercalls.sh FORCE
5560
$(call if_changed,hypercalls)
@@ -60,6 +65,7 @@ uapisyshdr-y += unistd_32.h unistd_64.h unistd_x32.h
6065
syshdr-y += syscalls_32.h
6166
syshdr-$(CONFIG_X86_64) += unistd_32_ia32.h unistd_64_x32.h
6267
syshdr-$(CONFIG_X86_64) += syscalls_64.h
68+
syshdr-$(CONFIG_X86_X32) += syscalls_x32.h
6369
syshdr-$(CONFIG_XEN) += xen-hypercalls.h
6470

6571
uapisyshdr-y := $(addprefix $(uapi)/, $(uapisyshdr-y))

arch/x86/entry/syscalls/syscalltbl.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

arch/x86/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
generated-y += syscalls_32.h
55
generated-y += syscalls_64.h
6+
generated-y += syscalls_x32.h
67
generated-y += unistd_32_ia32.h
78
generated-y += unistd_64_x32.h
89
generated-y += xen-hypercalls.h

arch/x86/um/sys_call_table_32.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626

2727
#define old_mmap sys_old_mmap
2828

29-
#define __SYSCALL_I386(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;
29+
#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
30+
31+
#define __SYSCALL(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
3032
#include <asm/syscalls_32.h>
3133

32-
#undef __SYSCALL_I386
33-
#define __SYSCALL_I386(nr, sym) [ nr ] = sym,
34+
#undef __SYSCALL
35+
#define __SYSCALL(nr, sym) [ nr ] = sym,
3436

3537
extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
3638

arch/x86/um/sys_call_table_64.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@
3636
#define stub_execveat sys_execveat
3737
#define stub_rt_sigreturn sys_rt_sigreturn
3838

39-
#define __SYSCALL_X32(nr, sym)
40-
#define __SYSCALL_COMMON(nr, sym) __SYSCALL_64(nr, sym)
41-
42-
#define __SYSCALL_64(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;
39+
#define __SYSCALL(nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
4340
#include <asm/syscalls_64.h>
4441

45-
#undef __SYSCALL_64
46-
#define __SYSCALL_64(nr, sym) [ nr ] = sym,
42+
#undef __SYSCALL
43+
#define __SYSCALL(nr, sym) [ nr ] = sym,
4744

4845
extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
4946

0 commit comments

Comments
 (0)