[RFC,1/5] syscall: Allow configure used system calls

Message ID ad53ec9ec7168b6ca5a55e4c6b4583baa4dd0fc6.1676594211.git.falcon@tinylab.org
State New
Headers
Series Add dead syscalls elimination support |

Commit Message

Zhangjin Wu Feb. 17, 2023, 12:49 a.m. UTC
  A new CONFIG_SYSCALLS_USED is added to configure the system calls used
in a target system (especially for the ultra small embedded systems),
the other system calls will be disabled.

If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the other
ones (if also not used by kernel itself) will be removed automatically.

The used system calls should be listed one by one like this:

    write exit reboot

The architecture should implement it and then select the
HAVE_SYSCALLS_USED option.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 init/Kconfig | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
  

Patch

diff --git a/init/Kconfig b/init/Kconfig
index 44e90b28a30f..2c4b8b234168 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1502,6 +1502,10 @@  config BPF
 	bool
 	select CRYPTO_LIB_SHA1
 
+config HAVE_SYSCALLS_USED
+	bool
+	default n
+
 menuconfig EXPERT
 	bool "Configure standard kernel features (expert users)"
 	# Unhide debug options, to make the on-by-default options visible
@@ -1728,6 +1732,24 @@  config MEMBARRIER
 
 	  If unsure, say Y.
 
+config SYSCALLS_USED
+	string "Configure used syscalls (EXPERIMENTAL)"  if EXPERT
+	depends on HAVE_SYSCALLS_USED
+	default ""
+	help
+          This option allows to configure the system calls used in a target
+          system, the other system calls will be disabled.
+
+          If further enabling CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION, the
+          other ones (if also not used by kernel itself) will be removed
+          automatically.
+
+          The used system calls should be listed one by one like this:
+
+              write exit reboot
+
+          If unsure, keep this empty.
+
 config KALLSYMS
 	bool "Load all symbols for debugging/ksymoops" if EXPERT
 	default y