Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64 Save maxv@ some work and put back the compat_...
details: https://anonhg.NetBSD.org/src/rev/288c02b34a63
branches: trunk
changeset: 358007:288c02b34a63
user: christos <christos%NetBSD.org@localhost>
date: Thu Dec 07 23:11:50 2017 +0000
description:
Save maxv@ some work and put back the compat_13_sigreturn changes that allow
amd64 to run ancient i386 binaries.
diffstat:
sys/arch/amd64/amd64/compat_13_machdep.c | 63 +++++++++++++++++++++++++++++
sys/arch/amd64/amd64/netbsd32_machdep.c | 68 +++++++++++++++++++++++++++++++-
sys/arch/amd64/conf/files.amd64 | 3 +-
3 files changed, 131 insertions(+), 3 deletions(-)
diffs (170 lines):
diff -r 2d579b36eb48 -r 288c02b34a63 sys/arch/amd64/amd64/compat_13_machdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/amd64/compat_13_machdep.c Thu Dec 07 23:11:50 2017 +0000
@@ -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
diff -r 2d579b36eb48 -r 288c02b34a63 sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Thu Dec 07 22:56:23 2017 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Thu Dec 07 23:11:50 2017 +0000
@@ -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 @@
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
diff -r 2d579b36eb48 -r 288c02b34a63 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64 Thu Dec 07 22:56:23 2017 +0000
+++ b/sys/arch/amd64/conf/files.amd64 Thu Dec 07 23:11:50 2017 +0000
@@ -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 @@
# 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)
Home |
Main Index |
Thread Index |
Old Index