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

Zhangjin Wu falcon at tinylab.org
Thu Feb 16 16:49:21 PST 2023


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 at tinylab.org>
---
 init/Kconfig | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

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
-- 
2.25.1




More information about the linux-riscv mailing list