Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/f58ca7aac894
branches:  netbsd-7-1
changeset: 800726:f58ca7aac894
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Apr 26 14:56:30 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 ece22a8a8399 -r f58ca7aac894 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c       Wed Apr 26 14:51:58 2017 +0000
+++ b/sys/arch/amd64/amd64/trap.c       Wed Apr 26 14:56:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.78.10.2 2017/04/26 14:51:58 martin Exp $    */
+/*     $NetBSD: trap.c,v 1.78.10.3 2017/04/26 14:56:30 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.10.2 2017/04/26 14:51:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78.10.3 2017/04/26 14:56:30 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