Skip to contentSkip to conversation

arch: convert everything to syscall.tbl

PATCH In review Arnd Bergmann 10 participants 38 messages Jul 4, 2024 – Jul 23, 2024

Subsystems (26)
Arm (32-bit) x86 PowerPC Kbuild +22 more subsystems
lore
Share & tools
lore
#0 lore raw

cover arch: convert everything to syscall.tbl

From: Arnd Bergmann <[email protected]>

There are eight architectures using include/uapi/asm-generic/unistd.h, which is still in an old format and not easily parsed by scripts. In addition, arm64 uses the old format for the 32-bit arm compat syscalls, despite them using the modern syscall.tbl format for the native calls.

As part of a larger cleanup, this converts all of them to use the new format with a shared file. I was planning to post this earlier, but ended up fixing up any system calls that have mismatched calling conventions between kernel and userspace first, as that seemed more important.

I originally tried adding the same arch/*/kernel/syscalls/Makefile as used on the other architectures, but ended up simplifying this in the process to use a single set of Makefile rules in scripts/Makefile.asm-headers, which in turn requires a few cleanups to arch/*/include/asm/Kbuild files.

Another prerequisite included in here is to make sys_clone3 get provided on all architectures, though it remains broken and returns -ENOSYS on hexagon, nios2, sh and sparc. To preserve the compile-time warning, I added an explicit #warning for those that are marked broken.

Once we have the new table format in place everywhere, additional improvements I have planned will be much easier, including:

- generating machine-readable syscall API descriptions for each syscall on each architecture

- type checking to ensure that the in-kernel prototype matches what userspace tools see

- unifying the last common bits of all tables so that new syscalls only need to get added in one place

- generate human-readable wrappers for native and compat syscalls on all architectures to replace the SYSCALL_DEFINEx() macros.

Arnd

Arnd Bergmann (17):
syscalls: add generic scripts/syscall.tbl
csky: drop asm/gpio.h wrapper
um: don't generate asm/bpf_perf_event.h
loongarch: avoid generating extra header files
kbuild: verify asm-generic header list
kbuild: add syscall table generation to scripts/Makefile.asm-headers
clone3: drop __ARCH_WANT_SYS_CLONE3 macro
arc: convert to generic syscall table
arm64: convert unistd_32.h to syscall.tbl format
arm64: generate 64-bit syscall.tbl
arm64: rework compat syscall macros
csky: convert to generic syscall table
hexagon: use new system call table
loongarch: convert to generic syscall table
nios2: convert to generic syscall table
openrisc: convert to generic syscall table
riscv: convert to generic syscall table

 Makefile                                      |   2 +-
 arch/alpha/include/asm/unistd.h               |   1 +
 arch/arc/include/asm/Kbuild                   |   2 +
 arch/arc/include/asm/unistd.h                 |  14 +
 arch/arc/include/uapi/asm/Kbuild              |   2 +
 arch/arc/include/uapi/asm/unistd.h            |  44 +-
 arch/arc/kernel/Makefile.syscalls             |   3 +
 arch/arc/kernel/sys.c                         |   5 +-
 arch/arm/include/asm/unistd.h                 |   1 -
 arch/arm64/include/asm/Kbuild                 |   8 +
 arch/arm64/include/asm/seccomp.h              |  13 +-
 arch/arm64/include/asm/unistd.h               |  22 +-
 arch/arm64/include/asm/unistd32.h             | 939 +-----------------
 .../include/asm/vdso/compat_gettimeofday.h    |  12 +-
 arch/arm64/include/uapi/asm/Kbuild            |   1 +
 arch/arm64/include/uapi/asm/unistd.h          |  25 +-
 arch/arm64/kernel/Makefile.syscalls           |   6 +
 arch/arm64/kernel/signal32.c                  |   2 +-
 arch/arm64/kernel/sigreturn32.S               |  18 +-
 arch/arm64/kernel/sys.c                       |   6 +-
 arch/arm64/kernel/sys32.c                     |  17 +-
 arch/arm64/kernel/syscall.c                   |   3 +-
 arch/arm64/tools/Makefile                     |   6 +-
 arch/arm64/tools/syscall_32.tbl               | 476 +++++++++
 arch/arm64/tools/syscall_64.tbl               |   1 +
 arch/csky/include/asm/Kbuild                  |   3 +-
 arch/csky/include/asm/unistd.h                |   3 +
 arch/csky/include/uapi/asm/Kbuild             |   2 +
 arch/csky/include/uapi/asm/unistd.h           |  15 +-
 arch/csky/kernel/Makefile.syscalls            |   4 +
 arch/csky/kernel/syscall_table.c              |   4 +-
 arch/hexagon/include/asm/Kbuild               |   2 +
 arch/hexagon/include/asm/unistd.h             |  10 +
 arch/hexagon/include/uapi/asm/Kbuild          |   2 +
 arch/hexagon/include/uapi/asm/unistd.h        |  13 +-
 arch/hexagon/kernel/Makefile.syscalls         |   3 +
 arch/hexagon/kernel/syscalltab.c              |   8 +-
 arch/loongarch/include/asm/Kbuild             |  17 +-
 arch/loongarch/include/asm/unistd.h           |   2 +
 arch/loongarch/include/uapi/asm/Kbuild        |   2 +
 arch/loongarch/include/uapi/asm/unistd.h      |   4 +-
 arch/loongarch/kernel/Makefile.syscalls       |   4 +
 arch/loongarch/kernel/syscall.c               |   3 +-
 arch/m68k/include/asm/unistd.h                |   1 -
 arch/microblaze/include/asm/unistd.h          |   2 +
 arch/mips/include/asm/unistd.h                |   1 -
 arch/nios2/include/asm/Kbuild                 |   2 +
 arch/nios2/include/asm/unistd.h               |  10 +
 arch/nios2/include/uapi/asm/Kbuild            |   2 +
 arch/nios2/include/uapi/asm/unistd.h          |  14 +-
 arch/nios2/kernel/Makefile.syscalls           |   3 +
 arch/nios2/kernel/syscall_table.c             |   6 +-
 arch/openrisc/include/asm/Kbuild              |   2 +
 arch/openrisc/include/asm/syscalls.h          |   4 -
 arch/openrisc/include/asm/unistd.h            |   8 +
 arch/openrisc/include/uapi/asm/Kbuild         |   2 +
 arch/openrisc/include/uapi/asm/unistd.h       |  15 +-
 arch/openrisc/kernel/Makefile.syscalls        |   3 +
 arch/openrisc/kernel/sys_call_table.c         |   9 +-
 arch/parisc/include/asm/unistd.h              |   1 -
 arch/powerpc/include/asm/unistd.h             |   1 -
 arch/riscv/include/asm/Kbuild                 |   3 +
 arch/riscv/include/asm/syscall_table.h        |   7 +
 arch/riscv/include/asm/unistd.h               |  13 +-
 arch/riscv/include/uapi/asm/Kbuild            |   2 +
 arch/riscv/include/uapi/asm/unistd.h          |  41 +-
 arch/riscv/kernel/Makefile.syscalls           |   4 +
 arch/riscv/kernel/compat_syscall_table.c      |   6 +-
 arch/riscv/kernel/syscall_table.c             |   6 +-
 arch/s390/include/asm/unistd.h                |   1 -
 arch/sh/include/asm/unistd.h                  |   2 +
 arch/sparc/include/asm/unistd.h               |   2 +
 arch/um/include/asm/Kbuild                    |   1 -
 arch/um/include/asm/bpf_perf_event.h          |   3 +
 arch/x86/include/asm/unistd.h                 |   1 -
 arch/xtensa/include/asm/unistd.h              |   1 -
 include/asm-generic/Kbuild                    |   1 -
 include/uapi/asm-generic/unistd.h             |   4 -
 kernel/fork.c                                 |   8 +-
 kernel/sys_ni.c                               |   2 -
 scripts/Makefile.asm-generic                  |  58 --
 scripts/Makefile.asm-headers                  |  98 ++
 scripts/syscall.tbl                           | 404 ++++++++
 tools/arch/arm64/include/uapi/asm/unistd.h    |   1 -
 .../arch/loongarch/include/uapi/asm/unistd.h  |   1 -
 tools/include/uapi/asm-generic/unistd.h       |   4 -
 86 files changed, 1219 insertions(+), 1271 deletions(-)
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/kernel/Makefile.syscalls
 create mode 100644 arch/arm64/kernel/Makefile.syscalls
 create mode 100644 arch/arm64/tools/syscall_32.tbl
 create mode 120000 arch/arm64/tools/syscall_64.tbl
 create mode 100644 arch/csky/kernel/Makefile.syscalls
 create mode 100644 arch/hexagon/include/asm/unistd.h
 create mode 100644 arch/hexagon/kernel/Makefile.syscalls
 create mode 100644 arch/loongarch/kernel/Makefile.syscalls
 create mode 100644 arch/nios2/include/asm/unistd.h
 create mode 100644 arch/nios2/kernel/Makefile.syscalls
 create mode 100644 arch/openrisc/include/asm/unistd.h
 create mode 100644 arch/openrisc/kernel/Makefile.syscalls
 create mode 100644 arch/riscv/include/asm/syscall_table.h
 create mode 100644 arch/riscv/kernel/Makefile.syscalls
 create mode 100644 arch/um/include/asm/bpf_perf_event.h
 delete mode 100644 scripts/Makefile.asm-generic
 create mode 100644 scripts/Makefile.asm-headers
 create mode 100644 scripts/syscall.tbl
Signature · 36 lines
2.39.2

Cc: Masahiro Yamada <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: Russell King <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Guo Ren <[email protected]>
Cc: Brian Cain <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: WANG Xuerui <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Stefan Kristiansson <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: John Paul Adrian Glaubitz <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
#1 lore raw

PATCH 1/17 syscalls: add generic scripts/syscall.tbl

From: Arnd Bergmann <[email protected]>

The asm-generic/unistd.h header still follows the old style of defining system call numbers and the table. Most architectures got the new syscall.tbl format as part of the y2038 conversion back in 2018, but the newer architectures that share a single table never did.

I did a semi-automated conversion of the asm-generic/unistd.h contents into a syscall.tbl format, using the ABI field to take care of all the relevant differences that are encoded using #ifdef checks in the existing header.

Conversion of the architectures is done one at a time in order to be able to review or revert them as needed.

---
 scripts/syscall.tbl | 388 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 388 insertions(+)
 create mode 100644 scripts/syscall.tbl
scripts/syscall.tbl new file +388 -0
new file mode 100644
index 000000000000..7871bbfa9b58
@@ -0,0 +1,388 @@
+# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
+#
+# This file contains the system call numbers for all of the
+# more recently added architectures.
+#
+# As a basic principle, no duplication of functionality
+# should be added, e.g. we don't use lseek when llseek
+# is present. New architectures should use this file
+# and implement the less feature-full calls in user space.
+#
+0	common	io_setup			sys_io_setup			compat_sys_io_setup
+1	common	io_destroy			sys_io_destroy
+2	common	io_submit			sys_io_submit			compat_sys_io_submit
+3	common	io_cancel			sys_io_cancel
+4	time32	io_getevents			sys_io_getevents_time32
+4	64	io_getevents			sys_io_getevents
+5	common	setxattr			sys_setxattr
+6	common	lsetxattr			sys_lsetxattr
+7	common	fsetxattr			sys_fsetxattr
+8	common	getxattr			sys_getxattr
+9	common	lgetxattr			sys_lgetxattr
+10	common	fgetxattr			sys_fgetxattr
+11	common	listxattr			sys_listxattr
+12	common	llistxattr			sys_llistxattr
+13	common	flistxattr			sys_flistxattr
+14	common	removexattr			sys_removexattr
+15	common	lremovexattr			sys_lremovexattr
+16	common	fremovexattr			sys_fremovexattr
+17	common	getcwd				sys_getcwd
+18	common	lookup_dcookie			sys_ni_syscall
+19	common	eventfd2			sys_eventfd2
+20	common	epoll_create1			sys_epoll_create1
+21	common	epoll_ctl			sys_epoll_ctl
+22	common	epoll_pwait			sys_epoll_pwait			compat_sys_epoll_pwait
+23	common	dup				sys_dup
+24	common	dup3				sys_dup3
+25	32	fcntl64				sys_fcntl64			compat_sys_fcntl64
+25	64	fcntl				sys_fcntl
+26	common	inotify_init1			sys_inotify_init1
+27	common	inotify_add_watch		sys_inotify_add_watch
+28	common	inotify_rm_watch		sys_inotify_rm_watch
+29	common	ioctl				sys_ioctl			compat_sys_ioctl
+30	common	ioprio_set			sys_ioprio_set
+31	common	ioprio_get			sys_ioprio_get
+32	common	flock				sys_flock
+33	common	mknodat				sys_mknodat
+34	common	mkdirat				sys_mkdirat
+35	common	unlinkat			sys_unlinkat
+36	common	symlinkat			sys_symlinkat
+37	common	linkat				sys_linkat
+# renameat is superseded with flags by renameat2
+38	renameat renameat			sys_renameat
+39	common	umount2				sys_umount
+40	common	mount				sys_mount
+41	common	pivot_root			sys_pivot_root
+43	32	statfs64			sys_statfs64			compat_sys_statfs64
+43	64	statfs				sys_statfs
+44	32	fstatfs64			sys_fstatfs64			compat_sys_fstatfs64
+44	64	fstatfs				sys_fstatfs
+45	32	truncate64			sys_truncate64			compat_sys_truncate64
+45	64	truncate			sys_truncate
+46	32	ftruncate64			sys_ftruncate64			compat_sys_ftruncate64
+46	64	ftruncate			sys_ftruncate
+47	common	fallocate			sys_fallocate			compat_sys_fallocate
+48	common	faccessat			sys_faccessat
+49	common	chdir				sys_chdir
+50	common	fchdir				sys_fchdir
+51	common	chroot				sys_chroot
+52	common	fchmod				sys_fchmod
+53	common	fchmodat			sys_fchmodat
+54	common	fchownat			sys_fchownat
+55	common	fchown				sys_fchown
+56	common	openat				sys_openat
+57	common	close				sys_close
+58	common	vhangup				sys_vhangup
+59	common	pipe2				sys_pipe2
+60	common	quotactl			sys_quotactl
+61	common	getdents64			sys_getdents64
+62	32	llseek				sys_llseek
+62	64	lseek				sys_lseek
+63	common	read				sys_read
+64	common	write				sys_write
+65	common	readv				sys_readv			sys_readv
+66	common	writev				sys_writev			sys_writev
+67	common	pread64				sys_pread64			compat_sys_pread64
+68	common	pwrite64			sys_pwrite64			compat_sys_pwrite64
+69	common	preadv				sys_preadv			compat_sys_preadv
+70	common	pwritev				sys_pwritev			compat_sys_pwritev
+71	32	sendfile64			sys_sendfile64
+71	64	sendfile			sys_sendfile64
+72	time32	pselect6			sys_pselect6_time32		compat_sys_pselect6_time32
+72	64	pselect6			sys_pselect6
+73	time32	ppoll				sys_ppoll_time32		compat_sys_ppoll_time32
+73	64	ppoll				sys_ppoll
+74	common	signalfd4			sys_signalfd4			compat_sys_signalfd4
+75	common	vmsplice			sys_vmsplice
+76	common	splice				sys_splice
+77	common	tee				sys_tee
+78	common	readlinkat			sys_readlinkat
+79	stat64	fstatat64			sys_fstatat64
+79	newstat	fstatat				sys_newfstatat
+80	stat64	fstat64				sys_fstat64
+80	newstat	fstat				sys_newfstat
+81	common	sync				sys_sync
+82	common	fsync				sys_fsync
+83	common	fdatasync			sys_fdatasync
+84	common	sync_file_range			sys_sync_file_range		compat_sys_sync_file_range
+85	common	timerfd_create			sys_timerfd_create
+86	time32	timerfd_settime			sys_timerfd_settime32
+86	64	timerfd_settime			sys_timerfd_settime
+87	time32	timerfd_gettime			sys_timerfd_gettime32
+87	64	timerfd_gettime			sys_timerfd_gettime
+88	time32	utimensat			sys_utimensat_time32
+88	64	utimensat			sys_utimensat
+89	common	acct				sys_acct
+90	common	capget				sys_capget
+91	common	capset				sys_capset
+92	common	personality			sys_personality
+93	common	exit				sys_exit
+94	common	exit_group			sys_exit_group
+95	common	waitid				sys_waitid			compat_sys_waitid
+96	common	set_tid_address			sys_set_tid_address
+97	common	unshare				sys_unshare
+98	time32	futex				sys_futex_time32
+98	64	futex				sys_futex
+99	common	set_robust_list			sys_set_robust_list		compat_sys_set_robust_list
+100	common	get_robust_list			sys_get_robust_list		compat_sys_get_robust_list
+101	time32	nanosleep			sys_nanosleep_time32
+101	64	nanosleep			sys_nanosleep
+102	common	getitimer			sys_getitimer			compat_sys_getitimer
+103	common	setitimer			sys_setitimer			compat_sys_setitimer
+104	common	kexec_load			sys_kexec_load			compat_sys_kexec_load
+105	common	init_module			sys_init_module
+106	common	delete_module			sys_delete_module
+107	common	timer_create			sys_timer_create		compat_sys_timer_create
+108	time32	timer_gettime			sys_timer_gettime32
+108	64	timer_gettime			sys_timer_gettime
+109	common	timer_getoverrun		sys_timer_getoverrun
+110	time32	timer_settime			sys_timer_settime32
+110	64	timer_settime			sys_timer_settime
+111	common	timer_delete			sys_timer_delete
+112	time32	clock_settime			sys_clock_settime32
+112	64	clock_settime			sys_clock_settime
+113	time32	clock_gettime			sys_clock_gettime32
+113	64	clock_gettime			sys_clock_gettime
+114	time32	clock_getres			sys_clock_getres_time32
+114	64	clock_getres			sys_clock_getres
+115	time32	clock_nanosleep			sys_clock_nanosleep_time32
+115	64	clock_nanosleep			sys_clock_nanosleep
+116	common	syslog				sys_syslog
+117	common	ptrace				sys_ptrace			compat_sys_ptrace
+118	common	sched_setparam			sys_sched_setparam
+119	common	sched_setscheduler		sys_sched_setscheduler
+120	common	sched_getscheduler		sys_sched_getscheduler
+121	common	sched_getparam			sys_sched_getparam
+122	common	sched_setaffinity		sys_sched_setaffinity		compat_sys_sched_setaffinity
+123	common	sched_getaffinity		sys_sched_getaffinity		compat_sys_sched_getaffinity
+124	common	sched_yield			sys_sched_yield
+125	common	sched_get_priority_max		sys_sched_get_priority_max
+126	common	sched_get_priority_min		sys_sched_get_priority_min
+127	time32	sched_rr_get_interval		sys_sched_rr_get_interval_time32
+127	64	sched_rr_get_interval		sys_sched_rr_get_interval
+128	common	restart_syscall			sys_restart_syscall
+129	common	kill				sys_kill
+130	common	tkill				sys_tkill
+131	common	tgkill				sys_tgkill
+132	common	sigaltstack			sys_sigaltstack			compat_sys_sigaltstack
+133	common	rt_sigsuspend			sys_rt_sigsuspend		compat_sys_rt_sigsuspend
+134	common	rt_sigaction			sys_rt_sigaction		compat_sys_rt_sigaction
+135	common	rt_sigprocmask			sys_rt_sigprocmask		compat_sys_rt_sigprocmask
+136	common	rt_sigpending			sys_rt_sigpending		compat_sys_rt_sigpending
+137	time32	rt_sigtimedwait			sys_rt_sigtimedwait_time32	compat_sys_rt_sigtimedwait_time32
+137	64	rt_sigtimedwait			sys_rt_sigtimedwait
+138	common	rt_sigqueueinfo			sys_rt_sigqueueinfo		compat_sys_rt_sigqueueinfo
+139	common	rt_sigreturn			sys_rt_sigreturn		compat_sys_rt_sigreturn
+140	common	setpriority			sys_setpriority
+141	common	getpriority			sys_getpriority
+142	common	reboot				sys_reboot
+143	common	setregid			sys_setregid
+144	common	setgid				sys_setgid
+145	common	setreuid			sys_setreuid
+146	common	setuid				sys_setuid
+147	common	setresuid			sys_setresuid
+148	common	getresuid			sys_getresuid
+149	common	setresgid			sys_setresgid
+150	common	getresgid			sys_getresgid
+151	common	setfsuid			sys_setfsuid
+152	common	setfsgid			sys_setfsgid
+153	common	times				sys_times			compat_sys_times
+154	common	setpgid				sys_setpgid
+155	common	getpgid				sys_getpgid
+156	common	getsid				sys_getsid
+157	common	setsid				sys_setsid
+158	common	getgroups			sys_getgroups
+159	common	setgroups			sys_setgroups
+160	common	uname				sys_newuname
+161	common	sethostname			sys_sethostname
+162	common	setdomainname			sys_setdomainname
+# getrlimit and setrlimit are superseded with prlimit64
+163	rlimit	getrlimit			sys_getrlimit			compat_sys_getrlimit
+164	rlimit	setrlimit			sys_setrlimit			compat_sys_setrlimit
+165	common	getrusage			sys_getrusage			compat_sys_getrusage
+166	common	umask				sys_umask
+167	common	prctl				sys_prctl
+168	common	getcpu				sys_getcpu
+169	time32	gettimeofday			sys_gettimeofday		compat_sys_gettimeofday
+169	64	gettimeofday			sys_gettimeofday
+170	time32	settimeofday			sys_settimeofday		compat_sys_settimeofday
+170	64	settimeofday			sys_settimeofday
+171	time32	adjtimex			sys_adjtimex_time32
+171	64	adjtimex			sys_adjtimex
+172	common	getpid				sys_getpid
+173	common	getppid				sys_getppid
+174	common	getuid				sys_getuid
+175	common	geteuid				sys_geteuid
+176	common	getgid				sys_getgid
+177	common	getegid				sys_getegid
+178	common	gettid				sys_gettid
+179	common	sysinfo				sys_sysinfo			compat_sys_sysinfo
+180	common	mq_open				sys_mq_open			compat_sys_mq_open
+181	common	mq_unlink			sys_mq_unlink
+182	time32	mq_timedsend			sys_mq_timedsend_time32
+182	64	mq_timedsend			sys_mq_timedsend
+183	time32	mq_timedreceive			sys_mq_timedreceive_time32
+183	64	mq_timedreceive			sys_mq_timedreceive
+184	common	mq_notify			sys_mq_notify			compat_sys_mq_notify
+185	common	mq_getsetattr			sys_mq_getsetattr		compat_sys_mq_getsetattr
+186	common	msgget				sys_msgget
+187	common	msgctl				sys_msgctl			compat_sys_msgctl
+188	common	msgrcv				sys_msgrcv			compat_sys_msgrcv
+189	common	msgsnd				sys_msgsnd			compat_sys_msgsnd
+190	common	semget				sys_semget
+191	common	semctl				sys_semctl			compat_sys_semctl
+192	time32	semtimedop			sys_semtimedop_time32
+192	64	semtimedop			sys_semtimedop
+193	common	semop				sys_semop
+194	common	shmget				sys_shmget
+195	common	shmctl				sys_shmctl			compat_sys_shmctl
+196	common	shmat				sys_shmat			compat_sys_shmat
+197	common	shmdt				sys_shmdt
+198	common	socket				sys_socket
+199	common	socketpair			sys_socketpair
+200	common	bind				sys_bind
+201	common	listen				sys_listen
+202	common	accept				sys_accept
+203	common	connect				sys_connect
+204	common	getsockname			sys_getsockname
+205	common	getpeername			sys_getpeername
+206	common	sendto				sys_sendto
+207	common	recvfrom			sys_recvfrom			compat_sys_recvfrom
+208	common	setsockopt			sys_setsockopt			sys_setsockopt
+209	common	getsockopt			sys_getsockopt			sys_getsockopt
+210	common	shutdown			sys_shutdown
+211	common	sendmsg				sys_sendmsg			compat_sys_sendmsg
+212	common	recvmsg				sys_recvmsg			compat_sys_recvmsg
+213	common	readahead			sys_readahead			compat_sys_readahead
+214	common	brk				sys_brk
+215	common	munmap				sys_munmap
+216	common	mremap				sys_mremap
+217	common	add_key				sys_add_key
+218	common	request_key			sys_request_key
+219	common	keyctl				sys_keyctl			compat_sys_keyctl
+220	common	clone				sys_clone
+221	common	execve				sys_execve			compat_sys_execve
+222	32	mmap2				sys_mmap2
+222	64	mmap				sys_mmap
+223	32	fadvise64_64			sys_fadvise64_64		compat_sys_fadvise64_64
+223	64	fadvise64			sys_fadvise64_64
+224	common	swapon				sys_swapon
+225	common	swapoff				sys_swapoff
+226	common	mprotect			sys_mprotect
+227	common	msync				sys_msync
+228	common	mlock				sys_mlock
+229	common	munlock				sys_munlock
+230	common	mlockall			sys_mlockall
+231	common	munlockall			sys_munlockall
+232	common	mincore				sys_mincore
+233	common	madvise				sys_madvise
+234	common	remap_file_pages		sys_remap_file_pages
+235	common	mbind				sys_mbind
+236	common	get_mempolicy			sys_get_mempolicy
+237	common	set_mempolicy			sys_set_mempolicy
+238	common	migrate_pages			sys_migrate_pages
+239	common	move_pages			sys_move_pages
+240	common	rt_tgsigqueueinfo		sys_rt_tgsigqueueinfo		compat_sys_rt_tgsigqueueinfo
+241	common	perf_event_open			sys_perf_event_open
+242	common	accept4				sys_accept4
+243	time32	recvmmsg			sys_recvmmsg_time32		compat_sys_recvmmsg_time32
+243	64	recvmmsg			sys_recvmmsg
+# Architectures may provide up to 16 syscalls of their own between 244 and 259
+260	time32	wait4				sys_wait4			compat_sys_wait4
+260	64	wait4				sys_wait4
+261	common	prlimit64			sys_prlimit64
+262	common	fanotify_init			sys_fanotify_init
+263	common	fanotify_mark			sys_fanotify_mark
+264	common	name_to_handle_at		sys_name_to_handle_at
+265	common	open_by_handle_at		sys_open_by_handle_at
+266	time32	clock_adjtime			sys_clock_adjtime32
+266	64	clock_adjtime			sys_clock_adjtime
+267	common	syncfs				sys_syncfs
+268	common	setns				sys_setns
+269	common	sendmmsg			sys_sendmmsg			compat_sys_sendmmsg
+270	common	process_vm_readv		sys_process_vm_readv
+271	common	process_vm_writev		sys_process_vm_writev
+272	common	kcmp				sys_kcmp
+273	common	finit_module			sys_finit_module
+274	common	sched_setattr			sys_sched_setattr
+275	common	sched_getattr			sys_sched_getattr
+276	common	renameat2			sys_renameat2
+277	common	seccomp				sys_seccomp
+278	common	getrandom			sys_getrandom
+279	common	memfd_create			sys_memfd_create
+280	common	bpf				sys_bpf
+281	common	execveat			sys_execveat			compat_sys_execveat
+282	common	userfaultfd			sys_userfaultfd
+283	common	membarrier			sys_membarrier
+284	common	mlock2				sys_mlock2
+285	common	copy_file_range			sys_copy_file_range
+286	common	preadv2				sys_preadv2			compat_sys_preadv2
+287	common	pwritev2			sys_pwritev2			compat_sys_pwritev2
+288	common	pkey_mprotect			sys_pkey_mprotect
+289	common	pkey_alloc			sys_pkey_alloc
+290	common	pkey_free			sys_pkey_free
+291	common	statx				sys_statx
+292	time32	io_pgetevents			sys_io_pgetevents_time32	compat_sys_io_pgetevents
+292	64	io_pgetevents			sys_io_pgetevents
+293	common	rseq				sys_rseq
+294	common	kexec_file_load			sys_kexec_file_load
+# 295 through 402 are unassigned to sync up with generic numbers don't use
+403	32	clock_gettime64			sys_clock_gettime
+404	32	clock_settime64			sys_clock_settime
+405	32	clock_adjtime64			sys_clock_adjtime
+406	32	clock_getres_time64		sys_clock_getres
+407	32	clock_nanosleep_time64		sys_clock_nanosleep
+408	32	timer_gettime64			sys_timer_gettime
+409	32	timer_settime64			sys_timer_settime
+410	32	timerfd_gettime64		sys_timerfd_gettime
+411	32	timerfd_settime64		sys_timerfd_settime
+412	32	utimensat_time64		sys_utimensat
+413	32	pselect6_time64			sys_pselect6			compat_sys_pselect6_time64
+414	32	ppoll_time64			sys_ppoll			compat_sys_ppoll_time64
+416	32	io_pgetevents_time64		sys_io_pgetevents		compat_sys_io_pgetevents_time64
+417	32	recvmmsg_time64			sys_recvmmsg			compat_sys_recvmmsg_time64
+418	32	mq_timedsend_time64		sys_mq_timedsend
+419	32	mq_timedreceive_time64		sys_mq_timedreceive
+420	32	semtimedop_time64		sys_semtimedop
+421	32	rt_sigtimedwait_time64		sys_rt_sigtimedwait		compat_sys_rt_sigtimedwait_time64
+422	32	futex_time64			sys_futex
+423	32	sched_rr_get_interval_time64	sys_sched_rr_get_interval
+424	common	pidfd_send_signal		sys_pidfd_send_signal
+425	common	io_uring_setup			sys_io_uring_setup
+426	common	io_uring_enter			sys_io_uring_enter
+427	common	io_uring_register		sys_io_uring_register
+428	common	open_tree			sys_open_tree
+429	common	move_mount			sys_move_mount
+430	common	fsopen				sys_fsopen
+431	common	fsconfig			sys_fsconfig
+432	common	fsmount				sys_fsmount
+433	common	fspick				sys_fspick
+434	common	pidfd_open			sys_pidfd_open
+435	common	clone3				sys_clone3
+436	common	close_range			sys_close_range
+437	common	openat2				sys_openat2
+438	common	pidfd_getfd			sys_pidfd_getfd
+439	common	faccessat2			sys_faccessat2
+440	common	process_madvise			sys_process_madvise
+441	common	epoll_pwait2			sys_epoll_pwait2		compat_sys_epoll_pwait2
+442	common	mount_setattr			sys_mount_setattr
+443	common	quotactl_fd			sys_quotactl_fd
+444	common	landlock_create_ruleset		sys_landlock_create_ruleset
+445	common	landlock_add_rule		sys_landlock_add_rule
+446	common	landlock_restrict_self		sys_landlock_restrict_self
+447	memfd_secret	memfd_secret		sys_memfd_secret
+448	common	process_mrelease		sys_process_mrelease
+449	common	futex_waitv			sys_futex_waitv
+450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
+451	common	cachestat			sys_cachestat
+452	common	fchmodat2			sys_fchmodat2
+453	common	map_shadow_stack		sys_map_shadow_stack
+454	common	futex_wake			sys_futex_wake
+455	common	futex_wait			sys_futex_wait
+456	common	futex_requeue			sys_futex_requeue
+457	common	statmount			sys_statmount
+458	common	listmount			sys_listmount
+459	common	lsm_get_self_attr		sys_lsm_get_self_attr
+460	common	lsm_set_self_attr		sys_lsm_set_self_attr
+461	common	lsm_list_modules		sys_lsm_list_modules
+462	common	mseal				sys_mseal
Signature · 1 line
2.39.2
#4 lore raw

PATCH 2/17 csky: drop asm/gpio.h wrapper

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The asm/gpio.h header is gone now that all architectures just use gpiolib, and so the redirect is no longer valid.

---
 arch/csky/include/asm/Kbuild | 1 -
 1 file changed, 1 deletion(-)
arch/csky/include/asm/Kbuild +0 -1
index 1117c28cb7e8..13ebc5e34360 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generic-y += asm-offsets.h
 generic-y += extable.h
-generic-y += gpio.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
Signature · 1 line
2.39.2
#8 lore raw

PATCH 3/17 um: don't generate asm/bpf_perf_event.h

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If we start validating the existence of the asm-generic side of generated headers, this one causes a warning:

make[3]: *** No rule to make target 'arch/um/include/generated/asm/bpf_perf_event.h', needed by 'all'. Stop.

The problem is that the asm-generic header only exists for the uapi variant, but arch/um has no uapi headers and instead uses the x86 userspace API.

Add a custom file with an explicit redirect to avoid this.

---
 arch/um/include/asm/Kbuild           | 1 -
 arch/um/include/asm/bpf_perf_event.h | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 arch/um/include/asm/bpf_perf_event.h
arch/um/include/asm/Kbuild +0 -1
index 6fe34779291a..6c583040537c 100644
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-generic-y += bpf_perf_event.h
 generic-y += bug.h
 generic-y += compat.h
 generic-y += current.h
arch/um/include/asm/bpf_perf_event.h new file +3 -0
new file mode 100644
index 000000000000..0a30420c83de
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <asm-generic/bpf_perf_event.h>
Signature · 1 line
2.39.2
#12 lore raw

PATCH 4/17 loongarch: avoid generating extra header files

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The list of generated headers is rather outdated, some of these no longer exist, while others are already listed in include/asm-generic/Kbuild so there is no need to list them here.

As we start validating the list of headers against the files that exist, the outdated ones now cause a warning.

---
 arch/loongarch/include/asm/Kbuild | 16 ----------------
 1 file changed, 16 deletions(-)
arch/loongarch/include/asm/Kbuild +0 -16
index c862672ed953..0db5ad14f014 100644
@@ -1,28 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
 generated-y += orc_hash.h
 
-generic-y += dma-contiguous.h
 generic-y += mcs_spinlock.h
 generic-y += parport.h
 generic-y += early_ioremap.h
 generic-y += qrwlock.h
 generic-y += qspinlock.h
-generic-y += rwsem.h
-generic-y += segment.h
 generic-y += user.h
-generic-y += stat.h
-generic-y += fcntl.h
 generic-y += ioctl.h
-generic-y += ioctls.h
-generic-y += mman.h
-generic-y += msgbuf.h
-generic-y += sembuf.h
-generic-y += shmbuf.h
 generic-y += statfs.h
-generic-y += socket.h
-generic-y += sockios.h
-generic-y += termbits.h
-generic-y += poll.h
 generic-y += param.h
-generic-y += posix_types.h
-generic-y += resource.h
Signature · 1 line
2.39.2
#13 lore raw

PATCH 5/17 kbuild: verify asm-generic header list

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

In order to integrate the system call header generation with generating the asm-generic wrappers, restrict the generated headers to those that actually exist in include/asm-generic/.

The path is already known, so add these as a dependency.

The asm-generic/bugs.h header was removed in commit 61235b24b9cb ("init:
Remove check_bugs() leftovers"), which now causes a build failure, so drop it from the list.

---
 include/asm-generic/Kbuild   | 1 -
 scripts/Makefile.asm-generic | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
include/asm-generic/Kbuild +0 -1
index b20fa25a7e8d..df7ed81c4589 100644
@@ -9,7 +9,6 @@ mandatory-y += archrandom.h
 mandatory-y += barrier.h
 mandatory-y += bitops.h
 mandatory-y += bug.h
-mandatory-y += bugs.h
 mandatory-y += cacheflush.h
 mandatory-y += cfi.h
 mandatory-y += checksum.h
scripts/Makefile.asm-generic +1 -1
index 1486abf34c7c..69434908930e 100644
@@ -46,7 +46,7 @@ all: $(generic-y)
 	$(if $(unwanted),$(call cmd,remove))
 	@:
 
-$(obj)/%.h:
+$(obj)/%.h: $(srctree)/$(generic)/%.h
 	$(call cmd,wrap)
 
 # Create output directory. Skip it if at least one old header exists
Signature · 1 line
2.39.2
#14 lore raw

PATCH 6/17 kbuild: add syscall table generation to scripts/Makefile.asm-headers

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

There are 11 copies of arch/*/kernel/syscalls/Makefile that all implement the same basic logic in a somewhat awkward way.

I tried out various ways of unifying the existing copies and ended up with something that hooks into the logic for generating the redirections to asm-generic headers. This gives a nicer syntax of being able to list the generated files in $(syscall-y) inside of arch/*/include/asm/Kbuild instead of both $(generated-y) in that place and also in another Makefile.

The configuration for which syscall.tbl file to use and which ABIs to enable is now done in arch/*/kernel/Makefile.syscalls. I have done patches for all architectures and made sure that the new generic rules implement a superset of all the architecture specific corner cases.

ince the header file is not specific to asm-generic/*.h redirects now, I ended up renaming the file to scripts/Makefile.asm-headers.

---
 Makefile                     |  2 +-
 scripts/Makefile.asm-generic | 58 ---------------------
 scripts/Makefile.asm-headers | 98 ++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 59 deletions(-)
 delete mode 100644 scripts/Makefile.asm-generic
 create mode 100644 scripts/Makefile.asm-headers
Makefile +1 -1
index 06aa6402b385..d62ef2b2c102 100644
@@ -1219,7 +1219,7 @@ remove-stale-files:
 	$(Q)$(srctree)/scripts/remove-stale-files
 
 # Support for using generic headers in asm-generic
-asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
+asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj
 
 PHONY += asm-generic uapi-asm-generic
 asm-generic: uapi-asm-generic
scripts/Makefile.asm-generic deleted +0 -58

58 lines not on this page · raw message

scripts/Makefile.asm-headers new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
2.39.2
#15 lore raw

PATCH 7/17 clone3: drop __ARCH_WANT_SYS_CLONE3 macro

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When clone3() was introduced, it was not obvious how each architecture deals with setting up the stack and keeping the register contents in a fork()-like system call, so this was left for the architecture maintainers to implement, with __ARCH_WANT_SYS_CLONE3 defined by those that already implement it.

Five years later, we still have a few architectures left that are missing clone3(), and the macro keeps getting in the way as it's fundamentally different from all the other __ARCH_WANT_SYS_* macros that are meant to provide backwards-compatibility with applications using older syscalls that are no longer provided by default.

Address this by reversing the polarity of the macro, adding an __ARCH_BROKEN_SYS_CLONE3 macro to all architectures that don't already provide the syscall, and remove __ARCH_WANT_SYS_CLONE3 from all the other ones.

---
 arch/arc/include/uapi/asm/unistd.h             | 1 -
 arch/arm/include/asm/unistd.h                  | 1 -
 arch/arm64/include/uapi/asm/unistd.h           | 1 -
 arch/csky/include/uapi/asm/unistd.h            | 1 -
 arch/hexagon/include/uapi/asm/unistd.h         | 2 ++
 arch/loongarch/include/uapi/asm/unistd.h       | 1 -
 arch/m68k/include/asm/unistd.h                 | 1 -
 arch/mips/include/asm/unistd.h                 | 1 -
 arch/nios2/include/uapi/asm/unistd.h           | 2 ++
 arch/openrisc/include/uapi/asm/unistd.h        | 1 -
 arch/parisc/include/asm/unistd.h               | 1 -
 arch/powerpc/include/asm/unistd.h              | 1 -
 arch/riscv/include/uapi/asm/unistd.h           | 1 -
 arch/s390/include/asm/unistd.h                 | 1 -
 arch/sh/include/asm/unistd.h                   | 2 ++
 arch/sparc/include/asm/unistd.h                | 2 ++
 arch/x86/include/asm/unistd.h                  | 1 -
 arch/xtensa/include/asm/unistd.h               | 1 -
 include/uapi/asm-generic/unistd.h              | 4 ----
 kernel/fork.c                                  | 8 +++++---
 kernel/sys_ni.c                                | 2 --
 tools/arch/arm64/include/uapi/asm/unistd.h     | 1 -
 tools/arch/loongarch/include/uapi/asm/unistd.h | 1 -
 tools/include/uapi/asm-generic/unistd.h        | 4 ----
 24 files changed, 13 insertions(+), 29 deletions(-)
arch/arc/include/uapi/asm/unistd.h +0 -1
index fa2713ae6bea..5eafa1115162 100644
@@ -21,7 +21,6 @@
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_TIME32_SYSCALLS
arch/arm/include/asm/unistd.h +0 -1
index 3676e82cf95c..9fb00973c608 100644
@@ -37,7 +37,6 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 /*
  * Unimplemented (or alternatively implemented) syscalls
arch/arm64/include/uapi/asm/unistd.h +0 -1
index ce2ee8f1e361..9306726337fe 100644
@@ -19,7 +19,6 @@
 #define __ARCH_WANT_NEW_STAT
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_MEMFD_SECRET
 
 #include <asm-generic/unistd.h>
arch/csky/include/uapi/asm/unistd.h +0 -1
index e0594b6370a6..d529d0432876 100644
@@ -3,7 +3,6 @@
 #define __ARCH_WANT_STAT64
 #define __ARCH_WANT_NEW_STAT
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_TIME32_SYSCALLS
 #define __ARCH_WANT_SYNC_FILE_RANGE2
arch/hexagon/include/uapi/asm/unistd.h +2 -0
index 21ae22306b5d..4bea7428e747 100644
@@ -38,4 +38,6 @@
 #define __ARCH_WANT_TIME32_SYSCALLS
 #define __ARCH_WANT_SYNC_FILE_RANGE2
 
+#define __ARCH_BROKEN_SYS_CLONE3
+
 #include <asm-generic/unistd.h>
arch/loongarch/include/uapi/asm/unistd.h +0 -1
index fcb668984f03..191614b9b207 100644
@@ -1,5 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 #include <asm-generic/unistd.h>
arch/m68k/include/asm/unistd.h +0 -1
index 4ae52414cd9d..2e0047cf86f8 100644
@@ -30,6 +30,5 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
-#define __ARCH_WANT_SYS_CLONE3
 
 #endif /* _ASM_M68K_UNISTD_H_ */
arch/mips/include/asm/unistd.h +0 -1
index 25a5253db7f4..ba83d3fb0a84 100644
@@ -58,7 +58,6 @@
 # endif
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 /* whitelists for checksyscalls */
 #define __IGNORE_fadvise64_64
arch/nios2/include/uapi/asm/unistd.h +2 -0
index 0b4bb1d41b28..d2bc5ac975fb 100644
@@ -23,6 +23,8 @@
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_TIME32_SYSCALLS
 
+#define __ARCH_BROKEN_SYS_CLONE3
+
 /* Use the standard ABI for syscalls */
 #include <asm-generic/unistd.h>
 
arch/openrisc/include/uapi/asm/unistd.h +0 -1
index fae34c60fa88..566f8c4f8047 100644
@@ -24,7 +24,6 @@
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_TIME32_SYSCALLS
 
 #include <asm-generic/unistd.h>
arch/parisc/include/asm/unistd.h +0 -1
index e38f9a90ac15..98851ff7699a 100644
@@ -160,7 +160,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)	\
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
 #define __ARCH_WANT_COMPAT_STAT
 
arch/powerpc/include/asm/unistd.h +0 -1
index 659a996c75aa..027ef94a12fb 100644
@@ -51,7 +51,6 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 #endif		/* __ASSEMBLY__ */
 #endif /* _ASM_POWERPC_UNISTD_H_ */
arch/riscv/include/uapi/asm/unistd.h +0 -1
index 950ab3fd4409..328520defc13 100644
@@ -20,7 +20,6 @@
 #define __ARCH_WANT_SET_GET_RLIMIT
 #endif /* __LP64__ */
 
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_MEMFD_SECRET
 
 #include <asm-generic/unistd.h>
arch/s390/include/asm/unistd.h +0 -1
index 4260bc5ce7f8..70fc671397da 100644
@@ -35,6 +35,5 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 #endif /* _ASM_S390_UNISTD_H_ */
arch/sh/include/asm/unistd.h +2 -0
index d6e126250136..3d7f35650a13 100644
@@ -28,4 +28,6 @@
 # define __ARCH_WANT_SYS_VFORK
 # define __ARCH_WANT_SYS_CLONE
 
+#define __ARCH_BROKEN_SYS_CLONE3
+
 #include <uapi/asm/unistd.h>
arch/sparc/include/asm/unistd.h +2 -0
index d6bc76706a7a..3380411a4537 100644
@@ -49,6 +49,8 @@
 #define __ARCH_WANT_COMPAT_STAT
 #endif
 
+#define __ARCH_BROKEN_SYS_CLONE3
+
 #ifdef __32bit_syscall_numbers__
 /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
  * it never had the plain ones and there is no value to adding those
arch/x86/include/asm/unistd.h +0 -1
index 761173ccc33c..6c9e5bdd3916 100644
@@ -56,6 +56,5 @@
 # define __ARCH_WANT_SYS_FORK
 # define __ARCH_WANT_SYS_VFORK
 # define __ARCH_WANT_SYS_CLONE
-# define __ARCH_WANT_SYS_CLONE3
 
 #endif /* _ASM_X86_UNISTD_H */
arch/xtensa/include/asm/unistd.h +0 -1
index b52236245e51..30af4dc3ce7b 100644
@@ -3,7 +3,6 @@
 #define _XTENSA_UNISTD_H
 
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 #include <uapi/asm/unistd.h>
 
 #define __ARCH_WANT_NEW_STAT
include/uapi/asm-generic/unistd.h +0 -4
index d4cc26932ff4..5bf6148cac2b 100644
@@ -776,12 +776,8 @@ __SYSCALL(__NR_fsmount, sys_fsmount)
 __SYSCALL(__NR_fspick, sys_fspick)
 #define __NR_pidfd_open 434
 __SYSCALL(__NR_pidfd_open, sys_pidfd_open)
-
-#ifdef __ARCH_WANT_SYS_CLONE3
 #define __NR_clone3 435
 __SYSCALL(__NR_clone3, sys_clone3)
-#endif
-
 #define __NR_close_range 436
 __SYSCALL(__NR_close_range, sys_close_range)
 #define __NR_openat2 437
kernel/fork.c +5 -3
index 99076dbe27d8..02f322424c49 100644
@@ -2941,8 +2941,6 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
 }
 #endif
 
-#ifdef __ARCH_WANT_SYS_CLONE3
-
 noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
 					      struct clone_args __user *uargs,
 					      size_t usize)
@@ -3086,6 +3084,11 @@ SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)
 	struct kernel_clone_args kargs;
 	pid_t set_tid[MAX_PID_NS_LEVEL];
 
+#ifdef __ARCH_BROKEN_SYS_CLONE3
+#warning clone3() entry point is missing, please fix
+	return -ENOSYS;
+#endif
+
 	kargs.set_tid = set_tid;
 
 	err = copy_clone_args_from_user(&kargs, uargs, size);
@@ -3097,7 +3100,6 @@ SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)
 
 	return kernel_clone(&kargs);
 }
-#endif
 
 void walk_process_tree(struct task_struct *top, proc_visitor visitor, void *data)
 {
kernel/sys_ni.c +0 -2
index b696b85ac63e..2ef820a2d067 100644
@@ -76,8 +76,6 @@ COND_SYSCALL(timerfd_gettime32);
 COND_SYSCALL(acct);
 COND_SYSCALL(capget);
 COND_SYSCALL(capset);
-/* __ARCH_WANT_SYS_CLONE3 */
-COND_SYSCALL(clone3);
 COND_SYSCALL(futex);
 COND_SYSCALL(futex_time32);
 COND_SYSCALL(set_robust_list);
tools/arch/arm64/include/uapi/asm/unistd.h +0 -1
index ce2ee8f1e361..9306726337fe 100644
@@ -19,7 +19,6 @@
 #define __ARCH_WANT_NEW_STAT
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_MEMFD_SECRET
 
 #include <asm-generic/unistd.h>
tools/arch/loongarch/include/uapi/asm/unistd.h +0 -1
index 0c743344e92d..8eeaac0087c3 100644
@@ -4,6 +4,5 @@
  */
 
 #define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_CLONE3
 
 #include <asm-generic/unistd.h>
tools/include/uapi/asm-generic/unistd.h +0 -4
index d983c48a3b6a..a00d53d02723 100644
@@ -776,12 +776,8 @@ __SYSCALL(__NR_fsmount, sys_fsmount)
 __SYSCALL(__NR_fspick, sys_fspick)
 #define __NR_pidfd_open 434
 __SYSCALL(__NR_pidfd_open, sys_pidfd_open)
-
-#ifdef __ARCH_WANT_SYS_CLONE3
 #define __NR_clone3 435
 __SYSCALL(__NR_clone3, sys_clone3)
-#endif
-
 #define __NR_close_range 436
 __SYSCALL(__NR_close_range, sys_close_range)
 #define __NR_openat2 437
Signature · 1 line
2.39.2
#17 lore raw

PATCH 8/17 arc: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_32.h and asm/syscall_table_32.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

arc has a couple of architecture specific system calls, which I add to the generic table. This for some reason includes the deprecated sys_sysfs() syscall that was presumably added by accident.

The time32, renameat, stat64 and rlimit entries in the syscall_abis_32 entry are for system calls that were part of the generic ABI when arch/arc got added but are no longer enabled by default for new architectures.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

---
 arch/arc/include/asm/Kbuild        |  2 ++
 arch/arc/include/asm/unistd.h      | 14 ++++++++++
 arch/arc/include/uapi/asm/Kbuild   |  2 ++
 arch/arc/include/uapi/asm/unistd.h | 43 +-----------------------------
 arch/arc/kernel/Makefile.syscalls  |  3 +++
 arch/arc/kernel/sys.c              |  5 ++--
 scripts/syscall.tbl                |  5 ++++
 7 files changed, 30 insertions(+), 44 deletions(-)
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/kernel/Makefile.syscalls
arch/arc/include/asm/Kbuild +2 -0
index 3c1afa524b9c..49285a3ce239 100644
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+
 generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
arch/arc/include/asm/unistd.h new file +14 -0
new file mode 100644
index 000000000000..211c230d88d6
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_ARC_UNISTD_H
+#define _ASM_ARC_UNISTD_H
+
+#include <uapi/asm/unistd.h>
+
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_VFORK
+#define __ARCH_WANT_SYS_FORK
+
+#define NR_syscalls __NR_syscalls
+
+#endif
arch/arc/include/uapi/asm/Kbuild +2 -0
index e78470141932..2501e82a1a0a 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
arch/arc/include/uapi/asm/unistd.h +1 -42

46 lines not on this page · raw message

arch/arc/kernel/Makefile.syscalls new file +3 -0
new file mode 100644
index 000000000000..391d30ab7a83
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += arc time32 renameat stat64 rlimit
arch/arc/kernel/sys.c +3 -2
index 1069446bdc58..36a2a95c083b 100644
@@ -8,11 +8,12 @@
 
 #define sys_clone	sys_clone_wrapper
 #define sys_clone3	sys_clone3_wrapper
+#define sys_mmap2	sys_mmap_pgoff
 
-#undef __SYSCALL
 #define __SYSCALL(nr, call) [nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat)  __SYSCALL(nr, native)
 
 void *sys_call_table[NR_syscalls] = {
 	[0 ... NR_syscalls-1] = sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
scripts/syscall.tbl +5 -0
index 7871bbfa9b58..13f4c79ba5c2 100644
@@ -288,6 +288,11 @@
 243	time32	recvmmsg			sys_recvmmsg_time32		compat_sys_recvmmsg_time32
 243	64	recvmmsg			sys_recvmmsg
 # Architectures may provide up to 16 syscalls of their own between 244 and 259
+244	arc	cacheflush			sys_cacheflush
+245	arc	arc_settls			sys_arc_settls
+246	arc	arc_gettls			sys_arc_gettls
+247	arc	sysfs				sys_sysfs
+248	arc	arc_usr_cmpxchg			sys_arc_usr_cmpxchg
 260	time32	wait4				sys_wait4			compat_sys_wait4
 260	64	wait4				sys_wait4
 261	common	prlimit64			sys_prlimit64
Signature · 1 line
2.39.2
#18 lore raw

PATCH 9/17 arm64: convert unistd_32.h to syscall.tbl format

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This is a straight conversion from the old asm/unistd32.h into the format used by 32-bit arm and most other architectures, calling scripts to generate the asm/unistd32.h header and a new asm/syscalls32.h headers.

I used a semi-automated text replacement method to do the conversion, and then used 'vimdiff' to synchronize the whitespace and the (unused) names of the non-compat syscalls with the arm version.

There are two differences between the generated syscalls names and the old version:

- the old asm/unistd32.h contained only a __NR_sync_file_range2 entry, while the arm32 version also defines __NR_arm_sync_file_range with the same number. I added this duplicate back in asm/unistd32.h.

- __NR__sysctl was removed from the arm64 file a while ago, but all the tables still contain it. This should probably get removed everywhere but I added it here for consistency.

On top of that, the arm64 version does not contain any references to the 32-bit OABI syscalls that are not supported by arm64. If we ever want to share the file between arm32 and arm64, it would not be hard to add support for both in one file.

---
 arch/arm64/include/asm/Kbuild       |   7 +
 arch/arm64/include/asm/seccomp.h    |   2 +-
 arch/arm64/include/asm/unistd.h     |   2 -
 arch/arm64/include/asm/unistd32.h   | 939 +---------------------------
 arch/arm64/kernel/Makefile.syscalls |   5 +
 arch/arm64/kernel/sys32.c           |  17 +-
 arch/arm64/kernel/syscall.c         |   3 +-
 arch/arm64/tools/syscall_32.tbl     | 476 ++++++++++++++
 8 files changed, 503 insertions(+), 948 deletions(-)
 create mode 100644 arch/arm64/kernel/Makefile.syscalls
 create mode 100644 arch/arm64/tools/syscall_32.tbl
arch/arm64/include/asm/Kbuild +7 -0
index 4b6d2d52053e..3fc45ef32e85 100644
@@ -1,4 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+
+# arm32 syscall table used by lib/compat_audit.c:
+syscall-y += unistd_32.h
+# same constants with prefixes, used by vdso, seccomp and sigreturn:
+syscall-y += unistd_compat_32.h
+
 generic-y += early_ioremap.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
arch/arm64/include/asm/seccomp.h +1 -1
index 30256233788b..d56164d3cac5 100644
@@ -24,7 +24,7 @@
 #define SECCOMP_ARCH_NATIVE_NAME	"aarch64"
 #ifdef CONFIG_COMPAT
 # define SECCOMP_ARCH_COMPAT		AUDIT_ARCH_ARM
-# define SECCOMP_ARCH_COMPAT_NR	__NR_compat_syscalls
+# define SECCOMP_ARCH_COMPAT_NR		__NR_compat32_syscalls
 # define SECCOMP_ARCH_COMPAT_NAME	"arm"
 #endif
 
arch/arm64/include/asm/unistd.h +0 -2
index 1346579f802f..55ac26355be4 100644
@@ -38,8 +38,6 @@
 #define __ARM_NR_compat_cacheflush	(__ARM_NR_COMPAT_BASE + 2)
 #define __ARM_NR_compat_set_tls		(__ARM_NR_COMPAT_BASE + 5)
 #define __ARM_NR_COMPAT_END		(__ARM_NR_COMPAT_BASE + 0x800)
-
-#define __NR_compat_syscalls		463
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +5 -934

943 lines not on this page · raw message

arch/arm64/kernel/Makefile.syscalls new file +5 -0
new file mode 100644
index 000000000000..1e14effb3921
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 +=
+
+syscalltbl = arch/arm64/tools/syscall_%.tbl
arch/arm64/kernel/sys32.c +7 -10
index fc40386afb1b..96bcfb907443 100644
@@ -5,17 +5,12 @@
  * Copyright (C) 2015 ARM Ltd.
  */
 
-/*
- * Needed to avoid conflicting __NR_* macros between uapi/asm/unistd.h and
- * asm/unistd32.h.
- */
-#define __COMPAT_SYSCALL_NR
-
 #include <linux/compat.h>
 #include <linux/compiler.h>
 #include <linux/syscalls.h>
 
 #include <asm/syscall.h>
+#include <asm/unistd_compat_32.h>
 
 asmlinkage long compat_sys_sigreturn(void);
 asmlinkage long compat_sys_rt_sigreturn(void);
@@ -122,14 +117,16 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode,
 	return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len));
 }
 
+#define __SYSCALL_WITH_COMPAT(nr, sym, compat) __SYSCALL(nr, compat)
+
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)	asmlinkage long __arm64_##sym(const struct pt_regs *);
-#include <asm/unistd32.h>
+#include <asm/syscall_table_32.h>
 
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)	[nr] = __arm64_##sym,
 
-const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = {
-	[0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall,
-#include <asm/unistd32.h>
+const syscall_fn_t compat_sys_call_table[__NR_compat32_syscalls] = {
+	[0 ... __NR_compat32_syscalls - 1] = __arm64_sys_ni_syscall,
+#include <asm/syscall_table_32.h>
 };
arch/arm64/kernel/syscall.c +2 -1
index 7230f6e20ab8..c442fcec6b9e 100644
@@ -14,6 +14,7 @@
 #include <asm/syscall.h>
 #include <asm/thread_info.h>
 #include <asm/unistd.h>
+#include <asm/unistd_compat_32.h>
 
 long compat_arm_syscall(struct pt_regs *regs, int scno);
 long sys_ni_syscall(void);
@@ -153,7 +154,7 @@ void do_el0_svc(struct pt_regs *regs)
 #ifdef CONFIG_COMPAT
 void do_el0_svc_compat(struct pt_regs *regs)
 {
-	el0_svc_common(regs, regs->regs[7], __NR_compat_syscalls,
+	el0_svc_common(regs, regs->regs[7], __NR_compat32_syscalls,
 		       compat_sys_call_table);
 }
 #endif
arch/arm64/tools/syscall_32.tbl new file +476 -0

476 lines not on this page · raw message

Signature · 1 line
2.39.2
#20 lore raw

PATCH 10/17 arm64: generate 64-bit syscall.tbl

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Change the asm/unistd.h header for arm64 to no longer include asm-generic/unistd.h itself, but instead generate both the asm/unistd.h contents and the list of entry points using the syscall.tbl scripts that we use on most other architectures.

Once his is done for the remaining architectures, the generic unistd.h header can be removed and the generated tbl file put in its place.

The Makefile changes are more complex than they should be, I need a little help to improve those. Ideally this should be done in an architecture-independent way as well.

---
 arch/arm64/include/asm/Kbuild        |  1 +
 arch/arm64/include/asm/seccomp.h     |  1 +
 arch/arm64/include/asm/unistd.h      |  5 ++---
 arch/arm64/include/uapi/asm/Kbuild   |  1 +
 arch/arm64/include/uapi/asm/unistd.h | 24 +-----------------------
 arch/arm64/kernel/Makefile.syscalls  |  1 +
 arch/arm64/kernel/sys.c              |  6 ++++--
 arch/arm64/tools/Makefile            |  6 +++++-
 arch/arm64/tools/syscall_64.tbl      |  1 +
 9 files changed, 17 insertions(+), 29 deletions(-)
 create mode 120000 arch/arm64/tools/syscall_64.tbl
arch/arm64/include/asm/Kbuild +1 -0
index 3fc45ef32e85..7d7d97ad3cd5 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 syscall-y += syscall_table_32.h
+syscall-y += syscall_table_64.h
 
 # arm32 syscall table used by lib/compat_audit.c:
 syscall-y += unistd_32.h
arch/arm64/include/asm/seccomp.h +1 -0
index d56164d3cac5..c83ca2c8b936 100644
@@ -23,6 +23,7 @@
 #define SECCOMP_ARCH_NATIVE_NR		NR_syscalls
 #define SECCOMP_ARCH_NATIVE_NAME	"aarch64"
 #ifdef CONFIG_COMPAT
+#include <asm/unistd_compat_32.h>
 # define SECCOMP_ARCH_COMPAT		AUDIT_ARCH_ARM
 # define SECCOMP_ARCH_COMPAT_NR		__NR_compat32_syscalls
 # define SECCOMP_ARCH_COMPAT_NAME	"arm"
arch/arm64/include/asm/unistd.h +2 -3
index 55ac26355be4..fdd16052f9bc 100644
@@ -41,9 +41,8 @@
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_NEW_STAT
 
-#ifndef __COMPAT_SYSCALL_NR
-#include <uapi/asm/unistd.h>
-#endif
+#include <asm/unistd_64.h>
 
 #define NR_syscalls (__NR_syscalls)
arch/arm64/include/uapi/asm/Kbuild +1 -0
index 602d137932dc..c6d141d7b7d7 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_64.h
 
 generic-y += kvm_para.h
arch/arm64/include/uapi/asm/unistd.h +1 -23
index 9306726337fe..038dddf8f554 100644
@@ -1,24 +1,2 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright (C) 2012 ARM Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define __ARCH_WANT_RENAMEAT
-#define __ARCH_WANT_NEW_STAT
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_MEMFD_SECRET
-
-#include <asm-generic/unistd.h>
+#include <unistd_64.h>
arch/arm64/kernel/Makefile.syscalls +1 -0
index 1e14effb3921..3cfafd003b2d 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
 syscall_abis_32 +=
+syscall_abis_64 += renameat newstat rlimit memfd_secret
 
 syscalltbl = arch/arm64/tools/syscall_%.tbl
arch/arm64/kernel/sys.c +4 -2
index d5ffaaab31a7..f08408b6e826 100644
@@ -48,14 +48,16 @@ asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
  */
 #define __arm64_sys_personality		__arm64_sys_arm64_personality
 
+#define __SYSCALL_WITH_COMPAT(nr, native, compat)  __SYSCALL(nr, native)
+
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)	asmlinkage long __arm64_##sym(const struct pt_regs *);
-#include <asm/unistd.h>
+#include <asm/syscall_table_64.h>
 
 #undef __SYSCALL
 #define __SYSCALL(nr, sym)	[nr] = __arm64_##sym,
 
 const syscall_fn_t sys_call_table[__NR_syscalls] = {
 	[0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_64.h>
 };
arch/arm64/tools/Makefile +5 -1
index fa2251d9762d..c2b34e761006 100644
@@ -3,12 +3,16 @@
 gen := arch/$(ARCH)/include/generated
 kapi := $(gen)/asm
 
-kapi-hdrs-y := $(kapi)/cpucap-defs.h $(kapi)/sysreg-defs.h
+kapisyshdr-y := cpucap-defs.h sysreg-defs.h
+
+kapi-hdrs-y := $(addprefix $(kapi)/, $(kapisyshdr-y))
 
 targets += $(addprefix ../../../, $(kapi-hdrs-y))
 
 PHONY += kapi
 
+all: $(syscall64) kapi
+
 kapi:   $(kapi-hdrs-y)
 
 quiet_cmd_gen_cpucaps = GEN     $@
arch/arm64/tools/syscall_64.tbl new file +1 -0
new file mode 120000
index 000000000000..63135cf34b65
@@ -0,0 +1 @@
+../../../scripts/syscall.tbl
\ No newline at end of file
Signature · 1 line
2.39.2
#25 lore raw

PATCH 11/17 arm64: rework compat syscall macros

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The generated asm/unistd_compat_32.h header file now contains macros that can be used directly in the vdso and the signal trampolines, so remove the duplicate definitions.

---
 arch/arm64/include/asm/seccomp.h               | 10 +++++-----
 arch/arm64/include/asm/unistd.h                | 15 ---------------
 .../include/asm/vdso/compat_gettimeofday.h     | 12 ++++++------
 arch/arm64/kernel/signal32.c                   |  2 +-
 arch/arm64/kernel/sigreturn32.S                | 18 +++++++++---------
 5 files changed, 21 insertions(+), 36 deletions(-)
arch/arm64/include/asm/seccomp.h +5 -5
index c83ca2c8b936..b83975555314 100644
@@ -8,13 +8,13 @@
 #ifndef _ASM_SECCOMP_H
 #define _ASM_SECCOMP_H
 
-#include <asm/unistd.h>
+#include <asm/unistd_compat_32.h>
 
 #ifdef CONFIG_COMPAT
-#define __NR_seccomp_read_32		__NR_compat_read
-#define __NR_seccomp_write_32		__NR_compat_write
-#define __NR_seccomp_exit_32		__NR_compat_exit
-#define __NR_seccomp_sigreturn_32	__NR_compat_rt_sigreturn
+#define __NR_seccomp_read_32		__NR_compat32_read
+#define __NR_seccomp_write_32		__NR_compat32_write
+#define __NR_seccomp_exit_32		__NR_compat32_exit
+#define __NR_seccomp_sigreturn_32	__NR_compat32_rt_sigreturn
 #endif /* CONFIG_COMPAT */
 
 #include <asm-generic/seccomp.h>
arch/arm64/include/asm/unistd.h +0 -15
index fdd16052f9bc..80618c9bbcd8 100644
@@ -16,21 +16,6 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 
-/*
- * Compat syscall numbers used by the AArch64 kernel.
- */
-#define __NR_compat_restart_syscall	0
-#define __NR_compat_exit		1
-#define __NR_compat_read		3
-#define __NR_compat_write		4
-#define __NR_compat_gettimeofday	78
-#define __NR_compat_sigreturn		119
-#define __NR_compat_rt_sigreturn	173
-#define __NR_compat_clock_gettime	263
-#define __NR_compat_clock_getres	264
-#define __NR_compat_clock_gettime64	403
-#define __NR_compat_clock_getres_time64	406
-
 /*
  * The following SVCs are ARM private.
  */
arch/arm64/include/asm/vdso/compat_gettimeofday.h +6 -6
index ecb6fd4c3c64..778c1202bbbf 100644
@@ -8,7 +8,7 @@
 #ifndef __ASSEMBLY__
 
 #include <asm/barrier.h>
-#include <asm/unistd.h>
+#include <asm/unistd_compat_32.h>
 #include <asm/errno.h>
 
 #include <asm/vdso/compat_barrier.h>
@@ -24,7 +24,7 @@ int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
 	register struct timezone *tz asm("r1") = _tz;
 	register struct __kernel_old_timeval *tv asm("r0") = _tv;
 	register long ret asm ("r0");
-	register long nr asm("r7") = __NR_compat_gettimeofday;
+	register long nr asm("r7") = __NR_compat32_gettimeofday;
 
 	asm volatile(
 	"	swi #0\n"
@@ -41,7 +41,7 @@ long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 	register struct __kernel_timespec *ts asm("r1") = _ts;
 	register clockid_t clkid asm("r0") = _clkid;
 	register long ret asm ("r0");
-	register long nr asm("r7") = __NR_compat_clock_gettime64;
+	register long nr asm("r7") = __NR_compat32_clock_gettime64;
 
 	asm volatile(
 	"	swi #0\n"
@@ -58,7 +58,7 @@ long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 	register struct old_timespec32 *ts asm("r1") = _ts;
 	register clockid_t clkid asm("r0") = _clkid;
 	register long ret asm ("r0");
-	register long nr asm("r7") = __NR_compat_clock_gettime;
+	register long nr asm("r7") = __NR_compat32_clock_gettime;
 
 	asm volatile(
 	"	swi #0\n"
@@ -75,7 +75,7 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 	register struct __kernel_timespec *ts asm("r1") = _ts;
 	register clockid_t clkid asm("r0") = _clkid;
 	register long ret asm ("r0");
-	register long nr asm("r7") = __NR_compat_clock_getres_time64;
+	register long nr asm("r7") = __NR_compat32_clock_getres_time64;
 
 	asm volatile(
 	"       swi #0\n"
@@ -92,7 +92,7 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 	register struct old_timespec32 *ts asm("r1") = _ts;
 	register clockid_t clkid asm("r0") = _clkid;
 	register long ret asm ("r0");
-	register long nr asm("r7") = __NR_compat_clock_getres;
+	register long nr asm("r7") = __NR_compat32_clock_getres;
 
 	asm volatile(
 	"       swi #0\n"
arch/arm64/kernel/signal32.c +1 -1
index bbd542704730..50b74cc5c64d 100644
@@ -451,7 +451,7 @@ int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
 
 void compat_setup_restart_syscall(struct pt_regs *regs)
 {
-       regs->regs[7] = __NR_compat_restart_syscall;
+       regs->regs[7] = __NR_compat32_restart_syscall;
 }
 
 /*
arch/arm64/kernel/sigreturn32.S +9 -9
index ccbd4aab4ba4..6f486b95b413 100644
@@ -13,7 +13,7 @@
  * need two 16-bit instructions.
  */
 
-#include <asm/unistd.h>
+#include <asm/unistd_compat_32.h>
 
 	.section .rodata
 	.globl __aarch32_sigret_code_start
@@ -22,26 +22,26 @@ __aarch32_sigret_code_start:
 	/*
 	 * ARM Code
 	 */
-	.byte	__NR_compat_sigreturn, 0x70, 0xa0, 0xe3		// mov	r7, #__NR_compat_sigreturn
-	.byte	__NR_compat_sigreturn, 0x00, 0x00, 0xef		// svc	#__NR_compat_sigreturn
+	.byte	__NR_compat32_sigreturn, 0x70, 0xa0, 0xe3	// mov	r7, #__NR_compat32_sigreturn
+	.byte	__NR_compat32_sigreturn, 0x00, 0x00, 0xef	// svc	#__NR_compat32_sigreturn
 
 	/*
 	 * Thumb code
 	 */
-	.byte	__NR_compat_sigreturn, 0x27			// svc	#__NR_compat_sigreturn
-	.byte	__NR_compat_sigreturn, 0xdf			// mov	r7, #__NR_compat_sigreturn
+	.byte	__NR_compat32_sigreturn, 0x27			// svc	#__NR_compat32_sigreturn
+	.byte	__NR_compat32_sigreturn, 0xdf			// mov	r7, #__NR_compat32_sigreturn
 
 	/*
 	 * ARM code
 	 */
-	.byte	__NR_compat_rt_sigreturn, 0x70, 0xa0, 0xe3	// mov	r7, #__NR_compat_rt_sigreturn
-	.byte	__NR_compat_rt_sigreturn, 0x00, 0x00, 0xef	// svc	#__NR_compat_rt_sigreturn
+	.byte	__NR_compat32_rt_sigreturn, 0x70, 0xa0, 0xe3	// mov	r7, #__NR_compat32_rt_sigreturn
+	.byte	__NR_compat32_rt_sigreturn, 0x00, 0x00, 0xef	// svc	#__NR_compat32_rt_sigreturn
 
 	/*
 	 * Thumb code
 	 */
-	.byte	__NR_compat_rt_sigreturn, 0x27			// svc	#__NR_compat_rt_sigreturn
-	.byte	__NR_compat_rt_sigreturn, 0xdf			// mov	r7, #__NR_compat_rt_sigreturn
+	.byte	__NR_compat32_rt_sigreturn, 0x27		// svc	#__NR_compat32_rt_sigreturn
+	.byte	__NR_compat32_rt_sigreturn, 0xdf		// mov	r7, #__NR_compat32_rt_sigreturn
 
         .globl __aarch32_sigret_code_end
 __aarch32_sigret_code_end:
Signature · 1 line
2.39.2
#27 lore raw

PATCH 12/17 csky: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_32.h and asm/syscall_table_32.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

csky has two architecture specific system calls, which I add to the generic table. The time32, stat64 and rlimit entries in the syscall_abis_32 line are for system calls that were part of the generic ABI when arch/csky got added but are no longer enabled by default for new architectures.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

---
 arch/csky/include/asm/Kbuild        |  2 ++
 arch/csky/include/asm/unistd.h      |  3 +++
 arch/csky/include/uapi/asm/Kbuild   |  2 ++
 arch/csky/include/uapi/asm/unistd.h | 14 ++------------
 arch/csky/kernel/Makefile.syscalls  |  4 ++++
 arch/csky/kernel/syscall_table.c    |  4 +++-
 scripts/syscall.tbl                 |  4 ++++
 7 files changed, 20 insertions(+), 13 deletions(-)
 create mode 100644 arch/csky/kernel/Makefile.syscalls
arch/csky/include/asm/Kbuild +2 -0
index 13ebc5e34360..9a9bc65b57a9 100644
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y := syscall_table_32.h
+
 generic-y += asm-offsets.h
 generic-y += extable.h
 generic-y += kvm_para.h
arch/csky/include/asm/unistd.h +3 -0
index 9cf97de9a26d..2c2c24de95d8 100644
@@ -2,4 +2,7 @@
 
 #include <uapi/asm/unistd.h>
 
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_CLONE
+
 #define NR_syscalls (__NR_syscalls)
arch/csky/include/uapi/asm/Kbuild +2 -0
index e78470141932..2501e82a1a0a 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
arch/csky/include/uapi/asm/unistd.h +2 -12
index d529d0432876..794adbc04e48 100644
@@ -1,14 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 
-#define __ARCH_WANT_STAT64
-#define __ARCH_WANT_NEW_STAT
-#define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_SYNC_FILE_RANGE2
-#include <asm-generic/unistd.h>
-
-#define __NR_set_thread_area	(__NR_arch_specific_syscall + 0)
-__SYSCALL(__NR_set_thread_area, sys_set_thread_area)
-#define __NR_cacheflush		(__NR_arch_specific_syscall + 1)
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
+#include <asm/unistd_32.h>
+#define __NR_sync_file_range2 __NR_sync_file_range
arch/csky/kernel/Makefile.syscalls new file +4 -0
new file mode 100644
index 000000000000..3df3b5822fce
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += csky time32 stat64 rlimit
+
arch/csky/kernel/syscall_table.c +3 -1
index a0c238c5377a..a6eb91a0e2f6 100644
@@ -6,9 +6,11 @@
 
 #undef __SYSCALL
 #define __SYSCALL(nr, call)[nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
 
 #define sys_fadvise64_64 sys_csky_fadvise64_64
+#define sys_sync_file_range sys_sync_file_range2
 void * const sys_call_table[__NR_syscalls] __page_aligned_data = {
 	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
scripts/syscall.tbl +4 -0
index 13f4c79ba5c2..ed0ecba8fea4 100644
@@ -293,6 +293,10 @@
 246	arc	arc_gettls			sys_arc_gettls
 247	arc	sysfs				sys_sysfs
 248	arc	arc_usr_cmpxchg			sys_arc_usr_cmpxchg
+
+244	csky	set_thread_area			sys_set_thread_area
+245	csky	cacheflush			sys_cacheflush
+
 260	time32	wait4				sys_wait4			compat_sys_wait4
 260	64	wait4				sys_wait4
 261	common	prlimit64			sys_prlimit64
Signature · 1 line
2.39.2
#30 lore raw

PATCH 13/17 hexagon: use new system call table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_32.h and asm/syscall_table_32.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

The time32, stat64, rlimit and renameat entries in the syscall_abis_32 line are for system calls that were part of the generic ABI when arch/hexagon got added but are no longer enabled by default for new architectures.

As a side-effect, calling an unimplemented syscall now return -ENOSYS rather than branching into a NULL pointer.

---
 arch/hexagon/include/asm/Kbuild        |  2 ++
 arch/hexagon/include/asm/unistd.h      | 10 ++++++++++
 arch/hexagon/include/uapi/asm/Kbuild   |  2 ++
 arch/hexagon/include/uapi/asm/unistd.h | 15 ++-------------
 arch/hexagon/kernel/Makefile.syscalls  |  3 +++
 arch/hexagon/kernel/syscalltab.c       |  8 ++++++--
 6 files changed, 25 insertions(+), 15 deletions(-)
 create mode 100644 arch/hexagon/include/asm/unistd.h
 create mode 100644 arch/hexagon/kernel/Makefile.syscalls
arch/hexagon/include/asm/Kbuild +2 -0
index 3ece3c93fe08..8c1a78c8f527 100644
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+
 generic-y += extable.h
 generic-y += iomap.h
 generic-y += kvm_para.h
arch/hexagon/include/asm/unistd.h new file +10 -0
new file mode 100644
index 000000000000..1f462bade75c
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_VFORK
+#define __ARCH_WANT_SYS_FORK
+
+#define __ARCH_BROKEN_SYS_CLONE3
+
+#include <uapi/asm/unistd.h>
arch/hexagon/include/uapi/asm/Kbuild +2 -0
index e78470141932..2501e82a1a0a 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
arch/hexagon/include/uapi/asm/unistd.h +2 -13
index 4bea7428e747..6f670347dd61 100644
@@ -27,17 +27,6 @@
  *  See also:  syscalltab.c
  */
 
-#define sys_mmap2 sys_mmap_pgoff
-#define __ARCH_WANT_RENAMEAT
-#define __ARCH_WANT_STAT64
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_SYS_EXECVE
-#define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_VFORK
-#define __ARCH_WANT_SYS_FORK
-#define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_SYNC_FILE_RANGE2
+#include <asm/unistd_32.h>
 
-#define __ARCH_BROKEN_SYS_CLONE3
-
-#include <asm-generic/unistd.h>
+#define __NR_sync_file_range2 __NR_sync_file_range
arch/hexagon/kernel/Makefile.syscalls new file +3 -0
new file mode 100644
index 000000000000..d2b7c5d44d95
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += hexagon time32 stat64 rlimit renameat
arch/hexagon/kernel/syscalltab.c +6 -2
index 5d98bdc494ec..b53e2eead4ac 100644
@@ -11,8 +11,10 @@
 
 #include <asm/syscall.h>
 
-#undef __SYSCALL
 #define __SYSCALL(nr, call) [nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat)        __SYSCALL(nr, native)
+
+#define sys_mmap2 sys_mmap_pgoff
 
 SYSCALL_DEFINE6(hexagon_fadvise64_64, int, fd, int, advice,
 		SC_ARG64(offset), SC_ARG64(len))
@@ -21,6 +23,8 @@ SYSCALL_DEFINE6(hexagon_fadvise64_64, int, fd, int, advice,
 }
 #define sys_fadvise64_64 sys_hexagon_fadvise64_64
 
+#define sys_sync_file_range sys_sync_file_range2
+
 void *sys_call_table[__NR_syscalls] = {
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
Signature · 1 line
2.39.2
#31 lore raw

PATCH 14/17 loongarch: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_64.h and asm/syscall_table_64.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

Unlike the other architectures using the asm-generic header, loongarch uses none of the deprecated system calls at the moment.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

---
 arch/loongarch/include/asm/Kbuild        | 1 +
 arch/loongarch/include/asm/unistd.h      | 2 ++
 arch/loongarch/include/uapi/asm/Kbuild   | 2 ++
 arch/loongarch/include/uapi/asm/unistd.h | 3 +--
 arch/loongarch/kernel/Makefile.syscalls  | 4 ++++
 arch/loongarch/kernel/syscall.c          | 3 ++-
 6 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 arch/loongarch/kernel/Makefile.syscalls
arch/loongarch/include/asm/Kbuild +1 -0
index 0db5ad14f014..2bb3676429c0 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_64.h
 generated-y += orc_hash.h
 
 generic-y += mcs_spinlock.h
arch/loongarch/include/asm/unistd.h +2 -0
index cfddb0116a8c..fc0a481a7416 100644
@@ -8,4 +8,6 @@
 
 #include <uapi/asm/unistd.h>
 
+#define __ARCH_WANT_SYS_CLONE
+
 #define NR_syscalls (__NR_syscalls)
arch/loongarch/include/uapi/asm/Kbuild +2 -0
index 4aa680ca2e5f..c6d141d7b7d7 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_64.h
+
 generic-y += kvm_para.h
arch/loongarch/include/uapi/asm/unistd.h +1 -2
index 191614b9b207..1f01980f9c94 100644
@@ -1,4 +1,3 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#define __ARCH_WANT_SYS_CLONE
 
-#include <asm-generic/unistd.h>
+#include <asm/unistd_64.h>
arch/loongarch/kernel/Makefile.syscalls new file +4 -0
new file mode 100644
index 000000000000..ab7d9baa2915
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# No special ABIs on loongarch so far
+syscall_abis_64 +=
arch/loongarch/kernel/syscall.c +2 -1
index 8801611143ab..ec17cd5163b7 100644
@@ -20,6 +20,7 @@
 
 #undef __SYSCALL
 #define __SYSCALL(nr, call)	[nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
 
 SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long,
 		prot, unsigned long, flags, unsigned long, fd, unsigned long, offset)
@@ -32,7 +33,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long,
 
 void *sys_call_table[__NR_syscalls] = {
 	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_64.h>
 };
 
 typedef long (*sys_call_fn)(unsigned long, unsigned long,
Signature · 1 line
2.39.2
#32 lore raw

PATCH 15/17 nios2: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_32.h and asm/syscall_table_32.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

nios2 has one extra system call that gets added to scripts/syscall.tbl.

The time32, stat64, and rlimit entries in the syscall_abis_32 line are for system calls that were part of the generic ABI when arch/nios2 got added but are no longer enabled by default for new architectures.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

---
 arch/nios2/include/asm/Kbuild        |  2 ++
 arch/nios2/include/asm/unistd.h      | 12 ++++++++++++
 arch/nios2/include/uapi/asm/Kbuild   |  2 ++
 arch/nios2/include/uapi/asm/unistd.h | 16 +---------------
 arch/nios2/kernel/Makefile.syscalls  |  3 +++
 arch/nios2/kernel/syscall_table.c    |  6 ++++--
 scripts/syscall.tbl                  |  2 ++
 7 files changed, 26 insertions(+), 17 deletions(-)
 create mode 100644 arch/nios2/include/asm/unistd.h
 create mode 100644 arch/nios2/kernel/Makefile.syscalls
arch/nios2/include/asm/Kbuild +2 -0
index 7fe7437555fb..0d09829ed144 100644
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+
 generic-y += cmpxchg.h
 generic-y += extable.h
 generic-y += kvm_para.h
arch/nios2/include/asm/unistd.h new file +12 -0
new file mode 100644
index 000000000000..1146e56473c5
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_UNISTD_H
+#define __ASM_UNISTD_H
+
+#include <uapi/asm/unistd.h>
+
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SET_GET_RLIMIT
+
+#define __ARCH_BROKEN_SYS_CLONE3
+
+#endif
arch/nios2/include/uapi/asm/Kbuild +2 -0
index e78470141932..2501e82a1a0a 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
arch/nios2/include/uapi/asm/unistd.h +1 -15
index d2bc5ac975fb..1f0e0f5538d9 100644
@@ -16,18 +16,4 @@
  *
  */
 
- #define sys_mmap2 sys_mmap_pgoff
-
-#define __ARCH_WANT_RENAMEAT
-#define __ARCH_WANT_STAT64
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_TIME32_SYSCALLS
-
-#define __ARCH_BROKEN_SYS_CLONE3
-
-/* Use the standard ABI for syscalls */
-#include <asm-generic/unistd.h>
-
-/* Additional Nios II specific syscalls. */
-#define __NR_cacheflush (__NR_arch_specific_syscall)
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
+#include <asm/unistd_32.h>
arch/nios2/kernel/Makefile.syscalls new file +3 -0
new file mode 100644
index 000000000000..579a9daec272
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += nios2 time32 stat64 renameat rlimit
arch/nios2/kernel/syscall_table.c +4 -2
index c2875a6dd5a4..434694067d8f 100644
@@ -9,10 +9,12 @@
 
 #include <asm/syscalls.h>
 
-#undef __SYSCALL
 #define __SYSCALL(nr, call) [nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat)        __SYSCALL(nr, native)
+
+#define sys_mmap2 sys_mmap_pgoff
 
 void *sys_call_table[__NR_syscalls] = {
 	[0 ... __NR_syscalls-1] = sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
scripts/syscall.tbl +2 -0
index ed0ecba8fea4..40307011abdb 100644
@@ -297,6 +297,8 @@
 244	csky	set_thread_area			sys_set_thread_area
 245	csky	cacheflush			sys_cacheflush
 
+244	nios2	cacheflush			sys_cacheflush
+
 260	time32	wait4				sys_wait4			compat_sys_wait4
 260	64	wait4				sys_wait4
 261	common	prlimit64			sys_prlimit64
Signature · 1 line
2.39.2
#33 lore raw

PATCH 16/17 openrisc: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_32.h and asm/syscall_table_32.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

openrisc has one extra system call that gets added to scripts/syscall.tbl.

The time32, stat64, rlimit and renameat entries in the syscall_abis_32 line are for system calls that were part of the generic ABI when arch/nios2 got added but are no longer enabled by default for new architectures.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

When asm/syscalls.h is included in kernel/fork.c for the purpose of type checking, the redirection macros cause problems. Move these so only the references get redirected.

---
 arch/openrisc/include/asm/Kbuild        |  2 ++
 arch/openrisc/include/asm/syscalls.h    |  4 ----
 arch/openrisc/include/asm/unistd.h      |  8 ++++++++
 arch/openrisc/include/uapi/asm/Kbuild   |  2 ++
 arch/openrisc/include/uapi/asm/unistd.h | 14 +-------------
 arch/openrisc/kernel/Makefile.syscalls  |  3 +++
 arch/openrisc/kernel/sys_call_table.c   |  9 +++++++--
 scripts/syscall.tbl                     |  2 ++
 8 files changed, 25 insertions(+), 19 deletions(-)
 create mode 100644 arch/openrisc/include/asm/unistd.h
 create mode 100644 arch/openrisc/kernel/Makefile.syscalls
arch/openrisc/include/asm/Kbuild +2 -0
index c8c99b554ca4..cef49d60d74c 100644
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+
 generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += parport.h
arch/openrisc/include/asm/syscalls.h +0 -4
index aa1c7e98722e..9f4c47961bea 100644
@@ -25,8 +25,4 @@ asmlinkage long __sys_clone(unsigned long clone_flags, unsigned long newsp,
 asmlinkage long __sys_clone3(struct clone_args __user *uargs, size_t size);
 asmlinkage long __sys_fork(void);
 
-#define sys_clone __sys_clone
-#define sys_clone3 __sys_clone3
-#define sys_fork __sys_fork
-
 #endif /* __ASM_OPENRISC_SYSCALLS_H */
arch/openrisc/include/asm/unistd.h new file +8 -0
new file mode 100644
index 000000000000..c73f65e18d3b
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_FORK
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_TIME32_SYSCALLS
+
+#include <uapi/asm/unistd.h>
arch/openrisc/include/uapi/asm/Kbuild +2 -0
index e78470141932..2501e82a1a0a 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
arch/openrisc/include/uapi/asm/unistd.h +1 -13
index 566f8c4f8047..46b94d454efd 100644
@@ -17,16 +17,4 @@
  * (at your option) any later version.
  */
 
-#define sys_mmap2 sys_mmap_pgoff
-
-#define __ARCH_WANT_RENAMEAT
-#define __ARCH_WANT_STAT64
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_SYS_FORK
-#define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_TIME32_SYSCALLS
-
-#include <asm-generic/unistd.h>
-
-#define __NR_or1k_atomic __NR_arch_specific_syscall
-__SYSCALL(__NR_or1k_atomic, sys_or1k_atomic)
+#include <asm/unistd_32.h>
arch/openrisc/kernel/Makefile.syscalls new file +3 -0
new file mode 100644
index 000000000000..525a1e7e7fc9
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += or1k time32 stat64 rlimit renameat
arch/openrisc/kernel/sys_call_table.c +7 -2
index 3d18008310e4..b2f57e2538f7 100644
@@ -16,9 +16,14 @@
 
 #include <asm/syscalls.h>
 
-#undef __SYSCALL
 #define __SYSCALL(nr, call) [nr] = (call),
+#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
+
+#define sys_mmap2 sys_mmap_pgoff
+#define sys_clone __sys_clone
+#define sys_clone3 __sys_clone3
+#define sys_fork __sys_fork
 
 void *sys_call_table[__NR_syscalls] = {
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
scripts/syscall.tbl +2 -0
index 40307011abdb..28329c00bf68 100644
@@ -299,6 +299,8 @@
 
 244	nios2	cacheflush			sys_cacheflush
 
+244	or1k	or1k_atomic			sys_or1k_atomic
+
 260	time32	wait4				sys_wait4			compat_sys_wait4
 260	64	wait4				sys_wait4
 261	common	prlimit64			sys_prlimit64
Signature · 1 line
2.39.2
#34 lore raw

PATCH 17/17 riscv: convert to generic syscall table

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The uapi/asm/unistd_{32,64}.h and asm/syscall_table_{32,64}.h headers can now be generated from scripts/syscall.tbl, which makes this consistent with the other architectures that have their own syscall.tbl.

riscv has two extra system call that gets added to scripts/syscall.tbl.

The newstat and rlimit entries in the syscall_abis_64 line are for system calls that were part of the generic ABI when riscv64 got added but are no longer enabled by default for new architectures. Both riscv32 and riscv64 also implement memfd_secret, which is optional for all architectures.

Unlike all the other 32-bit architectures, the time32 and stat64 sets of syscalls are not enabled on riscv32.

Both the user visible side of asm/unistd.h and the internal syscall table in the kernel should have the same effective contents after this.

---
 arch/riscv/include/asm/Kbuild            |  3 ++
 arch/riscv/include/asm/syscall_table.h   |  7 +++++
 arch/riscv/include/asm/unistd.h          | 13 +++++---
 arch/riscv/include/uapi/asm/Kbuild       |  2 ++
 arch/riscv/include/uapi/asm/unistd.h     | 40 +++---------------------
 arch/riscv/kernel/Makefile.syscalls      |  4 +++
 arch/riscv/kernel/compat_syscall_table.c |  6 ++--
 arch/riscv/kernel/syscall_table.c        |  6 ++--
 scripts/syscall.tbl                      |  3 ++
 9 files changed, 40 insertions(+), 44 deletions(-)
 create mode 100644 arch/riscv/include/asm/syscall_table.h
 create mode 100644 arch/riscv/kernel/Makefile.syscalls
arch/riscv/include/asm/Kbuild +3 -0
index 504f8b7e72d4..5c589770f2a8 100644
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += syscall_table_32.h
+syscall-y += syscall_table_64.h
+
 generic-y += early_ioremap.h
 generic-y += flat.h
 generic-y += kvm_para.h
arch/riscv/include/asm/syscall_table.h new file +7 -0
new file mode 100644
index 000000000000..0c2d61782813
@@ -0,0 +1,7 @@
+#include <asm/bitsperlong.h>
+
+#if __BITS_PER_LONG == 64
+#include <asm/syscall_table_64.h>
+#else
+#include <asm/syscall_table_32.h>
+#endif
arch/riscv/include/asm/unistd.h +8 -5
index 221630bdbd07..e6d904fa67c5 100644
@@ -3,11 +3,6 @@
  * Copyright (C) 2012 Regents of the University of California
  */
 
-/*
- * There is explicitly no include guard here because this file is expected to
- * be included multiple times.
- */
-
 #define __ARCH_WANT_SYS_CLONE
 
 #ifdef CONFIG_COMPAT
@@ -21,6 +16,14 @@
 #define __ARCH_WANT_COMPAT_FADVISE64_64
 #endif
 
+#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
+#define __ARCH_WANT_NEW_STAT
+#define __ARCH_WANT_SET_GET_RLIMIT
+#endif /* __LP64__ */
+
+#define __ARCH_WANT_MEMFD_SECRET
+
+
 #include <uapi/asm/unistd.h>
 
 #define NR_syscalls (__NR_syscalls)
arch/riscv/include/uapi/asm/Kbuild +2 -0
index f66554cd5c45..89ac01faa5ae 100644
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+syscall-y += unistd_64.h
arch/riscv/include/uapi/asm/unistd.h +5 -35
index 328520defc13..81896bbbf727 100644
@@ -14,40 +14,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
+#include <asm/bitsperlong.h>
 
-#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
-#define __ARCH_WANT_NEW_STAT
-#define __ARCH_WANT_SET_GET_RLIMIT
-#endif /* __LP64__ */
-
-#define __ARCH_WANT_MEMFD_SECRET
-
-#include <asm-generic/unistd.h>
-
-/*
- * Allows the instruction cache to be flushed from userspace.  Despite RISC-V
- * having a direct 'fence.i' instruction available to userspace (which we
- * can't trap!), that's not actually viable when running on Linux because the
- * kernel might schedule a process on another hart.  There is no way for
- * userspace to handle this without invoking the kernel (as it doesn't know the
- * thread->hart mappings), so we've defined a RISC-V specific system call to
- * flush the instruction cache.
- *
- * __NR_riscv_flush_icache is defined to flush the instruction cache over an
- * address range, with the flush applying to either all threads or just the
- * caller.  We don't currently do anything with the address range, that's just
- * in there for forwards compatibility.
- */
-#ifndef __NR_riscv_flush_icache
-#define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15)
-#endif
-__SYSCALL(__NR_riscv_flush_icache, sys_riscv_flush_icache)
-
-/*
- * Allows userspace to query the kernel for CPU architecture and
- * microarchitecture details across a given set of CPUs.
- */
-#ifndef __NR_riscv_hwprobe
-#define __NR_riscv_hwprobe (__NR_arch_specific_syscall + 14)
+#if __BITS_PER_LONG == 64
+#include <asm/unistd_64.h>
+#else
+#include <asm/unistd_32.h>
 #endif
-__SYSCALL(__NR_riscv_hwprobe, sys_riscv_hwprobe)
arch/riscv/kernel/Makefile.syscalls new file +4 -0
new file mode 100644
index 000000000000..52087a023b3d
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += riscv memfd_secret
+syscall_abis_64 += riscv newstat rlimit memfd_secret
arch/riscv/kernel/compat_syscall_table.c +4 -2
index ad7f2d712f5f..e884c069e88f 100644
@@ -8,9 +8,11 @@
 #include <asm-generic/syscalls.h>
 #include <asm/syscall.h>
 
+#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat)
+
 #undef __SYSCALL
 #define __SYSCALL(nr, call)	asmlinkage long __riscv_##call(const struct pt_regs *);
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 
 #undef __SYSCALL
 #define __SYSCALL(nr, call)      [nr] = __riscv_##call,
@@ -19,5 +21,5 @@ asmlinkage long compat_sys_rt_sigreturn(void);
 
 void * const compat_sys_call_table[__NR_syscalls] = {
 	[0 ... __NR_syscalls - 1] = __riscv_sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table_32.h>
 };
arch/riscv/kernel/syscall_table.c +4 -2
index dda913764903..6f1a36cb0f3f 100644
@@ -9,14 +9,16 @@
 #include <asm-generic/syscalls.h>
 #include <asm/syscall.h>
 
+#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native)
+
 #undef __SYSCALL
 #define __SYSCALL(nr, call)	asmlinkage long __riscv_##call(const struct pt_regs *);
-#include <asm/unistd.h>
+#include <asm/syscall_table.h>
 
 #undef __SYSCALL
 #define __SYSCALL(nr, call)	[nr] = __riscv_##call,
 
 void * const sys_call_table[__NR_syscalls] = {
 	[0 ... __NR_syscalls - 1] = __riscv_sys_ni_syscall,
-#include <asm/unistd.h>
+#include <asm/syscall_table.h>
 };
scripts/syscall.tbl +3 -0
index 28329c00bf68..797e20ea99a2 100644
@@ -301,6 +301,9 @@
 
 244	or1k	or1k_atomic			sys_or1k_atomic
 
+258	riscv	riscv_hwprobe			sys_riscv_hwprobe
+259	riscv	riscv_flush_icache		sys_riscv_flush_icache
+
 260	time32	wait4				sys_wait4			compat_sys_wait4
 260	64	wait4				sys_wait4
 261	common	prlimit64			sys_prlimit64
Signature · 1 line
2.39.2
maintainer Acked-by on v1 7/17
#16 lore raw

Re: [PATCH 07/17] clone3: drop __ARCH_WANT_SYS_CLONE3 macro

In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When clone3() was introduced, it was not obvious how each architecture deals with setting up the stack and keeping the register contents in a fork()-like system call, so this was left for the architecture maintainers to implement, with __ARCH_WANT_SYS_CLONE3 defined by those that already implement it.

Five years later, we still have a few architectures left that are missing clone3(), and the macro keeps getting in the way as it's fundamentally different from all the other __ARCH_WANT_SYS_* macros that are meant to provide backwards-compatibility with applications using older syscalls that are no longer provided by default.

Quoted 8 lines

Address this by reversing the polarity of the macro, adding an __ARCH_BROKEN_SYS_CLONE3 macro to all architectures that don't already provide the syscall, and remove __ARCH_WANT_SYS_CLONE3 from all the other ones.

 arch/m68k/include/asm/unistd.h                 | 1 -

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#36 lore raw
Quoted 6 lines · Maciej W. Rozycki
Quoted 1 line · Arnd Bergmann
 arch/alpha/include/asm/unistd.h               |   1 +

This seems out of sync with the actual changes, any idea what happened
here?

Sorry about this, I was writing the series description while still doing some treewide tests that showed I had missed a change in a rebase. When I originally wrote the clone3 patch, alpha was still missing clone3 support, so I added a line there to mark the syscall as broken. The current version is based on 6.10-rc, so clone3 actually works now and the patch I sent no longer needs to mark it as broken.

Arnd

maintainer Acked-by on v1 9/17
#19 lore raw

Re: [PATCH 09/17] arm64: convert unistd_32.h to syscall.tbl format

In reply to Arnd Bergmann
Quoted 22 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

This is a straight conversion from the old asm/unistd32.h into the format used by 32-bit arm and most other architectures, calling scripts to generate the asm/unistd32.h header and a new asm/syscalls32.h headers.

I used a semi-automated text replacement method to do the conversion, and then used 'vimdiff' to synchronize the whitespace and the (unused) names of the non-compat syscalls with the arm version.

There are two differences between the generated syscalls names and the old version:

- the old asm/unistd32.h contained only a __NR_sync_file_range2 entry, while the arm32 version also defines __NR_arm_sync_file_range with the same number. I added this duplicate back in asm/unistd32.h.

- __NR__sysctl was removed from the arm64 file a while ago, but all the tables still contain it. This should probably get removed everywhere but I added it here for consistency.

Quoted 6 lines

On top of that, the arm64 version does not contain any references to the 32-bit OABI syscalls that are not supported by arm64. If we ever want to share the file between arm32 and arm64, it would not be hard to add support for both in one file.

maintainer Acked-by on v1 10/17
#21 lore raw

Re: [PATCH 10/17] arm64: generate 64-bit syscall.tbl

In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Change the asm/unistd.h header for arm64 to no longer include asm-generic/unistd.h itself, but instead generate both the asm/unistd.h contents and the list of entry points using the syscall.tbl scripts that we use on most other architectures.

Quoted 8 lines

Once his is done for the remaining architectures, the generic unistd.h header can be removed and the generated tbl file put in its place.

The Makefile changes are more complex than they should be, I need a little help to improve those. Ideally this should be done in an architecture-independent way as well.

#9 lore raw

Re: [PATCH 03/17] um: don't generate asm/bpf_perf_event.h

In reply to Arnd Bergmann

Hi Arnd,

Quoted 37 lines · On Thu, 4 Jul 2024 16:35:57 +0200 Arnd Bergmann <[email protected]> wrote:

From: Arnd Bergmann <[email protected]>

If we start validating the existence of the asm-generic side of generated headers, this one causes a warning:

make[3]: *** No rule to make target 'arch/um/include/generated/asm/bpf_perf_event.h', needed by 'all'. Stop.

The problem is that the asm-generic header only exists for the uapi variant, but arch/um has no uapi headers and instead uses the x86 userspace API.

Add a custom file with an explicit redirect to avoid this.

---
 arch/um/include/asm/Kbuild           | 1 -
 arch/um/include/asm/bpf_perf_event.h | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 arch/um/include/asm/bpf_perf_event.h
arch/um/include/asm/Kbuild +0 -1
index 6fe34779291a..6c583040537c 100644
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-generic-y += bpf_perf_event.h
 generic-y += bug.h
 generic-y += compat.h
 generic-y += current.h
arch/um/include/asm/bpf_perf_event.h new file +0 -0
new file mode 100644
index 000000000000..0a30420c83de

arch/um/include/asm/bpf_perf_event.h line 3

Quoted 3 lines
arch/um/include/asm/bpf_perf_event.h new file +3 -0
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <asm-generic/bpf_perf_event.h>

Just wondering if that file should have some explanatory comment in it to prevent it being cleaned up in a few years ... or at least to explain why it causes the above error when removed.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer Acked-by on v1 2/17
#5 lore raw

Re: [PATCH 02/17] csky: drop asm/gpio.h wrapper

In reply to Arnd Bergmann
Quoted 24 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The asm/gpio.h header is gone now that all architectures just use gpiolib, and so the redirect is no longer valid.

---
 arch/csky/include/asm/Kbuild | 1 -
 1 file changed, 1 deletion(-)
arch/csky/include/asm/Kbuild +0 -2
index 1117c28cb7e8..13ebc5e34360 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generic-y += asm-offsets.h
 generic-y += extable.h
-generic-y += gpio.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
--
Quoted 2 lines

2.39.2

LGTM!

Signature · 2 lines
Best Regards
 Guo Ren
#22 lore raw

Re: [PATCH 10/17] arm64: generate 64-bit syscall.tbl

In reply to Arnd Bergmann

arch/arm64/include/asm/unistd.h line 46

Quoted 7 lines · Arnd Bergmann

#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd.h +2 -3
+#define __ARCH_WANT_NEW_STAT
 
-#ifndef __COMPAT_SYSCALL_NR
-#include <uapi/asm/unistd.h>
-#endif
+#include <asm/unistd_64.h>

It looks like this is causing widespread build breakage in kselftest in -next for arm64, there are *many* errors in the form:

In file included from test_signals_utils.c:14:
/build/stage/build-work/usr/include/asm/unistd.h:2:10: fatal error: unistd_64.h: No such file or directory

    2 | #include <unistd_64.h>
      |          ^~~~~~~~~~~~~

which obviously looks like it's tied to the above but I've not fully understood the patch/series yet. Build log at:

https://builds.sirena.org.uk/82d01fe6ee52086035b201cfa1410a3b04384257/arm64/defconfig/build.log

A bisect appears to confirm that it's this commit, which is in -next as 6e4a077c0b607c674536908c5b68f1c31e4e26ec.

git bisect start
# status: waiting for both good and bad commits
# bad: [82d01fe6ee52086035b201cfa1410a3b04384257] Add linux-next specific files for 20240709
git bisect bad 82d01fe6ee52086035b201cfa1410a3b04384257
# status: waiting for good commit(s), bad commit known
# good: [037206cd4cb43d535453723140fde1bcde0b296e] Merge branch 'for-linux-next-fixes' of https://gitlab.freedesktop.org/drm/misc/kernel.git
git bisect good 037206cd4cb43d535453723140fde1bcde0b296e
# bad: [2ae3e655fc40f1b6620194b90dcf9a4515257918] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect bad 2ae3e655fc40f1b6620194b90dcf9a4515257918
# bad: [4f2a367612d46dff2068582feadfbdd8e1c0443f] Merge branch 'fs-next' of linux-next
git bisect bad 4f2a367612d46dff2068582feadfbdd8e1c0443f
# bad: [d3da7ed72840f3660f90966490adfd499d96ea8f] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git
git bisect bad d3da7ed72840f3660f90966490adfd499d96ea8f
# good: [6355edbb3dfe322f0748b1eb3987973a568bbb42] Merge tag 'v6.11-rockchip-dts64-2' of https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into soc/dt git bisect good 6355edbb3dfe322f0748b1eb3987973a568bbb42
# good: [2073cda629a47f2ebe2afcd3cb8b3000d5cd13d1] mm: optimization on page allocation when CMA enabled
git bisect good 2073cda629a47f2ebe2afcd3cb8b3000d5cd13d1
# good: [91a2b5b12867f77dc68d2d15ec7381e6e43820cb] Merge branch 'perf-tools-next' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
git bisect good 91a2b5b12867f77dc68d2d15ec7381e6e43820cb
# bad: [b8c38a39b6ee44b02ee563b60439f417fec441ad] Merge branch 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git
git bisect bad b8c38a39b6ee44b02ee563b60439f417fec441ad
# good: [c100216635e922f43d9e783da918a749995350ca] Merge branch 'for-next/vcpu-hotplug' into for-next/core
git bisect good c100216635e922f43d9e783da918a749995350ca
# bad: [fafb823fc82dfb746cc9043b1573c4b29ef1d52a] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rmk/linux.git
git bisect bad fafb823fc82dfb746cc9043b1573c4b29ef1d52a
# bad: [8d46f9dd06378e346a562c75bc2a260a03abe807] csky: convert to generic syscall table
git bisect bad 8d46f9dd06378e346a562c75bc2a260a03abe807
# good: [57029ba74296a4dafe35f147e88d56d8ae7b69da] kbuild: add syscall table generation to scripts/Makefile.asm-headers
git bisect good 57029ba74296a4dafe35f147e88d56d8ae7b69da
# good: [ea0130bf3c45f276b1f9e005eeb255a80a10358b] arm64: convert unistd_32.h to syscall.tbl format
git bisect good ea0130bf3c45f276b1f9e005eeb255a80a10358b
# bad: [b2595bdb3eb3fe24137d0bd07a51bc622f068a81] arm64: rework compat syscall macros
git bisect bad b2595bdb3eb3fe24137d0bd07a51bc622f068a81
# bad: [6e4a077c0b607c674536908c5b68f1c31e4e26ec] arm64: generate 64-bit syscall.tbl
git bisect bad 6e4a077c0b607c674536908c5b68f1c31e4e26ec

# first bad commit: [6e4a077c0b607c674536908c5b68f1c31e4e26ec] arm64: generate 64-bit syscall.tbl
maintainer
#23 lore raw

Re: [PATCH 10/17] arm64: generate 64-bit syscall.tbl

Quoted 13 lines · Mark Brown

Review

Quoted 7 lines · Arnd Bergmann

#define __ARCH_WANT_SYS_CLONE

(quoted diff) +2 -3
+#define __ARCH_WANT_NEW_STAT
 
-#ifndef __COMPAT_SYSCALL_NR
-#include <uapi/asm/unistd.h>
-#endif
+#include <asm/unistd_64.h>

It looks like this is causing widespread build breakage in kselftest in -next for arm64, there are *many* errors in the form:

Quoted 9 lines

In file included from test_signals_utils.c:14:
/build/stage/build-work/usr/include/asm/unistd.h:2:10: fatal error:
unistd_64.h: No such file or directory

    2 | #include <unistd_64.h>
      |          ^~~~~~~~~~~~~

which obviously looks like it's tied to the above but I've not fully understood the patch/series yet. Build log at:

Thanks for the report! I just panicked a bit and thought I had done something entirely wrong here, but after having a closer look it turned out to be a silly typo:

arch/arm64/include/uapi/asm/unistd.h +1 -1
index 038dddf8f554..df36f23876e8 100644
@@ -1,2 +1,2 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#include <unistd_64.h>
+#include <asm/unistd_64.h>

I'm folding the fix into the tree now, in addition to the Acks I received and another small fixup.

I checked that arm64 is the only architecture that has this particular bug, and I tried building kselftest now, which seems to work better. There are still a few warnings and errors I get doing that, but I suspect those are all preexisting issues.

Arnd

maintainer
#28 lore raw

Re: [PATCH 12/17] csky: convert to generic syscall table

In reply to Arnd Bergmann

Review

Quoted 7 lines · Arnd Bergmann
(quoted diff) +2 -5
-
-#define __NR_set_thread_area	(__NR_arch_specific_syscall + 0)
-__SYSCALL(__NR_set_thread_area, sys_set_thread_area)
-#define __NR_cacheflush		(__NR_arch_specific_syscall + 1)
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
+#include <asm/unistd_32.h>
+#define __NR_sync_file_range2 __NR_sync_file_range

A small update: I have folded this fixup into this patch and the hexagon one, to ensure we don't define both __NR_sync_file_range2 and __NR_sync_file_range. I already have patches to clean this up further to avoid both the #undef and #define, but that is part of a larger rework that is not ready before the merge window.

Arnd

arch/csky/include/uapi/asm/unistd.h +3 -1
index 794adbc04e48..44882179a6e1 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 
 #include <asm/unistd_32.h>
-#define __NR_sync_file_range2 __NR_sync_file_range
+
+#define __NR_sync_file_range2 84
+#undef __NR_sync_file_range
arch/hexagon/include/uapi/asm/unistd.h +2 -1
index 6f670347dd61..a3b0cac25580 100644
@@ -29,4 +29,5 @@
 
 #include <asm/unistd_32.h>
 
-#define __NR_sync_file_range2 __NR_sync_file_range
+#define __NR_sync_file_range2 84
+#undef __NR_sync_file_range
#24 lore raw

Re: [PATCH 10/17] arm64: generate 64-bit syscall.tbl

In reply to Arnd Bergmann

arch/arm64/include/uapi/asm/unistd.h line 2

Quoted 6 lines · Arnd Bergmann

Thanks for the report! I just panicked a bit and thought I had done something entirely wrong here, but after having a closer look it turned out to be a silly typo:

arch/arm64/include/uapi/asm/unistd.h +1 -1
-#include <unistd_64.h>
+#include <asm/unistd_64.h>

Doh, I should've spotted that even from the very quick look I gave it! Thanks for the quick fix.

Quoted 5 lines

I checked that arm64 is the only architecture that has this particular bug, and I tried building kselftest now, which seems to work better. There are still a few warnings and errors I get doing that, but I suspect those are all preexisting issues.

Yeah, not everything there builds cleanly (and there's a bunch of external deps you need for many of the suites).

Reviewed-by on v1 2/17
#6 lore raw

Re: [PATCH 02/17] csky: drop asm/gpio.h wrapper

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The asm/gpio.h header is gone now that all architectures just use gpiolib, and so the redirect is no longer valid.

---

Quoted 18 lines
 arch/csky/include/asm/Kbuild | 1 -
 1 file changed, 1 deletion(-)
arch/csky/include/asm/Kbuild +0 -2
index 1117c28cb7e8..13ebc5e34360 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generic-y += asm-offsets.h
 generic-y += extable.h
-generic-y += gpio.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
--

2.39.2

Signature · 2 lines
Best Regards
Masahiro Yamada
#10 lore raw

Re: [PATCH 03/17] um: don't generate asm/bpf_perf_event.h

In reply to Arnd Bergmann
Quoted 41 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If we start validating the existence of the asm-generic side of generated headers, this one causes a warning:

make[3]: *** No rule to make target 'arch/um/include/generated/asm/bpf_perf_event.h', needed by 'all'. Stop.

The problem is that the asm-generic header only exists for the uapi variant, but arch/um has no uapi headers and instead uses the x86 userspace API.

Add a custom file with an explicit redirect to avoid this.

---
 arch/um/include/asm/Kbuild           | 1 -
 arch/um/include/asm/bpf_perf_event.h | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 arch/um/include/asm/bpf_perf_event.h
arch/um/include/asm/Kbuild +0 -1
index 6fe34779291a..6c583040537c 100644
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-generic-y += bpf_perf_event.h
 generic-y += bug.h
 generic-y += compat.h
 generic-y += current.h
arch/um/include/asm/bpf_perf_event.h new file +3 -1
new file mode 100644
index 000000000000..0a30420c83de
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <asm-generic/bpf_perf_event.h>
--
Quoted 2 lines

2.39.2

I guess this is a step backward.

Technically, kernel-space asm/*.h files are allowed to wrap UAPI <asm-generic/*.h>.
There is no reason why we ban generic-y for doing this, whereas check-in source is allowed.

--
Best Regards
Masahiro Yamada

#2 lore raw

Re: [PATCH 01/17] syscalls: add generic scripts/syscall.tbl

In reply to Arnd Bergmann
Quoted 16 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The asm-generic/unistd.h header still follows the old style of defining system call numbers and the table. Most architectures got the new syscall.tbl format as part of the y2038 conversion back in 2018, but the newer architectures that share a single table never did.

I did a semi-automated conversion of the asm-generic/unistd.h contents into a syscall.tbl format, using the ABI field to take care of all the relevant differences that are encoded using #ifdef checks in the existing header.

Conversion of the architectures is done one at a time in order to be able to review or revert them as needed.

Quoted 7 lines

---

+65     common  readv                           sys_readv                       sys_readv
+66     common  writev                          sys_writev                      sys_writev

Nit.

I know this is already written in this way in include/uapi/asm-generic/unistd.h, but the native and compat have the same function name.

Can we simplify it like this?

65     common  readv                           sys_readv
66     common  writev                          sys_writev

--
Best Regards
Masahiro Yamada

maintainer
#3 lore raw

Re: [PATCH 01/17] syscalls: add generic scripts/syscall.tbl

Quoted 11 lines · Masahiro Yamada

On Thu, Jul 4, 2024 at 11:36 PM Arnd Bergmann <[email protected]> wrote:

I know this is already written in this way in include/uapi/asm-generic/unistd.h, but the native and compat have the same function name.

Can we simplify it like this?

65     common  readv                           sys_readv
66     common  writev                          sys_writev

Good idea. It looks like this came from 5f764d624a89 ("fs:
remove the compat readv/writev syscalls"), and I'll fix it up in my follow-up series, which has a lot of other cleanups like this one across architectures.

Thanks,

Arnd

maintainer
#11 lore raw

Re: [PATCH 03/17] um: don't generate asm/bpf_perf_event.h

In reply to Masahiro Yamada
Quoted 21 lines · Masahiro Yamada
Quoted 14 lines · Arnd Bergmann
arch/um/include/asm/Kbuild +0 -1
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-generic-y += bpf_perf_event.h
 generic-y += bug.h
 generic-y += compat.h
 generic-y += current.h
arch/um/include/asm/bpf_perf_event.h new file +0 -0
new file mode 100644
index 000000000000..0a30420c83de

arch/um/include/asm/bpf_perf_event.h line 3

Quoted 3 lines
arch/um/include/asm/bpf_perf_event.h new file +3 -0
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <asm-generic/bpf_perf_event.h>

I guess this is a step backward.

Quoted 4 lines

Technically, kernel-space asm/*.h files are allowed to wrap UAPI <asm-generic/*.h>.
There is no reason why we ban generic-y for doing this, whereas check-in source is allowed.

I think in this case, the simplicity is the more important
argument: this is the only case we have of wrapping a uapi header from a non-uapi header, and no other architecture would need to do this.

The way the syscall-y rule works relies on enforcing some checking for existing asm-generic headers, and I could extend it to allow this special case, but that would make the Makefile rule less readable in exchange for avoiding effectively a one-line file.

Arnd

maintainer Acked-by
#29 lore raw

Re: [PATCH 12/17] csky: convert to generic syscall table

In reply to Arnd Bergmann
Quoted 24 lines · Arnd Bergmann

Review

Quoted 7 lines · Arnd Bergmann
(quoted diff) +2 -5
-
-#define __NR_set_thread_area (__NR_arch_specific_syscall + 0)
-__SYSCALL(__NR_set_thread_area, sys_set_thread_area)
-#define __NR_cacheflush              (__NR_arch_specific_syscall + 1)
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
+#include <asm/unistd_32.h>
+#define __NR_sync_file_range2 __NR_sync_file_range

A small update: I have folded this fixup into this patch and the hexagon one, to ensure we don't define both __NR_sync_file_range2 and __NR_sync_file_range. I already have patches to clean this up further to avoid both the #undef and #define, but that is part of a larger rework that is not ready before the merge window.

Arnd

arch/csky/include/uapi/asm/unistd.h +0 -0
index 794adbc04e48..44882179a6e1 100644

arch/csky/include/uapi/asm/unistd.h line 6

Quoted 7 lines
arch/csky/include/uapi/asm/unistd.h +3 -1
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 
 #include <asm/unistd_32.h>
-#define __NR_sync_file_range2 __NR_sync_file_range
+
+#define __NR_sync_file_range2 84
+#undef __NR_sync_file_range

For csky part:

Quoted 11 lines
arch/hexagon/include/uapi/asm/unistd.h +2 -1
index 6f670347dd61..a3b0cac25580 100644
@@ -29,4 +29,5 @@
 
 #include <asm/unistd_32.h>
 
-#define __NR_sync_file_range2 __NR_sync_file_range
+#define __NR_sync_file_range2 84
+#undef __NR_sync_file_range
Signature · 2 lines
Best Regards
 Guo Ren
maintainer Acked-by
#7 lore raw

Re: [PATCH 02/17] csky: drop asm/gpio.h wrapper

In reply to Masahiro Yamada
Quoted 9 lines · Masahiro Yamada
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The asm/gpio.h header is gone now that all architectures just use gpiolib, and so the redirect is no longer valid.

Quoted 29 lines
Quoted 1 line

---

Quoted 16 lines
 arch/csky/include/asm/Kbuild | 1 -
 1 file changed, 1 deletion(-)
arch/csky/include/asm/Kbuild +0 -2
index 1117c28cb7e8..13ebc5e34360 100644
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 generic-y += asm-offsets.h
 generic-y += extable.h
-generic-y += gpio.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
--
Quoted 2 lines

2.39.2

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
 Guo Ren
#37 lore raw
In reply to Arnd Bergmann
This series was applied to riscv/linux.git (for-next) by Arnd Bergmann <[email protected]>:

Hello:

This series was applied to riscv/linux.git (for-next) by Arnd Bergmann <[email protected]>:

Quoted 8 lines · On Thu, 4 Jul 2024 16:35:54 +0200 you wrote:

From: Arnd Bergmann <[email protected]>

There are eight architectures using include/uapi/asm-generic/unistd.h, which is still in an old format and not easily parsed by scripts. In addition, arm64 uses the old format for the 32-bit arm compat syscalls, despite them using the modern syscall.tbl format for the native calls.

[...]

Here is the summary with links:
- [01/17] syscalls: add generic scripts/syscall.tbl

    https://git.kernel.org/riscv/c/4fe53bf2ba0a
  - [02/17] csky: drop asm/gpio.h wrapper
    https://git.kernel.org/riscv/c/ed8023ae9d79
  - [03/17] um: don't generate asm/bpf_perf_event.h
    (no matching commit)
  - [04/17] loongarch: avoid generating extra header files
    https://git.kernel.org/riscv/c/ff96f5c6971c
  - [05/17] kbuild: verify asm-generic header list
    https://git.kernel.org/riscv/c/b70f12e962bc
  - [06/17] kbuild: add syscall table generation to scripts/Makefile.asm-headers
    https://git.kernel.org/riscv/c/fbb5c0606fa4
  - [07/17] clone3: drop __ARCH_WANT_SYS_CLONE3 macro
    https://git.kernel.org/riscv/c/505d66d1abfb
  - [08/17] arc: convert to generic syscall table
    https://git.kernel.org/riscv/c/4414ad8eb4c2
  - [09/17] arm64: convert unistd_32.h to syscall.tbl format
    https://git.kernel.org/riscv/c/7fe33e9f662c
  - [10/17] arm64: generate 64-bit syscall.tbl
    (no matching commit)
  - [11/17] arm64: rework compat syscall macros
    (no matching commit)
  - [12/17] csky: convert to generic syscall table
    (no matching commit)
  - [13/17] hexagon: use new system call table
    (no matching commit)
  - [14/17] loongarch: convert to generic syscall table
    https://git.kernel.org/riscv/c/26a3b85bac08
  - [15/17] nios2: convert to generic syscall table
    https://git.kernel.org/riscv/c/ef608c5767f9
  - [16/17] openrisc: convert to generic syscall table
    https://git.kernel.org/riscv/c/77122bf9e3df
  - [17/17] riscv: convert to generic syscall table
    https://git.kernel.org/riscv/c/3db80c999deb

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html