Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux/arch/i386 Split out the setup stack functio...



details:   https://anonhg.NetBSD.org/src/rev/61d917b84aa4
branches:  trunk
changeset: 571180:61d917b84aa4
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 13 06:01:34 2004 +0000

description:
Split out the setup stack function for the benefit of lkms.
XXX: Our lkm system sucks. We really need to be exporting symbols, but
that leads to symbol conflicts.

diffstat:

 sys/compat/linux/arch/i386/files.linux_i386     |    4 +-
 sys/compat/linux/arch/i386/linux_exec_machdep.c |  129 ++++++++++++++++++++++++
 2 files changed, 131 insertions(+), 2 deletions(-)

diffs (148 lines):

diff -r 46ddbca54dd2 -r 61d917b84aa4 sys/compat/linux/arch/i386/files.linux_i386
--- a/sys/compat/linux/arch/i386/files.linux_i386       Sat Nov 13 05:47:54 2004 +0000
+++ b/sys/compat/linux/arch/i386/files.linux_i386       Sat Nov 13 06:01:34 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.linux_i386,v 1.5 2002/03/31 22:40:17 christos Exp $
+#      $NetBSD: files.linux_i386,v 1.6 2004/11/13 06:01:34 christos Exp $
 #
 # Config file description for i386-dependent Linux compat code.
 
@@ -7,4 +7,4 @@
 file   compat/linux/arch/i386/linux_sysent.c           compat_linux
 file   compat/linux/arch/i386/linux_commons.c          compat_linux
 file   compat/linux/arch/i386/linux_ptrace.c           compat_linux
-
+file   compat/linux/arch/i386/linux_exec_machdep.c     compat_linux
diff -r 46ddbca54dd2 -r 61d917b84aa4 sys/compat/linux/arch/i386/linux_exec_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux/arch/i386/linux_exec_machdep.c   Sat Nov 13 06:01:34 2004 +0000
@@ -0,0 +1,129 @@
+/*     $NetBSD: linux_exec_machdep.c,v 1.1 2004/11/13 06:01:34 christos Exp $  */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_machdep.c,v 1.1 2004/11/13 06:01:34 christos Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_vm86.h"
+#include "opt_user_ldt.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/resource.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+#include <sys/vnode.h>
+#include <sys/lwp.h>
+
+#include <machine/cpu.h>
+#include <machine/vmparam.h>
+
+#include <uvm/uvm.h>
+
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_ioctl.h>
+#include <compat/linux/common/linux_hdio.h>
+#include <compat/linux/common/linux_exec.h>
+#include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_errno.h>
+
+int
+linux_exec_setup_stack(struct proc *p, struct exec_package *epp)
+{
+       u_long max_stack_size;
+       u_long access_linear_min, access_size;
+       u_long noaccess_linear_min, noaccess_size;
+
+#ifndef        USRSTACK32
+#define USRSTACK32     (0x00000000ffffffffL&~PGOFSET)
+#endif
+
+       if (epp->ep_flags & EXEC_32) {
+               epp->ep_minsaddr = USRSTACK32;
+               max_stack_size = MAXSSIZ;
+       } else {
+               epp->ep_minsaddr = USRSTACK;
+               max_stack_size = MAXSSIZ;
+       }
+
+       if (epp->ep_minsaddr > LINUX_USRSTACK)
+               epp->ep_minsaddr = LINUX_USRSTACK;
+#ifdef DEBUG_LINUX
+       else {
+               /*
+                * Someone needs to make KERNBASE and TEXTADDR
+                * java versions < 1.4.2 need the stack to be
+                * at 0xC0000000
+                */
+               uprintf("Cannot setup stack to 0xC0000000, "
+                   "java will not work properly\n");
+       }
+#endif
+       epp->ep_maxsaddr = (u_long)STACK_GROW(epp->ep_minsaddr, 
+               max_stack_size);
+       epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
+
+       /*
+        * set up commands for stack.  note that this takes *two*, one to
+        * map the part of the stack which we can access, and one to map
+        * the part which we can't.
+        *
+        * arguably, it could be made into one, but that would require the
+        * addition of another mapping proc, which is unnecessary
+        */
+       access_size = epp->ep_ssize;
+       access_linear_min = (u_long)STACK_ALLOC(epp->ep_minsaddr, access_size);
+       noaccess_size = max_stack_size - access_size;
+       noaccess_linear_min = (u_long)STACK_ALLOC(STACK_GROW(epp->ep_minsaddr, 
+           access_size), noaccess_size);
+       if (noaccess_size > 0) {
+               NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, noaccess_size,
+                   noaccess_linear_min, NULLVP, 0, VM_PROT_NONE);
+       }
+       KASSERT(access_size > 0);
+       NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, access_size,
+           access_linear_min, NULLVP, 0, VM_PROT_READ | VM_PROT_WRITE);
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index