git: d96eebfdb351 - stable/13 - linux: populate sv_syscallnames in each sysentvec

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Sun, 06 Nov 2022 14:55:40 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=d96eebfdb351abf5e604f43e8f022f8bb861bdbd

commit d96eebfdb351abf5e604f43e8f022f8bb861bdbd
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-10-28 21:19:39 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-11-06 14:54:46 +0000

    linux: populate sv_syscallnames in each sysentvec
    
    This allows the syscallname() function to give a usable result for Linux
    ABIs.
    
    Reported by:    jrtc27
    Reviewed by:    jrtc27, markj, jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37199
    
    (cherry picked from commit 1da65dcb1c57fae7be75ddf1bd300ddf19ced850)
    (cherry picked from commit f396f9b6c96f6d68d4e3606ddb090287230fc565)
---
 sys/amd64/linux/linux_sysvec.c     | 3 ++-
 sys/amd64/linux32/linux32_sysvec.c | 3 ++-
 sys/arm64/linux/linux_sysvec.c     | 3 ++-
 sys/i386/linux/linux_sysvec.c      | 3 ++-
 sys/modules/linux/Makefile         | 1 +
 sys/modules/linux64/Makefile       | 1 +
 6 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index dbf702d51bb1..60e90c03ad95 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -110,6 +110,7 @@ extern char _binary_linux_vdso_so_o_end;
 static vm_offset_t linux_vdso_base;
 
 extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
+extern const char *linux_syscallnames[];
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
@@ -728,7 +729,7 @@ struct sysentvec elf_linux_sysvec = {
 	    SV_SIG_WAITNDQ | SV_TIMEKEEP,
 	.sv_set_syscall_retval = linux_set_syscall_retval,
 	.sv_fetch_syscall_args = linux_fetch_syscall_args,
-	.sv_syscallnames = NULL,
+	.sv_syscallnames = linux_syscallnames,
 	.sv_shared_page_base = LINUX_SHAREDPAGE_LA48,
 	.sv_shared_page_len = PAGE_SIZE,
 	.sv_schedtail	= linux_schedtail,
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index 4b6464bd7b81..dc87d1a8a531 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -113,6 +113,7 @@ extern char _binary_linux32_vdso_so_o_end;
 static vm_offset_t linux_vdso_base;
 
 extern struct sysent linux32_sysent[LINUX32_SYS_MAXSYSCALL];
+extern const char *linux32_syscallnames[];
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
@@ -881,7 +882,7 @@ struct sysentvec elf_linux_sysvec = {
 	    SV_SIG_DISCIGN | SV_SIG_WAITNDQ | SV_TIMEKEEP,
 	.sv_set_syscall_retval = linux32_set_syscall_retval,
 	.sv_fetch_syscall_args = linux32_fetch_syscall_args,
-	.sv_syscallnames = NULL,
+	.sv_syscallnames = linux32_syscallnames,
 	.sv_shared_page_base = LINUX32_SHAREDPAGE,
 	.sv_shared_page_len = PAGE_SIZE,
 	.sv_schedtail	= linux_schedtail,
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index b8361584c31a..2533092b4cfd 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -98,6 +98,7 @@ extern char _binary_linux_vdso_so_o_end;
 static vm_offset_t linux_vdso_base;
 
 extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
+extern const char *linux_syscallnames[];
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
@@ -574,7 +575,7 @@ struct sysentvec elf_linux_sysvec = {
 	    SV_SIG_WAITNDQ | SV_TIMEKEEP,
 	.sv_set_syscall_retval = linux_set_syscall_retval,
 	.sv_fetch_syscall_args = linux_fetch_syscall_args,
-	.sv_syscallnames = NULL,
+	.sv_syscallnames = linux_syscallnames,
 	.sv_shared_page_base = LINUX_SHAREDPAGE,
 	.sv_shared_page_len = PAGE_SIZE,
 	.sv_schedtail	= linux_schedtail,
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 14be8f7aa36b..6726dc2cf0fd 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -96,6 +96,7 @@ extern char _binary_linux_vdso_so_o_end;
 static vm_offset_t linux_vdso_base;
 
 extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
+extern const char *linux_syscallnames[];
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
@@ -781,7 +782,7 @@ struct sysentvec linux_sysvec = {
 	    SV_SIG_DISCIGN | SV_SIG_WAITNDQ,
 	.sv_set_syscall_retval = linux_set_syscall_retval,
 	.sv_fetch_syscall_args = linux_fetch_syscall_args,
-	.sv_syscallnames = NULL,
+	.sv_syscallnames = linux_syscallnames,
 	.sv_schedtail	= linux_schedtail,
 	.sv_thread_detach = linux_thread_detach,
 	.sv_trap	= NULL,
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
index 808f87f87dc7..2cd7c54cd216 100644
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -25,6 +25,7 @@ SRCS=	linux${SFX}_dummy_machdep.c \
 	linux_signal.c \
 	linux_socket.c \
 	linux_stats.c \
+	linux${SFX}_syscalls.c \
 	linux_sysctl.c \
 	linux${SFX}_sysent.c \
 	linux${SFX}_sysvec.c \
diff --git a/sys/modules/linux64/Makefile b/sys/modules/linux64/Makefile
index 3d7b973742e9..ef6644c3deb7 100644
--- a/sys/modules/linux64/Makefile
+++ b/sys/modules/linux64/Makefile
@@ -22,6 +22,7 @@ SRCS=	linux_dummy_machdep.c \
 	linux_signal.c \
 	linux_socket.c \
 	linux_stats.c \
+	linux_syscalls.c \
 	linux_sysctl.c \
 	linux_sysent.c \
 	linux_sysvec.c \