Module Name: src Committed By: pooka Date: Sun Apr 27 15:08:52 UTC 2014
Modified Files: src/sys/rump/librump/rumpkern: rump.c rump_private.h Log Message: Eliminate weak symbols from rump kernel syscall handlers, part 4: Do not query system call handlers by using the rumpuser_dl_globalsym() hypercall -- it will not work in environments which are not in control of their own symbols (e.g. rumpuser-xen). Instead, provide rump_syscall_boot_establish(), which component constructors can use to establish their non-modular syscalls. To generate a diff of this commit: cvs rdiff -u -r1.303 -r1.304 src/sys/rump/librump/rumpkern/rump.c cvs rdiff -u -r1.83 -r1.84 src/sys/rump/librump/rumpkern/rump_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.303 src/sys/rump/librump/rumpkern/rump.c:1.304 --- src/sys/rump/librump/rumpkern/rump.c:1.303 Sat Apr 26 11:17:55 2014 +++ src/sys/rump/librump/rumpkern/rump.c Sun Apr 27 15:08:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.303 2014/04/26 11:17:55 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.304 2014/04/27 15:08:52 pooka Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.303 2014/04/26 11:17:55 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.304 2014/04/27 15:08:52 pooka Exp $"); #include <sys/systm.h> #define ELFSIZE ARCH_ELFSIZE @@ -455,68 +455,11 @@ rump_init(void) if (initproc == NULL) panic("where in the world is initproc?"); - /* - * Adjust syscall vector in case factions were dlopen()'d - * before calling rump_init(). - * (modules will handle dynamic syscalls the usual way) - * - * Note: this will adjust the function vectors of - * syscalls which use a funcalias (getpid etc.), but - * it makes no difference. - */ - for (i = 0; i < SYS_NSYSENT; i++) { - void *sym; - - if (rump_sysent[i].sy_flags & SYCALL_NOSYS || - *syscallnames[i] == '#' || - rump_sysent[i].sy_call == sys_nomodule) - continue; - - /* - * deal with compat wrappers. makesyscalls.sh should - * generate the necessary info instead of this hack, - * though. ugly, fix it later. - */ -#define CPFX "compat_" -#define CPFXLEN (sizeof(CPFX)-1) - if (strncmp(syscallnames[i], CPFX, CPFXLEN) == 0) { - const char *p = syscallnames[i] + CPFXLEN; - size_t namelen; - - /* skip version number */ - while (*p >= '0' && *p <= '9') - p++; - if (p == syscallnames[i] + CPFXLEN || *p != '_') - panic("invalid syscall name %s\n", - syscallnames[i]); - - /* skip over the next underscore */ - p++; - namelen = p + (sizeof("rumpns_")-1) - syscallnames[i]; - - strcpy(buf, "rumpns_"); - strcat(buf, syscallnames[i]); - /* XXX: no strncat in the kernel */ - strcpy(buf+namelen, "sys_"); - strcat(buf, p); -#undef CPFX -#undef CPFXLEN - } else { - snprintf(buf, sizeof(buf), "rumpns_sys_%s", - syscallnames[i]); - } - if ((sym = rumpuser_dl_globalsym(buf)) != NULL - && sym != rump_sysent[i].sy_call) { -#if 0 - rumpuser_dprintf("adjusting %s: %p (old %p)\n", - syscallnames[i], sym, rump_sysent[i].sy_call); -#endif - rump_sysent[i].sy_call = sym; - } - } - rump_component_init(RUMP_COMPONENT_POSTINIT); + /* load syscalls */ + rump_component_init(RUMP_COMPONENT_SYSCALL); + /* component inits done */ bootlwp = NULL; @@ -933,6 +876,20 @@ rump_syscall(int num, void *data, size_t return rv; } +void +rump_syscall_boot_establish(const struct rump_onesyscall *calls, size_t ncall) +{ + struct sysent *callp; + size_t i; + + for (i = 0; i < ncall; i++) { + callp = rump_sysent + calls[i].ros_num; + KASSERT(bootlwp != NULL + && callp->sy_call == (sy_call_t *)enosys); + callp->sy_call = calls[i].ros_handler; + } +} + /* * Temporary notification that rumpkern_time is obsolete. This is to * be removed along with obsoleting rumpkern_time in a few months. Index: src/sys/rump/librump/rumpkern/rump_private.h diff -u src/sys/rump/librump/rumpkern/rump_private.h:1.83 src/sys/rump/librump/rumpkern/rump_private.h:1.84 --- src/sys/rump/librump/rumpkern/rump_private.h:1.83 Wed Apr 23 23:25:45 2014 +++ src/sys/rump/librump/rumpkern/rump_private.h Sun Apr 27 15:08:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_private.h,v 1.83 2014/04/23 23:25:45 pooka Exp $ */ +/* $NetBSD: rump_private.h,v 1.84 2014/04/27 15:08:52 pooka Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -63,6 +63,7 @@ enum rump_component_type { RUMP_COMPONENT_KERN, RUMP_COMPONENT_KERN_VFS, RUMP_COMPONENT_POSTINIT, + RUMP_COMPONENT_SYSCALL, RUMP__FACTION_DEV, RUMP__FACTION_VFS, @@ -147,6 +148,12 @@ void rump_unschedule_cpu_interlock(struc void rump_unschedule_cpu1(struct lwp *, void *); int rump_syscall(int, void *, size_t, register_t *); +struct rump_onesyscall { + int ros_num; + const sy_call_t *ros_handler; +}; +void rump_syscall_boot_establish(const struct rump_onesyscall *, size_t); + void rump_schedlock_cv_wait(struct rumpuser_cv *); int rump_schedlock_cv_timedwait(struct rumpuser_cv *, const struct timespec *);