Date: Thu, 17 Sep 2020 11:39:33 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365832 - in head/sys: amd64/amd64 amd64/linux amd64/linux32 arm/arm arm64/arm64 arm64/linux compat/ia32 compat/linux i386/i386 i386/linux kern mips/mips powerpc/powerpc riscv/riscv sys Message-ID: <202009171139.08HBdXxD050270@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Thu Sep 17 11:39:33 2020 New Revision: 365832 URL: https://svnweb.freebsd.org/changeset/base/365832 Log: Get rid of sv_errtbl and SV_ABI_ERRNO(). Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26388 Modified: head/sys/amd64/amd64/elf_machdep.c head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux32_sysvec.c head/sys/arm/arm/elf_machdep.c head/sys/arm64/arm64/elf32_machdep.c head/sys/arm64/arm64/elf_machdep.c head/sys/arm64/linux/linux_sysvec.c head/sys/compat/ia32/ia32_sysvec.c head/sys/compat/linux/linux.h head/sys/compat/linux/linux_errno.c head/sys/compat/linux/linux_socket.c head/sys/i386/i386/elf_machdep.c head/sys/i386/linux/linux_sysvec.c head/sys/kern/imgact_aout.c head/sys/kern/init_main.c head/sys/mips/mips/elf_machdep.c head/sys/mips/mips/freebsd32_machdep.c head/sys/powerpc/powerpc/elf32_machdep.c head/sys/powerpc/powerpc/elf64_machdep.c head/sys/riscv/riscv/elf_machdep.c head/sys/sys/sysent.h Modified: head/sys/amd64/amd64/elf_machdep.c ============================================================================== --- head/sys/amd64/amd64/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/amd64/amd64/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -52,8 +52,6 @@ __FBSDID("$FreeBSD$"); struct sysentvec elf64_freebsd_sysvec_la48 = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, @@ -89,8 +87,6 @@ struct sysentvec elf64_freebsd_sysvec_la48 = { struct sysentvec elf64_freebsd_sysvec_la57 = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/amd64/linux/linux_sysvec.c ============================================================================== --- head/sys/amd64/linux/linux_sysvec.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/amd64/linux/linux_sysvec.c Thu Sep 17 11:39:33 2020 (r365832) @@ -221,7 +221,7 @@ linux_set_syscall_retval(struct thread *td, int error) if (__predict_false(error != 0)) { if (error != ERESTART && error != EJUSTRETURN) - frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error); + frame->tf_rax = linux_to_bsd_errno(error); } /* Restore all registers. */ @@ -732,8 +732,6 @@ linux_vsyscall(struct thread *td) struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_errsize = ELAST + 1, - .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_rt_sendsig, Modified: head/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysvec.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/amd64/linux32/linux32_sysvec.c Thu Sep 17 11:39:33 2020 (r365832) @@ -679,7 +679,7 @@ linux32_set_syscall_retval(struct thread *td, int erro if (__predict_false(error != 0)) { if (error != ERESTART && error != EJUSTRETURN) - frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error); + frame->tf_rax = linux_to_bsd_errno(error); } } @@ -898,8 +898,6 @@ linux32_fixlimit(struct rlimit *rl, int which) struct sysentvec elf_linux_sysvec = { .sv_size = LINUX32_SYS_MAXSYSCALL, .sv_table = linux32_sysent, - .sv_errsize = ELAST + 1, - .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_sendsig, Modified: head/sys/arm/arm/elf_machdep.c ============================================================================== --- head/sys/arm/arm/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/arm/arm/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -65,8 +65,6 @@ u_long elf_hwcap2; struct sysentvec elf32_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/arm64/arm64/elf32_machdep.c ============================================================================== --- head/sys/arm64/arm64/elf32_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/arm64/arm64/elf32_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -77,8 +77,6 @@ extern void freebsd32_sendsig(sig_t catcher, ksiginfo_ static struct sysentvec elf32_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = elf32_freebsd_fixup, .sv_sendsig = freebsd32_sendsig, Modified: head/sys/arm64/arm64/elf_machdep.c ============================================================================== --- head/sys/arm64/arm64/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/arm64/arm64/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -61,8 +61,6 @@ u_long __read_frequently elf_hwcap2; static struct sysentvec elf64_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/arm64/linux/linux_sysvec.c ============================================================================== --- head/sys/arm64/linux/linux_sysvec.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/arm64/linux/linux_sysvec.c Thu Sep 17 11:39:33 2020 (r365832) @@ -145,7 +145,7 @@ linux_set_syscall_retval(struct thread *td, int error) if (__predict_false(error != 0)) { if (error != ERESTART && error != EJUSTRETURN) { td->td_frame->tf_x[0] = - SV_ABI_ERRNO(td->td_proc, error); + linux_to_bsd_errno(error); } } } @@ -394,8 +394,6 @@ linux_vsyscall(struct thread *td) struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_errsize = ELAST + 1, - .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_elf_fixup, .sv_sendsig = linux_rt_sendsig, Modified: head/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- head/sys/compat/ia32/ia32_sysvec.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/compat/ia32/ia32_sysvec.c Thu Sep 17 11:39:33 2020 (r365832) @@ -98,8 +98,6 @@ SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_ struct sysentvec ia32_freebsd_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = elf32_freebsd_fixup, .sv_sendsig = ia32_sendsig, Modified: head/sys/compat/linux/linux.h ============================================================================== --- head/sys/compat/linux/linux.h Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/compat/linux/linux.h Thu Sep 17 11:39:33 2020 (r365832) @@ -192,4 +192,6 @@ int linux_to_bsd_bits_(int value, struct bsd_to_linux_ } #define BITMAP_1t1_LINUX(_name) BITMAP_EASY_LINUX(_name, LINUX_##_name) +int linux_to_bsd_errno(int error); + #endif /* _LINUX_MI_H_ */ Modified: head/sys/compat/linux/linux_errno.c ============================================================================== --- head/sys/compat/linux/linux_errno.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/compat/linux/linux_errno.c Thu Sep 17 11:39:33 2020 (r365832) @@ -1,6 +1,21 @@ /* $FreeBSD$ */ #include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> #include <sys/errno.h> +#include <sys/systm.h> +#include <compat/linux/linux.h> #include <compat/linux/linux_errno.inc> + +int +linux_to_bsd_errno(int error) +{ + + KASSERT(error >= 0 && error <= ELAST, + ("%s: bad error %d", __func__, error)); + + return (linux_errtbl[error]); +} Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/compat/linux/linux_socket.c Thu Sep 17 11:39:33 2020 (r365832) @@ -1553,7 +1553,7 @@ linux_getsockopt(struct thread *td, struct linux_getso name, &newval, UIO_SYSSPACE, &len); if (error != 0) return (error); - newval = -SV_ABI_ERRNO(td->td_proc, newval); + newval = -linux_to_bsd_errno(newval); return (copyout(&newval, PTRIN(args->optval), len)); /* NOTREACHED */ default: Modified: head/sys/i386/i386/elf_machdep.c ============================================================================== --- head/sys/i386/i386/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/i386/i386/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$"); struct sysentvec elf32_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/i386/linux/linux_sysvec.c ============================================================================== --- head/sys/i386/linux/linux_sysvec.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/i386/linux/linux_sysvec.c Thu Sep 17 11:39:33 2020 (r365832) @@ -801,7 +801,7 @@ linux_set_syscall_retval(struct thread *td, int error) if (__predict_false(error != 0)) { if (error != ERESTART && error != EJUSTRETURN) - frame->tf_eax = SV_ABI_ERRNO(td->td_proc, error); + frame->tf_eax = linux_to_bsd_errno(error); } } @@ -847,8 +847,6 @@ linux_get_machine(const char **dst) struct sysentvec linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_errsize = ELAST + 1, - .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup, .sv_sendsig = linux_sendsig, @@ -882,8 +880,6 @@ INIT_SYSENTVEC(aout_sysvec, &linux_sysvec); struct sysentvec elf_linux_sysvec = { .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, - .sv_errsize = ELAST + 1, - .sv_errtbl = linux_errtbl, .sv_transtrap = linux_translate_traps, .sv_fixup = linux_fixup_elf, .sv_sendsig = linux_sendsig, Modified: head/sys/kern/imgact_aout.c ============================================================================== --- head/sys/kern/imgact_aout.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/kern/imgact_aout.c Thu Sep 17 11:39:33 2020 (r365832) @@ -76,8 +76,6 @@ static int aout_fixup(uintptr_t *stack_base, struct im struct sysentvec aout_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = aout_fixup, .sv_sendsig = sendsig, @@ -117,8 +115,6 @@ extern u_long ia32_maxssiz; struct sysentvec aout_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = aout_fixup, .sv_sendsig = ia32_sendsig, Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/kern/init_main.c Thu Sep 17 11:39:33 2020 (r365832) @@ -403,8 +403,6 @@ null_set_syscall_retval(struct thread *td __unused, in struct sysentvec null_sysvec = { .sv_size = 0, .sv_table = NULL, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = NULL, .sv_sendsig = NULL, Modified: head/sys/mips/mips/elf_machdep.c ============================================================================== --- head/sys/mips/mips/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/mips/mips/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$"); static struct sysentvec elf_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- head/sys/mips/mips/freebsd32_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/mips/mips/freebsd32_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -77,8 +77,6 @@ extern const char *freebsd32_syscallnames[]; struct sysentvec elf32_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = freebsd32_sendsig, Modified: head/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf32_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/powerpc/powerpc/elf32_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -90,8 +90,6 @@ struct sysentvec elf32_freebsd_sysvec = { #else .sv_table = sysent, #endif - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_copyout_auxargs = __elfN(powerpc_copyout_auxargs), Modified: head/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/elf64_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/powerpc/powerpc/elf64_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -62,8 +62,6 @@ static void exec_setregs_funcdesc(struct thread *td, s struct sysentvec elf64_freebsd_sysvec_v1 = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, @@ -100,8 +98,6 @@ struct sysentvec elf64_freebsd_sysvec_v1 = { struct sysentvec elf64_freebsd_sysvec_v2 = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/riscv/riscv/elf_machdep.c ============================================================================== --- head/sys/riscv/riscv/elf_machdep.c Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/riscv/riscv/elf_machdep.c Thu Sep 17 11:39:33 2020 (r365832) @@ -65,8 +65,6 @@ u_long elf_hwcap; struct sysentvec elf64_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, .sv_transtrap = NULL, .sv_fixup = __elfN(freebsd_fixup), .sv_sendsig = sendsig, Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Thu Sep 17 07:13:41 2020 (r365831) +++ head/sys/sys/sysent.h Thu Sep 17 11:39:33 2020 (r365832) @@ -102,8 +102,6 @@ struct vnode; struct sysentvec { int sv_size; /* number of entries */ struct sysent *sv_table; /* pointer to sysent */ - int sv_errsize; /* size of errno translation table */ - const int *sv_errtbl; /* errno translation table */ int (*sv_transtrap)(int, int); /* translate trap-to-signal mapping */ int (*sv_fixup)(uintptr_t *, struct image_params *); @@ -158,8 +156,6 @@ struct sysentvec { #define SV_ASLR 0x080000 /* ASLR allowed. */ #define SV_ABI_MASK 0xff -#define SV_ABI_ERRNO(p, e) ((p)->p_sysent->sv_errsize <= 0 ? e : \ - ((e) >= (p)->p_sysent->sv_errsize ? -1 : (p)->p_sysent->sv_errtbl[e])) #define SV_PROC_FLAG(p, x) ((p)->p_sysent->sv_flags & (x)) #define SV_PROC_ABI(p) ((p)->p_sysent->sv_flags & SV_ABI_MASK) #define SV_CURPROC_FLAG(x) SV_PROC_FLAG(curproc, x)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009171139.08HBdXxD050270>