Share a single bsd-linux errno table across MD consumers
Three copies of the linuxulator linux_sysvec.c contained identical BSD to Linux errno translation tables, and future work to support other architectures will also use the same table. Move the table to a common file to be used by all. Make it 'const int' to place it in .rodata. (Some existing Linux architectures use MD errno values, but x86 and Arm share the generic set.) This change should introduce no functional change; a followup will add missing errno values. MFC after: 3 weeks Sponsored by: Turing Robotic Industries Inc. Differential Revision: https://reviews.freebsd.org/D14665
This commit is contained in:
parent
1d071ce340
commit
6e481f83f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331056
@ -130,26 +130,6 @@ static void linux_exec_setregs(struct thread *td, struct image_params *imgp,
|
||||
u_long stack);
|
||||
static int linux_vsyscall(struct thread *td);
|
||||
|
||||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
* Reference:
|
||||
* FreeBSD: src/sys/sys/errno.h
|
||||
* Linux: linux-2.6.17.8/include/asm-generic/errno-base.h
|
||||
* linux-2.6.17.8/include/asm-generic/errno.h
|
||||
*/
|
||||
static int bsd_to_linux_errno[ELAST + 1] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
-30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
|
||||
-90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
|
||||
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
|
||||
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
|
||||
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
|
||||
-6, -6, -43, -42, -75,-125, -84, -61, -16, -74,
|
||||
-72, -67, -71
|
||||
};
|
||||
|
||||
#define LINUX_T_UNKNOWN 255
|
||||
static int _bsd_to_linux_trapcode[] = {
|
||||
LINUX_T_UNKNOWN, /* 0 */
|
||||
@ -774,7 +754,7 @@ struct sysentvec elf_linux_sysvec = {
|
||||
.sv_table = linux_sysent,
|
||||
.sv_mask = 0,
|
||||
.sv_errsize = ELAST + 1,
|
||||
.sv_errtbl = bsd_to_linux_errno,
|
||||
.sv_errtbl = bsd_to_linux_errno_generic,
|
||||
.sv_transtrap = translate_traps,
|
||||
.sv_fixup = elf_linux_fixup,
|
||||
.sv_sendsig = linux_rt_sendsig,
|
||||
|
@ -131,26 +131,6 @@ static bool linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
|
||||
static void linux_vdso_install(void *param);
|
||||
static void linux_vdso_deinstall(void *param);
|
||||
|
||||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
* Reference:
|
||||
* FreeBSD: src/sys/sys/errno.h
|
||||
* Linux: linux-2.6.17.8/include/asm-generic/errno-base.h
|
||||
* linux-2.6.17.8/include/asm-generic/errno.h
|
||||
*/
|
||||
static int bsd_to_linux_errno[ELAST + 1] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
-30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
|
||||
-90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
|
||||
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
|
||||
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
|
||||
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
|
||||
-6, -6, -43, -42, -75,-125, -84, -61, -16, -74,
|
||||
-72, -67, -71
|
||||
};
|
||||
|
||||
#define LINUX_T_UNKNOWN 255
|
||||
static int _bsd_to_linux_trapcode[] = {
|
||||
LINUX_T_UNKNOWN, /* 0 */
|
||||
@ -973,7 +953,7 @@ struct sysentvec elf_linux_sysvec = {
|
||||
.sv_table = linux32_sysent,
|
||||
.sv_mask = 0,
|
||||
.sv_errsize = ELAST + 1,
|
||||
.sv_errtbl = bsd_to_linux_errno,
|
||||
.sv_errtbl = bsd_to_linux_errno_generic,
|
||||
.sv_transtrap = translate_traps,
|
||||
.sv_fixup = elf_linux_fixup,
|
||||
.sv_sendsig = linux_sendsig,
|
||||
|
@ -77,4 +77,6 @@ struct linux_pemuldata {
|
||||
|
||||
struct linux_pemuldata *pem_find(struct proc *);
|
||||
|
||||
extern const int bsd_to_linux_errno_generic[];
|
||||
|
||||
#endif /* !_LINUX_EMUL_H_ */
|
||||
|
143
sys/compat/linux/linux_errno.c
Normal file
143
sys/compat/linux/linux_errno.c
Normal file
@ -0,0 +1,143 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 1994-1996 Søren Schmidt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/errno.h>
|
||||
|
||||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
* Reference:
|
||||
* FreeBSD: src/sys/sys/errno.h
|
||||
* Linux: linux-2.6.17.8/include/asm-generic/errno-base.h
|
||||
* linux-2.6.17.8/include/asm-generic/errno.h
|
||||
*/
|
||||
const int bsd_to_linux_errno_generic[ELAST + 1] = {
|
||||
-0,
|
||||
-1,
|
||||
-2,
|
||||
-3,
|
||||
-4,
|
||||
-5,
|
||||
-6,
|
||||
-7,
|
||||
-8,
|
||||
-9,
|
||||
|
||||
-10,
|
||||
-35, /* EDEADLK */
|
||||
-12,
|
||||
-13,
|
||||
-14,
|
||||
-15,
|
||||
-16,
|
||||
-17,
|
||||
-18,
|
||||
-19,
|
||||
|
||||
-20,
|
||||
-21,
|
||||
-22,
|
||||
-23,
|
||||
-24,
|
||||
-25,
|
||||
-26,
|
||||
-27,
|
||||
-28,
|
||||
-29,
|
||||
|
||||
-30,
|
||||
-31,
|
||||
-32,
|
||||
-33,
|
||||
-34,
|
||||
-11, /* EAGAIN */
|
||||
-115,
|
||||
-114,
|
||||
-88,
|
||||
-89,
|
||||
|
||||
-90,
|
||||
-91,
|
||||
-92,
|
||||
-93,
|
||||
-94,
|
||||
-95,
|
||||
-96,
|
||||
-97,
|
||||
-98,
|
||||
-99,
|
||||
|
||||
-100,
|
||||
-101,
|
||||
-102,
|
||||
-103,
|
||||
-104,
|
||||
-105,
|
||||
-106,
|
||||
-107,
|
||||
-108,
|
||||
-109,
|
||||
|
||||
-110,
|
||||
-111,
|
||||
-40,
|
||||
-36,
|
||||
-112,
|
||||
-113,
|
||||
-39,
|
||||
-11,
|
||||
-87,
|
||||
-122,
|
||||
|
||||
-116,
|
||||
-66,
|
||||
-6, /* EBADRPC -> ENXIO */
|
||||
-6, /* ERPCMISMATCH -> ENXIO */
|
||||
-6, /* EPROGUNAVAIL -> ENXIO */
|
||||
-6, /* EPROGMISMATCH -> ENXIO */
|
||||
-6, /* EPROCUNAVAIL -> ENXIO */
|
||||
-37,
|
||||
-38,
|
||||
-9,
|
||||
|
||||
-6, /* EAUTH -> ENXIO */
|
||||
-6, /* ENEEDAUTH -> ENXIO */
|
||||
-43,
|
||||
-42,
|
||||
-75,
|
||||
-125,
|
||||
-84,
|
||||
-61,
|
||||
-16, /* EDOOFUS -> EBUSY */
|
||||
-74,
|
||||
|
||||
-72,
|
||||
-67,
|
||||
-71,
|
||||
};
|
@ -616,6 +616,7 @@ amd64/linux32/linux32_support.s optional compat_linux32 \
|
||||
amd64/linux32/linux32_sysent.c optional compat_linux32
|
||||
amd64/linux32/linux32_sysvec.c optional compat_linux32
|
||||
compat/linux/linux_emul.c optional compat_linux32
|
||||
compat/linux/linux_errno.c optional compat_linux32
|
||||
compat/linux/linux_file.c optional compat_linux32
|
||||
compat/linux/linux_fork.c optional compat_linux32
|
||||
compat/linux/linux_futex.c optional compat_linux32
|
||||
|
@ -88,6 +88,7 @@ compat/linprocfs/linprocfs.c optional linprocfs
|
||||
compat/linsysfs/linsysfs.c optional linsysfs
|
||||
compat/linux/linux_event.c optional compat_linux
|
||||
compat/linux/linux_emul.c optional compat_linux
|
||||
compat/linux/linux_errno.c optional compat_linux
|
||||
compat/linux/linux_file.c optional compat_linux
|
||||
compat/linux/linux_fork.c optional compat_linux
|
||||
compat/linux/linux_futex.c optional compat_linux
|
||||
|
@ -126,26 +126,6 @@ static eventhandler_tag linux_exit_tag;
|
||||
static eventhandler_tag linux_exec_tag;
|
||||
static eventhandler_tag linux_thread_dtor_tag;
|
||||
|
||||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
* Reference:
|
||||
* FreeBSD: src/sys/sys/errno.h
|
||||
* Linux: linux-2.6.17.8/include/asm-generic/errno-base.h
|
||||
* linux-2.6.17.8/include/asm-generic/errno.h
|
||||
*/
|
||||
static int bsd_to_linux_errno[ELAST + 1] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
-30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
|
||||
-90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
|
||||
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
|
||||
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
|
||||
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
|
||||
-6, -6, -43, -42, -75,-125, -84, -61, -16, -74,
|
||||
-72, -67, -71
|
||||
};
|
||||
|
||||
#define LINUX_T_UNKNOWN 255
|
||||
static int _bsd_to_linux_trapcode[] = {
|
||||
LINUX_T_UNKNOWN, /* 0 */
|
||||
@ -913,7 +893,7 @@ struct sysentvec linux_sysvec = {
|
||||
.sv_table = linux_sysent,
|
||||
.sv_mask = 0,
|
||||
.sv_errsize = ELAST + 1,
|
||||
.sv_errtbl = bsd_to_linux_errno,
|
||||
.sv_errtbl = bsd_to_linux_errno_generic,
|
||||
.sv_transtrap = translate_traps,
|
||||
.sv_fixup = linux_fixup,
|
||||
.sv_sendsig = linux_sendsig,
|
||||
@ -950,7 +930,7 @@ struct sysentvec elf_linux_sysvec = {
|
||||
.sv_table = linux_sysent,
|
||||
.sv_mask = 0,
|
||||
.sv_errsize = ELAST + 1,
|
||||
.sv_errtbl = bsd_to_linux_errno,
|
||||
.sv_errtbl = bsd_to_linux_errno_generic,
|
||||
.sv_transtrap = translate_traps,
|
||||
.sv_fixup = elf_linux_fixup,
|
||||
.sv_sendsig = linux_sendsig,
|
||||
|
@ -31,7 +31,7 @@ OBJS= ${VDSO}.so
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "i386"
|
||||
SRCS+= linux_ptrace.c imgact_linux.c linux_util.c linux_mib.c linux_mmap.c \
|
||||
linux_emul.c opt_cpu.h linux.c
|
||||
linux_emul.c linux_errno.c opt_cpu.h linux.c
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "i386"
|
||||
|
@ -4,9 +4,11 @@
|
||||
|
||||
KMOD= linux_common
|
||||
SRCS= linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \
|
||||
linux_errno.c \
|
||||
linux.c opt_compat.h device_if.h vnode_if.h bus_if.h
|
||||
|
||||
EXPORT_SYMS=
|
||||
EXPORT_SYMS+= bsd_to_linux_errno_generic
|
||||
EXPORT_SYMS+= linux_emul_path
|
||||
EXPORT_SYMS+= linux_ioctl_register_handler
|
||||
EXPORT_SYMS+= linux_ioctl_unregister_handler
|
||||
|
Loading…
Reference in New Issue
Block a user