Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 COMPAT_NETBSD32 is all about running the...
details: https://anonhg.NetBSD.org/src/rev/57aaa722fad0
branches: trunk
changeset: 1024815:57aaa722fad0
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Nov 06 20:42:56 2021 +0000
description:
COMPAT_NETBSD32 is all about running the 32-bit flavor of native
binaries on a 64-bit platform[*], as such:
- Make the logic about which "sendsig" flavor to call MI (as it is in the
native 64-bit environment) and follow the same rules as the native 32-bit
environment.
- Make COMPAT_NETBSD32 x COMPAT_16 work the same as it would in the
native 32-bit environment by providing a netbsd32_sendsig_sigcontext_16_hook,
rather than overriding the entire sendsig logic with a netbsd32_sendsig_hook.
- In netbsd32___sigaction_sigtramp(), make sure the compat_netbsd32_16
module is loaded if the trampoline version specifies a sigcontext style
handler, otherwise return EINVAL so that libc can try again with siginfo
style.
[*] ...except for arm32, which uses it to mean "run 32-bit OABI binaries
from the 32-bit EABI environment". Doing it this way was arguably a mistake,
but we are stuck with it for now, so support it by providing a machine-
dependent override for netbsd32_sendsig() that also disables the corresponding
logic in netbsd32___sigaction_sigtramp().
Fixes PR kern/56487.
diffstat:
sys/arch/aarch64/aarch64/netbsd32_machdep.c | 19 +----
sys/arch/amd64/amd64/netbsd32_machdep.c | 19 +----
sys/arch/amd64/amd64/netbsd32_machdep_16.c | 25 +-----
sys/arch/arm/include/netbsd32_machdep.h | 12 +++-
sys/arch/mips/mips/netbsd32_machdep.c | 20 +----
sys/arch/mips/mips/netbsd32_machdep_16.c | 24 +-----
sys/arch/sparc64/sparc64/netbsd32_machdep.c | 20 +----
sys/arch/sparc64/sparc64/netbsd32_machdep_16.c | 25 +-----
sys/compat/netbsd32/netbsd32.h | 8 +-
sys/compat/netbsd32/netbsd32_exec.h | 3 +-
sys/compat/netbsd32/netbsd32_signal.c | 91 ++++++++++++++++++++++++-
11 files changed, 132 insertions(+), 134 deletions(-)
diffs (truncated from 629 to 300 lines):
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/aarch64/aarch64/netbsd32_machdep.c
--- a/sys/arch/aarch64/aarch64/netbsd32_machdep.c Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/aarch64/aarch64/netbsd32_machdep.c Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.21 2021/11/01 05:07:15 thorpej Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.22 2021/11/06 20:42:56 thorpej Exp $ */
/*
* Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.21 2021/11/01 05:07:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.22 2021/11/06 20:42:56 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -300,7 +300,7 @@
return error;
}
-static void
+void
netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp * const l = curlwp;
@@ -375,19 +375,6 @@
}
void
-netbsd32_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
-{
-#ifdef COMPAT_16
-#error non EABI generation binaries are not supported
- if (curproc->p_sigacts->sa_sigdesc[ksi->ksi_signo].sd_vers <
- __SIGTRAMP_SIGINFO_VERSION)
- netbsd32_sendsig_sigcontext(ksi, mask);
- else
-#endif
- netbsd32_sendsig_siginfo(ksi, mask);
-}
-
-void
startlwp32(void *arg)
{
ucontext32_t *uc = arg;
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.139 2021/11/01 05:07:15 thorpej Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.139 2021/11/01 05:07:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.140 2021/11/06 20:42:56 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -109,7 +109,6 @@
int check_sigcontext32(struct lwp *, const struct netbsd32_sigcontext *);
void netbsd32_buildcontext(struct lwp *, struct trapframe *, void *,
sig_t, int);
-int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
#ifdef EXEC_AOUT
/*
@@ -206,7 +205,7 @@
}
}
-int
+void
netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp *l = curlwp;
@@ -274,18 +273,6 @@
}
netbsd32_buildcontext(l, tf, fp, catcher, onstack);
-
- return 0;
-}
-
-struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;
-
-void
-netbsd32_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
-{
-
- MODULE_HOOK_CALL_VOID(netbsd32_sendsig_hook, (ksi, mask),
- netbsd32_sendsig_siginfo(ksi, mask));
}
/*
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/amd64/amd64/netbsd32_machdep_16.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep_16.c Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep_16.c Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep_16.c,v 1.6 2021/10/27 04:14:59 thorpej Exp $ */
+/* $NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.6 2021/10/27 04:14:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -79,14 +79,8 @@
void netbsd32_buildcontext(struct lwp *, struct trapframe *, void *,
sig_t, int);
-void netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
-
int check_sigcontext32(struct lwp *, const struct netbsd32_sigcontext *);
-void netbsd32_sendsig_16(const ksiginfo_t *, const sigset_t *);
-
-extern struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;
-
static void
netbsd32_sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask)
{
@@ -176,16 +170,6 @@
netbsd32_buildcontext(l, tf, fp, catcher, onstack);
}
-void
-netbsd32_sendsig_16(const ksiginfo_t *ksi, const sigset_t *mask)
-{
- if (curproc->p_sigacts->sa_sigdesc[ksi->ksi_signo].sd_vers <
- __SIGTRAMP_SIGINFO_VERSION)
- netbsd32_sendsig_sigcontext(ksi, mask);
- else
- netbsd32_sendsig_siginfo(ksi, mask);
-}
-
int
compat_16_netbsd32___sigreturn14(struct lwp *l,
const struct compat_16_netbsd32___sigreturn14_args *uap,
@@ -251,12 +235,13 @@
netbsd32_machdep_md_16_init(void)
{
- MODULE_HOOK_SET(netbsd32_sendsig_hook, netbsd32_sendsig_16);
+ MODULE_HOOK_SET(netbsd32_sendsig_sigcontext_16_hook,
+ netbsd32_sendsig_sigcontext);
}
void
netbsd32_machdep_md_16_fini(void)
{
- MODULE_HOOK_UNSET(netbsd32_sendsig_hook);
+ MODULE_HOOK_UNSET(netbsd32_sendsig_sigcontext_16_hook);
}
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/arm/include/netbsd32_machdep.h
--- a/sys/arch/arm/include/netbsd32_machdep.h Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/arm/include/netbsd32_machdep.h Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.h,v 1.3 2021/10/06 05:33:15 skrll Exp $ */
+/* $NetBSD: netbsd32_machdep.h,v 1.4 2021/11/06 20:42:56 thorpej Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,6 +34,10 @@
#include <sys/types.h>
+#ifdef __aarch64__
+#error You have wandered from the path of righteousness.
+#endif
+
#define NETBSD32_POINTER_TYPE uint32_t
typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t;
@@ -55,6 +59,12 @@
#define netbsd32_esigcode esigcode
/*
+ * Using the entirety of COMPAT_NETBSD32 to support the OABI was
+ * a gigantic mistake, but here we are.
+ */
+#define __HAVE_MD_NETBSD32_SENDSIG
+
+/*
* Note: syscall_intern and setregs do not care about COMPAT_NETBSD32.
*/
#define netbsd32_syscall_intern syscall_intern
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/mips/mips/netbsd32_machdep.c
--- a/sys/arch/mips/mips/netbsd32_machdep.c Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep.c Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.22 2021/10/27 04:15:00 thorpej Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.23 2021/11/06 20:42:56 thorpej Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.22 2021/10/27 04:15:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.23 2021/11/06 20:42:56 thorpej Exp $");
#include "opt_compat_netbsd.h"
@@ -78,8 +78,6 @@
netbsd32_vm_default_addr
#endif
-int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
-
struct sigframe_siginfo32 {
siginfo32_t sf_si;
ucontext32_t sf_uc;
@@ -88,7 +86,7 @@
/*
* Send a signal to process.
*/
-int
+void
netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp * const l = curlwp;
@@ -160,8 +158,6 @@
/* Remember that we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
-
- return 0;
}
int
@@ -310,16 +306,6 @@
return error;
}
-struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;
-
-void
-netbsd32_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
-{
-
- MODULE_HOOK_CALL_VOID(netbsd32_sendsig_hook, (ksi, mask),
- netbsd32_sendsig_siginfo(ksi, mask));
-}
-
static const char *
netbsd32_machine32(void)
{
diff -r c058b9eb736b -r 57aaa722fad0 sys/arch/mips/mips/netbsd32_machdep_16.c
--- a/sys/arch/mips/mips/netbsd32_machdep_16.c Sat Nov 06 19:44:22 2021 +0000
+++ b/sys/arch/mips/mips/netbsd32_machdep_16.c Sat Nov 06 20:42:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep_16.c,v 1.6 2021/10/27 04:15:00 thorpej Exp $ */
+/* $NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.6 2021/10/27 04:15:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_16.c,v 1.7 2021/11/06 20:42:56 thorpej Exp $");
#include "opt_compat_netbsd.h"
@@ -66,12 +66,7 @@
#include <uvm/uvm_extern.h>
-void netbsd32_sendsig_16(const ksiginfo_t *, const sigset_t *);
-
void sendsig_context(const ksiginfo_t *, const sigset_t *);
-int netbsd32_sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
-
-extern struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;
int
compat_16_netbsd32___sigreturn14(struct lwp *l,
@@ -85,26 +80,17 @@
return compat_16_sys___sigreturn14(l, &ua, retval);
}
-void
-netbsd32_sendsig_16(const ksiginfo_t *ksi, const sigset_t *mask)
-{
Home |
Main Index |
Thread Index |
Old Index