Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpkern Eliminate weak symbols from rump k...



details:   https://anonhg.NetBSD.org/src/rev/70c152e5b1c3
branches:  trunk
changeset: 328987:70c152e5b1c3
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Apr 27 15:08:52 2014 +0000

description:
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.

diffstat:

 sys/rump/librump/rumpkern/rump.c         |  81 +++++++------------------------
 sys/rump/librump/rumpkern/rump_private.h |   9 +++-
 2 files changed, 27 insertions(+), 63 deletions(-)

diffs (140 lines):

diff -r 2133bac9a95a -r 70c152e5b1c3 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Sun Apr 27 15:05:30 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Sun Apr 27 15:08:52 2014 +0000
@@ -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,67 +455,10 @@
        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;
+       rump_component_init(RUMP_COMPONENT_POSTINIT);
 
-                       /* 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 @@
        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.
diff -r 2133bac9a95a -r 70c152e5b1c3 sys/rump/librump/rumpkern/rump_private.h
--- a/sys/rump/librump/rumpkern/rump_private.h  Sun Apr 27 15:05:30 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump_private.h  Sun Apr 27 15:08:52 2014 +0000
@@ -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 @@
        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_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 *);



Home | Main Index | Thread Index | Old Index