From: Zhangjin Wu <falcon@tinylab.org>
To: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
linux-riscv@lists.infradead.org, Arnd Bergmann <arnd@arndb.de>
Cc: falcon@tinylab.org, palmer@rivosinc.com,
paul.walmsley@sifive.com, paulburton@kernel.org,
paulmck@kernel.org, tsbogend@alpha.franken.de, w@1wt.eu,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Tim Bird" <tim.bird@sony.com>
Subject: [PATCH v1 0/7] DCE/DSE: Add Dead Syscalls Elimination support, part1
Date: Tue, 26 Sep 2023 06:33:44 +0800 [thread overview]
Message-ID: <cover.1695679700.git.falcon@tinylab.org> (raw)
Hi, all
This series aims to add DCE based DSE support, here is the first
revision of the RFC patchset [1], the whole series includes three parts,
here is the Part1.
This Part1 adds basic DCE based DSE support.
Part2 will further eliminate the unused syscalls forcely kept by the
exception tables.
Part3 will add DSE test support with nolibc-test.c.
Changes from RFC patchset [1]:
- The DCE support [2] for RISC-V has been merged [3]
- The "nolibc: Record used syscalls in their own sections" [4] will be
delayed to Part3
- Add debug support for DCE
- Further allows CONFIG_USED_SYSCALLS accept a file stores used syscalls
- Now, only accepts symbolic syscalls, not support integral number again
- Works with newly added riscv syscalls suffix: __riscv_
- Further trims the syscall tables by removing the tailing invalid parts
The nolibc-test based initrd run well on riscv64 kernel image with dead
syscalls eliminated:
$ nm build/riscv64/virt/linux/v6.6-rc2/vmlinux | grep "T __riscv_sys" | grep -v sys_ni_syscall | wc -l
48
These options should be enabled:
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION_DEBUG=y
CONFIG_TRIM_UNUSED_SYSCALLS=y
CONFIG_USED_SYSCALLS="sys_dup sys_dup3 sys_ioctl sys_mknodat sys_mkdirat sys_unlinkat sys_symlinkat sys_linkat sys_mount sys_chdir sys_chroot sys_fchmodat sys_fchownat sys_openat sys_close sys_pipe2 sys_getdents64 sys_lseek sys_read sys_write sys_pselect6 sys_ppoll sys_exit sys_sched_yield sys_kill sys_reboot sys_getpgid sys_prctl sys_gettimeofday sys_getpid sys_getppid sys_getuid sys_geteuid sys_brk sys_munmap sys_clone sys_execve sys_mmap sys_wait4 sys_statx"
The really used syscalls:
$ echo "sys_dup sys_dup3 sys_ioctl sys_mknodat sys_mkdirat sys_unlinkat sys_symlinkat sys_linkat sys_mount sys_chdir sys_chroot sys_fchmodat sys_fchownat sys_openat sys_close sys_pipe2 sys_getdents64 sys_lseek sys_read sys_write sys_pselect6 sys_ppoll sys_exit sys_sched_yield sys_kill sys_reboot sys_getpgid sys_prctl sys_gettimeofday sys_getpid sys_getppid sys_getuid sys_geteuid sys_brk sys_munmap sys_clone sys_execve sys_mmap sys_wait4 sys_statx" | tr ' ' '\n' | wc -l
40
Thanks to Yuan Tan, he has researched and verified the elimination of
the unused syscalls forcely kept by the exception tables, both section
group and section link order attributes of ld work. part2 will be sent
out soon to further remove another 8 unused syscalls and eventually we
are able to run a dead loop application on a kernel image without
syscalls.
Best Regards,
Zhangjin Wu
---
[1]: https://lore.kernel.org/lkml/cover.1676594211.git.falcon@tinylab.org/
[2]: https://lore.kernel.org/lkml/234017be6d06ef84844583230542e31068fa3685.1676594211.git.falcon@tinylab.org/
[3]: https://lore.kernel.org/lkml/CAFP8O3+41QFVyNTVJ2iZYkB0tqnvdLTAoGShgGy-qPP1PHjBEw@mail.gmail.com/
[4]: https://lore.kernel.org/lkml/cbcbfbb37cabfd9aed6088c75515e4ea86006cff.1676594211.git.falcon@tinylab.org/
Zhangjin Wu (7):
DCE: add debug support
DCE/DSE: add unused syscalls elimination configure support
DCE/DSE: Add a new scripts/Makefile.syscalls
DCE/DSE: mips: add HAVE_TRIM_UNUSED_SYSCALLS support
DCE/DSE: riscv: move syscall tables to syscalls/
DCE/DSE: riscv: add HAVE_TRIM_UNUSED_SYSCALLS support
DCE/DSE: riscv: trim syscall tables
Makefile | 3 +
arch/mips/Kconfig | 1 +
arch/mips/kernel/syscalls/Makefile | 23 ++++++-
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/unistd.h | 2 +
arch/riscv/kernel/Makefile | 7 +-
arch/riscv/kernel/syscalls/Makefile | 69 +++++++++++++++++++
.../{ => syscalls}/compat_syscall_table.c | 4 +-
.../kernel/{ => syscalls}/syscall_table.c | 4 +-
init/Kconfig | 49 +++++++++++++
scripts/Makefile.syscalls | 29 ++++++++
11 files changed, 182 insertions(+), 10 deletions(-)
create mode 100644 arch/riscv/kernel/syscalls/Makefile
rename arch/riscv/kernel/{ => syscalls}/compat_syscall_table.c (82%)
rename arch/riscv/kernel/{ => syscalls}/syscall_table.c (83%)
create mode 100644 scripts/Makefile.syscalls
--
2.25.1
next reply other threads:[~2023-09-25 22:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 22:33 Zhangjin Wu [this message]
2023-09-25 22:35 ` [PATCH v1 1/7] DCE: add debug support Zhangjin Wu
2023-09-25 22:36 ` [PATCH v1 2/7] DCE/DSE: add unused syscalls elimination configure support Zhangjin Wu
2023-10-07 10:01 ` Yuan Tan
2023-09-25 22:38 ` [PATCH v1 3/7] DCE/DSE: Add a new scripts/Makefile.syscalls Zhangjin Wu
2023-09-26 5:55 ` Arnd Bergmann
2023-09-25 22:40 ` [PATCH v1 4/7] DCE/DSE: mips: add HAVE_TRIM_UNUSED_SYSCALLS support Zhangjin Wu
2023-09-26 6:07 ` Arnd Bergmann
2023-10-07 12:58 ` Zhangjin Wu
2023-09-25 22:41 ` [PATCH v1 5/7] DCE/DSE: riscv: move syscall tables to syscalls/ Zhangjin Wu
2023-09-25 22:42 ` [PATCH v1 6/7] DCE/DSE: riscv: add HAVE_TRIM_UNUSED_SYSCALLS support Zhangjin Wu
2023-09-26 6:10 ` Arnd Bergmann
2023-10-07 13:29 ` Zhangjin Wu
2023-10-07 20:43 ` Arnd Bergmann
2023-09-25 22:43 ` [PATCH v1 7/7] DCE/DSE: riscv: trim syscall tables Zhangjin Wu
2023-09-26 6:01 ` Arnd Bergmann
2023-10-07 13:35 ` Zhangjin Wu
2023-09-26 7:14 ` [PATCH v1 0/7] DCE/DSE: Add Dead Syscalls Elimination support, part1 Arnd Bergmann
2023-09-26 11:24 ` Arnd Bergmann
2023-09-26 14:07 ` Arnd Bergmann
2023-09-26 20:49 ` Nicolas Pitre
2023-09-27 10:21 ` Arnd Bergmann
2023-09-30 9:31 ` Yuan Tan
2023-10-03 16:43 ` Yuan Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1695679700.git.falcon@tinylab.org \
--to=falcon@tinylab.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@weissschuh.net \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=paulburton@kernel.org \
--cc=paulmck@kernel.org \
--cc=tim.bird@sony.com \
--cc=tsbogend@alpha.franken.de \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®