[PATCH 00/17] arch: convert everything to syscall.tbl

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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   

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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 scripts/syscall.tbl | 388 
 1 file changed, 388 insertions(+)
 create mode 100644 scripts/syscall.tbl

diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
new file mode 100644
index ..7871bbfa9b58
--- /dev/null
+++ b/scripts/syscall.tbl
@@ -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_setupsys_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_geteventssys_io_getevents_time32
+4  64  io_geteventssys_io_getevents
+5  common  setxattrsys_setxattr
+6  common  lsetxattr   sys_lsetxattr
+7  common  fsetxattr   sys_fsetxattr
+8  common  getxattrsys_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  lremovexattrsys_lremovexattr
+16 common  fremovexattrsys_fremovexattr
+17 common  getcwd  sys_getcwd
+18 common  lookup_dcookie  sys_ni_syscall
+19 common  eventfd2sys_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  dup3sys_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_watchsys_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  unlinkatsys_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  statfs64sys_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  truncatesys_truncate
+46 32  ftruncate64 sys_ftruncate64 
compat_sys_ftruncate64
+46 64  ftruncate   sys_ftr

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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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

Signed-off-by: Arnd Bergmann 
---
 arch/csky/include/asm/Kbuild | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/csky/include/asm/Kbuild b/arch/csky/include/asm/Kbuild
index 1117c28cb7e8..13ebc5e34360 100644
--- a/arch/csky/include/asm/Kbuild
+++ b/arch/csky/include/asm/Kbuild
@@ -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


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index 6fe34779291a..6c583040537c 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -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
diff --git a/arch/um/include/asm/bpf_perf_event.h 
b/arch/um/include/asm/bpf_perf_event.h
new file mode 100644
index ..0a30420c83de
--- /dev/null
+++ b/arch/um/include/asm/bpf_perf_event.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include 
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 04/17] loongarch: avoid generating extra header files

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 arch/loongarch/include/asm/Kbuild | 16 
 1 file changed, 16 deletions(-)

diff --git a/arch/loongarch/include/asm/Kbuild 
b/arch/loongarch/include/asm/Kbuild
index c862672ed953..0db5ad14f014 100644
--- a/arch/loongarch/include/asm/Kbuild
+++ b/arch/loongarch/include/asm/Kbuild
@@ -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
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 05/17] kbuild: verify asm-generic header list

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 include/asm-generic/Kbuild   | 1 -
 scripts/Makefile.asm-generic | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
index b20fa25a7e8d..df7ed81c4589 100644
--- a/include/asm-generic/Kbuild
+++ b/include/asm-generic/Kbuild
@@ -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
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index 1486abf34c7c..69434908930e 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -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
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/Makefile b/Makefile
index 06aa6402b385..d62ef2b2c102 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
deleted file mode 100644
index 69434908930e..
--- a/scripts/Makefile.asm-generic
+++ /dev/null
@@ -1,58 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# include/asm-generic contains a lot of files that are used
-# verbatim by several architectures.
-#
-# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild
-# and for each file listed in this file with generic-y creates
-# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm.
-
-PHONY := all
-all:
-
-src := $(srctree)/$(subst /generated,,$(obj))
-
-include $(srctree)/scripts/Kbuild.include
--include $(kbuild-file)
-
-# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
-ifneq ($(SRCARCH),um)
-include $(srctree)/$(generic)/Kbuild
-endif
-
-redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
-redundant += $(foreach f, $(generic-y), $(if $(wildcard $(src)/$(f)),$(f)))
-redundant := $(sort $(redundant))
-$(if $(redundant),\
-   $(warning redundant generic-y found in $(src)/Kbuild: $(redundant)))
-
-# If arch does not implement mandatory headers, fallback to asm-generic ones.
-mandatory-y := $(filter-out $(generated-y), $(mandatory-y))
-generic-y   += $(foreach f, $(mandatory-y), $(if $(wildcard 
$(src)/$(f)),,$(f)))
-
-generic-y   := $(addprefix $(obj)/, $(generic-y))
-generated-y := $(addprefix $(obj)/, $(generated-y))
-
-# Remove stale wrappers when the corresponding files are removed from generic-y
-old-headers := $(wildcard $(obj)/*.h)
-unwanted:= $(filter-out $(generic-y) $(generated-y),$(old-headers))
-
-quiet_cmd_wrap = WRAP$@
-  cmd_wrap = echo "\#include " > $@
-
-quiet_cmd_remove = REMOVE  $(unwanted)
-  cmd_remove = rm -f $(unwanted)
-
-all: $(generic-y)
-   $(if $(unwanted),$(call cmd,remove))
-   @:
-
-$(obj)/%.h: $(srctree)/$(generic)/%.h
-   $(call cmd,wrap)
-
-# Create output directory. Skip it if at least one old header exists
-# since we know the output directory already exists.
-ifeq ($(old-headers),)
-$(shell mkdir -p $(obj))
-endif
-
-.PHONY: $(PHONY)
diff --git a/scripts/Makefile.asm-headers b/scripts/Makefile.asm-headers
new file mode 100644
index ..6b8e8318e810
--- /dev/null
+++ b/scripts/Makefile.asm-headers
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: GPL-2.0
+# include/asm-generic contains a lot of files that are used
+# verbatim by several architectures.
+#
+# This Makefile generates arch/$(SRCARCH)/include/generated/(uapi/)/asm
+# headers from multiple sources:
+#  - a small wrapper to include the corresponding asm-generic/*.h
+#is generated for each file listed as generic-y
+#  - uapi/asm/unistd_*.h files listed as syscalls-y are generated from
+#syscall.tbl with the __NR_* macros
+#  - Corresponding asm/syscall_table_*.h are generated from the same input
+
+PHONY := all
+all:
+
+src := $(srctree)/$(subst /generated,,$(obj))
+
+syscall_abis_32  += common,32
+syscall_abis_64  += common,64
+syscalltbl := $(srctree)/scripts/syscall.tbl
+syshdr-args := --emit-nr
+
+# let architectures override $(syscall_abis_%) and $(syscalltbl)
+-include $(srctree)/arch/$(SRCARCH)/kernel/Makefile.syscalls
+include $(srctree)/scripts/Kbuild.include
+-include $(

[PATCH 07/17] clone3: drop __ARCH_WANT_SYS_CLONE3 macro

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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(-)

diff --git a/arch/arc/include/uapi/asm/unistd.h 
b/arch/arc/include/uapi/asm/unistd.h
index fa2713ae6bea..5eafa1115162 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -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
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
index 3676e82cf95c..9fb00973c608 100644
--- a/arch/arm/include/asm/unistd.h
+++ b/arch/arm/include/asm/unistd.h
@@ -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
diff --git a/arch/arm64/include/uapi/asm/unistd.h 
b/arch/arm64/include/uapi/asm/unistd.h
index ce2ee8f1e361..9306726337fe 100644
--- a/arch/arm64/include/uapi/asm/unistd.h
+++ b/arch/arm64/include/uapi/asm/unistd.h
@@ -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 
diff --git a/arch/csky/include/uapi/asm/unistd.h 
b/arch/csky/include/uapi/asm/unistd.h
index e0594b6370a6..d529d0432876 100644
--- a/arch/csky/include/uapi/asm/unistd.h
+++ b/arch/csky/include/uapi/asm/unistd.h
@@ -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
diff --git a/arch/hexagon/include/uapi/asm/unistd.h 
b/arch/hexagon/include/uapi/asm/unistd.h
index 21ae22306b5d..4bea7428e747 100644
--- a/arch/hexagon/include/uapi/asm/unistd.h
+++ b/arch/hexagon/include/uapi/asm/unistd.h
@@ -38,4 +38,6 @@
 #define __ARCH_WANT_TIME32_SYSCALLS
 #define __ARCH_WANT_SYNC_FILE_RANGE2
 
+#define __ARCH_BROKEN_SYS_CLONE3
+
 #include 
diff --git a/arch/loongarch/include/uapi/asm/unistd.h 
b/arch/loongarch/include/uapi/asm/unistd.h
index fcb668984f03..191614b9b207 100644
--- a/arch/loongarch/include/uapi/asm/unistd.h
+++ b/arch/loongarch/include/uapi/asm/unistd.h
@@ -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 
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 4ae52414cd9d..2e0047cf86f8 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -30,6 +30,5 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #d

[PATCH 08/17] arc: convert to generic syscall table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 3c1afa524b9c..49285a3ce239 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -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
diff --git a/arch/arc/include/asm/unistd.h b/arch/arc/include/asm/unistd.h
new file mode 100644
index ..211c230d88d6
--- /dev/null
+++ b/arch/arc/include/asm/unistd.h
@@ -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 
+
+#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
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild
index e78470141932..2501e82a1a0a 100644
--- a/arch/arc/include/uapi/asm/Kbuild
+++ b/arch/arc/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
diff --git a/arch/arc/include/uapi/asm/unistd.h 
b/arch/arc/include/uapi/asm/unistd.h
index 5eafa1115162..cb2905c7c5da 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -7,45 +7,4 @@
  * published by the Free Software Foundation.
  */
 
-/ no-legacy-syscalls-ABI ***/
-
-/*
- * Non-typical guard macro to enable inclusion twice in ARCH sys.c
- * That is how the Generic syscall wrapper generator works
- */
-#if !defined(_UAPI_ASM_ARC_UNISTD_H) || defined(__SYSCALL)
-#define _UAPI_ASM_ARC_UNISTD_H
-
-#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 sys_mmap2 sys_mmap_pgoff
-
-#include 
-
-#define NR_syscalls__NR_syscalls
-
-/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
-#define __NR_sysfs (__NR_arch_specific_syscall + 3)
-
-/* ARC specific syscall */
-#define __NR_cacheflush(__NR_arch_specific_syscall + 0)
-#define __NR_arc_settls(__NR_arch_specific_syscall + 1)
-#define __NR_arc_gettls(__NR_arch_specific_syscall + 2)
-#define __NR_arc_usr_cmpxchg   (__NR_arch_specific_syscall + 4)
-
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
-__SYSCALL(__NR_arc_settls, sys_arc_settls)
-__SYSCALL(__NR_arc_gettls, sys_arc_gettls)
-__SYSCALL(__NR_arc_usr_cmpxchg, sys_arc_usr_cmpxchg)
-__SYSCALL(__NR_sysfs, sys_sysfs)
-
-#undef __SYSCALL
-
-#endif
+#include 
diff --git a/arch/arc/kernel/Makefile.syscalls 
b/arch/arc/kernel/Makefile.syscalls
new file mode 100644
index ..391d30ab7a83
--- /dev/null
+++ b/arch/arc/kernel/Makefile.syscalls
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += arc time32 renameat stat64 rlimit
diff --git a/arch/arc/kernel/sys.c b/arch/arc/kernel/sys.c
index 1069446bdc58..36a2a95c083b 100644
--- a/arch/arc/kernel/sys.c
+++ b/arch/arc/kernel/sys.c
@@ -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 
+#include 
 };
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index 7871bbfa9b58..

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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 4b6d2d52053e..3fc45ef32e85 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -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
diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h
index 30256233788b..d56164d3cac5 100644
--- a/arch/arm64/include/asm/seccomp.h
+++ b/arch/arm64/include/asm/seccomp.h
@@ -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
 
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 1346579f802f..55ac26355be4 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -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
diff --git a/arch/arm64/include/asm/unistd32.h 
b/arch/arm64/include/asm/unistd32.h
index 1386e8e751f2..e0b1a0b57f75 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -1,938 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AArch32 (compat) system call definitions.
- *
- * Copyright (C) 2001-2005 Russell King
- * Copyright (C) 2012 ARM Ltd.
- */
+#ifndef _UAPI__ASM_ARM_UNISTD_H
+#define _UAPI__ASM_ARM_UNISTD_H
 
-#ifndef __SYSCALL
-#define __SYSCALL(x, y)
-#endif
+#include 
 
-#define __NR_restart_syscall 0
-__SYSCALL(__NR_restart_syscall, sys_restart_syscall)
-#define __NR_exit 1
-__SYSCALL(__NR_exit, sys_exit)
-#define __NR_fork 2
-__SYSCALL(__NR_fork, sys_fork)
-#define __NR_read 3
-__SYSCALL(__NR_read, sys_read)
-#define __NR_write 4
-__SYSCALL(__NR_write, sys_write)
-#define __NR_open 5
-__SYSCALL(__NR_open, compat_sys_open)
-#define __NR_close 6
-__SYSCALL(__NR_close, sys_close)
-   /* 7 was sys_waitpid */
-__SYSCALL(7, sys_ni_syscall)
-#define __NR_creat 8
-__SYSCALL(__NR_creat, sys_creat)
-#define __NR_link 9
-__SYSCALL(__NR_link, sys_link)
-#define __NR_unlink 10
-__SYSCALL(__NR_unlink, sys_unlink)
-#define __NR_execve 11
-__SYSCALL(__NR_execve, compat_sys_execve)
-#define __NR_chdir 12
-__SYSCALL(__NR_chdir, sys_chdir)
-   /* 13 was sys_time */
-__SYSCALL(13, sys_ni_syscall)
-#define __NR_mknod 14
-__SYSCALL(__NR_mknod, sys_mknod)
-#define __NR_chmod 15
-__SYSCALL(__NR_chmod, sys_chmod)
-#define __NR_lchown 16
-__SYSCALL(__NR_lchown, sys_lchown16)
-   /* 17 was sys_break */
-__SYSCALL(17, sys_ni_syscall)
-

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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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 12 arch/arm64/tools/syscall_64.tbl

diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 3fc45ef32e85..7d7d97ad3cd5 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -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
diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h
index d56164d3cac5..c83ca2c8b936 100644
--- a/arch/arm64/include/asm/seccomp.h
+++ b/arch/arm64/include/asm/seccomp.h
@@ -23,6 +23,7 @@
 #define SECCOMP_ARCH_NATIVE_NR NR_syscalls
 #define SECCOMP_ARCH_NATIVE_NAME   "aarch64"
 #ifdef CONFIG_COMPAT
+#include 
 # define SECCOMP_ARCH_COMPAT   AUDIT_ARCH_ARM
 # define SECCOMP_ARCH_COMPAT_NR__NR_compat32_syscalls
 # define SECCOMP_ARCH_COMPAT_NAME  "arm"
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 55ac26355be4..fdd16052f9bc 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -41,9 +41,8 @@
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_NEW_STAT
 
-#ifndef __COMPAT_SYSCALL_NR
-#include 
-#endif
+#include 
 
 #define NR_syscalls (__NR_syscalls)
diff --git a/arch/arm64/include/uapi/asm/Kbuild 
b/arch/arm64/include/uapi/asm/Kbuild
index 602d137932dc..c6d141d7b7d7 100644
--- a/arch/arm64/include/uapi/asm/Kbuild
+++ b/arch/arm64/include/uapi/asm/Kbuild
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_64.h
 
 generic-y += kvm_para.h
diff --git a/arch/arm64/include/uapi/asm/unistd.h 
b/arch/arm64/include/uapi/asm/unistd.h
index 9306726337fe..038dddf8f554 100644
--- a/arch/arm64/include/uapi/asm/unistd.h
+++ b/arch/arm64/include/uapi/asm/unistd.h
@@ -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 .
- */
-
-#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 
+#include 
diff --git a/arch/arm64/kernel/Makefile.syscalls 
b/arch/arm64/kernel/Makefile.syscalls
index 1e14effb3921..3cfafd003b2d 100644
--- a/arch/arm64/kernel/Makefile.syscalls
+++ b/arch/arm64/kernel/Makefile.syscalls
@@ -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
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index d5ffaaab31a7..f08408b6e826 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -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 
+#include 
 
 #undef __SYSCALL
 #define __SYSCALL(nr, sym) [nr] = __arm64_##sym,
 
 const syscall_fn_t sys_call_table[__NR_syscalls] = {
[0 ... __NR_syscalls - 1] = __arm64_sy

[PATCH 11/17] arm64: rework compat syscall macros

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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(-)

diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h
index c83ca2c8b936..b8397314 100644
--- a/arch/arm64/include/asm/seccomp.h
+++ b/arch/arm64/include/asm/seccomp.h
@@ -8,13 +8,13 @@
 #ifndef _ASM_SECCOMP_H
 #define _ASM_SECCOMP_H
 
-#include 
+#include 
 
 #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 
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index fdd16052f9bc..80618c9bbcd8 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -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_syscall0
-#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_gettime64403
-#define __NR_compat_clock_getres_time64406
-
 /*
  * The following SVCs are ARM private.
  */
diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h 
b/arch/arm64/include/asm/vdso/compat_gettimeofday.h
index ecb6fd4c3c64..778c1202bbbf 100644
--- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h
+++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h
@@ -8,7 +8,7 @@
 #ifndef __ASSEMBLY__
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -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"
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index bbd542704730..50b74cc5c64d 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal

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

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/csky/include/asm/Kbuild b/arch/csky/include/asm/Kbuild
index 13ebc5e34360..9a9bc65b57a9 100644
--- a/arch/csky/include/asm/Kbuild
+++ b/arch/csky/include/asm/Kbuild
@@ -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
diff --git a/arch/csky/include/asm/unistd.h b/arch/csky/include/asm/unistd.h
index 9cf97de9a26d..2c2c24de95d8 100644
--- a/arch/csky/include/asm/unistd.h
+++ b/arch/csky/include/asm/unistd.h
@@ -2,4 +2,7 @@
 
 #include 
 
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SYS_CLONE
+
 #define NR_syscalls (__NR_syscalls)
diff --git a/arch/csky/include/uapi/asm/Kbuild 
b/arch/csky/include/uapi/asm/Kbuild
index e78470141932..2501e82a1a0a 100644
--- a/arch/csky/include/uapi/asm/Kbuild
+++ b/arch/csky/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
diff --git a/arch/csky/include/uapi/asm/unistd.h 
b/arch/csky/include/uapi/asm/unistd.h
index d529d0432876..794adbc04e48 100644
--- a/arch/csky/include/uapi/asm/unistd.h
+++ b/arch/csky/include/uapi/asm/unistd.h
@@ -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 
-
-#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 
+#define __NR_sync_file_range2 __NR_sync_file_range
diff --git a/arch/csky/kernel/Makefile.syscalls 
b/arch/csky/kernel/Makefile.syscalls
new file mode 100644
index ..3df3b5822fce
--- /dev/null
+++ b/arch/csky/kernel/Makefile.syscalls
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += csky time32 stat64 rlimit
+
diff --git a/arch/csky/kernel/syscall_table.c b/arch/csky/kernel/syscall_table.c
index a0c238c5377a..a6eb91a0e2f6 100644
--- a/arch/csky/kernel/syscall_table.c
+++ b/arch/csky/kernel/syscall_table.c
@@ -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 
+#include 
 };
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index 13f4c79ba5c2..ed0ecba8fea4 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -293,6 +293,10 @@
 246arc arc_gettls  sys_arc_gettls
 247arc sysfs   sys_sysfs
 248arc arc_usr_cmpxchg sys_arc_usr_cmpxchg
+
+244cskyset_thread_area sys_set_thread_area
+245cskycacheflush  sys_cacheflush
+
 260time32  wait4   sys_wait4   
compat_sys_wait4
 26064  wait4   sys_wait4
 261common  prlimit64   sys_prlimit64
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 13/17] hexagon: use new system call table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 3ece3c93fe08..8c1a78c8f527 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -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
diff --git a/arch/hexagon/include/asm/unistd.h 
b/arch/hexagon/include/asm/unistd.h
new file mode 100644
index ..1f462bade75c
--- /dev/null
+++ b/arch/hexagon/include/asm/unistd.h
@@ -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 
diff --git a/arch/hexagon/include/uapi/asm/Kbuild 
b/arch/hexagon/include/uapi/asm/Kbuild
index e78470141932..2501e82a1a0a 100644
--- a/arch/hexagon/include/uapi/asm/Kbuild
+++ b/arch/hexagon/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
diff --git a/arch/hexagon/include/uapi/asm/unistd.h 
b/arch/hexagon/include/uapi/asm/unistd.h
index 4bea7428e747..6f670347dd61 100644
--- a/arch/hexagon/include/uapi/asm/unistd.h
+++ b/arch/hexagon/include/uapi/asm/unistd.h
@@ -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 
 
-#define __ARCH_BROKEN_SYS_CLONE3
-
-#include 
+#define __NR_sync_file_range2 __NR_sync_file_range
diff --git a/arch/hexagon/kernel/Makefile.syscalls 
b/arch/hexagon/kernel/Makefile.syscalls
new file mode 100644
index ..d2b7c5d44d95
--- /dev/null
+++ b/arch/hexagon/kernel/Makefile.syscalls
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += hexagon time32 stat64 rlimit renameat
diff --git a/arch/hexagon/kernel/syscalltab.c b/arch/hexagon/kernel/syscalltab.c
index 5d98bdc494ec..b53e2eead4ac 100644
--- a/arch/hexagon/kernel/syscalltab.c
+++ b/arch/hexagon/kernel/syscalltab.c
@@ -11,8 +11,10 @@
 
 #include 
 
-#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 
+#include 
 };
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 14/17] loongarch: convert to generic syscall table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/loongarch/include/asm/Kbuild 
b/arch/loongarch/include/asm/Kbuild
index 0db5ad14f014..2bb3676429c0 100644
--- a/arch/loongarch/include/asm/Kbuild
+++ b/arch/loongarch/include/asm/Kbuild
@@ -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
diff --git a/arch/loongarch/include/asm/unistd.h 
b/arch/loongarch/include/asm/unistd.h
index cfddb0116a8c..fc0a481a7416 100644
--- a/arch/loongarch/include/asm/unistd.h
+++ b/arch/loongarch/include/asm/unistd.h
@@ -8,4 +8,6 @@
 
 #include 
 
+#define __ARCH_WANT_SYS_CLONE
+
 #define NR_syscalls (__NR_syscalls)
diff --git a/arch/loongarch/include/uapi/asm/Kbuild 
b/arch/loongarch/include/uapi/asm/Kbuild
index 4aa680ca2e5f..c6d141d7b7d7 100644
--- a/arch/loongarch/include/uapi/asm/Kbuild
+++ b/arch/loongarch/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_64.h
+
 generic-y += kvm_para.h
diff --git a/arch/loongarch/include/uapi/asm/unistd.h 
b/arch/loongarch/include/uapi/asm/unistd.h
index 191614b9b207..1f01980f9c94 100644
--- a/arch/loongarch/include/uapi/asm/unistd.h
+++ b/arch/loongarch/include/uapi/asm/unistd.h
@@ -1,4 +1,3 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#define __ARCH_WANT_SYS_CLONE
 
-#include 
+#include 
diff --git a/arch/loongarch/kernel/Makefile.syscalls 
b/arch/loongarch/kernel/Makefile.syscalls
new file mode 100644
index ..ab7d9baa2915
--- /dev/null
+++ b/arch/loongarch/kernel/Makefile.syscalls
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# No special ABIs on loongarch so far
+syscall_abis_64 +=
diff --git a/arch/loongarch/kernel/syscall.c b/arch/loongarch/kernel/syscall.c
index 8801611143ab..ec17cd5163b7 100644
--- a/arch/loongarch/kernel/syscall.c
+++ b/arch/loongarch/kernel/syscall.c
@@ -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 
+#include 
 };
 
 typedef long (*sys_call_fn)(unsigned long, unsigned long,
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 15/17] nios2: convert to generic syscall table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild
index 7fe7437555fb..0d09829ed144 100644
--- a/arch/nios2/include/asm/Kbuild
+++ b/arch/nios2/include/asm/Kbuild
@@ -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
diff --git a/arch/nios2/include/asm/unistd.h b/arch/nios2/include/asm/unistd.h
new file mode 100644
index ..1146e56473c5
--- /dev/null
+++ b/arch/nios2/include/asm/unistd.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_UNISTD_H
+#define __ASM_UNISTD_H
+
+#include 
+
+#define __ARCH_WANT_STAT64
+#define __ARCH_WANT_SET_GET_RLIMIT
+
+#define __ARCH_BROKEN_SYS_CLONE3
+
+#endif
diff --git a/arch/nios2/include/uapi/asm/Kbuild 
b/arch/nios2/include/uapi/asm/Kbuild
index e78470141932..2501e82a1a0a 100644
--- a/arch/nios2/include/uapi/asm/Kbuild
+++ b/arch/nios2/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
diff --git a/arch/nios2/include/uapi/asm/unistd.h 
b/arch/nios2/include/uapi/asm/unistd.h
index d2bc5ac975fb..1f0e0f5538d9 100644
--- a/arch/nios2/include/uapi/asm/unistd.h
+++ b/arch/nios2/include/uapi/asm/unistd.h
@@ -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 
-
-/* Additional Nios II specific syscalls. */
-#define __NR_cacheflush (__NR_arch_specific_syscall)
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
+#include 
diff --git a/arch/nios2/kernel/Makefile.syscalls 
b/arch/nios2/kernel/Makefile.syscalls
new file mode 100644
index ..579a9daec272
--- /dev/null
+++ b/arch/nios2/kernel/Makefile.syscalls
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += nios2 time32 stat64 renameat rlimit
diff --git a/arch/nios2/kernel/syscall_table.c 
b/arch/nios2/kernel/syscall_table.c
index c2875a6dd5a4..434694067d8f 100644
--- a/arch/nios2/kernel/syscall_table.c
+++ b/arch/nios2/kernel/syscall_table.c
@@ -9,10 +9,12 @@
 
 #include 
 
-#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 
+#include 
 };
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index ed0ecba8fea4..40307011abdb 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -297,6 +297,8 @@
 244cskyset_thread_area sys_set_thread_area
 245cskycacheflush  sys_cacheflush
 
+244nios2   cacheflush  sys_cacheflush
+
 260time32  wait4   sys_wait4   
compat_sys_wait4
 26064  wait4   sys_wait4
 261common  prlimit64   sys_prlimit64
-- 
2.39.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 16/17] openrisc: convert to generic syscall table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index c8c99b554ca4..cef49d60d74c 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -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
diff --git a/arch/openrisc/include/asm/syscalls.h 
b/arch/openrisc/include/asm/syscalls.h
index aa1c7e98722e..9f4c47961bea 100644
--- a/arch/openrisc/include/asm/syscalls.h
+++ b/arch/openrisc/include/asm/syscalls.h
@@ -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 */
diff --git a/arch/openrisc/include/asm/unistd.h 
b/arch/openrisc/include/asm/unistd.h
new file mode 100644
index ..c73f65e18d3b
--- /dev/null
+++ b/arch/openrisc/include/asm/unistd.h
@@ -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 
diff --git a/arch/openrisc/include/uapi/asm/Kbuild 
b/arch/openrisc/include/uapi/asm/Kbuild
index e78470141932..2501e82a1a0a 100644
--- a/arch/openrisc/include/uapi/asm/Kbuild
+++ b/arch/openrisc/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+
 generic-y += ucontext.h
diff --git a/arch/openrisc/include/uapi/asm/unistd.h 
b/arch/openrisc/include/uapi/asm/unistd.h
index 566f8c4f8047..46b94d454efd 100644
--- a/arch/openrisc/include/uapi/asm/unistd.h
+++ b/arch/openrisc/include/uapi/asm/unistd.h
@@ -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 
-
-#define __NR_or1k_atomic __NR_arch_specific_syscall
-__SYSCALL(__NR_or1k_atomic, sys_or1k_atomic)
+#include 
diff --git a/arch/openrisc/kernel/Makefile.syscalls 
b/arch/openrisc/kernel/Makefile.syscalls
new file mode 100644
index ..525a1e7e7fc9
--- /dev/null
+++ b/arch/openrisc/kernel/Makefile.syscalls
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+syscall_abis_32 += or1k time32 stat64 rlimit renameat
diff --git a/arch/openrisc/kernel/sys_call_table.c 
b/arch/openrisc/kernel/sys_call_table.c
index 3d18008310e4..b2f57e2538f7 100644
--- a/arch/openrisc/kernel/sys_call_table.c
+++ b/arch/openrisc/kernel/sys_call_table.c
@@ -16,9 +16,14 @@
 
 #include 
 
-#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 
+#include 
 };
diff --git a/scripts/syscall.tbl b/scripts/syscall.tbl
index 40307011abdb..28329c00bf68 100644
--- a/scripts/syscall.tbl
+++ b/scripts/syscall.tbl
@@ -299,6 +299,8 @@
 
 244nios2   cacheflush  sys_cacheflush
 
+244or1kor1k_atomic sys_or1k_atomic
+
 260time32  wait4 

[PATCH 17/17] riscv: convert to generic syscall table

2024-07-04 Thread Arnd Bergmann
From: Arnd Bergmann 

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.

Signed-off-by: Arnd Bergmann 
---
 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

diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild
index 504f8b7e72d4..5c589770f2a8 100644
--- a/arch/riscv/include/asm/Kbuild
+++ b/arch/riscv/include/asm/Kbuild
@@ -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
diff --git a/arch/riscv/include/asm/syscall_table.h 
b/arch/riscv/include/asm/syscall_table.h
new file mode 100644
index ..0c2d61782813
--- /dev/null
+++ b/arch/riscv/include/asm/syscall_table.h
@@ -0,0 +1,7 @@
+#include 
+
+#if __BITS_PER_LONG == 64
+#include 
+#else
+#include 
+#endif
diff --git a/arch/riscv/include/asm/unistd.h b/arch/riscv/include/asm/unistd.h
index 221630bdbd07..e6d904fa67c5 100644
--- a/arch/riscv/include/asm/unistd.h
+++ b/arch/riscv/include/asm/unistd.h
@@ -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 
 
 #define NR_syscalls (__NR_syscalls)
diff --git a/arch/riscv/include/uapi/asm/Kbuild 
b/arch/riscv/include/uapi/asm/Kbuild
index f66554cd5c45..89ac01faa5ae 100644
--- a/arch/riscv/include/uapi/asm/Kbuild
+++ b/arch/riscv/include/uapi/asm/Kbuild
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+syscall-y += unistd_32.h
+syscall-y += unistd_64.h
diff --git a/arch/riscv/include/uapi/asm/unistd.h 
b/arch/riscv/include/uapi/asm/unistd.h
index 328520defc13..81896bbbf727 100644
--- a/arch/riscv/include/uapi/asm/unistd.h
+++ b/arch/riscv/include/uapi/asm/unistd.h
@@ -14,40 +14,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see .
  */
+#include 
 
-#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 
-
-/*
- * 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_hwprob