| Message ID | 20260828-tonyk-syscall_table-v6-0-fdd358456cf1@igalia.com |
|---|---|
| Headers | show |
| Series | syscalls: Add a shared table for all archs | expand |
On Sat, Aug 29, 2026, at 01:19, André Almeida wrote: > While implementing a new syscall, we need to wire up it's number to the arch > table. Since syscall number 403, all architectures are on sync regarding the > number (except alpha), which make things a lot easier but more repetitive as > well. Have a look at commit b36d4b6aa88 ("arch: hookup listns() system call"), > with 15 lines of mostly: > > +470 common listns sys_listns > > There's already a "common" table shared with a bunch of archs at > `scripts/syscall.tbl`, but due to historical reasons some archs will never be > able to move to this table and share all the numbers. > > The generic table starts from 403 (clock_gettime64), the first common syscall. > > I've compile tested for arm32, arm64, s390, mips, sparc and alpha by comparing > the syscalls_*.h and unistd_*.h files generated before and after this patchset. > For most of cases the files are identical, for the few cases that they are not, > there's a note in the commit explaining why they are equivalent. I've tried merging these for the asm-generic tree now, and would like to send them for 7.4. Unfortunately, the build bot flagged problems on mips, see the patch below for my workarounds=, but I think we have to improve that still and didn't just fold it into your patch. As you took out the dependencies on the syscall_*.tbl files, the output does not get rebuilt if changes are made to the table, and I have not come up with a good solution for mips. My hack just adds both input files to all outputs, which works but is not technically correct. The rt_sigtimedwait and ustat entries had a typo that caused a link error, but I did not check if there were any additional mistakes that caused incorrect output data without causing a link failure. Arnd diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile index aaa5443ea906..51b9939ecff0 100644 --- a/arch/mips/kernel/syscalls/Makefile +++ b/arch/mips/kernel/syscalls/Makefile @@ -40,10 +40,10 @@ src_n32 := $(src)/syscall_n.tbl src_n64 := $(src)/syscall_n.tbl src_o32 := $(src)/syscall_o32.tbl -$(kapi)/unistd_nr_%.h: $(systbl_common) $(sysnr) FORCE +$(kapi)/unistd_nr_%.h: $(src_o32) $(src_n64) $(systbl_common) $(sysnr) FORCE $(call if_changed,sysnr) -$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) FORCE +$(kapi)/syscall_table_%.h: $(src_o32) $(src_n64) $(systbl) $(systbl_common) FORCE $(call if_changed,systbl) uapisyshdr-y += unistd_n32.h \ diff --git a/arch/mips/kernel/syscalls/syscall_n.tbl b/arch/mips/kernel/syscalls/syscall_n.tbl index e3d278f715b7..84c35c1f0c3e 100644 --- a/arch/mips/kernel/syscalls/syscall_n.tbl +++ b/arch/mips/kernel/syscalls/syscall_n.tbl @@ -133,14 +133,14 @@ 123 common capget sys_capget 124 common capset sys_capset 125 common rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending -126 common rt_sigtimedwait sys_rt_sigtimedwait_time compat_sys_rt_sigtimedwait_time32 +126 common rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait_time32 127 common rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo 128 common rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend 129 common sigaltstack sys_sigaltstack compat_sys_sigaltstack 130 common utime sys_utime sys_utime32 131 common mknod sys_mknod 132 common personality sys_personality sys_32_personality -133 common ustat sys_usta compat_sys_usta +133 common ustat sys_ustat compat_sys_ustat 134 common statfs sys_statfs compat_sys_statfs 135 common fstatfs sys_fstatfs compat_sys_fstatfs 136 common sysfs sys_sysfs
Em 15/09/2026 04:45, Arnd Bergmann escreveu: > On Sat, Aug 29, 2026, at 01:19, André Almeida wrote: >> While implementing a new syscall, we need to wire up it's number to the arch >> table. Since syscall number 403, all architectures are on sync regarding the >> number (except alpha), which make things a lot easier but more repetitive as >> well. Have a look at commit b36d4b6aa88 ("arch: hookup listns() system call"), >> with 15 lines of mostly: >> >> +470 common listns sys_listns >> >> There's already a "common" table shared with a bunch of archs at >> `scripts/syscall.tbl`, but due to historical reasons some archs will never be >> able to move to this table and share all the numbers. >> >> The generic table starts from 403 (clock_gettime64), the first common syscall. >> >> I've compile tested for arm32, arm64, s390, mips, sparc and alpha by comparing >> the syscalls_*.h and unistd_*.h files generated before and after this patchset. >> For most of cases the files are identical, for the few cases that they are not, >> there's a note in the commit explaining why they are equivalent. > > I've tried merging these for the asm-generic tree now, and would like to > send them for 7.4. > > Unfortunately, the build bot flagged problems on mips, see the patch below > for my workarounds=, but I think we have to improve that still and didn't > just fold it into your patch. > > As you took out the dependencies on the syscall_*.tbl files, the > output does not get rebuilt if changes are made to the table, and I > have not come up with a good solution for mips. My hack just adds both > input files to all outputs, which works but is not technically correct. > Thanks for testing! I believe I found a simple solution for this. I modified syscall_o32.tbl and can confirm it triggers a rebuild now: diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile index aaa5443ea906..9e31d1ce5015 100644 --- a/arch/mips/kernel/syscalls/Makefile +++ b/arch/mips/kernel/syscalls/Makefile @@ -40,10 +40,10 @@ src_n32 := $(src)/syscall_n.tbl src_n64 := $(src)/syscall_n.tbl src_o32 := $(src)/syscall_o32.tbl -$(kapi)/unistd_nr_%.h: $(systbl_common) $(sysnr) FORCE +$(kapi)/unistd_nr_%.h: $(systbl_common) $(src_%) $(sysnr) FORCE $(call if_changed,sysnr) -$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) FORCE +$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) $(src_%) FORCE $(call if_changed,systbl) uapisyshdr-y += unistd_n32.h \ > The rt_sigtimedwait and ustat entries had a typo that caused a link > error, but I did not check if there were any additional mistakes that > caused incorrect output data without causing a link failure. > Ops, my bad. I had another round comparing the tables, and I found another case that needed a fix: diff --git a/arch/mips/kernel/syscalls/syscall_n.tbl b/arch/mips/kernel/syscalls/syscall_n.tbl index e3d278f715b7..1882527053af 100644 --- a/arch/mips/kernel/syscalls/syscall_n.tbl +++ b/arch/mips/kernel/syscalls/syscall_n.tbl @@ -43,7 +43,7 @@ 33 common pause sys_pause 34 common nanosleep sys_nanosleep sys_nanosleep_time32 35 common getitimer sys_getitimer compat_sys_getitimer -36 common setitimer sys_setitimer compat_setitimer +36 common setitimer sys_setitimer compat_sys_setitimer 37 common alarm sys_alarm 38 common getpid sys_getpid 39 common sendfile sys_sendfile64 compat_sys_sendfile Let me know if both diffs look good to you, and then I can send a v7. Thanks! > Arnd > > diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile > index aaa5443ea906..51b9939ecff0 100644 > --- a/arch/mips/kernel/syscalls/Makefile > +++ b/arch/mips/kernel/syscalls/Makefile > @@ -40,10 +40,10 @@ src_n32 := $(src)/syscall_n.tbl > src_n64 := $(src)/syscall_n.tbl > src_o32 := $(src)/syscall_o32.tbl > > -$(kapi)/unistd_nr_%.h: $(systbl_common) $(sysnr) FORCE > +$(kapi)/unistd_nr_%.h: $(src_o32) $(src_n64) $(systbl_common) $(sysnr) FORCE > $(call if_changed,sysnr) > > -$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) FORCE > +$(kapi)/syscall_table_%.h: $(src_o32) $(src_n64) $(systbl) $(systbl_common) FORCE > $(call if_changed,systbl) > > uapisyshdr-y += unistd_n32.h \ > diff --git a/arch/mips/kernel/syscalls/syscall_n.tbl b/arch/mips/kernel/syscalls/syscall_n.tbl > index e3d278f715b7..84c35c1f0c3e 100644 > --- a/arch/mips/kernel/syscalls/syscall_n.tbl > +++ b/arch/mips/kernel/syscalls/syscall_n.tbl > @@ -133,14 +133,14 @@ > 123 common capget sys_capget > 124 common capset sys_capset > 125 common rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending > -126 common rt_sigtimedwait sys_rt_sigtimedwait_time compat_sys_rt_sigtimedwait_time32 > +126 common rt_sigtimedwait sys_rt_sigtimedwait compat_sys_rt_sigtimedwait_time32 > 127 common rt_sigqueueinfo sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo > 128 common rt_sigsuspend sys_rt_sigsuspend compat_sys_rt_sigsuspend > 129 common sigaltstack sys_sigaltstack compat_sys_sigaltstack > 130 common utime sys_utime sys_utime32 > 131 common mknod sys_mknod > 132 common personality sys_personality sys_32_personality > -133 common ustat sys_usta compat_sys_usta > +133 common ustat sys_ustat compat_sys_ustat > 134 common statfs sys_statfs compat_sys_statfs > 135 common fstatfs sys_fstatfs compat_sys_fstatfs > 136 common sysfs sys_sysfs
On Thu, Sep 17, 2026, at 00:19, André Almeida wrote: > Em 15/09/2026 04:45, Arnd Bergmann escreveu: >> On Sat, Aug 29, 2026, at 01:19, André Almeida wrote: > > Thanks for testing! I believe I found a simple solution for this. I > modified syscall_o32.tbl and can confirm it triggers a rebuild now: > > diff --git a/arch/mips/kernel/syscalls/Makefile > b/arch/mips/kernel/syscalls/Makefile > index aaa5443ea906..9e31d1ce5015 100644 > --- a/arch/mips/kernel/syscalls/Makefile > +++ b/arch/mips/kernel/syscalls/Makefile > @@ -40,10 +40,10 @@ src_n32 := $(src)/syscall_n.tbl > src_n64 := $(src)/syscall_n.tbl > src_o32 := $(src)/syscall_o32.tbl > > -$(kapi)/unistd_nr_%.h: $(systbl_common) $(sysnr) FORCE > +$(kapi)/unistd_nr_%.h: $(systbl_common) $(src_%) $(sysnr) FORCE > $(call if_changed,sysnr) > > -$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) FORCE > +$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) $(src_%) FORCE > $(call if_changed,systbl) I had tried the same thing already, but in my testing, it did not rebuild after changing the syscall_n.tbl file, only the syscall_o32.tbl file. Can you verify that your change rebuilds all nine files in the correct cases? >> The rt_sigtimedwait and ustat entries had a typo that caused a link >> error, but I did not check if there were any additional mistakes that >> caused incorrect output data without causing a link failure. >> > > Ops, my bad. I had another round comparing the tables, and I found > another case that needed a fix: > > diff --git a/arch/mips/kernel/syscalls/syscall_n.tbl > b/arch/mips/kernel/syscalls/syscall_n.tbl > index e3d278f715b7..1882527053af 100644 > --- a/arch/mips/kernel/syscalls/syscall_n.tbl > +++ b/arch/mips/kernel/syscalls/syscall_n.tbl > @@ -43,7 +43,7 @@ > 33 common pause sys_pause > 34 common nanosleep sys_nanosleep > sys_nanosleep_time32 > 35 common getitimer sys_getitimer > compat_sys_getitimer > -36 common setitimer sys_setitimer > compat_setitimer > +36 common setitimer sys_setitimer > compat_sys_setitimer > 37 common alarm sys_alarm > 38 common getpid sys_getpid > 39 common sendfile sys_sendfile64 > compat_sys_sendfile Looks good, thanks for checking this one. Arnd
Em 17/09/2026 02:55, Arnd Bergmann escreveu: > On Thu, Sep 17, 2026, at 00:19, André Almeida wrote: >> Em 15/09/2026 04:45, Arnd Bergmann escreveu: >>> On Sat, Aug 29, 2026, at 01:19, André Almeida wrote: >> >> Thanks for testing! I believe I found a simple solution for this. I >> modified syscall_o32.tbl and can confirm it triggers a rebuild now: >> >> diff --git a/arch/mips/kernel/syscalls/Makefile >> b/arch/mips/kernel/syscalls/Makefile >> index aaa5443ea906..9e31d1ce5015 100644 >> --- a/arch/mips/kernel/syscalls/Makefile >> +++ b/arch/mips/kernel/syscalls/Makefile >> @@ -40,10 +40,10 @@ src_n32 := $(src)/syscall_n.tbl >> src_n64 := $(src)/syscall_n.tbl >> src_o32 := $(src)/syscall_o32.tbl >> >> -$(kapi)/unistd_nr_%.h: $(systbl_common) $(sysnr) FORCE >> +$(kapi)/unistd_nr_%.h: $(systbl_common) $(src_%) $(sysnr) FORCE >> $(call if_changed,sysnr) >> >> -$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) FORCE >> +$(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) $(src_%) FORCE >> $(call if_changed,systbl) > > I had tried the same thing already, but in my testing, it did > not rebuild after changing the syscall_n.tbl file, only the > syscall_o32.tbl file. Can you verify that your change rebuilds > all nine files in the correct cases? > After a more careful look, I have found out a couple of issues: - The first one, the one that the build bot originally warned as about this outdated rule: $(uapi)/unistd_%.h: $(src)/syscall_%.tbl $(syshdr) FORCE $(call if_changed,syshdr) $(src)/syscall_%.tbl doesn't make anymore for n32 and n64, and needed to be updated. - Secondly, $(src_%) doesn't work as I expected. % only works like this for files (like syscall_%.tbl). For variables, the correct form is $(src_$*). Now the pattern matching started working and generating $(src_n32), $(src_n64), ... - Finally, this wasn't enough either. Due to how make works[1], the variable was being generated but it wasn't being evaluated. So I had to add the .SECONDEXPANSION target to finally make it work, resulting on those rules: .SECONDEXPANSION: $(uapi)/unistd_%.h: $(systbl_common) $$(src_$$*) $(syshdr) FORCE $(call if_changed,syshdr) $(kapi)/unistd_nr_%.h: $(systbl_common) $$(src_$$*) $(sysnr) FORCE $(call if_changed,sysnr) $(kapi)/syscall_table_%.h: $(systbl) $(systbl_common) $$(src_$$*) FORCE $(call if_changed,systbl) And now, testing updating the tables: $ touch arch/mips/kernel/syscalls/syscall_o32.tbl $ make -j31 W=1 O=mips ARCH=mips LLVM=1 prepare | grep SYS SYSHDR arch/mips/include/generated/uapi/asm/unistd_o32.h SYSTBL arch/mips/include/generated/asm/syscall_table_o32.h SYSNR arch/mips/include/generated/asm/unistd_nr_o32.h $ touch arch/mips/kernel/syscalls/syscall_n.tb $ make -j31 W=1 O=mips ARCH=mips LLVM=1 prepare | grep SYS SYSHDR arch/mips/include/generated/uapi/asm/unistd_n32.h SYSHDR arch/mips/include/generated/uapi/asm/unistd_n64.h SYSTBL arch/mips/include/generated/asm/syscall_table_n32.h SYSTBL arch/mips/include/generated/asm/syscall_table_n64.h SYSNR arch/mips/include/generated/asm/unistd_nr_n32.h SYSNR arch/mips/include/generated/asm/unistd_nr_n64.h $ touch scripts/syscall_common.tbl $ make -j31 W=1 O=mips ARCH=mips LLVM=1 prepare | grep SYS SYSHDR arch/mips/include/generated/uapi/asm/unistd_n32.h SYSHDR arch/mips/include/generated/uapi/asm/unistd_n64.h SYSHDR arch/mips/include/generated/uapi/asm/unistd_o32.h SYSTBL arch/mips/include/generated/asm/syscall_table_n32.h SYSTBL arch/mips/include/generated/asm/syscall_table_n64.h SYSTBL arch/mips/include/generated/asm/syscall_table_o32.h SYSNR arch/mips/include/generated/asm/unistd_nr_n32.h SYSNR arch/mips/include/generated/asm/unistd_nr_n64.h SYSNR arch/mips/include/generated/asm/unistd_nr_o32.h I will send a v7 with this changes for mips. Thanks! [1] https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
While implementing a new syscall, we need to wire up it's number to the arch table. Since syscall number 403, all architectures are on sync regarding the number (except alpha), which make things a lot easier but more repetitive as well. Have a look at commit b36d4b6aa88 ("arch: hookup listns() system call"), with 15 lines of mostly: +470 common listns sys_listns There's already a "common" table shared with a bunch of archs at `scripts/syscall.tbl`, but due to historical reasons some archs will never be able to move to this table and share all the numbers. The generic table starts from 403 (clock_gettime64), the first common syscall. I've compile tested for arm32, arm64, s390, mips, sparc and alpha by comparing the syscalls_*.h and unistd_*.h files generated before and after this patchset. For most of cases the files are identical, for the few cases that they are not, there's a note in the commit explaining why they are equivalent. Thanks! André Changes in v6: - Rebased on top of 7.3-rc0: new syscall fchroot() - Fix compliance with POSIX shells - Add $(syscalltbl_common) to the prereq build files, so the build is triggered if the common table changes - v5: https://patch.msgid.link/20260812-tonyk-syscall_table-v5-0-3d383927c609@igalia.com Changes in v5: - Add archs lists to Cc - alpha: Change custom alpha_syscall to __syscall - mips: Use "common" for all ABI tables - mips: Kept it as a single table for n32/n64 - Fix bug introduced by mixing --offset and --compat-offset - v4: https://patch.msgid.link/20260812-tonyk-syscall_table-v4-0-748d0229ad40@igalia.com Changes in v4: - Replace cln3 with clone3 in the ABIs - mips: Get rid of custom mips ABIs (o32, n32, n64) and use 32 and 64 - mips: Unify n32 and n64 tables - Add alpha to the syscall party, along with it's adaptations - Remove --no-compat option and define SYSCALL_WITH_COMPAT() macro for archs that need it - v3: https://patch.msgid.link/20260807-tonyk-syscall_table-v3-0-7c45a23c50b5@igalia.com Changes in v3: - Removed x86 for now, let's wait till x32 is dropped - Added much more archs - v2: https://patch.msgid.link/20260727-tonyk-syscall_table-v2-0-95d4f1ee471f@igalia.com Changes in v2: - Managed to move to the real first common syscall: 403 (clock_gettime64) - Added -no-compat option to be used with x86_64 - v1: https://patch.msgid.link/20260724-tonyk-syscall_table-v1-0-9c53188423da@igalia.com --- André Almeida (13): syscalls: Make --abis parsing more robust syscalls: Create unified partial table for all archs scripts/syscall.tbl: Use the common table arm: Use the common syscall table s390: Use the common syscall table sparc: Use the common syscall table mips: Remove duplicated syscallnr.sh mips: Get rid of custom mips ABIs for syscall tables mips: Use the common syscall table syscalls: Add an option for offsetting the common table alpha: Define entry point for set_mempolicy_home_node syscall alpha: Remove alpha_ prefix from custom syscall entries alpha: Use the common syscall table arch/alpha/kernel/entry.S | 8 +- arch/alpha/kernel/syscalls/Makefile | 14 +- arch/alpha/kernel/syscalls/syscall.tbl | 55 +- arch/alpha/kernel/systbls.S | 1 + arch/arm/tools/Makefile | 14 +- arch/arm/tools/syscall.tbl | 69 --- arch/arm64/tools/syscall_32.tbl | 69 --- arch/mips/kernel/scall64-n32.S | 1 + arch/mips/kernel/scall64-n64.S | 2 + arch/mips/kernel/syscalls/Makefile | 30 +- arch/mips/kernel/syscalls/syscall_n.tbl | 464 +++++++++++++++++ arch/mips/kernel/syscalls/syscall_n32.tbl | 413 --------------- arch/mips/kernel/syscalls/syscall_n64.tbl | 389 -------------- arch/mips/kernel/syscalls/syscall_o32.tbl | 827 ++++++++++++++---------------- arch/mips/kernel/syscalls/syscallnr.sh | 26 - arch/s390/kernel/syscall.c | 2 + arch/s390/kernel/syscalls/Makefile | 12 +- arch/s390/kernel/syscalls/syscall.tbl | 49 -- arch/sparc/kernel/syscalls/Makefile | 12 +- arch/sparc/kernel/syscalls/syscall.tbl | 69 --- scripts/Makefile.asm-headers | 15 +- scripts/syscall.tbl | 69 --- scripts/syscall_common.tbl | 84 +++ scripts/syscallhdr.sh | 83 ++- scripts/syscalltbl.sh | 50 +- 25 files changed, 1111 insertions(+), 1716 deletions(-) --- base-commit: 548e7bcd0c5460ddcbca9600cea603ebeebf4da7 change-id: 20260724-tonyk-syscall_table-928bbb1b26bb Best regards, -- André Almeida <andrealmeid@igalia.com>