Source-Changes-HG archive

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

[src/trunk]: src/sys many changes for COMPAT_LINUX:



details:   https://anonhg.NetBSD.org/src/rev/9ec8974bb648
branches:  trunk
changeset: 756137:9ec8974bb648
user:      chs <chs%NetBSD.org@localhost>
date:      Wed Jul 07 01:30:32 2010 +0000

description:
many changes for COMPAT_LINUX:
 - update the linux syscall table for each platform.
 - support new-style (NPTL) linux pthreads on all platforms.
   clone() with CLONE_THREAD uses 1 process with many LWPs
   instead of separate processes.
 - move the contents of sys__lwp_setprivate() into a new
   lwp_setprivate() and use that everywhere.
 - update linux_release[] and linux32_release[] to "2.6.18".
 - adjust placement of emul fork/exec/exit hooks as needed
   and adjust other emul code to match.
 - convert all struct emul definitions to use named initializers.
 - change the pid allocator to allow multiple pids to refer to the same proc.
 - remove a few fields from struct proc that are no longer needed.
 - disable the non-functional "vdso" code in linux32/amd64,
   glibc works fine without it.
 - fix a race in the futex code where we could miss a wakeup after
   a requeue operation.
 - redo futex locking to be a little more efficient.

diffstat:

 sys/arch/x86/x86/linux_trap.c                      |   57 ++-
 sys/compat/aoutm68k/aoutm68k_exec.c                |   58 +-
 sys/compat/darwin/darwin_exec.c                    |   91 ++--
 sys/compat/freebsd/freebsd_exec.c                  |   65 +-
 sys/compat/ibcs2/ibcs2_exec.c                      |   65 +-
 sys/compat/irix/irix_exec.c                        |   75 +-
 sys/compat/linux/arch/alpha/files.linux_alpha      |    3 +-
 sys/compat/linux/arch/alpha/linux_machdep.c        |    6 +-
 sys/compat/linux/arch/alpha/syscalls.master        |   84 +++-
 sys/compat/linux/arch/amd64/linux_exec_machdep.c   |   20 +-
 sys/compat/linux/arch/amd64/linux_machdep.c        |   81 +---
 sys/compat/linux/arch/amd64/linux_machdep.h        |    5 +-
 sys/compat/linux/arch/amd64/syscalls.master        |   28 +-
 sys/compat/linux/arch/arm/linux_commons.c          |    5 +-
 sys/compat/linux/arch/arm/linux_machdep.c          |    6 +-
 sys/compat/linux/arch/arm/linux_ptrace.c           |   22 +-
 sys/compat/linux/arch/arm/linux_sys_machdep.c      |   14 +-
 sys/compat/linux/arch/arm/syscalls.master          |  219 +++++-----
 sys/compat/linux/arch/i386/linux_exec_machdep.c    |  182 +--------
 sys/compat/linux/arch/i386/linux_machdep.c         |   36 +-
 sys/compat/linux/arch/i386/linux_machdep.h         |   89 +----
 sys/compat/linux/arch/i386/linux_ptrace.c          |   53 +-
 sys/compat/linux/arch/i386/syscalls.master         |   68 +--
 sys/compat/linux/arch/m68k/files.linux_m68k        |    3 +-
 sys/compat/linux/arch/m68k/linux_machdep.c         |    6 +-
 sys/compat/linux/arch/m68k/syscalls.master         |  100 ++++-
 sys/compat/linux/arch/mips/files.linux_mips        |    3 +-
 sys/compat/linux/arch/mips/linux_machdep.c         |   26 +-
 sys/compat/linux/arch/mips/syscalls.master         |   89 ++++-
 sys/compat/linux/arch/powerpc/files.linux_powerpc  |    3 +-
 sys/compat/linux/arch/powerpc/linux_exec_powerpc.c |   10 +-
 sys/compat/linux/arch/powerpc/linux_machdep.c      |   58 +--
 sys/compat/linux/arch/powerpc/syscalls.master      |   85 +++-
 sys/compat/linux/common/linux_emuldata.h           |   45 +--
 sys/compat/linux/common/linux_exec.c               |  336 +++--------------
 sys/compat/linux/common/linux_exec.h               |   15 +-
 sys/compat/linux/common/linux_futex.c              |  408 ++++++++++++++------
 sys/compat/linux/common/linux_futex.h              |    7 +-
 sys/compat/linux/common/linux_machdep.h            |   12 +-
 sys/compat/linux/common/linux_misc.c               |   27 +-
 sys/compat/linux/common/linux_misc_notalpha.c      |    8 +-
 sys/compat/linux/common/linux_sched.c              |  331 ++++++++--------
 sys/compat/linux/common/linux_signal.c             |   35 +-
 sys/compat/linux/common/linux_sysctl.c             |   13 +-
 sys/compat/linux32/arch/amd64/linux32_exec.h       |   13 +-
 sys/compat/linux32/arch/amd64/linux32_machdep.c    |  134 +++---
 sys/compat/linux32/arch/amd64/linux32_types.h      |   12 +-
 sys/compat/linux32/arch/amd64/syscalls.master      |   93 ++++-
 sys/compat/linux32/common/linux32_exec.c           |  219 +----------
 sys/compat/linux32/common/linux32_exec.h           |    7 +-
 sys/compat/linux32/common/linux32_exec_elf32.c     |  190 ++++-----
 sys/compat/linux32/common/linux32_machdep.h        |    8 +-
 sys/compat/linux32/common/linux32_misc.c           |   79 +++-
 sys/compat/linux32/common/linux32_mod.c            |    8 +-
 sys/compat/linux32/common/linux32_sched.c          |  127 +++++-
 sys/compat/linux32/common/linux32_sysctl.c         |    8 +-
 sys/compat/linux32/common/linux32_time.c           |   14 +-
 sys/compat/linux32/common/linux32_types.h          |   10 +-
 sys/compat/mach/mach_exec.c                        |   92 ++--
 sys/compat/mach/mach_exec.h                        |    8 +-
 sys/compat/osf1/osf1_exec.c                        |   61 +-
 sys/compat/pecoff/pecoff_emul.c                    |   73 +--
 sys/compat/sunos/sunos_exec.c                      |   61 +-
 sys/compat/sunos32/sunos32_exec.c                  |   65 +-
 sys/compat/svr4/svr4_exec.c                        |   66 +-
 sys/compat/svr4_32/svr4_32_exec.c                  |   66 +-
 sys/compat/ultrix/ultrix_misc.c                    |   69 +-
 sys/kern/kern_exec.c                               |   16 +-
 sys/kern/kern_exit.c                               |    6 +-
 sys/kern/kern_fork.c                               |   35 +-
 sys/kern/kern_lwp.c                                |   57 +-
 sys/kern/kern_proc.c                               |   80 ++-
 sys/kern/sys_lwp.c                                 |   11 +-
 sys/sys/lwp.h                                      |   10 +-
 sys/sys/proc.h                                     |    9 +-
 75 files changed, 2317 insertions(+), 2342 deletions(-)

diffs (truncated from 8069 to 300 lines):

diff -r a2c204095e49 -r 9ec8974bb648 sys/arch/x86/x86/linux_trap.c
--- a/sys/arch/x86/x86/linux_trap.c     Wed Jul 07 01:24:52 2010 +0000
+++ b/sys/arch/x86/x86/linux_trap.c     Wed Jul 07 01:30:32 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_trap.c,v 1.9 2010/01/13 15:31:47 njoly Exp $     */
+/*     $NetBSD: linux_trap.c,v 1.10 2010/07/07 01:30:32 chs Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,11 +30,11 @@
  */
 
 /*
- * 386 Trap and System call handling
+ * x86 Trap and System call handling
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.9 2010/01/13 15:31:47 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.10 2010/07/07 01:30:32 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,6 +58,24 @@
 
 #include <compat/linux/common/linux_exec.h>
 
+#ifndef DEBUG_LINUX
+#define DPRINTF(a)
+#else
+#define DPRINTF(a)     uprintf a
+#endif
+
+struct linux_user_desc {
+       unsigned int            entry_number;
+       unsigned int            base_addr;
+       unsigned int            limit;
+       unsigned int            seg_32bit:1;
+       unsigned int            contents:2;
+       unsigned int            read_exec_only:1;
+       unsigned int            limit_in_pages:1;
+       unsigned int            seg_not_present:1;
+       unsigned int            useable:1;
+};
+
 #define LINUX_T_DIVIDE                 0
 #define LINUX_T_DEBUG                  1
 #define LINUX_T_NMI                    2
@@ -128,6 +146,7 @@
 void
 linux_trapsignal(struct lwp *l, ksiginfo_t *ksi)
 {
+       ksiginfo_t nksi;
 
        switch (ksi->ksi_signo) {
        case SIGILL:
@@ -138,7 +157,7 @@
        case SIGSEGV:
                KASSERT(KSI_TRAP_P(ksi));
                if (ksi->ksi_trap < __arraycount(trapno_to_x86_vec)) {
-                       ksiginfo_t nksi = *ksi;
+                       nksi = *ksi;
                        nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap];
                        if (nksi.ksi_trap < __arraycount(linux_x86_vec_to_sig)) {
                                nksi.ksi_signo 
@@ -152,8 +171,38 @@
                        uprintf("Unhandled trap type %d\n", ksi->ksi_trap);
                }
                /*FALLTHROUGH*/
+
        default:
                trapsignal(l, ksi);
                return;
        }
 }
+
+int
+linux_lwp_setprivate(struct lwp *l, void *ptr)
+{
+       struct linux_user_desc info;
+       int error;
+
+#ifdef __x86_64__
+       if ((l->l_proc->p_flag & PK_32) == 0) {
+               return lwp_setprivate(l, ptr);
+       }
+#endif
+       error = copyin(ptr, &info, sizeof(info));
+       if (error)
+               return error;
+
+       DPRINTF(("linux_lwp_setprivate: %i, %x, %x, %i, %i, %i, %i, %i, %i\n",
+           info.entry_number, info.base_addr, info.limit, info.seg_32bit,
+           info.contents, info.read_exec_only, info.limit_in_pages,
+           info.seg_not_present, info.useable));
+
+       if (info.entry_number != GUGS_SEL) {
+               info.entry_number = GUGS_SEL;
+               error = copyout(&info, ptr, sizeof(info));
+               if (error)
+                       return error;
+       }
+       return lwp_setprivate(l, (void *)(uintptr_t)info.base_addr);
+}
diff -r a2c204095e49 -r 9ec8974bb648 sys/compat/aoutm68k/aoutm68k_exec.c
--- a/sys/compat/aoutm68k/aoutm68k_exec.c       Wed Jul 07 01:24:52 2010 +0000
+++ b/sys/compat/aoutm68k/aoutm68k_exec.c       Wed Jul 07 01:30:32 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aoutm68k_exec.c,v 1.24 2009/06/02 23:21:38 pooka Exp $ */
+/*     $NetBSD: aoutm68k_exec.c,v 1.25 2010/07/07 01:30:32 chs Exp $   */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aoutm68k_exec.c,v 1.24 2009/06/02 23:21:38 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aoutm68k_exec.c,v 1.25 2010/07/07 01:30:32 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_syscall_debug.h"
@@ -55,34 +55,36 @@
 struct uvm_object *emul_netbsd_aoutm68k_object;
 
 struct emul emul_netbsd_aoutm68k = {
-       "aoutm68k",
-       "/emul/aout",
+       .e_name =               "aoutm68k",
+       .e_path =               "/emul/aoutm68k",
 #ifndef __HAVE_MINIMAL_EMUL
-       EMUL_HAS_SYS___syscall,
-       NULL,
-       AOUTM68K_SYS_syscall,
-       AOUTM68K_SYS_NSYSENT,
+       .e_flags =              EMUL_HAS_SYS___syscall,
+       .e_errno =              NULL,
+       .e_nosys =              AOUTM68K_SYS_syscall,
+       .e_nsysent =            AOUTM68K_SYS_NSYSENT,
 #endif
-       aoutm68k_sysent,
+       .e_sysent =             aoutm68k_sysent,
 #ifdef SYSCALL_DEBUG
-       syscallnames,
-#else
-       NULL,
+       .e_syscallnames =       syscallnames,
 #endif
-       sendsig,
-       trapsignal,
-       NULL,
-       sigcode,
-       esigcode,
-       &emul_netbsd_aoutm68k_object,
-       setregs,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       aoutm68k_syscall_intern,
-       NULL,
-       NULL,
-       uvm_default_mapaddr,
+       .e_sendsig =            sendsig,
+       .e_trapsignal =         trapsignal,
+       .e_tracesig =           NULL,
+       .e_sigcode =            sigcode,
+       .e_esigcode =           esigcode,
+       .e_sigobject =          &emul_netbsd_aoutm68k_object,
+       .e_setregs =            setregs,
+       .e_proc_exec =          NULL,
+       .e_proc_fork =          NULL,
+       .e_proc_exit =          NULL,
+       .e_lwp_fork =           NULL,
+       .e_lwp_exit =           NULL,
+       .e_syscall_intern =     aoutm68k_syscall_intern,
+       .e_sysctlovly =         NULL,
+       .e_fault =              NULL,
+       .e_vm_default_addr =    uvm_default_mapaddr,
+       .e_usertrap =           NULL,
+       .e_sa =                 NULL,
+       .e_ucsize =             0,
+       .e_startlwp =           NULL
 };
diff -r a2c204095e49 -r 9ec8974bb648 sys/compat/darwin/darwin_exec.c
--- a/sys/compat/darwin/darwin_exec.c   Wed Jul 07 01:24:52 2010 +0000
+++ b/sys/compat/darwin/darwin_exec.c   Wed Jul 07 01:30:32 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_exec.c,v 1.60 2010/01/05 13:22:40 mbalmer Exp $ */
+/*     $NetBSD: darwin_exec.c,v 1.61 2010/07/07 01:30:32 chs Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "opt_compat_darwin.h" /* For COMPAT_DARWIN in mach_port.h */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.60 2010/01/05 13:22:40 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.61 2010/07/07 01:30:32 chs Exp $");
 
 #include "opt_syscall_debug.h"
 #include "wsdisplay.h"
@@ -76,9 +76,9 @@
 #endif
 
 static void darwin_e_proc_exec(struct proc *, struct exec_package *);
-static void darwin_e_proc_fork(struct proc *, struct proc *, int);
+static void darwin_e_proc_fork(struct proc *, struct lwp *, int);
 static void darwin_e_proc_exit(struct proc *);
-static void darwin_e_proc_init(struct proc *, struct vmspace *);
+static void darwin_e_proc_init(struct proc *);
 
 extern struct sysent darwin_sysent[];
 #ifdef SYSCALL_DEBUG
@@ -91,45 +91,42 @@
 #endif
 
 struct emul emul_darwin = {
-       "darwin",
-       "/emul/darwin",
+       .e_name =               "darwin",
+       .e_path =               "/emul/darwin",
 #ifndef __HAVE_MINIMAL_EMUL
-       0,
-       0,
-       DARWIN_SYS_syscall,
-       DARWIN_SYS_NSYSENT,
+       .e_flags =              0,
+       .e_errno =              NULL
+       .e_nosys =              DARWIN_SYS_syscall,
+       .e_nsysent =            DARWIN_SYS_NSYSENT,
 #endif
-       darwin_sysent,
+       .e_sysent =             darwin_sysent,
 #ifdef SYSCALL_DEBUG
-       darwin_syscallnames,
-#else
-       NULL,
+       .e_syscallnames =       darwin_syscallnames,
 #endif
-       darwin_sendsig,
-       darwin_trapsignal,
-       darwin_tracesig,
-       NULL,
-       NULL,
-       NULL,
-       setregs,
-       darwin_e_proc_exec,
-       darwin_e_proc_fork,
-       darwin_e_proc_exit,
-       mach_e_lwp_fork,
-       mach_e_lwp_exit,
+       .e_sendsig =            darwin_sendsig,
+       .e_trapsignal =         darwin_trapsignal,
+       .e_tracesig =           darwin_tracesig,
+       .e_sigcode =            NULL,
+       .e_esigcode =           NULL,
+       .e_sigobject =          NULL,
+       .e_setregs =            setregs,
+       .e_proc_exec =          darwin_e_proc_exec,
+       .e_proc_fork =          darwin_e_proc_fork,
+       .e_proc_exit =          darwin_e_proc_exit,
+       .e_lwp_fork =           mach_e_lwp_fork,
+       .e_lwp_exit =           mach_e_lwp_exit,
 #ifdef __HAVE_SYSCALL_INTERN
-       mach_syscall_intern,
+       .e_syscall_intern =     mach_syscall_intern,
 #else
-       syscall,
+       .e_syscall_intern =     syscall,
 #endif
-       NULL,
-       NULL,
-
-       uvm_default_mapaddr,
-       NULL,
-       NULL,
-       0,
-       NULL,
+       .e_sysctlovly =         NULL,
+       .e_fault =              NULL,
+       .e_vm_default_addr =    uvm_default_mapaddr,
+       .e_usertrap =           NULL,
+       .e_sa =                 NULL,
+       .e_ucsize =             0,
+       .e_startlwp =           NULL
 };
 
 /*
@@ -229,7 +226,7 @@
 {
        struct darwin_emuldata *ded;
 
-       darwin_e_proc_init(p, p->p_vmspace);
+       darwin_e_proc_init(p);
 
        /* Setup the mach_emuldata part of darwin_emuldata */
        mach_e_proc_exec(p, epp);
@@ -245,27 +242,25 @@



Home | Main Index | Thread Index | Old Index