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 !
This commit is contained in:
pgoyette 2015-11-30 22:47:19 +00:00
parent e4ed2565fe
commit 0513b92c02
6 changed files with 42 additions and 22 deletions

View File

@ -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. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -59,7 +59,7 @@
*/ */
#include <sys/cdefs.h> #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_exec.h"
#include "opt_execfmt.h" #include "opt_execfmt.h"
@ -181,6 +181,11 @@ struct exec_entry {
void syscall(void); void syscall(void);
#endif #endif
/* NetBSD autoloadable syscalls */
#ifdef MODULAR
#include <kern/syscalls_autoload.c>
#endif
/* NetBSD emul struct */ /* NetBSD emul struct */
struct emul emul_netbsd = { struct emul emul_netbsd = {
.e_name = "netbsd", .e_name = "netbsd",
@ -194,6 +199,9 @@ struct emul emul_netbsd = {
.e_errno = NULL, .e_errno = NULL,
.e_nosys = SYS_syscall, .e_nosys = SYS_syscall,
.e_nsysent = SYS_NSYSENT, .e_nsysent = SYS_NSYSENT,
#endif
#ifdef MODULAR
.e_sc_autoload = netbsd_syscalls_autoload,
#endif #endif
.e_sysent = sysent, .e_sysent = sysent,
#ifdef SYSCALL_DEBUG #ifdef SYSCALL_DEBUG

View File

@ -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. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #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 #ifdef _KERNEL_OPT
#include "opt_modular.h" #include "opt_modular.h"
@ -60,11 +60,11 @@ int
sys_nomodule(struct lwp *l, const void *v, register_t *retval) sys_nomodule(struct lwp *l, const void *v, register_t *retval)
{ {
#ifdef MODULAR #ifdef MODULAR
#include <kern/syscalls_autoload.c>
const struct sysent *sy; const struct sysent *sy;
const struct emul *em; 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 * Restart the syscall if we interrupted a module unload that
@ -82,21 +82,21 @@ sys_nomodule(struct lwp *l, const void *v, register_t *retval)
* works, retry the request. * works, retry the request.
*/ */
em = l->l_proc->p_emul; em = l->l_proc->p_emul;
if (em == &emul_netbsd) { code = sy - em->e_sysent;
code = sy - em->e_sysent;
for (i = 0; i < __arraycount(syscalls_autoload); i++) { if ((auto_list = em->e_sc_autoload) != NULL)
if (syscalls_autoload[i].al_code != code) { for (; auto_list->al_code > 0; auto_list++) {
if (auto_list->al_code != code) {
continue; continue;
} }
if (module_autoload(syscalls_autoload[i].al_module, if (module_autoload(auto_list->al_module,
MODULE_CLASS_ANY) != 0 || MODULE_CLASS_ANY) != 0 ||
sy->sy_call == sys_nomodule) { sy->sy_call == sys_nomodule) {
break; break;
} }
kernconfig_unlock(); kernconfig_unlock();
return ERESTART; return ERESTART;
} }
}
kernconfig_unlock(); kernconfig_unlock();
#endif /* MODULAR */ #endif /* MODULAR */

View File

@ -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 # Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
# All rights reserved. # All rights reserved.
@ -51,6 +51,7 @@ esac
# switchname the name for the 'struct sysent' we define # switchname the name for the 'struct sysent' we define
# namesname the name for the 'const char *[]' we define # namesname the name for the 'const char *[]' we define
# constprefix the prefix for the system call constants # constprefix the prefix for the system call constants
# autoloadprefix the prefix for the autoload table name
# registertype the type for register_t # registertype the type for register_t
# nsysent the size of the sysent table # nsysent the size of the sysent table
# sys_nosys [optional] name of function called for unsupported # sys_nosys [optional] name of function called for unsupported
@ -165,6 +166,7 @@ BEGIN {
switchname = \"$switchname\" switchname = \"$switchname\"
namesname = \"$namesname\" namesname = \"$namesname\"
constprefix = \"$constprefix\" constprefix = \"$constprefix\"
autoloadprefix = \"$autoloadprefix\"
registertype = \"$registertype\" registertype = \"$registertype\"
sysalign=\"$sysalign\" sysalign=\"$sysalign\"
if (!registertype) { if (!registertype) {
@ -255,10 +257,9 @@ NR == 1 {
printf " * created from%s\n */\n\n", $0 > sysautoload printf " * created from%s\n */\n\n", $0 > sysautoload
printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload printf "#include <sys/cdefs.h>\n__KERNEL_RCSID(0, \"%s\");\n\n", tag > sysautoload
printf("static struct {\n") > sysautoload printf("#include <sys/proc.h>\n") > sysautoload
printf("\tu_int\t\tal_code;\n") > sysautoload printf("static struct sc_auto " autoloadprefix \
printf("\tconst char\t*al_module;\n") > sysautoload "_syscalls_autoload[] = {\n") > sysautoload
printf("} const syscalls_autoload[] = {\n") > sysautoload
printf " * created from%s\n */\n\n", $0 > rumpcalls printf " * created from%s\n */\n\n", $0 > rumpcalls
printf "#ifdef RUMP_CLIENT\n" > rumpcalls printf "#ifdef RUMP_CLIENT\n" > rumpcalls
@ -1149,6 +1150,7 @@ END {
cat $sysprotos >> $sysarghdr cat $sysprotos >> $sysarghdr
echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr echo "#endif /* _${constprefix}SYSCALL_H_ */" >> $sysnumhdr
echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr echo "#endif /* _${constprefix}SYSCALLARGS_H_ */" >> $sysarghdr
echo "\t { 0, NULL }" >> $sysautoload
echo "};" >> $sysautoload echo "};" >> $sysautoload
printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos printf "\n#endif /* _RUMP_RUMP_SYSCALLS_H_ */\n" >> $rumpprotos
cat $sysdcl $sysent > $syssw cat $sysdcl $sysent > $syssw

View File

@ -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" sysnames="syscalls.c"
sysnumhdr="../sys/syscall.h" sysnumhdr="../sys/syscall.h"
@ -17,4 +17,5 @@ libcompatopts=""
switchname="sysent" switchname="sysent"
namesname="syscallnames" namesname="syscallnames"
constprefix="SYS_" constprefix="SYS_"
autoloadprefix="netbsd"
nsysent=512 nsysent=512

View File

@ -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 * Copyright (c) 1982, 1986, 1989, 1993
@ -67,7 +67,7 @@
* 2.99.9 (299000900) * 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) + \ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__) (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

View File

@ -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. * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -123,6 +123,14 @@ struct pgrp {
*/ */
}; };
/*
* Autoloadable syscall definition
*/
struct sc_auto {
u_int al_code;
const char *al_module;
};
/* /*
* One structure allocated per emulation. * One structure allocated per emulation.
*/ */
@ -143,6 +151,7 @@ struct emul {
struct sysent *e_sysent; /* System call array */ struct sysent *e_sysent; /* System call array */
const char * const *e_syscallnames; /* System call name array */ const char * const *e_syscallnames; /* System call name array */
/* Signal sending function */ /* Signal sending function */
struct sc_auto *e_sc_autoload; /* List of autoloadable syscalls */
void (*e_sendsig)(const struct ksiginfo *, void (*e_sendsig)(const struct ksiginfo *,
const sigset_t *); const sigset_t *);
void (*e_trapsignal)(struct lwp *, struct ksiginfo *); void (*e_trapsignal)(struct lwp *, struct ksiginfo *);