linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls
@ 2023-09-11 18:02 Sohil Mehta
  2023-09-11 18:02 ` [PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries Sohil Mehta
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sohil Mehta @ 2023-09-11 18:02 UTC (permalink / raw)
  To: linux-kernel, linux-api, linux-arch
  Cc: Sohil Mehta, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Michal Simek, Thomas Bogendoerfer, James E . J . Bottomley,
	Helge Deller, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	David S . Miller, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, Chris Zankel,
	Max Filippov, Arnd Bergmann, Peter Zijlstra,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
	Lukas Bulwahn, Sergei Trofimovich, Andrew Morton, Rohan McLure,
	Andreas Schwab, Eric W . Biederman, Brian Gerst, Randy Dunlap,
	Rick Edgecombe, Mark Brown, Deepak Gupta, linux-alpha,
	linux-arm-kernel, linux-ia64, linux-m68k, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-perf-users

6.6-rc1 has added support for 2 new system calls:
[1] fchmodat2()
[2] x86-specific map_shadow_stack()

This series mainly synchronizes the syscall tables arcoss the core kernel and
tools to reflect the recent updates.

For fchmodat2(), it fixes the missing entries in the tools directory.

For map_shadow_stack(), it reserves the syscall across the board. Since
map_shadow_stack() is x86 specific for now, it is marked as a conditional
syscall in sys_ni.c. Adding it to the syscall tables of other architectures is
harmless and would return ENOSYS when exercised.

Reserving arch-specific syscall numbers in the tables of all architectures is
good practice and would help avoid future conflicts.

[1]: https://lore.kernel.org/lkml/20230824-frohlocken-vorabend-725f6fdaad50@brauner/
[2]: https://lore.kernel.org/lkml/20230830234752.19858-1-dave.hansen@linux.intel.com/

Sohil Mehta (2):
  tools headers UAPI: Sync fchmodat2() syscall table entries
  arch: Reserve map_shadow_stack() syscall number for all architectures

 arch/alpha/kernel/syscalls/syscall.tbl              | 1 +
 arch/arm/tools/syscall.tbl                          | 1 +
 arch/arm64/include/asm/unistd.h                     | 2 +-
 arch/arm64/include/asm/unistd32.h                   | 2 ++
 arch/ia64/kernel/syscalls/syscall.tbl               | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl               | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl         | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl           | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl           | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl           | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl             | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl            | 1 +
 arch/s390/kernel/syscalls/syscall.tbl               | 1 +
 arch/sh/kernel/syscalls/syscall.tbl                 | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl              | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl              | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl             | 1 +
 include/uapi/asm-generic/unistd.h                   | 5 ++++-
 tools/include/uapi/asm-generic/unistd.h             | 8 +++++++-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 2 ++
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 2 ++
 tools/perf/arch/s390/entry/syscalls/syscall.tbl     | 2 ++
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 2 ++
 23 files changed, 37 insertions(+), 3 deletions(-)


base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries
  2023-09-11 18:02 [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
@ 2023-09-11 18:02 ` Sohil Mehta
  2023-09-11 18:02 ` [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures Sohil Mehta
  2023-09-13 19:32 ` [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
  2 siblings, 0 replies; 8+ messages in thread
From: Sohil Mehta @ 2023-09-11 18:02 UTC (permalink / raw)
  To: linux-kernel, linux-api, linux-arch
  Cc: Sohil Mehta, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Michal Simek, Thomas Bogendoerfer, James E . J . Bottomley,
	Helge Deller, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	David S . Miller, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, Chris Zankel,
	Max Filippov, Arnd Bergmann, Peter Zijlstra,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
	Lukas Bulwahn, Sergei Trofimovich, Andrew Morton, Rohan McLure,
	Andreas Schwab, Eric W . Biederman, Brian Gerst, Randy Dunlap,
	Rick Edgecombe, Mark Brown, Deepak Gupta, linux-alpha,
	linux-arm-kernel, linux-ia64, linux-m68k, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-perf-users

The syscall table entries in the core kernel and perf are expected to be
in sync. This would fix perf build warnings and also add support for
fchmodat2 in 'perf trace'.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
 tools/include/uapi/asm-generic/unistd.h             | 5 ++++-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 +
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 1 +
 tools/perf/arch/s390/entry/syscalls/syscall.tbl     | 1 +
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 1 +
 5 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index fd6c1cb585db..abe087c53b4b 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -820,8 +820,11 @@ __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
 #define __NR_cachestat 451
 __SYSCALL(__NR_cachestat, sys_cachestat)
 
+#define __NR_fchmodat2 452
+__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
+
 #undef __NR_syscalls
-#define __NR_syscalls 452
+#define __NR_syscalls 453
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
index cfda2511badf..cb5e757f6621 100644
--- a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
+++ b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
@@ -366,3 +366,4 @@
 449	n64	futex_waitv			sys_futex_waitv
 450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	n64	cachestat			sys_cachestat
+452	n64	fchmodat2			sys_fchmodat2
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
index 8c0b08b7a80e..20e50586e8a2 100644
--- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -538,3 +538,4 @@
 449	common  futex_waitv                     sys_futex_waitv
 450 	nospu	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	common	cachestat			sys_cachestat
+452	common	fchmodat2			sys_fchmodat2
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
index a6935af2235c..0122cc156952 100644
--- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
@@ -454,3 +454,4 @@
 449  common	futex_waitv		sys_futex_waitv			sys_futex_waitv
 450  common	set_mempolicy_home_node	sys_set_mempolicy_home_node	sys_set_mempolicy_home_node
 451  common	cachestat		sys_cachestat			sys_cachestat
+452  common	fchmodat2		sys_fchmodat2			sys_fchmodat2
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index 227538b0ce80..a5db10ddf540 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -373,6 +373,7 @@
 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
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures
  2023-09-11 18:02 [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
  2023-09-11 18:02 ` [PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries Sohil Mehta
@ 2023-09-11 18:02 ` Sohil Mehta
  2023-09-11 21:10   ` Edgecombe, Rick P
  2023-09-13 19:32 ` [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
  2 siblings, 1 reply; 8+ messages in thread
From: Sohil Mehta @ 2023-09-11 18:02 UTC (permalink / raw)
  To: linux-kernel, linux-api, linux-arch
  Cc: Sohil Mehta, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Russell King, Catalin Marinas, Will Deacon, Geert Uytterhoeven,
	Michal Simek, Thomas Bogendoerfer, James E . J . Bottomley,
	Helge Deller, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	David S . Miller, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, Chris Zankel,
	Max Filippov, Arnd Bergmann, Peter Zijlstra,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
	Lukas Bulwahn, Sergei Trofimovich, Andrew Morton, Rohan McLure,
	Andreas Schwab, Eric W . Biederman, Brian Gerst, Randy Dunlap,
	Rick Edgecombe, Mark Brown, Deepak Gupta, linux-alpha,
	linux-arm-kernel, linux-ia64, linux-m68k, linux-mips,
	linux-parisc, linuxppc-dev, linux-s390, linux-sh, sparclinux,
	linux-perf-users

Support for map_shadow_stack() was recently added but it is an x86
only system call for now. There is a possibility that other
architectures (namely, arm64 and Risc-V) that are implementing support
for shadow stacks, might need to add support for it.

Independent of that, reserving arch-specific syscall numbers in the
syscall tables of all architectures is good practice and would help
avoid future conflicts.

Note, map_shadow_stack() was assigned #453 since #452 was taken by
fchmodat2().

Link:https://lore.kernel.org/lkml/20230830234752.19858-1-dave.hansen@linux.intel.com/

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
 arch/alpha/kernel/syscalls/syscall.tbl              | 1 +
 arch/arm/tools/syscall.tbl                          | 1 +
 arch/arm64/include/asm/unistd.h                     | 2 +-
 arch/arm64/include/asm/unistd32.h                   | 2 ++
 arch/ia64/kernel/syscalls/syscall.tbl               | 1 +
 arch/m68k/kernel/syscalls/syscall.tbl               | 1 +
 arch/microblaze/kernel/syscalls/syscall.tbl         | 1 +
 arch/mips/kernel/syscalls/syscall_n32.tbl           | 1 +
 arch/mips/kernel/syscalls/syscall_n64.tbl           | 1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl           | 1 +
 arch/parisc/kernel/syscalls/syscall.tbl             | 1 +
 arch/powerpc/kernel/syscalls/syscall.tbl            | 1 +
 arch/s390/kernel/syscalls/syscall.tbl               | 1 +
 arch/sh/kernel/syscalls/syscall.tbl                 | 1 +
 arch/sparc/kernel/syscalls/syscall.tbl              | 1 +
 arch/x86/entry/syscalls/syscall_32.tbl              | 1 +
 arch/xtensa/kernel/syscalls/syscall.tbl             | 1 +
 include/uapi/asm-generic/unistd.h                   | 5 ++++-
 tools/include/uapi/asm-generic/unistd.h             | 5 ++++-
 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 +
 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl  | 1 +
 tools/perf/arch/s390/entry/syscalls/syscall.tbl     | 1 +
 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl   | 1 +
 23 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl
index ad37569d0507..6e8479c96e65 100644
--- a/arch/alpha/kernel/syscalls/syscall.tbl
+++ b/arch/alpha/kernel/syscalls/syscall.tbl
@@ -492,3 +492,4 @@
 560	common	set_mempolicy_home_node		sys_ni_syscall
 561	common	cachestat			sys_cachestat
 562	common	fchmodat2			sys_fchmodat2
+563	common	map_shadow_stack		sys_map_shadow_stack
diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl
index c572d6c3dee0..6d494dfbf5e4 100644
--- a/arch/arm/tools/syscall.tbl
+++ b/arch/arm/tools/syscall.tbl
@@ -466,3 +466,4 @@
 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
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index bd77253b62e0..6a28fb91b85d 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -39,7 +39,7 @@
 #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		453
+#define __NR_compat_syscalls		454
 #endif
 
 #define __ARCH_WANT_SYS_CLONE
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index 78b68311ec81..a201d842ec82 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
 __SYSCALL(__NR_cachestat, sys_cachestat)
 #define __NR_fchmodat2 452
 __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
+#define __NR_map_shadow_stack 453
+__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
 
 /*
  * Please add new compat syscalls above this comment and update
diff --git a/arch/ia64/kernel/syscalls/syscall.tbl b/arch/ia64/kernel/syscalls/syscall.tbl
index 83d8609aec03..be02ce9d376f 100644
--- a/arch/ia64/kernel/syscalls/syscall.tbl
+++ b/arch/ia64/kernel/syscalls/syscall.tbl
@@ -373,3 +373,4 @@
 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
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl
index 259ceb125367..bee2d2f7f82c 100644
--- a/arch/m68k/kernel/syscalls/syscall.tbl
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -452,3 +452,4 @@
 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
diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl
index a3798c2637fd..09eda7ed91b0 100644
--- a/arch/microblaze/kernel/syscalls/syscall.tbl
+++ b/arch/microblaze/kernel/syscalls/syscall.tbl
@@ -458,3 +458,4 @@
 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
diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl
index 152034b8e0a0..3c02cc3886ca 100644
--- a/arch/mips/kernel/syscalls/syscall_n32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
@@ -391,3 +391,4 @@
 450	n32	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	n32	cachestat			sys_cachestat
 452	n32	fchmodat2			sys_fchmodat2
+453	n32	map_shadow_stack		sys_map_shadow_stack
diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl
index cb5e757f6621..aa9ed6a7cb48 100644
--- a/arch/mips/kernel/syscalls/syscall_n64.tbl
+++ b/arch/mips/kernel/syscalls/syscall_n64.tbl
@@ -367,3 +367,4 @@
 450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	n64	cachestat			sys_cachestat
 452	n64	fchmodat2			sys_fchmodat2
+453	n64	map_shadow_stack		sys_map_shadow_stack
diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl
index 1a646813afdc..756f6feb21c2 100644
--- a/arch/mips/kernel/syscalls/syscall_o32.tbl
+++ b/arch/mips/kernel/syscalls/syscall_o32.tbl
@@ -440,3 +440,4 @@
 450	o32	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	o32	cachestat			sys_cachestat
 452	o32	fchmodat2			sys_fchmodat2
+453	o32	map_shadow_stack		sys_map_shadow_stack
diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl
index e97c175b56f9..c80eedbe0170 100644
--- a/arch/parisc/kernel/syscalls/syscall.tbl
+++ b/arch/parisc/kernel/syscalls/syscall.tbl
@@ -451,3 +451,4 @@
 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
diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
index 20e50586e8a2..2767b8a42636 100644
--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -539,3 +539,4 @@
 450 	nospu	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
diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl
index 0122cc156952..22249c07e556 100644
--- a/arch/s390/kernel/syscalls/syscall.tbl
+++ b/arch/s390/kernel/syscalls/syscall.tbl
@@ -455,3 +455,4 @@
 450  common	set_mempolicy_home_node	sys_set_mempolicy_home_node	sys_set_mempolicy_home_node
 451  common	cachestat		sys_cachestat			sys_cachestat
 452  common	fchmodat2		sys_fchmodat2			sys_fchmodat2
+453  common	map_shadow_stack	sys_map_shadow_stack		sys_map_shadow_stack
diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl
index e90d585c4d3e..5ccfe6fbb6b1 100644
--- a/arch/sh/kernel/syscalls/syscall.tbl
+++ b/arch/sh/kernel/syscalls/syscall.tbl
@@ -455,3 +455,4 @@
 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
diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl
index 4ed06c71c43f..b2d664edebdd 100644
--- a/arch/sparc/kernel/syscalls/syscall.tbl
+++ b/arch/sparc/kernel/syscalls/syscall.tbl
@@ -498,3 +498,4 @@
 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
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 2d0b1bd866ea..743a7ef5a4b9 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -457,3 +457,4 @@
 450	i386	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	i386	cachestat		sys_cachestat
 452	i386	fchmodat2		sys_fchmodat2
+453	i386	map_shadow_stack	sys_map_shadow_stack
diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl
index fc1a4f3c81d9..94e6bcc2bec7 100644
--- a/arch/xtensa/kernel/syscalls/syscall.tbl
+++ b/arch/xtensa/kernel/syscalls/syscall.tbl
@@ -423,3 +423,4 @@
 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
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index abe087c53b4b..203ae30d7761 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -823,8 +823,11 @@ __SYSCALL(__NR_cachestat, sys_cachestat)
 #define __NR_fchmodat2 452
 __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
 
+#define __NR_map_shadow_stack 453
+__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
+
 #undef __NR_syscalls
-#define __NR_syscalls 453
+#define __NR_syscalls 454
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index abe087c53b4b..203ae30d7761 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -823,8 +823,11 @@ __SYSCALL(__NR_cachestat, sys_cachestat)
 #define __NR_fchmodat2 452
 __SYSCALL(__NR_fchmodat2, sys_fchmodat2)
 
+#define __NR_map_shadow_stack 453
+__SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack)
+
 #undef __NR_syscalls
-#define __NR_syscalls 453
+#define __NR_syscalls 454
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
index cb5e757f6621..aa9ed6a7cb48 100644
--- a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
+++ b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
@@ -367,3 +367,4 @@
 450	common	set_mempolicy_home_node		sys_set_mempolicy_home_node
 451	n64	cachestat			sys_cachestat
 452	n64	fchmodat2			sys_fchmodat2
+453	n64	map_shadow_stack		sys_map_shadow_stack
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
index 20e50586e8a2..2767b8a42636 100644
--- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -539,3 +539,4 @@
 450 	nospu	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
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
index 0122cc156952..22249c07e556 100644
--- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
@@ -455,3 +455,4 @@
 450  common	set_mempolicy_home_node	sys_set_mempolicy_home_node	sys_set_mempolicy_home_node
 451  common	cachestat		sys_cachestat			sys_cachestat
 452  common	fchmodat2		sys_fchmodat2			sys_fchmodat2
+453  common	map_shadow_stack	sys_map_shadow_stack		sys_map_shadow_stack
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index a5db10ddf540..6a5819362530 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -374,6 +374,7 @@
 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
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures
  2023-09-11 18:02 ` [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures Sohil Mehta
@ 2023-09-11 21:10   ` Edgecombe, Rick P
  2023-09-13 19:18     ` Sohil Mehta
  2023-09-14 12:26     ` Michael Ellerman
  0 siblings, 2 replies; 8+ messages in thread
From: Edgecombe, Rick P @ 2023-09-11 21:10 UTC (permalink / raw)
  To: Mehta, Sohil, linux-kernel, linux-arch, linux-api
  Cc: svens, catalin.marinas, schwab, brgerst, alexander.shishkin,
	linux-perf-users, x86, monstr, borntraeger, dave.hansen,
	christophe.leroy, mark.rutland, glaubitz, dalias, lukas.bulwahn,
	rdunlap, tglx, hca, linux, sparclinux, arnd, linux-ia64,
	ebiederm, Lutomirski, Andy, jolsa, linux-parisc, akpm, linux-sh,
	linuxppc-dev, mpe, geert, hpa, James.Bottomley, peterz, ink,
	linux-m68k, tsbogend, broonie, Hunter, Adrian, acme, ysato,
	deller, debug, rmclure, gor, slyich, npiggin, agordeev, chris,
	mingo, linux-mips, linux-alpha, mattst88, linux-s390,
	linux-arm-kernel, jcmvbkbc, bp, richard.henderson, irogers,
	namhyung, will, davem

On Mon, 2023-09-11 at 18:02 +0000, Sohil Mehta wrote:
> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
> b/arch/powerpc/kernel/syscalls/syscall.tbl
> index 20e50586e8a2..2767b8a42636 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -539,3 +539,4 @@
>  450    nospu   set_mempolicy_home_node         sys_set_mempolicy_hom
> e_node
>  451    common  cachestat                       sys_cachestat
>  452    common  fchmodat2                       sys_fchmodat2
> +453    common  map_shadow_stack                sys_map_shadow_stack

I noticed in powerpc, the not implemented syscalls are manually mapped
to sys_ni_syscall. It also has some special extra sys_ni_syscall()
implementation bits to handle both ARCH_HAS_SYSCALL_WRAPPER and
!ARCH_HAS_SYSCALL_WRAPPER. So wondering if it might need special
treatment. Did you see those parts?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures
  2023-09-11 21:10   ` Edgecombe, Rick P
@ 2023-09-13 19:18     ` Sohil Mehta
  2023-09-13 22:05       ` Edgecombe, Rick P
  2023-09-14 12:26     ` Michael Ellerman
  1 sibling, 1 reply; 8+ messages in thread
From: Sohil Mehta @ 2023-09-13 19:18 UTC (permalink / raw)
  To: Edgecombe, Rick P, linux-kernel, linux-arch, linux-api
  Cc: svens, catalin.marinas, schwab, brgerst, alexander.shishkin,
	linux-perf-users, x86, monstr, borntraeger, dave.hansen,
	christophe.leroy, mark.rutland, glaubitz, dalias, lukas.bulwahn,
	rdunlap, tglx, hca, linux, sparclinux, arnd, linux-ia64,
	ebiederm, Lutomirski, Andy, jolsa, linux-parisc, akpm, linux-sh,
	linuxppc-dev, mpe, geert, hpa, James.Bottomley, peterz, ink,
	linux-m68k, tsbogend, broonie, Hunter, Adrian, acme, ysato,
	deller, debug, rmclure, gor, slyich, npiggin, agordeev, chris,
	mingo, linux-mips, linux-alpha, mattst88, linux-s390,
	linux-arm-kernel, jcmvbkbc, bp, richard.henderson, irogers,
	namhyung, will, davem

On 9/11/2023 2:10 PM, Edgecombe, Rick P wrote:
> On Mon, 2023-09-11 at 18:02 +0000, Sohil Mehta wrote:
>> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
>> b/arch/powerpc/kernel/syscalls/syscall.tbl
>> index 20e50586e8a2..2767b8a42636 100644
>> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
>> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
>> @@ -539,3 +539,4 @@
>>  450    nospu   set_mempolicy_home_node         sys_set_mempolicy_hom
>> e_node
>>  451    common  cachestat                       sys_cachestat
>>  452    common  fchmodat2                       sys_fchmodat2
>> +453    common  map_shadow_stack                sys_map_shadow_stack
> 
> I noticed in powerpc, the not implemented syscalls are manually mapped
> to sys_ni_syscall. It also has some special extra sys_ni_syscall()
> implementation bits to handle both ARCH_HAS_SYSCALL_WRAPPER and
> !ARCH_HAS_SYSCALL_WRAPPER. So wondering if it might need special
> treatment. Did you see those parts?
> 

Thanks for pointing this out. Powerpc seems to be unique in their
handling of not implemented syscalls. Maybe it's because of their
special casing of the ARCH_HAS_SYSCALL_WRAPPER.

The code below in arch/powerpc/include/asm/syscalls.h suggests to me
that it should be safe to map map_shadow_stack() to sys_ni_syscall() and
the special handling will be taken care of.

#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
long sys_ni_syscall(void);
#else
long sys_ni_syscall(const struct pt_regs *regs);
#endif

I don't quite understand the underlying reasoning for it though. Do you
have any additional insight into how we should handle this?

I am thinking of doing the following in the next iteration unless
someone chimes in and says otherwise.

--- a/arch/powerpc/kernel/syscalls/syscall.tbl
+++ b/arch/powerpc/kernel/syscalls/syscall.tbl
@@ -539,4 +539,4 @@
 450    nospu   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
+453    common  map_shadow_stack                sys_ni_syscall


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls
  2023-09-11 18:02 [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
  2023-09-11 18:02 ` [PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries Sohil Mehta
  2023-09-11 18:02 ` [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures Sohil Mehta
@ 2023-09-13 19:32 ` Sohil Mehta
  2 siblings, 0 replies; 8+ messages in thread
From: Sohil Mehta @ 2023-09-13 19:32 UTC (permalink / raw)
  To: linux-kernel, linux-api, linux-arch
  Cc: Richard Henderson, Ivan Kokshaysky, Matt Turner, Russell King,
	Catalin Marinas, Will Deacon, Geert Uytterhoeven, Michal Simek,
	Thomas Bogendoerfer, James E . J . Bottomley, Helge Deller,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, David S . Miller,
	Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H . Peter Anvin, Chris Zankel, Max Filippov,
	Arnd Bergmann, Peter Zijlstra, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Lukas Bulwahn, Sergei Trofimovich,
	Andrew Morton, Rohan McLure, Andreas Schwab, Eric W . Biederman,
	Brian Gerst, Randy Dunlap, Rick Edgecombe, Mark Brown,
	Deepak Gupta, linux-alpha, linux-arm-kernel, linux-ia64,
	linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-s390,
	linux-sh, sparclinux, linux-perf-users

On 9/11/2023 11:02 AM, Sohil Mehta wrote:
> Sohil Mehta (2):
>   tools headers UAPI: Sync fchmodat2() syscall table entries

I now see a patch by Arnaldo that does something similar:
https://lore.kernel.org/lkml/ZP8bE7aXDBu%2Fdrak@kernel.org/

Also, it states that:

"The tools/perf/check-headers.sh script, part of the tools/ build
process, points out changes in the original files.

So its important not to touch the copies in tools/ when doing changes in
the original kernel headers, that will be done later, when
check-headers.sh inform about the change to the perf tools hackers."

I was unaware of this and therefore I'll drop all the tools/ related
changes from this series.

Sohil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures
  2023-09-13 19:18     ` Sohil Mehta
@ 2023-09-13 22:05       ` Edgecombe, Rick P
  0 siblings, 0 replies; 8+ messages in thread
From: Edgecombe, Rick P @ 2023-09-13 22:05 UTC (permalink / raw)
  To: Mehta, Sohil, linux-kernel, linux-arch, linux-api
  Cc: svens, catalin.marinas, schwab, brgerst, alexander.shishkin,
	linux-perf-users, x86, dalias, monstr, borntraeger, dave.hansen,
	christophe.leroy, mark.rutland, glaubitz, lukas.bulwahn, rdunlap,
	tglx, hca, linux, sparclinux, jolsa, arnd, ebiederm, Lutomirski,
	Andy, linux-ia64, linux-parisc, linux-sh, akpm, linuxppc-dev,
	mpe, geert, hpa, James.Bottomley, peterz, ink, linux-m68k,
	broonie, tsbogend, Hunter, Adrian, acme, ysato, deller, debug,
	rmclure, gor, slyich, npiggin, agordeev, chris, mingo,
	linux-mips, linux-alpha, mattst88, linux-s390, linux-arm-kernel,
	bp, jcmvbkbc, richard.henderson, irogers, namhyung, will, davem

On Wed, 2023-09-13 at 12:18 -0700, Sohil Mehta wrote:
> On 9/11/2023 2:10 PM, Edgecombe, Rick P wrote:
> > On Mon, 2023-09-11 at 18:02 +0000, Sohil Mehta wrote:
> > > diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
> > > b/arch/powerpc/kernel/syscalls/syscall.tbl
> > > index 20e50586e8a2..2767b8a42636 100644
> > > --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> > > +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> > > @@ -539,3 +539,4 @@
> > >  450    nospu   set_mempolicy_home_node         sys_set_mempolicy
> > > _hom
> > > e_node
> > >  451    common  cachestat                       sys_cachestat
> > >  452    common  fchmodat2                       sys_fchmodat2
> > > +453    common  map_shadow_stack                sys_map_shadow_st
> > > ack
> > 
> > I noticed in powerpc, the not implemented syscalls are manually
> > mapped
> > to sys_ni_syscall. It also has some special extra sys_ni_syscall()
> > implementation bits to handle both ARCH_HAS_SYSCALL_WRAPPER and
> > !ARCH_HAS_SYSCALL_WRAPPER. So wondering if it might need special
> > treatment. Did you see those parts?
> > 
> 
> Thanks for pointing this out. Powerpc seems to be unique in their
> handling of not implemented syscalls. Maybe it's because of their
> special casing of the ARCH_HAS_SYSCALL_WRAPPER.
> 
> The code below in arch/powerpc/include/asm/syscalls.h suggests to me
> that it should be safe to map map_shadow_stack() to sys_ni_syscall()
> and
> the special handling will be taken care of.
> 
> #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
> long sys_ni_syscall(void);
> #else
> long sys_ni_syscall(const struct pt_regs *regs);
> #endif
> 
> I don't quite understand the underlying reasoning for it though. Do
> you
> have any additional insight into how we should handle this?
> 
> I am thinking of doing the following in the next iteration unless
> someone chimes in and says otherwise.
> 
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -539,4 +539,4 @@
>  450    nospu   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
> +453    common  map_shadow_stack                sys_ni_syscall

It might have something to do with that powerpc's COND_SYSCALL()
implementation only defines the struct pt_regs variety, but TBH I get a
bit lost when I get to the inline assembly symbol definitions parts and
how it all ties together.

Doing powerpc's version as sys_ni_syscall seems to be consistent at
least, and makes sense with respect to the code you quoted.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures
  2023-09-11 21:10   ` Edgecombe, Rick P
  2023-09-13 19:18     ` Sohil Mehta
@ 2023-09-14 12:26     ` Michael Ellerman
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2023-09-14 12:26 UTC (permalink / raw)
  To: Edgecombe, Rick P, Mehta, Sohil, linux-kernel, linux-arch, linux-api
  Cc: svens, catalin.marinas, schwab, brgerst, alexander.shishkin,
	linux-perf-users, x86, monstr, borntraeger, dave.hansen,
	christophe.leroy, mark.rutland, glaubitz, dalias, lukas.bulwahn,
	rdunlap, tglx, hca, linux, sparclinux, arnd, linux-ia64,
	ebiederm, Lutomirski, Andy, jolsa, linux-parisc, akpm, linux-sh,
	linuxppc-dev, geert, hpa, James.Bottomley, peterz, ink,
	linux-m68k, tsbogend, broonie, Hunter, Adrian, acme, ysato,
	deller, debug, rmclure, gor, slyich, npiggin, agordeev, chris,
	mingo, linux-mips, linux-alpha, mattst88, linux-s390,
	linux-arm-kernel, jcmvbkbc, bp, richard.henderson, irogers,
	namhyung, will, davem

"Edgecombe, Rick P" <rick.p.edgecombe@intel.com> writes:
> On Mon, 2023-09-11 at 18:02 +0000, Sohil Mehta wrote:
>> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl
>> b/arch/powerpc/kernel/syscalls/syscall.tbl
>> index 20e50586e8a2..2767b8a42636 100644
>> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
>> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
>> @@ -539,3 +539,4 @@
>>  450    nospu   set_mempolicy_home_node         sys_set_mempolicy_hom
>> e_node
>>  451    common  cachestat                       sys_cachestat
>>  452    common  fchmodat2                       sys_fchmodat2
>> +453    common  map_shadow_stack                sys_map_shadow_stack
>
> I noticed in powerpc, the not implemented syscalls are manually mapped
> to sys_ni_syscall. It also has some special extra sys_ni_syscall()
> implementation bits to handle both ARCH_HAS_SYSCALL_WRAPPER and
> !ARCH_HAS_SYSCALL_WRAPPER. So wondering if it might need special
> treatment. Did you see those parts?

I don't think it needs any special treatment. It's processed by the same
script as other arches (scripts/syscalltbl.sh). So if there's no compat
or native entry it will default to sys_ni_syscall.

I think it's just habit/historical that we always spell out sys_ni_syscall.

cheers

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-14 12:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 18:02 [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta
2023-09-11 18:02 ` [PATCH 1/2] tools headers UAPI: Sync fchmodat2() syscall table entries Sohil Mehta
2023-09-11 18:02 ` [PATCH 2/2] arch: Reserve map_shadow_stack() syscall number for all architectures Sohil Mehta
2023-09-11 21:10   ` Edgecombe, Rick P
2023-09-13 19:18     ` Sohil Mehta
2023-09-13 22:05       ` Edgecombe, Rick P
2023-09-14 12:26     ` Michael Ellerman
2023-09-13 19:32 ` [PATCH 0/2] arch: Sync all syscall tables with 2 newly added system calls Sohil Mehta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).