Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64/amd64 restore the ability to run netbsd 1.0 3...
details: https://anonhg.NetBSD.org/src/rev/8f8241bc6461
branches: trunk
changeset: 823478:8f8241bc6461
user: chs <chs%NetBSD.org@localhost>
date: Mon Apr 24 17:03:43 2017 +0000
description:
restore the ability to run netbsd 1.0 32-bit executables
by checking for the relevant lcall instruction in the trap handler
and treating it as a syscall.
diffstat:
sys/arch/amd64/amd64/trap.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diffs (65 lines):
diff -r b1c10fb995aa -r 8f8241bc6461 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c Mon Apr 24 13:19:50 2017 +0000
+++ b/sys/arch/amd64/amd64/trap.c Mon Apr 24 17:03:43 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.95 2017/03/23 17:25:51 maxv Exp $ */
+/* $NetBSD: trap.c,v 1.96 2017/04/24 17:03:43 chs Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,12 +68,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.95 2017/03/23 17:25:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.96 2017/04/24 17:03:43 chs Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
#include "opt_xen.h"
#include "opt_dtrace.h"
+#include "opt_compat_netbsd.h"
+#include "opt_compat_netbsd32.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -90,6 +92,11 @@
#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 <machine/psl.h>
@@ -403,6 +410,27 @@
#endif
case T_PROTFLT|T_USER: /* protection fault */
+#if defined(COMPAT_NETBSD32) && defined(COMPAT_10)
+ {
+ static const char lcall[7] = { 0x9a, 0, 0, 0, 0, 7, 0 };
+ const size_t sz = sizeof(lcall);
+ char tmp[sz];
+
+ /* 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;
+ }
+ }
+#endif
case T_TSSFLT|T_USER:
case T_SEGNPFLT|T_USER:
case T_STKFLT|T_USER:
Home |
Main Index |
Thread Index |
Old Index