CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: rin Date: Sun Feb 17 05:32:35 UTC 2019 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: Set WARN=3 for sing-compare. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/modules/syscallemu/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/usermode/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 src/sys/arch/usermode/modules/syscallemu/Makefile:1.6 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 Sun Nov 10 22:08:58 2013 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Feb 17 05:32:35 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2013/11/10 22:08:58 jmcneill Exp $ +# $NetBSD: Makefile,v 1.6 2019/02/17 05:32:35 rin Exp $ .include @@ -19,4 +19,6 @@ SRCS+= syscallemu_arm.c .error ${MACHINE_CPU} not implemented .endif +WARNS= 3 + .include
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: jmcneill Date: Sun Nov 10 19:58:38 UTC 2013 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Added Files: src/sys/arch/usermode/modules/syscallemu: syscallemu_arm.c Log Message: arm support for syscallemu, not tested To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/modules/syscallemu/Makefile cvs rdiff -u -r0 -r1.1 \ src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/usermode/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 Tue Jul 3 21:07:41 2012 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Nov 10 19:58:38 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2012/07/03 21:07:41 christos Exp $ +# $NetBSD: Makefile,v 1.4 2013/11/10 19:58:38 jmcneill Exp $ .include bsd.own.mk @@ -13,6 +13,8 @@ KMOD= syscallemu SRCS= syscallemu.c .if ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64 SRCS+= syscallemu_x86.c +.elif ${MACHINE_ARCH} == arm || ${MACHINE_ARCH} == earm +SRCS+= syscallemu_arm.c .else .error ${MACHINE_ARCH} not implemented .endif Added files: Index: src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c diff -u /dev/null src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c:1.1 --- /dev/null Sun Nov 10 19:58:38 2013 +++ src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c Sun Nov 10 19:58:38 2013 @@ -0,0 +1,107 @@ +/* $NetBSD: syscallemu_arm.c,v 1.1 2013/11/10 19:58:38 jmcneill Exp $ */ + +/*- + * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org + * Copyright (c) 2012-2013 Jared D. McNeill jmcne...@invisible.ca + * 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 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: syscallemu_arm.c,v 1.1 2013/11/10 19:58:38 jmcneill Exp $); + +#include sys/param.h +#include sys/proc.h +#include sys/systm.h + +#include arch/arm/include/locore.h + +#include syscallemu.h + +#define ARM_TF_PC(frame) ((frame)-tf_pc) + +/* + * If syscallemu specific data is present for the process, verify that the + * caller is allowed to execute system calls. If not, deliver a SIGILL to + * the process. When syscallemu specific data is not present, simply defer + * to the original syscall handler. + */ +static void +arm_syscall_emu(struct trapframe *frame, struct lwp *l, uint32_t insn) +{ + void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t) = NULL; + struct syscallemu_data *sce; + register_t pc_call; + struct proc *p; + ksiginfo_t ksi; + + p = l-l_proc; + + pc_call = ARM_TF_PC(frame) - INSN_SIZE; + + /* Determine if we need to emulate the system call */ + sce = syscallemu_getsce(p); + if (sce) { + if ((pc_call = sce-sce_user_start + pc_call sce-sce_user_end) || + (pc_call + INSN_SIZE = sce-sce_user_start + pc_call + INSN_SIZE sce-sce_user_end)) { + md_syscall = NULL; + } else { + md_syscall = sce-sce_md_syscall; + } + } else { + md_syscall = p-p_md.md_syscall; + } + + if (md_syscall == NULL) { + /* If emulating, deliver SIGILL to process */ + ARM_TF_PC(frame) = pc_call; + KSI_INIT_TRAP(ksi); + ksi.ksi_signo = SIGILL; + ksi.ksi_code = ILL_ILLTRP; + ksi.ksi_addr = (void *)ARM_TF_PC(frame); + ksi.ksi_trap = 0; + trapsignal(l, ksi); + userret(l); + } else { + /* Not emulating, so treat as a normal syscall */ + KASSERT(md_syscall != NULL); + md_syscall(frame, l, insn); + } +} + +/* + * Set
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: jmcneill Date: Sun Nov 10 22:08:58 UTC 2013 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: use MACHINE_CPU instead of MACHINE_ARCH To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/modules/syscallemu/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/usermode/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 Sun Nov 10 19:58:38 2013 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Nov 10 22:08:58 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2013/11/10 19:58:38 jmcneill Exp $ +# $NetBSD: Makefile,v 1.5 2013/11/10 22:08:58 jmcneill Exp $ .include bsd.own.mk @@ -11,12 +11,12 @@ M?= ${S}/modules KMOD= syscallemu SRCS= syscallemu.c -.if ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64 +.if ${MACHINE_CPU} == i386 || ${MACHINE_CPU} == x86_64 SRCS+= syscallemu_x86.c -.elif ${MACHINE_ARCH} == arm || ${MACHINE_ARCH} == earm +.elif ${MACHINE_CPU} == arm SRCS+= syscallemu_arm.c .else -.error ${MACHINE_ARCH} not implemented +.error ${MACHINE_CPU} not implemented .endif .include bsd.kmodule.mk
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: christos Date: Tue Jul 3 21:07:41 UTC 2012 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: no home-brewed NETBSDSRCDIR please (fix the build) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/modules/syscallemu/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/usermode/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.2 src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.2 Fri Jan 6 08:16:20 2012 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Tue Jul 3 17:07:41 2012 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.2 2012/01/06 13:16:20 jmcneill Exp $ +# $NetBSD: Makefile,v 1.3 2012/07/03 21:07:41 christos Exp $ -NETBSDSRCDIR?= ../../../../.. +.include bsd.own.mk S?= ${NETBSDSRCDIR}/sys M?= ${S}/modules
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: jmcneill Date: Fri Jan 6 13:16:20 UTC 2012 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Added Files: src/sys/arch/usermode/modules/syscallemu: syscallemu_x86.c Removed Files: src/sys/arch/usermode/modules/syscallemu: syscallemu_i386.c Log Message: i386 and x86_64 versions of this code are the same, rename to syscallemu_x86.c To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/modules/syscallemu/Makefile cvs rdiff -u -r1.1 -r0 \ src/sys/arch/usermode/modules/syscallemu/syscallemu_i386.c cvs rdiff -u -r0 -r1.1 \ src/sys/arch/usermode/modules/syscallemu/syscallemu_x86.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/usermode/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.1 src/sys/arch/usermode/modules/syscallemu/Makefile:1.2 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.1 Thu Jan 5 13:26:51 2012 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Fri Jan 6 13:16:20 2012 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2012/01/05 13:26:51 jmcneill Exp $ +# $NetBSD: Makefile,v 1.2 2012/01/06 13:16:20 jmcneill Exp $ NETBSDSRCDIR?= ../../../../.. @@ -11,6 +11,10 @@ M?= ${S}/modules KMOD= syscallemu SRCS= syscallemu.c -SRCS+= syscallemu_${MACHINE_ARCH}.c +.if ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64 +SRCS+= syscallemu_x86.c +.else +.error ${MACHINE_ARCH} not implemented +.endif .include bsd.kmodule.mk Added files: Index: src/sys/arch/usermode/modules/syscallemu/syscallemu_x86.c diff -u /dev/null src/sys/arch/usermode/modules/syscallemu/syscallemu_x86.c:1.1 --- /dev/null Fri Jan 6 13:16:20 2012 +++ src/sys/arch/usermode/modules/syscallemu/syscallemu_x86.c Fri Jan 6 13:16:20 2012 @@ -0,0 +1,107 @@ +/* $NetBSD: syscallemu_x86.c,v 1.1 2012/01/06 13:16:20 jmcneill Exp $ */ + +/*- + * Copyright (c) 2011 Reinoud Zandijk rein...@netbsd.org + * Copyright (c) 2012 Jared D. McNeill jmcne...@invisible.ca + * 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 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: syscallemu_x86.c,v 1.1 2012/01/06 13:16:20 jmcneill Exp $); + +#include sys/param.h +#include sys/proc.h +#include sys/systm.h + +#include machine/userret.h + +#include syscallemu.h + +/* + * If syscallemu specific data is present for the process, verify that the + * caller is allowed to execute system calls. If not, deliver a SIGILL to + * the process. When syscallemu specific data is not present, simply defer + * to the original syscall handler. + */ +static void +x86_syscall_emu(struct trapframe *frame) +{ + void (*md_syscall)(struct trapframe *) = NULL; + struct syscallemu_data *sce; + register_t rip_call; + struct proc *p; + ksiginfo_t ksi; + lwp_t *l; + + l = curlwp; + p = l-l_proc; + + rip_call = X86_TF_RIP(frame) - frame-tf_err; + + /* Determine if we need to emulate the system call */ + sce = syscallemu_getsce(p); + if (sce) { + if ((rip_call = sce-sce_user_start + rip_call sce-sce_user_end) || + (rip_call + frame-tf_err = sce-sce_user_start + rip_call + frame-tf_err sce-sce_user_end)) { + md_syscall = NULL; + } else { + md_syscall = sce-sce_md_syscall; + } + } else { + md_syscall = p-p_md.md_syscall; + } + + if (md_syscall == NULL) { + /* If emulating, deliver SIGILL to process */ + X86_TF_RIP(frame) = rip_call; + KSI_INIT_TRAP(ksi); + ksi.ksi_signo = SIGILL; + ksi.ksi_code = ILL_ILLTRP; + ksi.ksi_addr = (void *)X86_TF_RIP(frame); + ksi.ksi_trap = 0; + trapsignal(l, ksi); +