Source-Changes-HG archive

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

[src/trunk]: src/sys Make the list of syscalls which can trigger a module aut...



details:   https://anonhg.NetBSD.org/src/rev/4e9012a1bf80
branches:  trunk
changeset: 812086:4e9012a1bf80
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Nov 30 22:47:19 2015 +0000

description:
Make the list of syscalls which can trigger a module autoload an
attribute of each emulation, rather than having a single global
list which applies only to the default emulation.

This changes 'struct emul' so

        Welcome to 7.99.23 !

diffstat:

 sys/kern/kern_exec.c     |  12 ++++++++++--
 sys/kern/kern_syscall.c  |  22 +++++++++++-----------
 sys/kern/makesyscalls.sh |  12 +++++++-----
 sys/kern/syscalls.conf   |   3 ++-
 sys/sys/param.h          |   4 ++--
 sys/sys/proc.h           |  11 ++++++++++-
 6 files changed, 42 insertions(+), 22 deletions(-)

diffs (213 lines):

diff -r bdaf474883d3 -r 4e9012a1bf80 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/kern/kern_exec.c      Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.422 2015/11/26 13:15:34 martin Exp $   */
+/*     $NetBSD: kern_exec.c,v 1.423 2015/11/30 22:47:19 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.422 2015/11/26 13:15:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.423 2015/11/30 22:47:19 pgoyette Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -181,6 +181,11 @@
 void   syscall(void);
 #endif
 
+/* NetBSD autoloadable syscalls */
+#ifdef MODULAR
+#include <kern/syscalls_autoload.c>
+#endif
+
 /* NetBSD emul struct */
 struct emul emul_netbsd = {
        .e_name =               "netbsd",
@@ -195,6 +200,9 @@
        .e_nosys =              SYS_syscall,
        .e_nsysent =            SYS_NSYSENT,
 #endif
+#ifdef MODULAR
+       .e_sc_autoload =        netbsd_syscalls_autoload,
+#endif
        .e_sysent =             sysent,
 #ifdef SYSCALL_DEBUG
        .e_syscallnames =       syscallnames,
diff -r bdaf474883d3 -r 4e9012a1bf80 sys/kern/kern_syscall.c
--- a/sys/kern/kern_syscall.c   Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/kern/kern_syscall.c   Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_syscall.c,v 1.11 2015/05/09 05:56:36 pgoyette Exp $       */
+/*     $NetBSD: kern_syscall.c,v 1.12 2015/11/30 22:47:19 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.11 2015/05/09 05:56:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.12 2015/11/30 22:47:19 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_modular.h"
@@ -60,11 +60,11 @@
 sys_nomodule(struct lwp *l, const void *v, register_t *retval)
 {
 #ifdef MODULAR
-#include <kern/syscalls_autoload.c>
 
        const struct sysent *sy;
        const struct emul *em;
-       int code, i;
+       const struct sc_auto *auto_list;
+       int code;
 
        /*
         * Restart the syscall if we interrupted a module unload that
@@ -82,21 +82,21 @@
         * works, retry the request.
         */
        em = l->l_proc->p_emul;
-       if (em == &emul_netbsd) {
-               code = sy - em->e_sysent;
-               for (i = 0; i < __arraycount(syscalls_autoload); i++) {
-                       if (syscalls_autoload[i].al_code != code) {
+       code = sy - em->e_sysent;
+
+       if ((auto_list = em->e_sc_autoload) != NULL)
+               for (; auto_list->al_code > 0; auto_list++) {
+                       if (auto_list->al_code != code) {
                                continue;
                        }
-                       if (module_autoload(syscalls_autoload[i].al_module,
-                           MODULE_CLASS_ANY) != 0 ||
+                       if (module_autoload(auto_list->al_module,
+                                           MODULE_CLASS_ANY) != 0 ||
                            sy->sy_call == sys_nomodule) {
                                break;
                        }
                        kernconfig_unlock();
                        return ERESTART;
                }
-       }
        kernconfig_unlock();
 #endif /* MODULAR */
 
diff -r bdaf474883d3 -r 4e9012a1bf80 sys/kern/makesyscalls.sh
--- a/sys/kern/makesyscalls.sh  Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/kern/makesyscalls.sh  Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: makesyscalls.sh,v 1.154 2015/09/24 14:30:52 christos Exp $
+#      $NetBSD: makesyscalls.sh,v 1.155 2015/11/30 22:47:19 pgoyette Exp $
 #
 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
 # All rights reserved.
@@ -51,6 +51,7 @@
 #      switchname      the name for the 'struct sysent' we define
 #      namesname       the name for the 'const char *[]' we define
 #      constprefix     the prefix for the system call constants
+#      autoloadprefix  the prefix for the autoload table name
 #      registertype    the type for register_t
 #      nsysent         the size of the sysent table
 #      sys_nosys       [optional] name of function called for unsupported
@@ -165,6 +166,7 @@
        switchname = \"$switchname\"
        namesname = \"$namesname\"
        constprefix = \"$constprefix\"
+       autoloadprefix = \"$autoloadprefix\"
        registertype = \"$registertype\"
        sysalign=\"$sysalign\"
        if (!registertype) {
@@ -255,10 +257,9 @@
 
        printf " * created from%s\n */\n\n", $0 > sysautoload
        printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload
-       printf("static struct {\n")                     > sysautoload
-       printf("\tu_int\t\tal_code;\n")                 > sysautoload
-       printf("\tconst char\t*al_module;\n")           > sysautoload
-       printf("} const syscalls_autoload[] = {\n")     > sysautoload
+       printf("#include <sys/proc.h>\n")               > sysautoload
+       printf("static struct sc_auto " autoloadprefix \
+               "_syscalls_autoload[] = {\n")           > sysautoload
 
        printf " * created from%s\n */\n\n", $0 > rumpcalls
        printf "#ifdef RUMP_CLIENT\n" > rumpcalls
@@ -1149,6 +1150,7 @@
 cat $sysprotos >> $sysarghdr
 echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
 echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
+echo "\t    { 0, NULL }" >> $sysautoload
 echo "};" >> $sysautoload
 printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos
 cat $sysdcl $sysent > $syssw
diff -r bdaf474883d3 -r 4e9012a1bf80 sys/kern/syscalls.conf
--- a/sys/kern/syscalls.conf    Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/kern/syscalls.conf    Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: syscalls.conf,v 1.24 2015/08/24 16:05:46 pooka Exp $
+#      $NetBSD: syscalls.conf,v 1.25 2015/11/30 22:47:19 pgoyette Exp $
 
 sysnames="syscalls.c"
 sysnumhdr="../sys/syscall.h"
@@ -17,4 +17,5 @@
 switchname="sysent"
 namesname="syscallnames"
 constprefix="SYS_"
+autoloadprefix="netbsd"
 nsysent=512
diff -r bdaf474883d3 -r 4e9012a1bf80 sys/sys/param.h
--- a/sys/sys/param.h   Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/sys/param.h   Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.487 2015/11/26 13:17:07 martin Exp $       */
+/*     $NetBSD: param.h,v 1.488 2015/11/30 22:47:19 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *     2.99.9          (299000900)
  */
 
-#define        __NetBSD_Version__      799002200       /* NetBSD 7.99.22 */
+#define        __NetBSD_Version__      799002300       /* NetBSD 7.99.23 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
diff -r bdaf474883d3 -r 4e9012a1bf80 sys/sys/proc.h
--- a/sys/sys/proc.h    Mon Nov 30 19:59:34 2015 +0000
+++ b/sys/sys/proc.h    Mon Nov 30 22:47:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: proc.h,v 1.324 2015/11/26 13:15:34 martin Exp $        */
+/*     $NetBSD: proc.h,v 1.325 2015/11/30 22:47:19 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -124,6 +124,14 @@
 };
 
 /*
+ * Autoloadable syscall definition
+ */
+struct sc_auto {
+       u_int           al_code;
+       const char      *al_module;
+};
+
+/*
  * One structure allocated per emulation.
  */
 struct exec_package;
@@ -143,6 +151,7 @@
        struct sysent   *e_sysent;      /* System call array */
        const char * const *e_syscallnames; /* System call name array */
                                        /* Signal sending function */
+       struct sc_auto  *e_sc_autoload; /* List of autoloadable syscalls */
        void            (*e_sendsig)(const struct ksiginfo *,
                                          const sigset_t *);
        void            (*e_trapsignal)(struct lwp *, struct ksiginfo *);



Home | Main Index | Thread Index | Old Index