Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys Pull up following revision(s) (requested by pgoyette ...
details: https://anonhg.NetBSD.org/src/rev/dd7cc5a00826
branches: netbsd-9
changeset: 745650:dd7cc5a00826
user: martin <martin%NetBSD.org@localhost>
date: Sun Mar 08 10:54:43 2020 +0000
description:
Pull up following revision(s) (requested by pgoyette in ticket #762):
sys/arch/amd64/amd64/trap.c: revision 1.126
sys/compat/netbsd32/netbsd32_mod.c: revision 1.17
sys/compat/netbsd32/netbsd32_mod.c: revision 1.18
sys/sys/compat_stub.h: revision 1.23
Fix another left-over from last year's [pgoyette-compat] work. This
allows recognition of the oosyscall sequence for amd64.
Fixes PR kern/55038
XXX pullup-9
-
fix indentation. NFCI
diffstat:
sys/arch/amd64/amd64/trap.c | 44 ++++++---------------
sys/compat/netbsd32/netbsd32_mod.c | 74 ++++++++++++++++++++++++++++++++++++-
sys/sys/compat_stub.h | 9 ++++-
3 files changed, 93 insertions(+), 34 deletions(-)
diffs (226 lines):
diff -r e520c5227ace -r dd7cc5a00826 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c Sun Mar 08 10:38:10 2020 +0000
+++ b/sys/arch/amd64/amd64/trap.c Sun Mar 08 10:54:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.121 2019/07/13 17:03:01 mlelstv Exp $ */
+/* $NetBSD: trap.c,v 1.121.2.1 2020/03/08 10:54:43 martin Exp $ */
/*
* Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121 2019/07/13 17:03:01 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121.2.1 2020/03/08 10:54:43 martin Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -83,14 +83,11 @@
#include <sys/syscall.h>
#include <sys/cpu.h>
#include <sys/ucontext.h>
+#include <sys/module_hook.h>
+#include <sys/compat_stub.h>
#include <uvm/uvm_extern.h>
-#ifdef COMPAT_NETBSD32
-#include <sys/exec.h>
-#include <compat/netbsd32/netbsd32_exec.h>
-#endif
-
#include <machine/cpufunc.h>
#include <x86/fpu.h>
#include <x86/dbregs.h>
@@ -121,6 +118,11 @@
dtrace_doubletrap_func_t dtrace_doubletrap_func = NULL;
#endif
+/*
+ * Module hook for amd64_oosyscall
+ */
+struct amd64_oosyscall_hook_t amd64_oosyscall_hook;
+
void nmitrap(struct trapframe *);
void doubletrap(struct trapframe *);
void trap(struct trapframe *);
@@ -350,32 +352,12 @@
goto we_re_toast;
case T_PROTFLT|T_USER: /* protection fault */
-#if defined(COMPAT_NETBSD32) && defined(COMPAT_10)
-
-/*
- * XXX This code currently not included in loadable module; it is
- * only included in built-in modules.
- */
- {
- static const char lcall[7] = { 0x9a, 0, 0, 0, 0, 7, 0 };
- const size_t sz = sizeof(lcall);
- char tmp[sz];
+ { int hook_ret;
- /* Check for the oosyscall lcall instruction. */
- if (p->p_emul == &emul_netbsd32 &&
- frame->tf_rip < VM_MAXUSER_ADDRESS32 - sz &&
- copyin((void *)frame->tf_rip, tmp, sz) == 0 &&
- memcmp(tmp, lcall, sz) == 0) {
-
- /* Advance past the lcall. */
- frame->tf_rip += sz;
-
- /* Do the syscall. */
- p->p_md.md_syscall(frame);
- goto out;
- }
+ MODULE_HOOK_CALL(amd64_oosyscall_hook, (p, frame),
+ ENOSYS, hook_ret);
+ if (hook_ret == 0)
}
-#endif
/* FALLTHROUGH */
case T_TSSFLT|T_USER:
case T_SEGNPFLT|T_USER:
diff -r e520c5227ace -r dd7cc5a00826 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c Sun Mar 08 10:38:10 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c Sun Mar 08 10:54:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_mod.c,v 1.15 2019/01/27 02:08:40 pgoyette Exp $ */
+/* $NetBSD: netbsd32_mod.c,v 1.15.4.1 2020/03/08 10:54:43 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,8 +29,37 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum, and by Maxime Villard.
+ *
+ * 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: netbsd32_mod.c,v 1.15 2019/01/27 02:08:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15.4.1 2020/03/08 10:54:43 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_execfmt.h"
@@ -45,6 +74,7 @@
#include <sys/exec.h>
#include <sys/exec_elf.h>
#include <sys/module_hook.h>
+#include <sys/compat_stub.h>
#include <compat/netbsd32/netbsd32_sysctl.h>
#include <compat/netbsd32/netbsd32_kern_proc.h>
@@ -100,6 +130,35 @@
#endif
};
+#if defined(__amd64__)
+
+/* This code was moved here, from $SRC/arch/amd64/amd64/trap.c */
+
+static int
+amd64_oosyscall_handle(struct proc *p, struct trapframe *frame)
+{
+
+ static const char lcall[7] = { 0x9a, 0, 0, 0, 0, 7, 0 };
+ const size_t sz = sizeof(lcall);
+ char tmp[sizeof(lcall) /* Avoids VLA */];
+
+ /* Check for the oosyscall lcall instruction. */
+ if (p->p_emul == &emul_netbsd32 &&
+ frame->tf_rip < VM_MAXUSER_ADDRESS32 - sz &&
+ copyin((void *)frame->tf_rip, tmp, sz) == 0 &&
+ memcmp(tmp, lcall, sz) == 0) {
+
+ /* Advance past the lcall. */
+ frame->tf_rip += sz;
+
+ /* Do the syscall */
+ p->p_md.md_syscall(frame);
+ return 0;
+ } else
+ return EPASSTHROUGH;
+}
+#endif
+
static int
compat_netbsd32_modcmd(modcmd_t cmd, void *arg)
{
@@ -113,10 +172,17 @@
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
netbsd32_kern_proc_32_init();
+#if defined(__amd64__)
+ MODULE_HOOK_SET(amd64_oosyscall_hook,
+ amd64_oosyscall_handle);
+#endif
}
return error;
case MODULE_CMD_FINI:
+#if defined(__amd64__)
+ MODULE_HOOK_UNSET(amd64_oosyscall_hook);
+#endif
netbsd32_machdep_md_fini();
netbsd32_sysctl_fini();
netbsd32_kern_proc_32_fini();
@@ -127,6 +193,10 @@
netbsd32_kern_proc_32_init();
netbsd32_sysctl_init();
netbsd32_machdep_md_init();
+#if defined(__amd64__)
+ MODULE_HOOK_SET(amd64_oosyscall_hook,
+ amd64_oosyscall_handle);
+#endif
}
return error;
diff -r e520c5227ace -r dd7cc5a00826 sys/sys/compat_stub.h
--- a/sys/sys/compat_stub.h Sun Mar 08 10:38:10 2020 +0000
+++ b/sys/sys/compat_stub.h Sun Mar 08 10:54:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.18.2.2 2019/11/11 17:11:07 martin Exp $ */
+/* $NetBSD: compat_stub.h,v 1.18.2.3 2020/03/08 10:54:43 martin Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -371,4 +371,11 @@
*/
MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
+/*
+ * Hook for amd64 handler for oosyscall for COMPAT_NETBSD32 && COMPAT_10)
+ */
+struct proc;
+struct trapframe;
+MODULE_HOOK(amd64_oosyscall_hook, int, (struct proc *, struct trapframe *));
+
#endif /* _SYS_COMPAT_STUB_H */
Home |
Main Index |
Thread Index |
Old Index