Source-Changes-HG archive

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

[src/pgoyette-compat]: src Create and build a compat_16 module



details:   https://anonhg.NetBSD.org/src/rev/ac14a3f7fdd8
branches:  pgoyette-compat
changeset: 321125:ac14a3f7fdd8
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Mar 30 05:35:47 2018 +0000

description:
Create and build a compat_16 module

diffstat:

 distrib/sets/lists/modules/mi     |   4 +-
 sys/compat/common/compat_16_mod.c |  94 ++++++++++++++++++++++++++++++++++++++
 sys/compat/common/compat_mod.c    |  78 +------------------------------
 sys/compat/common/compat_mod.h    |   9 +++-
 sys/compat/common/files.common    |   3 +-
 sys/compat/common/kern_sig_16.c   |  96 ++++++++++++++++++++++++++++++++++++++-
 sys/modules/Makefile              |   4 +-
 7 files changed, 207 insertions(+), 81 deletions(-)

diffs (truncated from 447 to 300 lines):

diff -r 1f658d2b60e1 -r ac14a3f7fdd8 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Fri Mar 30 02:52:06 2018 +0000
+++ b/distrib/sets/lists/modules/mi     Fri Mar 30 05:35:47 2018 +0000
@@ -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
diff -r 1f658d2b60e1 -r ac14a3f7fdd8 sys/compat/common/compat_16_mod.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/compat_16_mod.c Fri Mar 30 05:35:47 2018 +0000
@@ -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
diff -r 1f658d2b60e1 -r ac14a3f7fdd8 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Fri Mar 30 02:52:06 2018 +0000
+++ b/sys/compat/common/compat_mod.c    Fri Mar 30 05:35:47 2018 +0000
@@ -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 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 @@
        { 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 @@
 #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 @@
 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 @@
 #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 @@
 #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 @@
                }
 #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
diff -r 1f658d2b60e1 -r ac14a3f7fdd8 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Fri Mar 30 02:52:06 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Fri Mar 30 05:35:47 2018 +0000
@@ -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_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_ */
diff -r 1f658d2b60e1 -r ac14a3f7fdd8 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Fri Mar 30 02:52:06 2018 +0000
+++ b/sys/compat/common/files.common    Fri Mar 30 05:35:47 2018 +0000
@@ -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/rtsock_14.c               compat_14
 
 # Compatibility code for NetBSD 1.6



Home | Main Index | Thread Index | Old Index