Module Name: src
Committed By: pgoyette
Date: Fri Mar 30 05:35:47 UTC 2018
Modified Files:
src/distrib/sets/lists/modules [pgoyette-compat]: mi
src/sys/compat/common [pgoyette-compat]: compat_mod.c compat_mod.h
files.common kern_sig_16.c
src/sys/modules [pgoyette-compat]: Makefile
Added Files:
src/sys/compat/common [pgoyette-compat]: compat_16_mod.c
Log Message:
Create and build a compat_16 module
To generate a diff of this commit:
cvs rdiff -u -r1.114.2.9 -r1.114.2.10 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/compat_16_mod.c
cvs rdiff -u -r1.24.14.25 -r1.24.14.26 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.42.13 -r1.1.42.14 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.24 -r1.1.2.25 src/sys/compat/common/files.common
cvs rdiff -u -r1.2 -r1.2.38.1 src/sys/compat/common/kern_sig_16.c
cvs rdiff -u -r1.202.2.13 -r1.202.2.14 src/sys/modules/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.114.2.9 src/distrib/sets/lists/modules/mi:1.114.2.10
--- src/distrib/sets/lists/modules/mi:1.114.2.9 Fri Mar 30 02:28:25 2018
+++ src/distrib/sets/lists/modules/mi Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.114.2.9 2018/03/30 02:28:25 pgoyette Exp $
+# $NetBSD: mi,v 1.114.2.10 2018/03/30 05:35:47 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -68,6 +68,8 @@
./@MODULEDIR@/coda5/coda5.kmod base-kernel-modules kmod
./@MODULEDIR@/compat base-kernel-modules kmod
./@MODULEDIR@/compat/compat.kmod base-kernel-modules kmod
+./@MODULEDIR@/compat_16 base-kernel-modules kmod
+./@MODULEDIR@/compat_16/compat_16.kmod base-kernel-modules kmod
./@MODULEDIR@/compat_20 base-kernel-modules kmod
./@MODULEDIR@/compat_20/compat_20.kmod base-kernel-modules kmod
./@MODULEDIR@/compat_30 base-kernel-modules kmod
Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.25 src/sys/compat/common/compat_mod.c:1.24.14.26
--- src/sys/compat/common/compat_mod.c:1.24.14.25 Fri Mar 30 02:52:06 2018
+++ src/sys/compat/common/compat_mod.c Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.24.14.25 2018/03/30 02:52:06 pgoyette Exp $ */
+/* $NetBSD: compat_mod.c,v 1.24.14.26 2018/03/30 05:35:47 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.25 2018/03/30 02:52:06 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.26 2018/03/30 05:35:47 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -78,24 +78,13 @@ static struct sysctllog *compat_clog = N
static const char * const compat_includes[] = {
"compat_80", "compat_70", "compat_60", "compat_50", "compat_40",
- "compat_30","compat_20",
+ "compat_30", "compat_20",
NULL
};
MODULE_WITH_ALIASES(MODULE_CLASS_EXEC, compat, NULL, &compat_includes);
-#ifdef _MODULE
-#ifdef COMPAT_16
-#if !defined(__amd64__) || defined(COMPAT_NETBSD32)
-#define COMPAT_SIGCONTEXT
-extern char sigcode[], esigcode[];
-struct uvm_object *emul_netbsd_object;
-#endif
-#endif
-#endif /* _MODULE */
-
-extern krwlock_t exec_lock;
extern krwlock_t ttcompat_lock;
static const struct syscall_package compat_syscalls[] = {
@@ -160,13 +149,6 @@ static const struct syscall_package comp
{ SYS_compat_13_sigsuspend13, 0, (sy_call_t *)compat_13_sys_sigsuspend },
#endif
-#if defined(COMPAT_16)
-#if defined(COMPAT_SIGCONTEXT)
- { SYS_compat_16___sigaction14, 0, (sy_call_t *)compat_16_sys___sigaction14 },
- { SYS_compat_16___sigreturn14, 0, (sy_call_t *)compat_16_sys___sigreturn14 },
-#endif
-#endif
-
{ 0, 0, NULL },
};
@@ -192,10 +174,10 @@ struct compat_init_fini {
#ifdef COMPAT_20
{ compat_20_init, compat_20_fini },
#endif
-#if 0 /* NOT YET */
#ifdef COMPAT_16
{ compat_16_init, compat_16_fini },
#endif
+#if 0 /* NOT YET */
#ifdef COMPAT_14
{ compat_14_init, compat_14_fini },
#endif
@@ -220,9 +202,6 @@ struct compat_init_fini {
static int
compat_modcmd(modcmd_t cmd, void *arg)
{
-#ifdef COMPAT_16
- proc_t *p;
-#endif
int error;
int i, j;
@@ -266,18 +245,6 @@ compat_modcmd(modcmd_t cmd, void *arg)
#ifdef COMPAT_13
uvm_13_init();
#endif
-#ifdef COMPAT_16
-#if defined(COMPAT_SIGCONTEXT)
- KASSERT(emul_netbsd.e_sigobject == NULL);
- rw_enter(&exec_lock, RW_WRITER);
- emul_netbsd.e_sigcode = sigcode;
- emul_netbsd.e_esigcode = esigcode;
- emul_netbsd.e_sigobject = &emul_netbsd_object;
- rw_exit(&exec_lock);
- KASSERT(sendsig_sigcontext_vec == NULL);
- sendsig_sigcontext_vec = sendsig_sigcontext;
-#endif
-#endif
#ifdef COMPAT_10
vfs_syscalls_10_init();
#endif
@@ -291,25 +258,6 @@ compat_modcmd(modcmd_t cmd, void *arg)
#ifdef COMPAT_13
uvm_13_fini();
#endif
-#ifdef COMPAT_16
- /*
- * Ensure sendsig_sigcontext() is not being used.
- * module_lock prevents the flag being set on any
- * further processes while we are here. See
- * sigaction1() for the opposing half.
- */
- mutex_enter(proc_lock);
- PROCLIST_FOREACH(p, &allproc) {
- if ((p->p_lflag & PL_SIGCOMPAT) != 0) {
- break;
- }
- }
- mutex_exit(proc_lock);
- if (p != NULL) {
- return EBUSY;
- }
- sendsig_sigcontext_vec = NULL;
-#endif
/* Unlink the system calls. */
error = syscall_disestablish(NULL, compat_syscalls);
if (error != 0) {
@@ -328,24 +276,6 @@ compat_modcmd(modcmd_t cmd, void *arg)
}
#endif
#endif /* NOTYET XXX */
-#ifdef COMPAT_16
-#if defined(COMPAT_SIGCONTEXT)
- /*
- * The sigobject may persist if still in use, but
- * is reference counted so will die eventually.
- */
- rw_enter(&exec_lock, RW_WRITER);
- if (emul_netbsd_object != NULL) {
- (*emul_netbsd_object->pgops->pgo_detach)
- (emul_netbsd_object);
- }
- emul_netbsd_object = NULL;
- emul_netbsd.e_sigcode = NULL;
- emul_netbsd.e_esigcode = NULL;
- emul_netbsd.e_sigobject = NULL;
- rw_exit(&exec_lock);
-#endif
-#endif /* COMPAT_16 */
/*
* Disable included components in reverse order;
* if any component fails to fini(), re-init those
Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.13 src/sys/compat/common/compat_mod.h:1.1.42.14
--- src/sys/compat/common/compat_mod.h:1.1.42.13 Fri Mar 30 02:28:49 2018
+++ src/sys/compat/common/compat_mod.h Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.h,v 1.1.42.13 2018/03/30 02:28:49 pgoyette Exp $ */
+/* $NetBSD: compat_mod.h,v 1.1.42.14 2018/03/30 05:35:47 pgoyette Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -116,4 +116,11 @@ void if43_20_init(void);
void if43_20_fini(void);
#endif
+#ifdef COMPAT_16
+int compat_16_init(void);
+int compat_16_fini(void);
+int kern_sig_16_init(void);
+int kern_sig_16_fini(void);
+#endif
+
#endif /* !_COMPAT_MOD_H_ */
Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.24 src/sys/compat/common/files.common:1.1.2.25
--- src/sys/compat/common/files.common:1.1.2.24 Fri Mar 30 02:28:49 2018
+++ src/sys/compat/common/files.common Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.common,v 1.1.2.24 2018/03/30 02:28:49 pgoyette Exp $
+# $NetBSD: files.common,v 1.1.2.25 2018/03/30 05:35:47 pgoyette Exp $
#
# Generic files, used by all compat options.
@@ -41,6 +41,7 @@ file compat/common/uvm_13.c compat_13
file compat/common/rtsock_14.c compat_14
# Compatibility code for NetBSD 1.6
+file compat/common/compat_16_mod.c compat_20
file compat/common/kern_sig_16.c compat_16
# Compatibility code for NetBSD 2.0
Index: src/sys/compat/common/kern_sig_16.c
diff -u src/sys/compat/common/kern_sig_16.c:1.2 src/sys/compat/common/kern_sig_16.c:1.2.38.1
--- src/sys/compat/common/kern_sig_16.c:1.2 Sun Feb 19 21:06:36 2012
+++ src/sys/compat/common/kern_sig_16.c Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig_16.c,v 1.2 2012/02/19 21:06:36 rmind Exp $ */
+/* $NetBSD: kern_sig_16.c,v 1.2.38.1 2018/03/30 05:35:47 pgoyette Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,18 +66,41 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.2 2012/02/19 21:06:36 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.2.38.1 2018/03/30 05:35:47 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/rwlock.h>
#include <sys/signalvar.h>
#include <sys/proc.h>
#include <sys/pool.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
#include <sys/syscallargs.h>
#include <sys/kauth.h>
#include <sys/wait.h>
#include <sys/kmem.h>
+#include <compat/common/compat_mod.h>
+
+extern krwlock_t exec_lock;
+
+#if !defined(__amd64__) || defined(COMPAT_NETBSD32)
+#define COMPAT_SIGCONTEXT
+extern char sigcode[], esigcode[];
+struct uvm_object *emul_netbsd_object;
+#endif
+
+static const struct syscall_package kern_sig_16_syscalls[] = {
+#ifdef COMPAT_SIGCONTEXT
+ { SYS_compat_16___sigaction14, 0,
+ (sy_call_t *)compat_16_sys___sigaction14 },
+ { SYS_compat_16___sigreturn14, 0,
+ (sy_call_t *)compat_16_sys___sigreturn14 },
+#endif
+ { 0, 0, NULL }
+};
+
int
compat_16_sys___sigaction14(struct lwp *l,
const struct compat_16_sys___sigaction14_args *uap, register_t *retval)
@@ -107,3 +130,72 @@ compat_16_sys___sigaction14(struct lwp *
}
return (0);
}
+
+int
+kern_sig_16_init(void)
+{
+ int error;
+
+ error = syscall_establish(NULL, kern_sig_16_syscalls);
+ if (error)
+ return error;
+#if defined(COMPAT_SIGCONTEXT)
+ KASSERT(emul_netbsd.e_sigobject == NULL);
+ rw_enter(&exec_lock, RW_WRITER);
+ emul_netbsd.e_sigcode = sigcode;
+ emul_netbsd.e_esigcode = esigcode;
+ emul_netbsd.e_sigobject = &emul_netbsd_object;
+ rw_exit(&exec_lock);
+ KASSERT(sendsig_sigcontext_vec == NULL);
+ sendsig_sigcontext_vec = sendsig_sigcontext;
+#endif
+
+ return 0;
+}
+
+int
+kern_sig_16_fini(void)
+{
+ proc_t *p;
+ int error;
+
+ error = syscall_disestablish(NULL, kern_sig_16_syscalls);
+ if (error)
+ return error;
+ /*
+ * Ensure sendsig_sigcontext() is not being used.
+ * module_lock prevents the flag being set on any
+ * further processes while we are here. See
+ * sigaction1() for the opposing half.
+ */
+ mutex_enter(proc_lock);
+ PROCLIST_FOREACH(p, &allproc) {
+ if ((p->p_lflag & PL_SIGCOMPAT) != 0) {
+ break;
+ }
+ }
+ mutex_exit(proc_lock);
+ if (p != NULL) {
+ syscall_establish(NULL, kern_sig_16_syscalls);
+ return EBUSY;
+ }
+ sendsig_sigcontext_vec = NULL;
+
+#if defined(COMPAT_SIGCONTEXT)
+ /*
+ * The sigobject may persist if still in use, but
+ * is reference counted so will die eventually.
+ */
+ rw_enter(&exec_lock, RW_WRITER);
+ if (emul_netbsd_object != NULL) {
+ (*emul_netbsd_object->pgops->pgo_detach)(emul_netbsd_object);
+ }
+ emul_netbsd_object = NULL;
+ emul_netbsd.e_sigcode = NULL;
+ emul_netbsd.e_esigcode = NULL;
+ emul_netbsd.e_sigobject = NULL;
+ rw_exit(&exec_lock);
+#endif
+ return 0;
+}
+
Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.202.2.13 src/sys/modules/Makefile:1.202.2.14
--- src/sys/modules/Makefile:1.202.2.13 Fri Mar 30 02:28:49 2018
+++ src/sys/modules/Makefile Fri Mar 30 05:35:47 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.202.2.13 2018/03/30 02:28:49 pgoyette Exp $
+# $NetBSD: Makefile,v 1.202.2.14 2018/03/30 05:35:47 pgoyette Exp $
.include <bsd.own.mk>
@@ -7,7 +7,7 @@
# Modules for compatability with earlier versions of NetBSD
SUBDIR+= compat compat_80 compat_70 compat_60 compat_50
-SUBDIR+= compat_40 compat_30 compat_20 #compat_16 compat_14
+SUBDIR+= compat_40 compat_30 compat_20 compat_16 #compat_14
#SUBDIR+= compat_13 compat_12 compat_10 compat_09
SUBDIR+= compat_ossaudio
SUBDIR+= compat_sysv
Added files:
Index: src/sys/compat/common/compat_16_mod.c
diff -u /dev/null src/sys/compat/common/compat_16_mod.c:1.1.2.1
--- /dev/null Fri Mar 30 05:35:47 2018
+++ src/sys/compat/common/compat_16_mod.c Fri Mar 30 05:35:47 2018
@@ -0,0 +1,94 @@
+/* $NetBSD: compat_16_mod.c,v 1.1.2.1 2018/03/30 05:35:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ */
+
+/*
+ * Linkage for the compat module: spaghetti.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_16_mod.c,v 1.1.2.1 2018/03/30 05:35:47 pgoyette Exp $");
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+
+#include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
+
+int
+compat_16_init(void)
+{
+ int error = 0;
+
+ error = kern_sig_16_init();
+ if (error != 0)
+ return error;
+
+ return error;
+}
+
+int
+compat_16_fini(void)
+{
+ int error = 0;
+
+ error = kern_sig_16_fini();
+ if (error != 0) {
+ return error;
+ }
+
+ return error;
+}
+
+#ifdef _MODULE
+
+#define REQD_16_1 "compat_80,compat_70,compat_60,compat_50,"
+#define REQD_16_2 "compat_40,compat_30,compat_20"
+
+MODULE(MODULE_CLASS_EXEC, compat_16, REQD_16_1 REQD_16_2);
+
+static int
+compat_16_modcmd(modcmd_t cmd, void *arg)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return compat_16_init();
+ case MODULE_CMD_FINI:
+ return compat_16_init();
+ default:
+ return ENOTTY;
+ }
+}
+#endif