Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
  that will return the default VM map address. The default function
  is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
  macro. This gives emulations control over the default map address,
  and allows things to be mapped at the right address (in 32bit range)
  for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
  or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
  instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
This commit is contained in:
fvdl 2005-03-26 05:12:34 +00:00
parent 049130f10b
commit c487efe4a7
32 changed files with 262 additions and 68 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.11 2004/09/17 14:11:21 skrll Exp $ */
/* $NetBSD: netbsd32_machdep.c,v 1.12 2005/03/26 05:12:34 fvdl Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.11 2004/09/17 14:11:21 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.12 2005/03/26 05:12:34 fvdl Exp $");
#include "opt_compat_netbsd.h"
#include "opt_execfmt.h"
@ -124,6 +124,8 @@ netbsd32_setregs(struct lwp *l, struct exec_package *pack, u_long stack)
pmap_ldt_cleanup(p);
#endif
netbsd32_adjust_limits(p);
l->l_md.md_flags &= ~MDP_USEDFPU;
pcb->pcb_flags = 0;
pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__;
@ -870,3 +872,9 @@ check_mcontext32(const mcontext32_t *mcp, struct trapframe *tf)
return EINVAL;
return 0;
}
vaddr_t
netbsd32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t size)
{
return round_page((vaddr_t)(base) + (vsize_t)MAXDSIZ32);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmparam.h,v 1.7 2005/02/11 11:01:10 ws Exp $ */
/* $NetBSD: vmparam.h,v 1.8 2005/03/26 05:12:34 fvdl Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -80,6 +80,24 @@
#define MAXSSIZ (32*1024*1024) /* max stack size */
#endif
/*
* 32bit memory related constants.
*/
#define MAXTSIZ32 (64*1024*1024)
#ifndef DFLDSIZ32
#define DFLDSIZ32 (256*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ32
#define MAXDSIZ32 (2L*1024*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 (2*1024*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 (32*1024*1024) /* max stack size */
#endif
/*
* Size of shared memory map
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmparam.h,v 1.26 2003/10/21 12:08:11 kleink Exp $ */
/* $NetBSD: vmparam.h,v 1.27 2005/03/26 05:12:34 fvdl Exp $ */
/*
* Copyright (c) 1992, 1993
@ -120,6 +120,26 @@
#define MAXSSIZ (8*1024*1024) /* max stack size */
#endif
#endif
/*
* 32-bit emulation limits.
*/
#ifndef MAXTSIZ32
#define MAXTSIZ32 (1*1024*1024*1024) /* max text size */
#endif
#ifndef DFLDSIZ32
#define DFLDSIZ32 (128*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ32
#define MAXDSIZ32 (1*1024*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 (2*1024*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 (8*1024*1024) /* max stack size */
#endif
/*
* Size of shared memory map
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.44 2004/11/08 17:05:37 kleink Exp $ */
/* $NetBSD: netbsd32_machdep.c,v 1.45 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.44 2004/11/08 17:05:37 kleink Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.45 2005/03/26 05:12:35 fvdl Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -106,6 +106,8 @@ netbsd32_setregs(struct lwp *l, struct exec_package *pack, u_long stack)
/* Mark this as a 32-bit emulation */
p->p_flag |= P_32;
netbsd32_adjust_limits(p);
/* Setup the ev_out32 hook */
#if NFIRM_EVENTS > 0
if (ev_out32_hook == NULL)
@ -1262,3 +1264,9 @@ cpu_getmcontext32(struct lwp *l, mcontext32_t *mcp, unsigned int *flags)
mcp->__fpregs.__fpu_en = 0;
}
}
vaddr_t
netbsd32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t size)
{
return round_page((vaddr_t)(base) + (vsize_t)MAXDSIZ32);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_machdep.c,v 1.19 2005/03/12 16:29:59 dsl Exp $ */
/* $NetBSD: svr4_32_machdep.c,v 1.20 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.19 2005/03/12 16:29:59 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.20 2005/03/26 05:12:35 fvdl Exp $");
#ifndef _LKM
#include "opt_ddb.h"
@ -61,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.19 2005/03/12 16:29:59 dsl Exp
#include <sys/exec_elf.h>
#include <sys/types.h>
#include <uvm/uvm_param.h>
#include <compat/svr4_32/svr4_32_types.h>
#include <compat/svr4_32/svr4_32_lwp.h>
#include <compat/svr4_32/svr4_32_ucontext.h>
@ -687,3 +689,9 @@ svr4_32_sys_sysarch(l, v, retval)
return EINVAL;
}
}
vaddr_t
svr4_32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t size)
{
return round_page((vaddr_t)(base) + (vsize_t)MAXDSIZ32);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: aoutm68k_exec.c,v 1.18 2004/09/12 11:09:32 jdolecek Exp $ */
/* $NetBSD: aoutm68k_exec.c,v 1.19 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: aoutm68k_exec.c,v 1.18 2004/09/12 11:09:32 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: aoutm68k_exec.c,v 1.19 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -50,6 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: aoutm68k_exec.c,v 1.18 2004/09/12 11:09:32 jdolecek
#include <sys/exec.h>
#include <sys/signalvar.h>
#include <uvm/uvm_extern.h>
#include <compat/aoutm68k/aoutm68k_syscall.h>
extern struct sysent aoutm68k_sysent[];
@ -91,4 +93,5 @@ const struct emul emul_netbsd_aoutm68k = {
aoutm68k_syscall_intern,
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_exec.c,v 1.39 2005/02/26 23:10:18 perry Exp $ */
/* $NetBSD: darwin_exec.c,v 1.40 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -38,7 +38,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.39 2005/02/26 23:10:18 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_exec.c,v 1.40 2005/03/26 05:12:35 fvdl Exp $");
#include "opt_syscall_debug.h"
@ -125,6 +125,9 @@ const struct emul emul_darwin = {
syscall,
#endif
NULL,
NULL,
uvm_default_mapaddr,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_exec.c,v 1.26 2004/09/12 10:38:25 jdolecek Exp $ */
/* $NetBSD: freebsd_exec.c,v 1.27 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1993, 1994 Christopher G. Demetriou
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_exec.c,v 1.26 2004/09/12 10:38:25 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: freebsd_exec.c,v 1.27 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: freebsd_exec.c,v 1.26 2004/09/12 10:38:25 jdolecek E
#include <sys/proc.h>
#include <machine/freebsd_machdep.h>
#include <uvm/uvm_extern.h>
#include <compat/freebsd/freebsd_syscall.h>
#include <compat/freebsd/freebsd_exec.h>
#include <compat/freebsd/freebsd_signal.h>
@ -91,4 +93,6 @@ const struct emul emul_freebsd = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_exec.c,v 1.45 2005/02/26 23:10:18 perry Exp $ */
/* $NetBSD: hpux_exec.c,v 1.46 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hpux_exec.c,v 1.45 2005/02/26 23:10:18 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: hpux_exec.c,v 1.46 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -90,6 +90,8 @@ __KERNEL_RCSID(0, "$NetBSD: hpux_exec.c,v 1.45 2005/02/26 23:10:18 perry Exp $")
#include <sys/mman.h>
#include <sys/stat.h>
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
#include <machine/reg.h>
@ -149,6 +151,8 @@ const struct emul emul_hpux = {
#endif
NULL,
NULL,
uvm_map_defaultaddr,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibcs2_exec.c,v 1.62 2005/03/03 04:39:37 christos Exp $ */
/* $NetBSD: ibcs2_exec.c,v 1.63 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1994, 1995, 1998 Scott Bartram
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec.c,v 1.62 2005/03/03 04:39:37 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec.c,v 1.63 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -51,6 +51,8 @@ __KERNEL_RCSID(0, "$NetBSD: ibcs2_exec.c,v 1.62 2005/03/03 04:39:37 christos Exp
#include <sys/mount.h>
#include <sys/exec.h>
#include <uvm/uvm_extern.h>
#include <machine/ibcs2_machdep.h>
#include <compat/ibcs2/ibcs2_types.h>
@ -108,6 +110,8 @@ const struct emul emul_ibcs2 = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_exec.c,v 1.40 2005/02/26 23:10:18 perry Exp $ */
/* $NetBSD: irix_exec.c,v 1.41 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.40 2005/02/26 23:10:18 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.41 2005/03/26 05:12:35 fvdl Exp $");
#ifdef _KERNEL_OPT
#include "opt_syscall_debug.h"
@ -121,6 +121,8 @@ const struct emul emul_irix = {
#endif
NULL,
irix_vm_fault,
uvm_default_mapaddr,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_exec.c,v 1.72 2004/08/08 19:52:37 jdolecek Exp $ */
/* $NetBSD: linux_exec.c,v 1.73 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1994, 1995, 1998, 2000 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.72 2004/08/08 19:52:37 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.73 2005/03/26 05:12:35 fvdl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_exec.c,v 1.72 2004/08/08 19:52:37 jdolecek Exp
#include <sys/sa.h>
#include <sys/syscallargs.h>
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
#include <machine/reg.h>
@ -144,6 +146,8 @@ const struct emul emul_linux = {
#endif
NULL,
NULL,
uvm_map_defaultaddr,
};
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_exec.c,v 1.55 2005/02/26 23:10:19 perry Exp $ */
/* $NetBSD: mach_exec.c,v 1.56 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 2001-2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.55 2005/02/26 23:10:19 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.56 2005/03/26 05:12:35 fvdl Exp $");
#include "opt_syscall_debug.h"
@ -119,6 +119,8 @@ const struct emul emul_mach = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32.h,v 1.30 2005/02/26 23:10:21 perry Exp $ */
/* $NetBSD: netbsd32.h,v 1.31 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -589,6 +589,9 @@ int coredump_netbsd32(struct lwp *, struct vnode *, struct ucred *);
void netbsd32_from_stat43 __P((struct stat43 *, struct netbsd32_stat43 *));
int netbsd32_execve2(struct lwp *, struct sys_execve_args *, register_t *);
vaddr_t netbsd32_vm_default_addr(struct proc *, vaddr_t, vsize_t);
void netbsd32_adjust_limits(struct proc *);
#ifdef SYSCTL_SETUP_PROTO
SYSCTL_SETUP_PROTO(netbsd32_sysctl_emul_setup);
#endif /* SYSCTL_SETUP_PROTO */

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_netbsd.c,v 1.87 2005/02/26 23:10:21 perry Exp $ */
/* $NetBSD: netbsd32_netbsd.c,v 1.88 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.87 2005/02/26 23:10:21 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.88 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
@ -154,6 +154,8 @@ const struct emul emul_netbsd32 = {
#endif
&netbsd32_sysctl_root,
NULL,
netbsd32_vm_default_addr,
};
/*
@ -1692,6 +1694,24 @@ netbsd32_setrlimit(l, v, retval)
sizeof(struct rlimit));
if (error)
return (error);
switch (which) {
case RLIMIT_DATA:
if (alim.rlim_cur > MAXDSIZ32)
alim.rlim_cur = MAXDSIZ32;
if (alim.rlim_max > MAXDSIZ32)
alim.rlim_max = MAXDSIZ32;
break;
case RLIMIT_STACK:
if (alim.rlim_cur > MAXSSIZ32)
alim.rlim_cur = MAXSSIZ32;
if (alim.rlim_max > MAXSSIZ32)
alim.rlim_max = MAXSSIZ32;
default:
break;
}
return (dosetrlimit(p, p->p_cred, which, &alim));
}
@ -2233,3 +2253,22 @@ netbsd32_ovadvise(l, v, retval)
return (sys_ovadvise(l, &ua, retval));
}
void
netbsd32_adjust_limits(struct proc *p)
{
rlim_t *valp;
valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
*valp = MAXDSIZ32;
valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
*valp = MAXDSIZ32;
valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
*valp = MAXSSIZ32;
valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
*valp = MAXSSIZ32;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_exec.c,v 1.38 2005/01/16 20:01:48 drochner Exp $ */
/* $NetBSD: osf1_exec.c,v 1.39 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: osf1_exec.c,v 1.38 2005/01/16 20:01:48 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: osf1_exec.c,v 1.39 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -43,6 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: osf1_exec.c,v 1.38 2005/01/16 20:01:48 drochner Exp
#include <sys/signalvar.h>
#include <sys/exec.h>
#include <uvm/uvm_extern.h>
#include <compat/osf1/osf1.h>
#include <compat/osf1/osf1_syscall.h>
#include <compat/osf1/osf1_cvt.h>
@ -92,4 +94,6 @@ const struct emul emul_osf1 = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: pecoff_emul.c,v 1.10 2003/12/20 19:01:30 fvdl Exp $ */
/* $NetBSD: pecoff_emul.c,v 1.11 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 2000 Masaru OKI
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pecoff_emul.c,v 1.10 2003/12/20 19:01:30 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: pecoff_emul.c,v 1.11 2005/03/26 05:12:35 fvdl Exp $");
/*#define DEBUG_PECOFF*/
@ -57,6 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: pecoff_emul.c,v 1.10 2003/12/20 19:01:30 fvdl Exp $"
#include <sys/resourcevar.h>
#include <sys/stat.h>
#include <uvm/uvm_extern.h>
#include <sys/exec_coff.h>
#include <machine/coff_machdep.h>
@ -111,4 +113,6 @@ const struct emul emul_pecoff = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos_exec.c,v 1.46 2005/02/26 23:10:21 perry Exp $ */
/* $NetBSD: sunos_exec.c,v 1.47 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 1993 Theo de Raadt
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos_exec.c,v 1.46 2005/02/26 23:10:21 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos_exec.c,v 1.47 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: sunos_exec.c,v 1.46 2005/02/26 23:10:21 perry Exp $"
#include <sys/vnode.h>
#include <sys/exec.h>
#include <uvm/uvm_extern.h>
#include <compat/sunos/sunos.h>
#include <compat/sunos/sunos_syscall.h>
@ -93,4 +95,6 @@ const struct emul emul_sunos = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos32_exec.c,v 1.19 2003/12/20 19:01:30 fvdl Exp $ */
/* $NetBSD: sunos32_exec.c,v 1.20 2005/03/26 05:12:35 fvdl Exp $ */
/*
* Copyright (c) 2001 Matthew R. Green
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sunos32_exec.c,v 1.19 2003/12/20 19:01:30 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sunos32_exec.c,v 1.20 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -39,6 +39,8 @@ __KERNEL_RCSID(0, "$NetBSD: sunos32_exec.c,v 1.19 2003/12/20 19:01:30 fvdl Exp $
#include <sys/proc.h>
#include <sys/mount.h>
#include <uvm/uvm_extern.h>
#include <compat/sunos32/sunos32.h>
#include <compat/sunos32/sunos32_syscall.h>
#include <compat/sunos32/sunos32_exec.h>
@ -83,4 +85,5 @@ const struct emul emul_sunos = {
syscall,
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_exec.c,v 1.55 2004/09/12 10:38:25 jdolecek Exp $ */
/* $NetBSD: svr4_exec.c,v 1.56 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1994, 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_exec.c,v 1.55 2004/09/12 10:38:25 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_exec.c,v 1.56 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_exec.c,v 1.55 2004/09/12 10:38:25 jdolecek Exp
#include <sys/systm.h>
#include <sys/proc.h>
#include <uvm/uvm_extern.h>
#include <machine/svr4_machdep.h>
#include <compat/svr4/svr4_types.h>
@ -98,4 +100,6 @@ const struct emul emul_svr4 = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_exec.c,v 1.15 2004/09/12 10:38:26 jdolecek Exp $ */
/* $NetBSD: svr4_32_exec.c,v 1.16 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1994, 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_exec.c,v 1.15 2004/09/12 10:38:26 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_exec.c,v 1.16 2005/03/26 05:12:35 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@ -49,6 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_exec.c,v 1.15 2004/09/12 10:38:26 jdolecek E
#include <sys/systm.h>
#include <sys/proc.h>
#include <uvm/uvm_extern.h>
#include <machine/svr4_machdep.h>
#include <compat/svr4_32/svr4_32_types.h>
@ -100,4 +102,6 @@ const struct emul emul_svr4_32 = {
#endif
NULL,
NULL,
svr4_32_vm_default_addr,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_exec.h,v 1.8 2003/10/31 14:04:36 drochner Exp $ */
/* $NetBSD: svr4_32_exec.h,v 1.9 2005/03/26 05:12:35 fvdl Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -70,6 +70,7 @@ int svr4_32_copyargs __P((struct proc *, struct exec_package *, struct ps_string
extern const struct emul emul_svr4_32;
void svr4_32_setregs __P((struct lwp *, struct exec_package *, u_long));
vaddr_t svr4_32_vm_default_addr(struct proc *, vaddr_t, vsize_t);
int svr4_32_elf32_probe __P((struct proc *, struct exec_package *, void *,
char *, vaddr_t *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_resource.c,v 1.4 2005/02/26 23:10:21 perry Exp $ */
/* $NetBSD: svr4_32_resource.c,v 1.5 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_resource.c,v 1.4 2005/02/26 23:10:21 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_resource.c,v 1.5 2005/03/26 05:12:36 fvdl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: svr4_32_resource.c,v 1.4 2005/02/26 23:10:21 perry E
#include <sys/resource.h>
#include <sys/resourcevar.h>
#include <machine/vmparam.h>
#include <compat/svr4_32/svr4_32_types.h>
#include <compat/svr4_32/svr4_32_resource.h>
#include <compat/svr4_32/svr4_32_signal.h>
@ -138,6 +140,23 @@ svr4_32_sys_getrlimit(l, v, retval)
else
slim.rlim_cur = SVR4_RLIM_SAVED_CUR;
switch (rl) {
case RLIMIT_DATA:
if (blim.rlim_cur > MAXDSIZ32)
blim.rlim_cur = MAXDSIZ32;
if (blim.rlim_max > MAXDSIZ32)
blim.rlim_max = MAXDSIZ32;
break;
case RLIMIT_STACK:
if (blim.rlim_cur > MAXSSIZ32)
blim.rlim_cur = MAXSSIZ32;
if (blim.rlim_max > MAXSSIZ32)
blim.rlim_max = MAXSSIZ32;
default:
break;
}
return copyout(&slim, (caddr_t)(u_long)SCARG(uap, rlp), sizeof(slim));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ultrix_misc.c,v 1.98 2005/02/26 23:10:22 perry Exp $ */
/* $NetBSD: ultrix_misc.c,v 1.99 2005/03/26 05:12:36 fvdl Exp $ */
/*
* Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.98 2005/02/26 23:10:22 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.99 2005/03/26 05:12:36 fvdl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfsserver.h"
@ -124,6 +124,8 @@ __KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.98 2005/02/26 23:10:22 perry Exp $
#include <sys/sa.h>
#include <sys/syscallargs.h>
#include <uvm/uvm_extern.h>
#include <compat/ultrix/ultrix_syscall.h>
#include <compat/ultrix/ultrix_syscallargs.h>
#include <compat/common/compat_util.h>
@ -193,6 +195,8 @@ const struct emul emul_ultrix = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};
#define GSI_PROG_ENV 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf32.c,v 1.102 2005/03/02 11:05:34 mycroft Exp $ */
/* $NetBSD: exec_elf32.c,v 1.103 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: exec_elf32.c,v 1.102 2005/03/02 11:05:34 mycroft Exp $");
__KERNEL_RCSID(1, "$NetBSD: exec_elf32.c,v 1.103 2005/03/26 05:12:36 fvdl Exp $");
/* If not included by exec_elf64.c, ELFSIZE won't be defined. */
#ifndef ELFSIZE
@ -423,7 +423,8 @@ ELFNAME(load_file)(struct proc *p, struct exec_package *epp, char *path,
/*
* Now compute the size and load address.
*/
addr = VM_DEFAULT_ADDRESS(epp->ep_daddr,
addr = (*epp->ep_esch->es_emul->e_vm_default_addr)(p,
epp->ep_daddr,
round_page(limit) - trunc_page(base_ph->p_vaddr));
} else
addr = *last; /* may be ELF_LINK_ADDR */

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.194 2005/02/18 00:21:37 peter Exp $ */
/* $NetBSD: kern_exec.c,v 1.195 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.194 2005/02/18 00:21:37 peter Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.195 2005/03/26 05:12:36 fvdl Exp $");
#include "opt_ktrace.h"
#include "opt_syscall_debug.h"
@ -176,6 +176,8 @@ const struct emul emul_netbsd = {
#endif
NULL,
NULL,
uvm_default_mapaddr,
};
#ifdef LKM
@ -1330,7 +1332,8 @@ exec_sigcode_map(struct proc *p, const struct emul *e)
}
/* Just a hint to uvm_map where to put it. */
va = VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, round_page(sz));
va = e->e_vm_default_addr(p, (vaddr_t)p->p_vmspace->vm_daddr,
round_page(sz));
#ifdef __alpha__
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_resource.c,v 1.90 2005/03/23 04:01:04 christos Exp $ */
/* $NetBSD: kern_resource.c,v 1.91 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.90 2005/03/23 04:01:04 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.91 2005/03/26 05:12:36 fvdl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -328,11 +328,13 @@ dosetrlimit(p, cred, which, limp)
if (limp->rlim_cur > alimp->rlim_cur) {
prot = VM_PROT_READ | VM_PROT_WRITE;
size = limp->rlim_cur - alimp->rlim_cur;
addr = USRSTACK - limp->rlim_cur;
addr = (vaddr_t)p->p_vmspace->vm_minsaddr -
limp->rlim_cur;
} else {
prot = VM_PROT_NONE;
size = alimp->rlim_cur - limp->rlim_cur;
addr = USRSTACK - alimp->rlim_cur;
addr = (vaddr_t)p->p_vmspace->vm_minsaddr -
alimp->rlim_cur;
}
(void) uvm_map_protect(&p->p_vmspace->vm_map,
addr, addr+size, prot, FALSE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_shm.c,v 1.82 2004/10/17 11:24:42 jdolecek Exp $ */
/* $NetBSD: sysv_shm.c,v 1.83 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.82 2004/10/17 11:24:42 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.83 2005/03/26 05:12:36 fvdl Exp $");
#define SYSVSHM
@ -358,7 +358,8 @@ sys_shmat(l, v, retval)
return EINVAL;
} else {
/* This is just a hint to uvm_mmap() about where to put it. */
attach_va = VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, size);
attach_va = p->p_emul->e_vm_default_addr(p,
(vaddr_t)p->p_vmspace->vm_daddr, size);
}
uobj = shmseg->_shm_internal;
(*uobj->pgops->pgo_reference)(uobj);

View File

@ -1,4 +1,4 @@
/* $NetBSD: param.h,v 1.212 2005/03/17 00:22:34 jmc Exp $ */
/* $NetBSD: param.h,v 1.213 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -63,7 +63,7 @@
* 2.99.9 (299000900)
*/
#define __NetBSD_Version__ 399000100 /* NetBSD 3.99.1 */
#define __NetBSD_Version__ 399000200 /* NetBSD 3.99.1 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) >= __NetBSD_Version__)

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.197 2005/02/26 22:25:34 perry Exp $ */
/* $NetBSD: proc.h,v 1.198 2005/03/26 05:12:36 fvdl Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -126,6 +126,8 @@ struct emul {
/* Emulation specific sysctl data */
struct sysctlnode *e_sysctlovly;
int (*e_fault)(struct proc *, vaddr_t, int, int);
vaddr_t (*e_vm_default_addr)(struct proc *, vaddr_t, vsize_t);
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_extern.h,v 1.98 2005/01/13 11:50:32 yamt Exp $ */
/* $NetBSD: uvm_extern.h,v 1.99 2005/03/26 05:12:36 fvdl Exp $ */
/*
*
@ -687,6 +687,7 @@ int uvm_sysctl(int *, u_int, void *, size_t *,
int uvm_mmap(struct vm_map *, vaddr_t *, vsize_t,
vm_prot_t, vm_prot_t, int,
void *, voff_t, vsize_t);
vaddr_t uvm_default_mapaddr(struct proc *, vaddr_t, vsize_t);
/* uvm_page.c */
struct vm_page *uvm_pagealloc_strat(struct uvm_object *,

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_mmap.c,v 1.88 2005/02/11 02:12:03 chs Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.89 2005/03/26 05:12:36 fvdl Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.88 2005/02/11 02:12:03 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.89 2005/03/26 05:12:36 fvdl Exp $");
#include "opt_compat_netbsd.h"
@ -297,7 +297,7 @@ sys_mmap(l, v, retval)
vsize_t size, pageoff;
vm_prot_t prot, maxprot;
int flags, fd;
vaddr_t vm_min_address = VM_MIN_ADDRESS;
vaddr_t vm_min_address = VM_MIN_ADDRESS, defaddr;
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct vnode *vp;
@ -363,13 +363,14 @@ sys_mmap(l, v, retval)
* VAC, etc)
*/
defaddr = p->p_emul->e_vm_default_addr(p,
(vaddr_t)p->p_vmspace->vm_daddr, size);
if (addr == 0 ||
!(p->p_vmspace->vm_map.flags & VM_MAP_TOPDOWN))
addr = MAX(addr,
VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, size));
addr = MAX(addr, defaddr);
else
addr = MIN(addr,
VM_DEFAULT_ADDRESS(p->p_vmspace->vm_daddr, size));
addr = MIN(addr, defaddr);
}
/*
@ -1206,3 +1207,9 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit)
vm_map_unlock(map);
return 0;
}
vaddr_t
uvm_default_mapaddr(struct proc *p, vaddr_t base, vsize_t sz)
{
return VM_DEFAULT_ADDRESS(base, sz);
}