summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/init_sysent.c4
-rw-r--r--sys/kern/kern_exec.c4
-rw-r--r--sys/kern/syscalls.c3
-rw-r--r--sys/kern/syscalls.master4
-rw-r--r--sys/kern/sysv_shm.c5
-rw-r--r--sys/sys/mman.h4
-rw-r--r--sys/sys/syscall.h7
-rw-r--r--sys/sys/syscallargs.h11
-rw-r--r--sys/uvm/uvm_map.c13
-rw-r--r--sys/uvm/uvm_map.h3
-rw-r--r--sys/uvm/uvm_mmap.c70
11 files changed, 107 insertions, 21 deletions
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index 1ad052d3757..a95f5062910 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_sysent.c,v 1.59 2003/01/30 15:32:44 millert Exp $ */
+/* $OpenBSD: init_sysent.c,v 1.60 2003/04/14 04:53:50 art Exp $ */
/*
* System call switch table.
@@ -746,5 +746,7 @@ struct sysent sysent[] = {
sys_getresgid }, /* 283 = getresgid */
{ 3, s(struct sys_setresgid_args),
sys_setresgid }, /* 284 = setresgid */
+ { 5, s(struct sys_mquery_args),
+ sys_mquery }, /* 285 = mquery */
};
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 77faaf4960f..9504237bc22 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.76 2003/03/09 01:27:50 millert Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.77 2003/04/14 04:53:50 art Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -732,7 +732,7 @@ exec_sigcode_map(struct proc *p, struct emul *e)
}
/* Just a hint to uvm_mmap where to put it. */
- p->p_sigcode = round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ);
+ p->p_sigcode = uvm_map_hint(p, VM_PROT_READ|VM_PROT_EXECUTE);
uao_reference(e->e_sigobject);
if (uvm_map(&p->p_vmspace->vm_map, &p->p_sigcode, round_page(sz),
e->e_sigobject, 0, 0, UVM_MAPFLAG(UVM_PROT_RX, UVM_PROT_RX,
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index 86cedb94c6c..01a67ae9d07 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscalls.c,v 1.59 2003/01/30 03:32:44 millert Exp $ */
+/* $OpenBSD: syscalls.c,v 1.60 2003/04/14 04:53:50 art Exp $ */
/*
* System call names.
@@ -380,4 +380,5 @@ char *syscallnames[] = {
"setresuid", /* 282 = setresuid */
"getresgid", /* 283 = getresgid */
"setresgid", /* 284 = setresgid */
+ "mquery", /* 285 = mquery */
};
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index b427bc216ee..e414ac0e100 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.52 2003/01/30 03:29:49 millert Exp $
+; $OpenBSD: syscalls.master,v 1.53 2003/04/14 04:53:50 art Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -570,3 +570,5 @@
gid_t *sgid); }
284 STD { int sys_setresgid(gid_t rgid, gid_t egid, \
gid_t sgid); }
+285 STD { int sys_mquery(int flags, void **addr, size_t size, \
+ int fd, off_t off); }
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index aaf85095b1a..56b473ccce1 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_shm.c,v 1.33 2003/01/07 00:34:41 millert Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.34 2003/04/14 04:53:50 art Exp $ */
/* $NetBSD: sysv_shm.c,v 1.50 1998/10/21 22:24:29 tron Exp $ */
/*
@@ -273,8 +273,7 @@ sys_shmat(struct proc *p, void *v, register_t *retval)
return (EINVAL);
} else {
/* This is just a hint to uvm_map() about where to put it. */
- attach_va = round_page((vaddr_t)p->p_vmspace->vm_taddr +
- MAXTSIZ + MAXDSIZ);
+ attach_va = uvm_map_hint(p, prot);
}
shm_handle = shmseg->shm_internal;
uao_reference(shm_handle->shm_object);
diff --git a/sys/sys/mman.h b/sys/sys/mman.h
index 2676f153f05..180c57726a8 100644
--- a/sys/sys/mman.h
+++ b/sys/sys/mman.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mman.h,v 1.11 2002/03/14 01:27:14 millert Exp $ */
+/* $OpenBSD: mman.h,v 1.12 2003/04/14 04:53:50 art Exp $ */
/* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */
/*-
@@ -106,7 +106,6 @@
#define MCL_CURRENT 0x01 /* lock all pages currently mapped */
#define MCL_FUTURE 0x02 /* lock all pages mapped in the future */
-
#ifndef _KERNEL
#include <sys/cdefs.h>
@@ -124,6 +123,7 @@ int munlockall(void);
int madvise(void *, size_t, int);
int mincore(void *, size_t, char *);
int minherit(void *, size_t, int);
+int mquery(int flags, void **addr, size_t size, int fd, off_t off);
__END_DECLS
#endif /* !_KERNEL */
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index c1af409324c..5ca97f3505b 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.h,v 1.58 2003/01/30 03:32:44 millert Exp $ */
+/* $OpenBSD: syscall.h,v 1.59 2003/04/14 04:53:50 art Exp $ */
/*
* System call numbers.
@@ -668,4 +668,7 @@
/* syscall: "setresgid" ret: "int" args: "gid_t" "gid_t" "gid_t" */
#define SYS_setresgid 284
-#define SYS_MAXSYSCALL 285
+/* syscall: "mquery" ret: "int" args: "int" "void **" "size_t" "int" "off_t" */
+#define SYS_mquery 285
+
+#define SYS_MAXSYSCALL 286
diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h
index 420bd13bbb3..e2d70e279d8 100644
--- a/sys/sys/syscallargs.h
+++ b/sys/sys/syscallargs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscallargs.h,v 1.60 2003/01/30 03:32:44 millert Exp $ */
+/* $OpenBSD: syscallargs.h,v 1.61 2003/04/14 04:53:50 art Exp $ */
/*
* System call argument lists.
@@ -1203,6 +1203,14 @@ struct sys_setresgid_args {
syscallarg(gid_t) sgid;
};
+struct sys_mquery_args {
+ syscallarg(int) flags;
+ syscallarg(void **) addr;
+ syscallarg(size_t) size;
+ syscallarg(int) fd;
+ syscallarg(off_t) off;
+};
+
/*
* System call prototypes.
*/
@@ -1492,3 +1500,4 @@ int sys_getresuid(struct proc *, void *, register_t *);
int sys_setresuid(struct proc *, void *, register_t *);
int sys_getresgid(struct proc *, void *, register_t *);
int sys_setresgid(struct proc *, void *, register_t *);
+int sys_mquery(struct proc *, void *, register_t *);
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c
index a7cba41ff66..30af50d1508 100644
--- a/sys/uvm/uvm_map.c
+++ b/sys/uvm/uvm_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_map.c,v 1.56 2002/12/09 02:35:21 art Exp $ */
+/* $OpenBSD: uvm_map.c,v 1.57 2003/04/14 04:53:51 art Exp $ */
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
/*
@@ -1072,6 +1072,16 @@ uvm_map_spacefits(vm_map_t map, vaddr_t *phint, vsize_t length,
}
/*
+ * uvm_map_hint: return the beginning of the best area suitable for
+ * creating a new mapping with "prot" protection.
+ */
+vaddr_t
+uvm_map_hint(struct proc *p, vm_prot_t prot)
+{
+ return (round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ));
+}
+
+/*
* uvm_map_findspace: find "length" sized space in "map".
*
* => "hint" is a hint about where we want it, unless FINDSPACE_FIXED is
@@ -3588,7 +3598,6 @@ uvmspace_fork(vm1)
return(vm2);
}
-
#if defined(DDB)
/*
diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h
index 8dbc4fda58b..97e23a3d830 100644
--- a/sys/uvm/uvm_map.h
+++ b/sys/uvm/uvm_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_map.h,v 1.28 2002/10/29 18:30:21 art Exp $ */
+/* $OpenBSD: uvm_map.h,v 1.29 2003/04/14 04:53:51 art Exp $ */
/* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -335,6 +335,7 @@ int uvm_map_extract(vm_map_t, vaddr_t, vsize_t,
vm_map_t, vaddr_t *, int);
vm_map_entry_t uvm_map_findspace(vm_map_t, vaddr_t, vsize_t, vaddr_t *,
struct uvm_object *, voff_t, vsize_t, int);
+vaddr_t uvm_map_hint(struct proc *, vm_prot_t);
int uvm_map_inherit(vm_map_t, vaddr_t, vaddr_t, vm_inherit_t);
int uvm_map_advice(vm_map_t, vaddr_t, vaddr_t, int);
void uvm_map_init(void);
diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c
index 0e09b0096f2..0a68cc18275 100644
--- a/sys/uvm/uvm_mmap.c
+++ b/sys/uvm/uvm_mmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_mmap.c,v 1.39 2003/04/07 14:47:08 mpech Exp $ */
+/* $OpenBSD: uvm_mmap.c,v 1.40 2003/04/14 04:53:51 art Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -117,6 +117,68 @@ sys_sstk(p, v, retval)
}
/*
+ * sys_mquery: provide mapping hints to applications that do fixed mappings
+ *
+ * flags: 0 or MAP_FIXED (MAP_FIXED - means that we insist on this addr and
+ * don't care about PMAP_PREFER or such)
+ * addr: hint where we'd like to place the mapping.
+ * size: size of the mapping
+ * fd: fd of the file we want to map
+ * off: offset within the file
+ */
+
+/* ARGSUSED */
+int
+sys_mquery(struct proc *p, void *v, register_t *retval)
+{
+ struct sys_mquery_args /* {
+ syscallarg(int) flags;
+ syscallarg(void **) addr;
+ syscallarg(size_t) size;
+ syscallarg(int) fd;
+ syscallarg(off_t) off;
+ } */ *uap = v;
+ struct file *fp;
+ struct uvm_object *uobj;
+ voff_t uoff;
+ int error;
+ vaddr_t vaddr;
+ int flags = 0;
+ vm_prot_t prot = SCARG(uap, flags) & VM_PROT_ALL;
+
+ if (SCARG(uap, flags) & MAP_FIXED)
+ flags |= UVM_FLAG_FIXED;
+
+ if ((error = copyin(SCARG(uap, addr), &vaddr, sizeof(void *))) != 0)
+ return (error);
+
+ if (SCARG(uap, fd) >= 0) {
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+ uobj = &((struct vnode *)fp->f_data)->v_uvm.u_obj;
+ uoff = SCARG(uap, off);
+ } else {
+ fp = NULL;
+ uobj = NULL;
+ uoff = 0;
+ }
+
+ if (vaddr == 0)
+ vaddr = uvm_map_hint(p, prot);
+
+ if (uvm_map_findspace(&p->p_vmspace->vm_map, vaddr, SCARG(uap, size),
+ &vaddr, uobj, uoff, 0, flags) == NULL) {
+ error = ENOMEM;
+ } else {
+ error = copyout(&vaddr, SCARG(uap, addr), sizeof(void *));
+ }
+
+ if (fp != NULL)
+ FRELE(fp);
+ return (error);
+}
+
+/*
* sys_mincore: determine if pages are in core or not.
*/
@@ -350,10 +412,8 @@ sys_mmap(p, v, retval)
* we will refine our guess later (e.g. to account for VAC, etc)
*/
- if (addr < round_page((vaddr_t)p->p_vmspace->vm_daddr +
- MAXDSIZ))
- addr = round_page((vaddr_t)p->p_vmspace->vm_daddr +
- MAXDSIZ);
+ if (addr < uvm_map_hint(p, prot))
+ addr = uvm_map_hint(p, prot);
}
/*