Tue Aug 1 14:43:54 2017 UTC ()
Move arch/i386/i386/freebsd_* into compat/freebsd/. COMPAT_FREEBSD is
i386-specific.
(maxv)
diff -r1.382 -r1.383 src/sys/arch/i386/conf/files.i386
diff -r1.60 -r0 src/sys/arch/i386/i386/freebsd_machdep.c
diff -r1.5 -r0 src/sys/arch/i386/i386/freebsd_sigcode.S
diff -r1.40 -r0 src/sys/arch/i386/i386/freebsd_syscall.c
diff -r1.151 -r1.152 src/sys/arch/xen/conf/files.xen
diff -r1.14 -r1.15 src/sys/compat/freebsd/files.freebsd
diff -r0 -r1.1 src/sys/compat/freebsd/freebsd_machdep.c
diff -r0 -r1.1 src/sys/compat/freebsd/freebsd_sigcode.S
diff -r0 -r1.1 src/sys/compat/freebsd/freebsd_syscall.c
diff -r1.4 -r1.5 src/sys/modules/compat_freebsd/Makefile
--- src/sys/arch/i386/conf/files.i386 2017/08/01 13:47:49 1.382
+++ src/sys/arch/i386/conf/files.i386 2017/08/01 14:43:54 1.383
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.i386,v 1.382 2017/08/01 13:47:49 maxv Exp $ | | 1 | # $NetBSD: files.i386,v 1.383 2017/08/01 14:43:54 maxv Exp $ |
2 | # | | 2 | # |
3 | # new style config file for i386 architecture | | 3 | # new style config file for i386 architecture |
4 | # | | 4 | # |
5 | | | 5 | |
6 | ifndef xen | | 6 | ifndef xen |
7 | | | 7 | |
8 | # maxpartitions must be first item in files.${ARCH}.newconf | | 8 | # maxpartitions must be first item in files.${ARCH}.newconf |
9 | maxpartitions 8 | | 9 | maxpartitions 8 |
10 | | | 10 | |
11 | maxusers 2 16 128 | | 11 | maxusers 2 16 128 |
12 | | | 12 | |
13 | defparam opt_kernbase.h KERNBASE | | 13 | defparam opt_kernbase.h KERNBASE |
14 | | | 14 | |
| @@ -330,29 +330,26 @@ include "compat/ibcs2/files.ibcs2" | | | @@ -330,29 +330,26 @@ include "compat/ibcs2/files.ibcs2" |
330 | file arch/i386/i386/ibcs2_machdep.c compat_ibcs2 | | 330 | file arch/i386/i386/ibcs2_machdep.c compat_ibcs2 |
331 | file arch/i386/i386/ibcs2_sigcode.S compat_ibcs2 | | 331 | file arch/i386/i386/ibcs2_sigcode.S compat_ibcs2 |
332 | file arch/i386/i386/ibcs2_syscall.c compat_ibcs2 | | 332 | file arch/i386/i386/ibcs2_syscall.c compat_ibcs2 |
333 | | | 333 | |
334 | # Linux binary compatibility (COMPAT_LINUX) | | 334 | # Linux binary compatibility (COMPAT_LINUX) |
335 | include "compat/linux/files.linux" | | 335 | include "compat/linux/files.linux" |
336 | include "compat/linux/arch/i386/files.linux_i386" | | 336 | include "compat/linux/arch/i386/files.linux_i386" |
337 | file arch/i386/i386/linux_sigcode.S compat_linux | | 337 | file arch/i386/i386/linux_sigcode.S compat_linux |
338 | file arch/i386/i386/linux_syscall.c compat_linux | | 338 | file arch/i386/i386/linux_syscall.c compat_linux |
339 | file arch/x86/x86/linux_trap.c compat_linux | | 339 | file arch/x86/x86/linux_trap.c compat_linux |
340 | | | 340 | |
341 | # FreeBSD binary compatibility (COMPAT_FREEBSD) | | 341 | # FreeBSD binary compatibility (COMPAT_FREEBSD) |
342 | include "compat/freebsd/files.freebsd" | | 342 | include "compat/freebsd/files.freebsd" |
343 | file arch/i386/i386/freebsd_machdep.c compat_freebsd | | | |
344 | file arch/i386/i386/freebsd_sigcode.S compat_freebsd | | | |
345 | file arch/i386/i386/freebsd_syscall.c compat_freebsd | | | |
346 | | | 343 | |
347 | # NDIS compatibilty (COMPAT_NDIS) | | 344 | # NDIS compatibilty (COMPAT_NDIS) |
348 | include "compat/ndis/files.ndis" | | 345 | include "compat/ndis/files.ndis" |
349 | | | 346 | |
350 | # OSS audio driver compatibility | | 347 | # OSS audio driver compatibility |
351 | include "compat/ossaudio/files.ossaudio" | | 348 | include "compat/ossaudio/files.ossaudio" |
352 | | | 349 | |
353 | # | | 350 | # |
354 | # CARDBUS | | 351 | # CARDBUS |
355 | # | | 352 | # |
356 | include "dev/cardbus/files.cardbus" | | 353 | include "dev/cardbus/files.cardbus" |
357 | file arch/i386/i386/rbus_machdep.c cardbus | | 354 | file arch/i386/i386/rbus_machdep.c cardbus |
358 | | | 355 | |
--- src/sys/arch/xen/conf/files.xen 2017/08/01 13:47:49 1.151
+++ src/sys/arch/xen/conf/files.xen 2017/08/01 14:43:54 1.152
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.xen,v 1.151 2017/08/01 13:47:49 maxv Exp $ | | 1 | # $NetBSD: files.xen,v 1.152 2017/08/01 14:43:54 maxv Exp $ |
2 | # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp | | 2 | # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp |
3 | # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp | | 3 | # NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp |
4 | | | 4 | |
5 | ifdef i386 | | 5 | ifdef i386 |
6 | maxpartitions 8 | | 6 | maxpartitions 8 |
7 | else | | 7 | else |
8 | maxpartitions 16 | | 8 | maxpartitions 16 |
9 | endif | | 9 | endif |
10 | | | 10 | |
11 | maxusers 2 16 128 | | 11 | maxusers 2 16 128 |
12 | | | 12 | |
13 | defparam opt_kernbase.h KERNBASE | | 13 | defparam opt_kernbase.h KERNBASE |
14 | | | 14 | |
| @@ -324,29 +324,26 @@ include "compat/ibcs2/files.ibcs2" | | | @@ -324,29 +324,26 @@ include "compat/ibcs2/files.ibcs2" |
324 | file arch/i386/i386/ibcs2_machdep.c compat_ibcs2 | | 324 | file arch/i386/i386/ibcs2_machdep.c compat_ibcs2 |
325 | file arch/i386/i386/ibcs2_sigcode.S compat_ibcs2 | | 325 | file arch/i386/i386/ibcs2_sigcode.S compat_ibcs2 |
326 | file arch/i386/i386/ibcs2_syscall.c compat_ibcs2 | | 326 | file arch/i386/i386/ibcs2_syscall.c compat_ibcs2 |
327 | | | 327 | |
328 | # Linux binary compatibility (COMPAT_LINUX) | | 328 | # Linux binary compatibility (COMPAT_LINUX) |
329 | include "compat/linux/files.linux" | | 329 | include "compat/linux/files.linux" |
330 | include "compat/linux/arch/i386/files.linux_i386" | | 330 | include "compat/linux/arch/i386/files.linux_i386" |
331 | file arch/i386/i386/linux_sigcode.S compat_linux | | 331 | file arch/i386/i386/linux_sigcode.S compat_linux |
332 | file arch/i386/i386/linux_syscall.c compat_linux | | 332 | file arch/i386/i386/linux_syscall.c compat_linux |
333 | file arch/x86/x86/linux_trap.c compat_linux | | 333 | file arch/x86/x86/linux_trap.c compat_linux |
334 | | | 334 | |
335 | # FreeBSD binary compatibility (COMPAT_FREEBSD) | | 335 | # FreeBSD binary compatibility (COMPAT_FREEBSD) |
336 | include "compat/freebsd/files.freebsd" | | 336 | include "compat/freebsd/files.freebsd" |
337 | file arch/i386/i386/freebsd_machdep.c compat_freebsd | | | |
338 | file arch/i386/i386/freebsd_sigcode.S compat_freebsd | | | |
339 | file arch/i386/i386/freebsd_syscall.c compat_freebsd | | | |
340 | | | 337 | |
341 | elifdef amd64 | | 338 | elifdef amd64 |
342 | | | 339 | |
343 | # Binary compatibility with previous NetBSD releases (COMPAT_XX) | | 340 | # Binary compatibility with previous NetBSD releases (COMPAT_XX) |
344 | file arch/amd64/amd64/compat_13_machdep.c compat_13 | | 341 | file arch/amd64/amd64/compat_13_machdep.c compat_13 |
345 | file arch/amd64/amd64/compat_16_machdep.c compat_16 | | 342 | file arch/amd64/amd64/compat_16_machdep.c compat_16 |
346 | | | 343 | |
347 | # NetBSD/i386 32-bit binary compatibility (COMPAT_NETBSD32) | | 344 | # NetBSD/i386 32-bit binary compatibility (COMPAT_NETBSD32) |
348 | include "compat/netbsd32/files.netbsd32" | | 345 | include "compat/netbsd32/files.netbsd32" |
349 | file arch/amd64/amd64/netbsd32_machdep.c compat_netbsd32 | | 346 | file arch/amd64/amd64/netbsd32_machdep.c compat_netbsd32 |
350 | file arch/amd64/amd64/netbsd32_sigcode.S compat_netbsd32 & compat_16 | | 347 | file arch/amd64/amd64/netbsd32_sigcode.S compat_netbsd32 & compat_16 |
351 | file arch/amd64/amd64/netbsd32_syscall.c compat_netbsd32 | | 348 | file arch/amd64/amd64/netbsd32_syscall.c compat_netbsd32 |
352 | | | 349 | |
--- src/sys/compat/freebsd/files.freebsd 2017/07/29 10:39:48 1.14
+++ src/sys/compat/freebsd/files.freebsd 2017/08/01 14:43:54 1.15
| @@ -1,22 +1,23 @@ | | | @@ -1,22 +1,23 @@ |
1 | # $NetBSD: files.freebsd,v 1.14 2017/07/29 10:39:48 maxv Exp $ | | 1 | # $NetBSD: files.freebsd,v 1.15 2017/08/01 14:43:54 maxv Exp $ |
2 | # | | 2 | # |
3 | # Config file description for machine-independent FreeBSD compat code. | | 3 | # Config file description for machine-independent FreeBSD compat code. |
4 | # Included by ports that need it. | | 4 | # Included by ports that need it. Only i386 is supported. |
5 | | | | |
6 | # ports should define any machine-specific files they need in their | | | |
7 | # own file lists. | | | |
8 | | | 5 | |
9 | define compat_freebsd | | 6 | define compat_freebsd |
10 | file compat/freebsd/freebsd_exec.c compat_freebsd | | 7 | file compat/freebsd/freebsd_exec.c compat_freebsd |
11 | file compat/freebsd/freebsd_exec_elf32.c compat_freebsd & exec_elf32 | | 8 | file compat/freebsd/freebsd_exec_elf32.c compat_freebsd & exec_elf32 |
12 | file compat/freebsd/freebsd_file.c compat_freebsd | | 9 | file compat/freebsd/freebsd_file.c compat_freebsd |
13 | file compat/freebsd/freebsd_fork.c compat_freebsd | | 10 | file compat/freebsd/freebsd_fork.c compat_freebsd |
14 | file compat/freebsd/freebsd_ioctl.c compat_freebsd | | 11 | file compat/freebsd/freebsd_ioctl.c compat_freebsd |
15 | file compat/freebsd/freebsd_ipc.c compat_freebsd | | 12 | file compat/freebsd/freebsd_ipc.c compat_freebsd |
| | | 13 | file compat/freebsd/freebsd_machdep.c compat_freebsd |
16 | file compat/freebsd/freebsd_misc.c compat_freebsd | | 14 | file compat/freebsd/freebsd_misc.c compat_freebsd |
17 | file compat/freebsd/freebsd_mod.c compat_freebsd | | 15 | file compat/freebsd/freebsd_mod.c compat_freebsd |
18 | file compat/freebsd/freebsd_ptrace.c compat_freebsd & ptrace | | 16 | file compat/freebsd/freebsd_ptrace.c compat_freebsd & ptrace |
19 | file compat/freebsd/freebsd_sched.c compat_freebsd | | 17 | file compat/freebsd/freebsd_sched.c compat_freebsd |
| | | 18 | file compat/freebsd/freebsd_sigcode.S compat_freebsd |
20 | file compat/freebsd/freebsd_sysctl.c compat_freebsd | | 19 | file compat/freebsd/freebsd_sysctl.c compat_freebsd |
21 | file compat/freebsd/freebsd_sysent.c compat_freebsd | | 20 | file compat/freebsd/freebsd_sysent.c compat_freebsd |
22 | file compat/freebsd/freebsd_syscalls.c compat_freebsd | | 21 | file compat/freebsd/freebsd_syscalls.c compat_freebsd |
| | | 22 | file compat/freebsd/freebsd_syscall.c compat_freebsd |
| | | 23 | |
/* $NetBSD: freebsd_machdep.c,v 1.1 2017/08/01 14:43:54 maxv Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.1 2017/08/01 14:43:54 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vm86.h"
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/proc.h>
#include <sys/exec.h>
#include <sys/mount.h>
#include <compat/sys/signal.h>
#include <machine/cpufunc.h>
#include <x86/fpu.h>
#include <machine/reg.h>
#include <machine/vm86.h>
#include <machine/vmparam.h>
#include <machine/freebsd_machdep.h>
#include <compat/freebsd/freebsd_syscallargs.h>
#include <compat/freebsd/freebsd_exec.h>
#include <compat/freebsd/freebsd_signal.h>
void
freebsd_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
{
setregs(l, epp, stack);
fpu_set_default_cw(l, __FreeBSD_NPXCW__);
}
/*
* signal support
*/
/*
* Send an interrupt to process.
*
* Stack is set up to allow sigcode stored
* in u. to call routine, followed by kcall
* to sigreturn routine below. After sigreturn
* resets the signal mask, the stack, and the
* frame pointer, it returns to the user
* specified pc, psl.
*/
void
freebsd_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
int sig = ksi->ksi_signo;
u_long code = KSI_TRAPCODE(ksi);
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
int onstack, error;
struct freebsd_sigframe *fp = getframe(l, sig, &onstack), frame;
sig_t catcher = SIGACTION(p, sig).sa_handler;
struct trapframe *tf = l->l_md.md_regs;
fp--;
/* Build stack frame for signal trampoline. */
frame.sf_signum = sig;
frame.sf_code = code;
frame.sf_scp = &fp->sf_sc;
frame.sf_addr = (char *)rcr2();
frame.sf_handler = catcher;
/* Save context. */
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.sf_sc.sc_gs = tf->tf_vm86_gs;
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
frame.sf_sc.sc_efl = get_vflags(l);
(*p->p_emul->e_syscall_intern)(p);
} else
#endif
{
frame.sf_sc.sc_gs = tf->tf_gs;
frame.sf_sc.sc_fs = tf->tf_fs;
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
frame.sf_sc.sc_efl = tf->tf_eflags;
}
frame.sf_sc.sc_edi = tf->tf_edi;
frame.sf_sc.sc_esi = tf->tf_esi;
frame.sf_sc.sc_ebp = tf->tf_ebp;
frame.sf_sc.sc_isp = 0; /* don't have to pass kernel sp to user. */
frame.sf_sc.sc_ebx = tf->tf_ebx;
frame.sf_sc.sc_edx = tf->tf_edx;
frame.sf_sc.sc_ecx = tf->tf_ecx;
frame.sf_sc.sc_eax = tf->tf_eax;
frame.sf_sc.sc_eip = tf->tf_eip;
frame.sf_sc.sc_cs = tf->tf_cs;
frame.sf_sc.sc_esp = tf->tf_esp;
frame.sf_sc.sc_ss = tf->tf_ss;
/* Save signal stack. */
frame.sf_sc.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK;
/* Save signal mask. */
/* XXX freebsd_osigcontext compat? */
frame.sf_sc.sc_mask = *mask;
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
error = copyout(&frame, fp, sizeof(frame));
mutex_enter(p->p_lock);
if (error != 0) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
sigexit(l, SIGILL);
/* NOTREACHED */
}
buildcontext(l, GUCODEBIG_SEL, p->p_sigctx.ps_sigcode, fp);
/* Remember that we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
}
/*
* System call to cleanup state after a signal
* has been taken. Reset signal mask and
* stack state from context left by sendsig (above).
* Return to previous pc and psl as specified by
* context left by sendsig. Check carefully to
* make sure that the user has not modified the
* psl to gain improper privileges or to cause
* a machine fault.
*/
int
freebsd_sys_sigreturn(struct lwp *l, const struct freebsd_sys_sigreturn_args *uap, register_t *retval)
{
/* {
syscallarg(struct freebsd_sigcontext *) scp;
} */
struct proc *p = l->l_proc;
struct freebsd_sigcontext *scp, context;
struct trapframe *tf;
sigset_t mask;
/*
* The trampoline code hands us the context.
* It is unsafe to keep track of it ourselves, in the event that a
* program jumps out of a signal handler.
*/
scp = SCARG(uap, scp);
if (copyin((void *)scp, &context, sizeof(*scp)) != 0)
return (EFAULT);
/* Restore register context. */
tf = l->l_md.md_regs;
#ifdef VM86
if (context.sc_efl & PSL_VM) {
void syscall_vm86(struct trapframe *);
tf->tf_vm86_gs = context.sc_gs;
tf->tf_vm86_fs = context.sc_fs;
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
set_vflags(l, context.sc_efl);
p->p_md.md_syscall = syscall_vm86;
} else
#endif
{
/*
* Check for security violations. If we're returning to
* protected mode, the CPU will validate the segment registers
* automatically and generate a trap on violations. We handle
* the trap, rather than doing all of the checking here.
*/
if (((context.sc_efl ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
!USERMODE(context.sc_cs, context.sc_efl))
return (EINVAL);
tf->tf_gs = context.sc_gs;
tf->tf_fs = context.sc_fs;
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
tf->tf_eflags &= ~PSL_USER;
tf->tf_eflags |= context.sc_efl & PSL_USER;
}
tf->tf_edi = context.sc_edi;
tf->tf_esi = context.sc_esi;
tf->tf_ebp = context.sc_ebp;
/* FreeBSD's context.sc_isp is useless. (`popal' ignores it.) */
tf->tf_ebx = context.sc_ebx;
tf->tf_edx = context.sc_edx;
tf->tf_ecx = context.sc_ecx;
tf->tf_eax = context.sc_eax;
tf->tf_eip = context.sc_eip;
tf->tf_cs = context.sc_cs;
tf->tf_esp = context.sc_esp;
tf->tf_ss = context.sc_ss;
mutex_enter(p->p_lock);
/* Restore signal stack. */
if (context.sc_onstack & SS_ONSTACK)
l->l_sigstk.ss_flags |= SS_ONSTACK;
else
l->l_sigstk.ss_flags &= ~SS_ONSTACK;
/* Restore signal mask. */
/* XXX freebsd_osigcontext compat? */
mask = context.sc_mask;
(void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
mutex_exit(p->p_lock);
return (EJUSTRETURN);
}
/* $NetBSD: freebsd_sigcode.S,v 1.1 2017/08/01 14:43:54 maxv Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)locore.s 7.3 (Berkeley) 5/13/91
*/
#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_sigcode.S,v 1.1 2017/08/01 14:43:54 maxv Exp $");
#include "assym.h"
#include <sys/errno.h>
#include <sys/syscall.h>
#include <compat/freebsd/freebsd_syscall.h>
/*
* Signal trampoline; copied to top of user stack.
*/
/* LINTSTUB: Var: char freebsd_sigcode[1], freebsd_esigcode[1]; */
NENTRY(freebsd_sigcode)
call *FREEBSD_SIGF_HANDLER(%esp)
leal FREEBSD_SIGF_SC(%esp),%eax # scp (the call may have clobbered
# the copy at SIGF_SCP(%esp))
pushl %eax
pushl %eax # junk to fake return address
movl $FREEBSD_SYS_sigreturn,%eax
int $0x80 # enter kernel with args on stack
movl $FREEBSD_SYS_exit,%eax
int $0x80 # exit if sigreturn fails
.globl _C_LABEL(freebsd_esigcode)
_C_LABEL(freebsd_esigcode):
/* $NetBSD: freebsd_syscall.c,v 1.1 2017/08/01 14:43:54 maxv Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
__KERNEL_RCSID(0, "$NetBSD: freebsd_syscall.c,v 1.1 2017/08/01 14:43:54 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/signal.h>
#include <sys/syscall.h>
#include <sys/syscallvar.h>
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
#include <machine/psl.h>
#include <machine/userret.h>
#include <compat/sys/signal.h>
#include <machine/freebsd_machdep.h>
#include <compat/freebsd/freebsd_syscall.h>
void freebsd_syscall(struct trapframe *);
void
freebsd_syscall_intern(struct proc *p)
{
p->p_md.md_syscall = freebsd_syscall;
}
/*
* syscall(frame):
* System call request from POSIX system call gate interface to kernel.
* Like trap(), argument is call by reference.
*/
void
freebsd_syscall(struct trapframe *frame)
{
char *params;
const struct sysent *callp;
struct lwp *l;
struct proc *p;
int error;
size_t argsize;
register_t code, args[8], rval[2];
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
code = frame->tf_eax;
callp = p->p_emul->e_sysent;
params = (char *)frame->tf_esp + sizeof(int);
switch (code) {
case SYS_syscall:
/*
* Code is first argument, followed by actual args.
*/
code = fuword(params);
params += sizeof(int);
break;
case SYS___syscall:
/*
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
code = fuword(params + _QUAD_LOWWORD * sizeof(int));
params += sizeof(quad_t);
break;
default:
break;
}
code &= (SYS_NSYSENT - 1);
callp += code;
argsize = callp->sy_argsize;
if (argsize) {
error = copyin(params, (void *)args, argsize);
if (error)
goto bad;
}
if (!__predict_false(p->p_trace_enabled || KDTRACE_ENTRY(callp->sy_entry))
|| (error = trace_enter(code, callp, args)) == 0) {
rval[0] = 0;
rval[1] = frame->tf_edx; /* need to keep edx for shared FreeBSD bins */
error = sy_call(callp, l, args, rval);
}
switch (error) {
case 0:
frame->tf_eax = rval[0];
frame->tf_edx = rval[1];
frame->tf_eflags &= ~PSL_C; /* carry bit */
break;
case ERESTART:
/*
* The offset to adjust the PC by depends on whether we entered
* the kernel through the trap or call gate. We pushed the
* size of the instruction into tf_err on entry.
*/
frame->tf_eip -= frame->tf_err;
break;
case EJUSTRETURN:
/* nothing to do */
break;
default:
bad:
frame->tf_eax = error;
frame->tf_eflags |= PSL_C; /* carry bit */
break;
}
if (__predict_false(p->p_trace_enabled || KDTRACE_ENTRY(callp->sy_return)))
trace_exit(code, callp, args, rval, error);
userret(l);
}
--- src/sys/modules/compat_freebsd/Makefile 2017/07/29 10:39:48 1.4
+++ src/sys/modules/compat_freebsd/Makefile 2017/08/01 14:43:54 1.5
| @@ -1,24 +1,23 @@ | | | @@ -1,24 +1,23 @@ |
1 | # $NetBSD: Makefile,v 1.4 2017/07/29 10:39:48 maxv Exp $ | | 1 | # $NetBSD: Makefile,v 1.5 2017/08/01 14:43:54 maxv Exp $ |
2 | | | 2 | |
3 | .include "../Makefile.inc" | | 3 | .include "../Makefile.inc" |
4 | .include "../Makefile.assym" | | 4 | .include "../Makefile.assym" |
5 | | | 5 | |
6 | KMOD= compat_freebsd | | 6 | KMOD= compat_freebsd |
7 | | | 7 | |
8 | CPPFLAGS+= -DSYSVSHM -DSYSVSEM -DSYSVMSG -DKTRACE -DPTRACE -DNTP | | 8 | CPPFLAGS+= -DSYSVSHM -DSYSVSEM -DSYSVMSG -DKTRACE -DPTRACE -DNTP |
9 | CPPFLAGS+= -DCOMPAT_FREEBSD | | 9 | CPPFLAGS+= -DCOMPAT_FREEBSD |
10 | | | 10 | |
11 | .PATH: ${S}/compat/freebsd | | 11 | .PATH: ${S}/compat/freebsd |
12 | | | 12 | |
13 | SRCS+= freebsd_exec.c freebsd_exec_elf32.c | | 13 | SRCS+= freebsd_exec.c freebsd_exec_elf32.c |
14 | SRCS+= freebsd_file.c freebsd_fork.c freebsd_ioctl.c freebsd_ipc.c | | 14 | SRCS+= freebsd_file.c freebsd_fork.c freebsd_ioctl.c freebsd_ipc.c |
15 | SRCS+= freebsd_misc.c freebsd_ptrace.c freebsd_sched.c freebsd_syscalls.c | | 15 | SRCS+= freebsd_misc.c freebsd_ptrace.c freebsd_sched.c freebsd_syscalls.c |
16 | SRCS+= freebsd_sysctl.c freebsd_sysent.c freebsd_mod.c | | 16 | SRCS+= freebsd_sysctl.c freebsd_sysent.c freebsd_mod.c |
17 | | | 17 | |
18 | .if ${MACHINE_ARCH} == "i386" | | 18 | .if ${MACHINE_ARCH} == "i386" |
19 | CPPFLAGS+= -DEXEC_ELF32 | | 19 | CPPFLAGS+= -DEXEC_ELF32 |
20 | .PATH: ${S}/arch/i386/i386 | | | |
21 | SRCS+= freebsd_machdep.c freebsd_syscall.c freebsd_sigcode.S | | 20 | SRCS+= freebsd_machdep.c freebsd_syscall.c freebsd_sigcode.S |
22 | .endif | | 21 | .endif |
23 | | | 22 | |
24 | .include <bsd.kmodule.mk> | | 23 | .include <bsd.kmodule.mk> |