Module Name: src
Committed By: christos
Date: Thu Dec 7 23:11:50 UTC 2017
Modified Files:
src/sys/arch/amd64/amd64: netbsd32_machdep.c
src/sys/arch/amd64/conf: files.amd64
Added Files:
src/sys/arch/amd64/amd64: compat_13_machdep.c
Log Message:
Save maxv@ some work and put back the compat_13_sigreturn changes that allow
amd64 to run ancient i386 binaries.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.3 src/sys/arch/amd64/amd64/compat_13_machdep.c
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/amd64/amd64/netbsd32_machdep.c
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/amd64/conf/files.amd64
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/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.114 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.115
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.114 Thu Dec 7 11:22:22 2017
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Thu Dec 7 18:11:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.114 2017/12/07 16:22:22 christos Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.115 2017/12/07 23:11:50 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.114 2017/12/07 16:22:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.115 2017/12/07 23:11:50 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -1114,3 +1114,67 @@ netbsd32_vm_default_addr(struct proc *p,
else
return VM_DEFAULT_ADDRESS32_BOTTOMUP(base, sz);
}
+
+#ifdef COMPAT_13
+int
+compat_13_netbsd32_sigreturn(struct lwp *l, const struct compat_13_netbsd32_sigreturn_args *uap, register_t *retval)
+{
+ /* {
+ syscallarg(struct netbsd32_sigcontext13 *) sigcntxp;
+ } */
+ struct proc *p = l->l_proc;
+ struct netbsd32_sigcontext13 *scp, context;
+ struct trapframe *tf;
+ sigset_t mask;
+ int error;
+
+ /*
+ * The trampoline code hands us the context.
+ * It is unsafe to keep track of it ourselves, in the event that a
+ * program jumps out of a signal handler.
+ */
+ scp = (struct netbsd32_sigcontext13 *)NETBSD32PTR64(SCARG(uap, sigcntxp));
+ if (copyin((void *)scp, &context, sizeof(*scp)) != 0)
+ return (EFAULT);
+
+ /* Restore register context. */
+ tf = l->l_md.md_regs;
+
+ /*
+ * Check for security violations.
+ */
+ error = check_sigcontext32(l, (const struct netbsd32_sigcontext *)&context);
+ if (error != 0)
+ return error;
+
+ tf->tf_gs = context.sc_gs & 0xFFFF;
+ tf->tf_fs = context.sc_fs & 0xFFFF;
+ tf->tf_es = context.sc_es & 0xFFFF;
+ tf->tf_ds = context.sc_ds & 0xFFFF;
+ tf->tf_rflags = context.sc_eflags;
+ tf->tf_rdi = context.sc_edi;
+ tf->tf_rsi = context.sc_esi;
+ tf->tf_rbp = context.sc_ebp;
+ tf->tf_rbx = context.sc_ebx;
+ tf->tf_rdx = context.sc_edx;
+ tf->tf_rcx = context.sc_ecx;
+ tf->tf_rax = context.sc_eax;
+ tf->tf_rip = context.sc_eip;
+ tf->tf_cs = context.sc_cs & 0xFFFF;
+ tf->tf_rsp = context.sc_esp;
+ tf->tf_ss = context.sc_ss & 0xFFFF;
+
+ mutex_enter(p->p_lock);
+ /* Restore signal stack. */
+ if (context.sc_onstack & SS_ONSTACK)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ l->l_sigstk.ss_flags &= ~SS_ONSTACK;
+ /* Restore signal mask. */
+ native_sigset13_to_sigset((sigset13_t *)&context.sc_mask, &mask);
+ (void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
+ mutex_exit(p->p_lock);
+
+ return (EJUSTRETURN);
+}
+#endif
Index: src/sys/arch/amd64/conf/files.amd64
diff -u src/sys/arch/amd64/conf/files.amd64:1.95 src/sys/arch/amd64/conf/files.amd64:1.96
--- src/sys/arch/amd64/conf/files.amd64:1.95 Sat Dec 2 08:03:15 2017
+++ src/sys/arch/amd64/conf/files.amd64 Thu Dec 7 18:11:50 2017
@@ -1,4 +1,4 @@
-# $NetBSD: files.amd64,v 1.95 2017/12/02 13:03:15 maxv Exp $
+# $NetBSD: files.amd64,v 1.96 2017/12/07 23:11:50 christos Exp $
#
# new style config file for amd64 architecture
#
@@ -136,6 +136,7 @@ attach fd at fdc
# Compatibility modules
#
# Binary compatibility with previous NetBSD releases (COMPAT_XX)
+file arch/amd64/amd64/compat_13_machdep.c compat_13
file arch/amd64/amd64/compat_16_machdep.c compat_16
# NetBSD/i386 32-bit binary compatibility (COMPAT_NETBSD32)
Added files:
Index: src/sys/arch/amd64/amd64/compat_13_machdep.c
diff -u /dev/null src/sys/arch/amd64/amd64/compat_13_machdep.c:1.3
--- /dev/null Thu Dec 7 18:11:50 2017
+++ src/sys/arch/amd64/amd64/compat_13_machdep.c Thu Dec 7 18:11:50 2017
@@ -0,0 +1,63 @@
+/* $NetBSD: compat_13_machdep.c,v 1.3 2017/12/07 23:11:50 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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: compat_13_machdep.c,v 1.3 2017/12/07 23:11:50 christos Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/sys/signal.h>
+#include <compat/sys/signalvar.h>
+
+#ifdef COMPAT_13
+
+int compat_13_sys_sigreturn(struct lwp *, const struct compat_13_sys_sigreturn_args *, register_t *);
+
+/*
+ * There is no NetBSD-1.6 compatibility for native code.
+ * COMPAT_13 is useful for i386 emulation (COMPAT_NETBSD32) only.
+ */
+int
+compat_13_sys_sigreturn(struct lwp *l, const struct compat_13_sys_sigreturn_args *uap, register_t *retval)
+{
+
+ return ENOSYS;
+}
+#endif