linux(4): Deduplicate translate_traps()
As translate_traps() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks
This commit is contained in:
parent
b387a075d9
commit
2434137f69
@ -176,29 +176,6 @@ LINUX_VDSO_SYM_INTPTR(kern_timekeep_base);
|
||||
LINUX_VDSO_SYM_INTPTR(kern_tsc_selector);
|
||||
LINUX_VDSO_SYM_INTPTR(kern_cpu_selector);
|
||||
|
||||
/*
|
||||
* If FreeBSD & Linux have a difference of opinion about what a trap
|
||||
* means, deal with it here.
|
||||
*
|
||||
* MPSAFE
|
||||
*/
|
||||
static int
|
||||
linux_translate_traps(int signal, int trap_code)
|
||||
{
|
||||
|
||||
if (signal != SIGBUS)
|
||||
return (signal);
|
||||
switch (trap_code) {
|
||||
case T_PROTFLT:
|
||||
case T_TSSFLT:
|
||||
case T_DOUBLEFLT:
|
||||
case T_PAGEFLT:
|
||||
return (SIGSEGV);
|
||||
default:
|
||||
return (signal);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
linux_fetch_syscall_args(struct thread *td)
|
||||
{
|
||||
|
@ -190,28 +190,6 @@ LINUX_VDSO_SYM_INTPTR(kern_tsc_selector);
|
||||
LINUX_VDSO_SYM_INTPTR(kern_cpu_selector);
|
||||
LINUX_VDSO_SYM_CHAR(linux_platform);
|
||||
|
||||
/*
|
||||
* If FreeBSD & Linux have a difference of opinion about what a trap
|
||||
* means, deal with it here.
|
||||
*
|
||||
* MPSAFE
|
||||
*/
|
||||
static int
|
||||
linux_translate_traps(int signal, int trap_code)
|
||||
{
|
||||
if (signal != SIGBUS)
|
||||
return (signal);
|
||||
switch (trap_code) {
|
||||
case T_PROTFLT:
|
||||
case T_TSSFLT:
|
||||
case T_DOUBLEFLT:
|
||||
case T_PAGEFLT:
|
||||
return (SIGSEGV);
|
||||
default:
|
||||
return (signal);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
|
||||
{
|
||||
|
@ -164,28 +164,6 @@ LINUX_VDSO_SYM_INTPTR(kern_timekeep_base);
|
||||
LINUX_VDSO_SYM_INTPTR(kern_tsc_selector);
|
||||
LINUX_VDSO_SYM_INTPTR(kern_cpu_selector);
|
||||
|
||||
/*
|
||||
* If FreeBSD & Linux have a difference of opinion about what a trap
|
||||
* means, deal with it here.
|
||||
*
|
||||
* MPSAFE
|
||||
*/
|
||||
static int
|
||||
linux_translate_traps(int signal, int trap_code)
|
||||
{
|
||||
if (signal != SIGBUS)
|
||||
return (signal);
|
||||
switch (trap_code) {
|
||||
case T_PROTFLT:
|
||||
case T_TSSFLT:
|
||||
case T_DOUBLEFLT:
|
||||
case T_PAGEFLT:
|
||||
return (SIGSEGV);
|
||||
default:
|
||||
return (signal);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
linux_fixup(uintptr_t *stack_base, struct image_params *imgp)
|
||||
{
|
||||
|
@ -41,7 +41,8 @@ OBJS= linux${SFX}_vdso.so
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "i386"
|
||||
SRCS+= linux_ptrace_machdep.c imgact_linux.c linux_util.c linux_mib.c \
|
||||
linux_mmap.c linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c
|
||||
linux_mmap.c linux_dummy.c linux_emul.c linux_errno.c opt_cpu.h linux.c \
|
||||
linux_x86.c
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "i386"
|
||||
|
@ -1,12 +1,16 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${SRCTOP}/sys/compat/linux
|
||||
.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/x86/linux
|
||||
|
||||
KMOD= linux_common
|
||||
SRCS= linux_common.c linux_mib.c linux_mmap.c linux_util.c linux_emul.c \
|
||||
linux_dummy.c linux_errno.c \
|
||||
linux.c device_if.h vnode_if.h bus_if.h opt_inet6.h
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "amd64"
|
||||
SRCS+= linux_x86.c
|
||||
.endif
|
||||
|
||||
EXPORT_SYMS=
|
||||
EXPORT_SYMS+= linux_emul_path
|
||||
EXPORT_SYMS+= linux_get_osname
|
||||
|
56
sys/x86/linux/linux_x86.c
Normal file
56
sys/x86/linux/linux_x86.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/signal.h>
|
||||
#include <x86/trap.h>
|
||||
|
||||
#include <x86/linux/linux_x86.h>
|
||||
|
||||
/*
|
||||
* If FreeBSD & Linux have a difference of opinion about what a trap
|
||||
* means, deal with it here.
|
||||
*/
|
||||
int
|
||||
linux_translate_traps(int signal, int trap_code)
|
||||
{
|
||||
if (signal != SIGBUS)
|
||||
return (signal);
|
||||
switch (trap_code) {
|
||||
case T_PROTFLT:
|
||||
case T_TSSFLT:
|
||||
case T_DOUBLEFLT:
|
||||
case T_PAGEFLT:
|
||||
return (SIGSEGV);
|
||||
default:
|
||||
return (signal);
|
||||
}
|
||||
}
|
@ -35,4 +35,6 @@
|
||||
int linux_vdso_tsc_selector_idx(void);
|
||||
int linux_vdso_cpu_selector_idx(void);
|
||||
|
||||
int linux_translate_traps(int, int);
|
||||
|
||||
#endif /* _X86_INCLUDE_LINUX_LINUX_X86_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user