Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys/compat/netbsd32 Use the MP-safe compat hooks f...



details:   https://anonhg.NetBSD.org/src/rev/2594e98c8148
branches:  pgoyette-compat
changeset: 830723:2594e98c8148
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Sep 18 10:35:04 2018 +0000

description:
Use the MP-safe compat hooks for netbsd32_compat_80.c's modctl

diffstat:

 sys/compat/netbsd32/netbsd32.h           |   7 ++++---
 sys/compat/netbsd32/netbsd32_compat_80.c |  14 +++++++-------
 sys/compat/netbsd32/netbsd32_mod.c       |  14 ++++----------
 sys/compat/netbsd32/netbsd32_module.c    |  20 ++++++++++++++++----
 4 files changed, 31 insertions(+), 24 deletions(-)

diffs (183 lines):

diff -r 6dabeb70312a -r 2594e98c8148 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Tue Sep 18 10:34:08 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Tue Sep 18 10:35:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32.h,v 1.116.2.7 2018/09/14 09:21:33 pgoyette Exp $      */
+/*     $NetBSD: netbsd32.h,v 1.116.2.8 2018/09/18 10:35:04 pgoyette Exp $      */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -46,6 +46,7 @@
 #include <sys/shm.h>
 #include <sys/ucontext.h>
 #include <sys/ucred.h>
+#include <sys/compat_hook.h>
 #include <compat/sys/ucontext.h>
 #include <compat/sys/mount.h>
 #include <compat/sys/signal.h>
@@ -1176,8 +1177,8 @@
 extern struct sysctlnode netbsd32_sysctl_root;
 
 struct netbsd32_modctl_args;
-extern int (*vec_compat32_80_modctl)(struct lwp *,
-    const struct netbsd32_modctl_args *, register_t *);
+COMPAT_HOOK(compat32_80_modctl_hook,
+    (struct lwp *, const struct netbsd32_modctl_args *, register_t *));
 
 /*
  * Finally, declare emul_netbsd32 as this is needed in lots of
diff -r 6dabeb70312a -r 2594e98c8148 sys/compat/netbsd32/netbsd32_compat_80.c
--- a/sys/compat/netbsd32/netbsd32_compat_80.c  Tue Sep 18 10:34:08 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_80.c  Tue Sep 18 10:35:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_compat_80.c,v 1.1.2.3 2018/09/11 09:22:51 pgoyette Exp $      */
+/*     $NetBSD: netbsd32_compat_80.c,v 1.1.2.4 2018/09/18 10:35:04 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_80.c,v 1.1.2.3 2018/09/11 09:22:51 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_80.c,v 1.1.2.4 2018/09/18 10:35:04 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -175,22 +175,22 @@
        return error;
 }
 
+COMPAT_SET_HOOK(compat32_80_modctl_hook, "nb32_modctl_80", netbsd32_80_modctl);
+COMPAT_UNSET_HOOK(compat32_80_modctl_hook);
+
 MODULE(MODULE_CLASS_EXEC, compat_netbsd32_80, "compat_netbsd32,compat_80");
 
 static int
 compat_netbsd32_80_modcmd(modcmd_t cmd, void *arg)
 {
-static int (*orig_netbsd32_80_modctl)(struct lwp *,
-    const struct netbsd32_modctl_args *, register_t *);
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               orig_netbsd32_80_modctl = vec_compat32_80_modctl;
-               vec_compat32_80_modctl = netbsd32_80_modctl;
+               compat32_80_modctl_hook_set();
                return 0;
 
        case MODULE_CMD_FINI:
-               vec_compat32_80_modctl = orig_netbsd32_80_modctl;
+               compat32_80_modctl_hook_unset();
                return 0;
 
        default:
diff -r 6dabeb70312a -r 2594e98c8148 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c        Tue Sep 18 10:34:08 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c        Tue Sep 18 10:35:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_mod.c,v 1.13.16.11 2018/09/14 08:38:37 pgoyette Exp $ */
+/*     $NetBSD: netbsd32_mod.c,v 1.13.16.12 2018/09/18 10:35:04 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.11 2018/09/14 08:38:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.13.16.12 2018/09/18 10:35:04 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -44,6 +44,7 @@
 #include <sys/module.h>
 #include <sys/exec.h>
 #include <sys/exec_elf.h>
+#include <sys/compat_hook.h>
 
 #include <compat/netbsd32/netbsd32_sysctl.h>
 #include <compat/netbsd32/netbsd32_exec.h>
@@ -51,11 +52,7 @@
 #define ELF32_AUXSIZE (howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), \
     sizeof(Elf32_Addr)) + MAXPATHLEN + ALIGN(1))
 
-int compat32_80_modctl_compat_stub(struct lwp *,
-    const struct netbsd32_modctl_args *, register_t *);
-
-int (*vec_compat32_80_modctl)(struct lwp *,
-    const struct netbsd32_modctl_args *, register_t *);
+struct compat32_80_modctl_hook_t compat32_80_modctl_hook;
 
 # define       DEPS1   "ksem,coredump,compat_util"
 
@@ -113,21 +110,18 @@
                    __arraycount(netbsd32_execsw));
                if (error == 0) {
                        netbsd32_sysctl_init();
-                       vec_compat32_80_modctl = compat32_80_modctl_compat_stub;
                        netbsd32_machdep_md_init();
                }
                return error;
 
        case MODULE_CMD_FINI:
                netbsd32_machdep_md_fini();
-               vec_compat32_80_modctl = (void *)enosys;
                netbsd32_sysctl_fini();
 
                error = exec_remove(netbsd32_execsw,
                    __arraycount(netbsd32_execsw));
                if (error) {
                        netbsd32_sysctl_init();
-                       vec_compat32_80_modctl = compat32_80_modctl_compat_stub;
                        netbsd32_machdep_md_init();
                }
                return error;
diff -r 6dabeb70312a -r 2594e98c8148 sys/compat/netbsd32/netbsd32_module.c
--- a/sys/compat/netbsd32/netbsd32_module.c     Tue Sep 18 10:34:08 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_module.c     Tue Sep 18 10:35:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_module.c,v 1.6.2.6 2018/09/14 08:53:22 pgoyette Exp $ */
+/*     $NetBSD: netbsd32_module.c,v 1.6.2.7 2018/09/18 10:35:04 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.6.2.6 2018/09/14 08:53:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_module.c,v 1.6.2.7 2018/09/18 10:35:04 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -200,6 +200,18 @@
        return EPASSTHROUGH;
 }
 
+/* Module hook for netbsd32_80_modctl */
+COMPAT_CALL_HOOK_DECL(compat32_80_modctl_hook, f,
+    (struct lwp *lwp, const struct netbsd32_modctl_args *uap,
+      register_t *result),
+    (lwp, uap, result),
+    enosys());
+COMPAT_CALL_HOOK(compat32_80_modctl_hook, f,
+    (struct lwp *lwp, const struct netbsd32_modctl_args *uap,
+      register_t *result),
+    (lwp, uap, result),
+    enosys());
+
 int
 netbsd32_modctl(struct lwp *lwp, const struct netbsd32_modctl_args *uap,
        register_t *result)
@@ -219,8 +231,8 @@
 
        arg = SCARG_P32(uap, arg);
 
-       error = (*vec_compat32_80_modctl)(lwp, uap, result);
-       if (error != EPASSTHROUGH)
+       error = compat32_80_modctl_hook_f_call(lwp, uap, result);
+       if (error != EPASSTHROUGH && error != ENOSYS)
                return error;
 
        switch (SCARG(uap, cmd)) {



Home | Main Index | Thread Index | Old Index