Get rid of sv_errtbl and SV_ABI_ERRNO().

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26388
This commit is contained in:
Edward Tomasz Napierala 2020-09-17 11:39:33 +00:00
parent 4653454ee8
commit 70890254b3
21 changed files with 23 additions and 52 deletions

View File

@ -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,

View File

@ -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,

View File

@ -679,7 +679,7 @@ linux32_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);
}
}
@ -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,

View File

@ -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,

View File

@ -77,8 +77,6 @@ extern void freebsd32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
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,

View File

@ -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,

View File

@ -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,

View File

@ -98,8 +98,6 @@ SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, &ia32_maxvmem, 0, "
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,

View File

@ -192,4 +192,6 @@ int linux_to_bsd_bits_(int value, struct bsd_to_linux_bitmap *bitmap,
}
#define BITMAP_1t1_LINUX(_name) BITMAP_EASY_LINUX(_name, LINUX_##_name)
int linux_to_bsd_errno(int error);
#endif /* _LINUX_MI_H_ */

View File

@ -1,6 +1,21 @@
/* $FreeBSD$ */
#include <sys/cdefs.h>
#include <sys/errno.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]);
}

View File

@ -1553,7 +1553,7 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
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:

View File

@ -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,

View File

@ -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,

View File

@ -76,8 +76,6 @@ static int aout_fixup(uintptr_t *stack_base, struct image_params *imgp);
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,

View File

@ -403,8 +403,6 @@ null_set_syscall_retval(struct thread *td __unused, int error __unused)
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,

View File

@ -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,

View File

@ -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,

View File

@ -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),

View File

@ -62,8 +62,6 @@ static void exec_setregs_funcdesc(struct thread *td, struct image_params *imgp,
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,

View File

@ -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,

View File

@ -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)