- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
/* $NetBSD: irix_mman.c,v 1.4 2002/09/21 21:14:57 manu Exp $ */
|
2002-04-22 09:58:46 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Emmanuel Dreyfus.
|
|
|
|
*
|
|
|
|
* 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>
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: irix_mman.c,v 1.4 2002/09/21 21:14:57 manu Exp $");
|
2002-06-13 00:33:20 +04:00
|
|
|
|
|
|
|
#include "opt_sysv.h"
|
2002-04-22 09:58:46 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/proc.h>
|
2002-06-13 00:33:20 +04:00
|
|
|
#include <sys/exec.h>
|
2002-04-22 09:58:46 +04:00
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/vnode_if.h>
|
|
|
|
#include <sys/mount.h>
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
#include <sys/lock.h>
|
2002-04-22 09:58:46 +04:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
2002-06-13 00:33:20 +04:00
|
|
|
#include <compat/svr4/svr4_types.h>
|
|
|
|
#include <compat/svr4/svr4_lwp.h>
|
|
|
|
#include <compat/svr4/svr4_ucontext.h>
|
|
|
|
#include <compat/svr4/svr4_signal.h>
|
|
|
|
#include <compat/svr4/svr4_syscallargs.h>
|
|
|
|
|
2002-04-22 09:58:46 +04:00
|
|
|
#include <compat/irix/irix_types.h>
|
|
|
|
#include <compat/irix/irix_signal.h>
|
|
|
|
#include <compat/irix/irix_mman.h>
|
2002-06-13 00:33:20 +04:00
|
|
|
#include <compat/irix/irix_prctl.h>
|
|
|
|
#include <compat/irix/irix_exec.h>
|
2002-04-22 09:58:46 +04:00
|
|
|
#include <compat/irix/irix_syscallargs.h>
|
|
|
|
|
2002-06-13 00:33:20 +04:00
|
|
|
static int irix_mmap __P((struct proc *, void *, size_t, int ,
|
|
|
|
int, int, off_t, register_t *));
|
2002-04-22 09:58:46 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
irix_sys_mmap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct irix_sys_mmap_args /* {
|
|
|
|
syscallarg(void *) addr;
|
|
|
|
syscallarg(irix_size_t) len;
|
|
|
|
syscallarg(int) prot;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(irix_off_t) pos;
|
|
|
|
} */ *uap = v;
|
|
|
|
|
|
|
|
return irix_mmap(p, SCARG(uap, addr), SCARG(uap, len),
|
|
|
|
SCARG(uap, prot), SCARG(uap, flags), SCARG(uap, fd),
|
|
|
|
SCARG(uap, pos), retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
irix_sys_mmap64(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct irix_sys_mmap64_args /* {
|
|
|
|
syscallarg(void *) addr;
|
|
|
|
syscallarg(irix_size_t) len;
|
|
|
|
syscallarg(int) prot;
|
|
|
|
syscallarg(int) flags;
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(int) pad1;
|
|
|
|
syscallarg(irix_off64_t) pos;
|
|
|
|
} */ *uap = v;
|
|
|
|
return irix_mmap(p, SCARG(uap, addr), SCARG(uap, len),
|
|
|
|
SCARG(uap, prot), SCARG(uap, flags), SCARG(uap, fd),
|
|
|
|
SCARG(uap, pos), retval);
|
|
|
|
}
|
|
|
|
|
2002-06-13 00:33:20 +04:00
|
|
|
static int
|
2002-04-22 09:58:46 +04:00
|
|
|
irix_mmap(p, addr, len, prot, flags, fd, pos, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *addr;
|
|
|
|
size_t len;
|
|
|
|
int prot;
|
|
|
|
int flags;
|
|
|
|
int fd;
|
|
|
|
off_t pos;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct sys_mmap_args cup;
|
|
|
|
int bsd_flags = 0;
|
2002-06-13 00:33:20 +04:00
|
|
|
int error = 0;
|
2002-04-22 09:58:46 +04:00
|
|
|
|
2002-08-03 03:02:51 +04:00
|
|
|
#ifdef DEBUG_IRIX
|
|
|
|
printf("irix_sys_mmap(): addr = %p, len = 0x%x, prot = 0x%x ",
|
|
|
|
addr, len, prot);
|
|
|
|
printf("flags = 0x%x, fd = %d, pos = 0x%lx\n", flags, fd, (long)pos);
|
|
|
|
|
|
|
|
#endif
|
2002-04-22 09:58:46 +04:00
|
|
|
if (flags & IRIX_MAP_SHARED)
|
|
|
|
bsd_flags |= MAP_SHARED;
|
|
|
|
if (flags & IRIX_MAP_PRIVATE)
|
|
|
|
bsd_flags |= MAP_PRIVATE;
|
|
|
|
if (flags & IRIX_MAP_COPY)
|
|
|
|
bsd_flags |= MAP_PRIVATE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note about MAP_FIXED: IRIX's mmap(2) states that
|
|
|
|
* when MAP_FIXED is unset, range 0x30000000 to 0x40000000
|
|
|
|
* will not be used except if MAP_SGI_ANYADDR is set
|
|
|
|
* or if syssgi(SGI_UNSUPPORTED_MAP_RESERVED_RANGE) was
|
|
|
|
* enabled. We do not emulate this behavior for now.
|
|
|
|
*/
|
|
|
|
if (flags & IRIX_MAP_FIXED)
|
|
|
|
bsd_flags |= MAP_FIXED;
|
|
|
|
if (flags & IRIX_MAP_RENAME)
|
|
|
|
bsd_flags |= MAP_RENAME;
|
|
|
|
|
|
|
|
if (flags & IRIX_MAP_LOCAL)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag MAP_LOCAL\n");
|
|
|
|
if (flags & IRIX_MAP_AUTORESRV)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag MAP_AUTORESV\n");
|
|
|
|
if (flags & IRIX_MAP_TEXT)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag MAP_TEXT\n");
|
|
|
|
if (flags & IRIX_MAP_BRK)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag MAP_BRK\n");
|
|
|
|
if (flags & IRIX_MAP_PRIMARY)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag MAP_PRIMARY\n");
|
|
|
|
if (flags & IRIX_MAP_SGI_ANYADDR)
|
|
|
|
printf("Warning: unsupported IRIX mmap() flag IRIX_MAP_SGI_ANYADDR\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When AUTOGROW is set and the mapping is bigger than
|
|
|
|
* the file, if pages beyond the end of file are touched,
|
|
|
|
* IRIX will increase the file size accordingly. We are
|
|
|
|
* not able to emulate this (yet), hence we immediatly
|
|
|
|
* grow the file to fit the mapping, before mapping it.
|
|
|
|
*/
|
|
|
|
if (flags & IRIX_MAP_AUTOGROW) {
|
|
|
|
struct file *fp;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct vattr vattr;
|
|
|
|
|
|
|
|
/* getvnode does FILE_USE */
|
|
|
|
if ((error = getvnode(p->p_fd, fd, &fp)) != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
if ((fp->f_flag & FWRITE) == 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
vp = (struct vnode *)fp->f_data;
|
|
|
|
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
|
|
|
|
error = ESPIPE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vp->v_type == VDIR) {
|
|
|
|
error = EISDIR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (pos + len > vattr.va_size) {
|
|
|
|
VATTR_NULL(&vattr);
|
|
|
|
vattr.va_size = round_page(pos + len);
|
|
|
|
|
|
|
|
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
|
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
|
|
|
|
|
|
|
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
|
|
|
|
|
|
|
|
VOP_UNLOCK(vp, 0);
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
FILE_UNUSE(fp, p);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SCARG(&cup, addr) = addr;
|
|
|
|
SCARG(&cup, len) = len;
|
|
|
|
SCARG(&cup, prot) = prot;
|
|
|
|
SCARG(&cup, flags) = bsd_flags;
|
|
|
|
SCARG(&cup, fd) = fd;
|
|
|
|
SCARG(&cup, pos) = pos;
|
|
|
|
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
IRIX_VM_SYNC(p, error = sys_mmap(p, &cup, retval));
|
|
|
|
return error;
|
|
|
|
}
|
2002-06-13 00:33:20 +04:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
irix_sys_munmap(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
IRIX_VM_SYNC(p, error = sys_munmap(p, v, retval));
|
|
|
|
return error;
|
2002-06-13 00:33:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
irix_sys_break(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
IRIX_VM_SYNC(p, error = svr4_sys_break(p, v, retval));
|
|
|
|
return error;
|
2002-06-13 00:33:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SYSVSHM
|
|
|
|
int
|
|
|
|
irix_sys_shmsys(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
IRIX_VM_SYNC(p, error = svr4_sys_shmsys(p, v, retval));
|
|
|
|
return error;
|
2002-06-13 00:33:20 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
irix_sys_mprotect(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
int error;
|
2002-06-13 00:33:20 +04:00
|
|
|
|
- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.
- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports
- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));
- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
2002-09-22 01:14:54 +04:00
|
|
|
IRIX_VM_SYNC(p, error = sys_mprotect(p, v, retval));
|
|
|
|
return error;
|
2002-04-22 09:58:46 +04:00
|
|
|
}
|