Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/arch/amd64/amd64 Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/3de25107bad4
branches:  netbsd-7
changeset: 800198:3de25107bad4
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Apr 26 14:54:57 2017 +0000

description:
Pull up following revision(s) (requested by chs in ticket #1410):
        sys/arch/amd64/amd64/trap.c: revision 1.96
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 4563e11fae56 -r 3de25107bad4 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c       Wed Apr 26 14:52:50 2017 +0000
+++ b/sys/arch/amd64/amd64/trap.c       Wed Apr 26 14:54:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.78.4.2 2017/04/26 14:52:50 martin Exp $     */
+/*     $NetBSD: trap.c,v 1.78.4.3 2017/04/26 14:54:57 martin 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.78.4.2 2017/04/26 14:52:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.4.3 2017/04/26 14:54:57 martin 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>
@@ -389,6 +396,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