svn commit: r214436 - in projects/ofed/head/sys:
ofed/drivers/infiniband/core ofed/drivers/infiniband/hw/mthca vm
Jeff Roberson
jeff at FreeBSD.org
Wed Oct 27 23:21:31 UTC 2010
Author: jeff
Date: Wed Oct 27 23:21:30 2010
New Revision: 214436
URL: http://svn.freebsd.org/changeset/base/214436
Log:
- Add a new flag to vm_map_wire(), VM_MAP_WIRE_WRITE which checks for
write access when adding a wired region. This is required when
ib's umem requests write access.
Sponsored by: Isilon Systems, iX Systems, and Panasas.
Modified:
projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
projects/ofed/head/sys/vm/vm_map.c
projects/ofed/head/sys/vm/vm_map.h
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Wed Oct 27 23:18:25 2010 (r214435)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Wed Oct 27 23:21:30 2010 (r214436)
@@ -327,7 +327,8 @@ out:
return ERR_PTR(-EAGAIN);
}
error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES |
+ umem->writable ? VM_MAP_WIRE_WRITE : 0);
if (error != KERN_SUCCESS) {
kfree(umem);
return ERR_PTR(-ENOMEM);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c Wed Oct 27 23:18:25 2010 (r214435)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c Wed Oct 27 23:21:30 2010 (r214436)
@@ -564,8 +564,7 @@ out:
}
start = uaddr & PAGE_MASK;
ret = vm_map_wire(&proc->p_vmspace->vm_map, start, start + PAGE_SIZE,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES /* | VM_MAP_WIRE_READ |
- VM_MAP_WIRE_WRITE */);
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES | VM_MAP_WIRE_WRITE);
if (ret != KERN_SUCCESS) {
start = 0;
ret = -ENOMEM;
Modified: projects/ofed/head/sys/vm/vm_map.c
==============================================================================
--- projects/ofed/head/sys/vm/vm_map.c Wed Oct 27 23:18:25 2010 (r214435)
+++ projects/ofed/head/sys/vm/vm_map.c Wed Oct 27 23:21:30 2010 (r214436)
@@ -2299,7 +2299,11 @@ vm_map_wire(vm_map_t map, vm_offset_t st
unsigned int last_timestamp;
int rv;
boolean_t fictitious, need_wakeup, result, user_wire;
+ vm_prot_t prot;
+ prot = VM_PROT_READ | VM_PROT_EXECUTE;
+ if (flags & VM_MAP_WIRE_WRITE)
+ prot |= VM_PROT_WRITE;
user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE;
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
@@ -2367,20 +2371,16 @@ vm_map_wire(vm_map_t map, vm_offset_t st
* above.)
*/
entry->eflags |= MAP_ENTRY_IN_TRANSITION;
- /*
- *
- */
- if (entry->wired_count == 0) {
- if ((entry->protection & (VM_PROT_READ|VM_PROT_EXECUTE))
- == 0) {
- entry->eflags |= MAP_ENTRY_WIRE_SKIPPED;
- if ((flags & VM_MAP_WIRE_HOLESOK) == 0) {
- end = entry->end;
- rv = KERN_INVALID_ADDRESS;
- goto done;
- }
- goto next_entry;
+ if ((entry->protection & prot) != prot) {
+ entry->eflags |= MAP_ENTRY_WIRE_SKIPPED;
+ if ((flags & VM_MAP_WIRE_HOLESOK) == 0) {
+ end = entry->end;
+ rv = KERN_INVALID_ADDRESS;
+ goto done;
}
+ goto next_entry;
+ }
+ if (entry->wired_count == 0) {
entry->wired_count++;
saved_start = entry->start;
saved_end = entry->end;
Modified: projects/ofed/head/sys/vm/vm_map.h
==============================================================================
--- projects/ofed/head/sys/vm/vm_map.h Wed Oct 27 23:18:25 2010 (r214435)
+++ projects/ofed/head/sys/vm/vm_map.h Wed Oct 27 23:21:30 2010 (r214436)
@@ -339,6 +339,8 @@ long vmspace_wired_count(struct vmspace
#define VM_MAP_WIRE_NOHOLES 0 /* region must not have holes */
#define VM_MAP_WIRE_HOLESOK 2 /* region may have holes */
+#define VM_MAP_WIRE_WRITE 4 /* Validate writable. */
+
#ifdef _KERNEL
boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t);
vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t);
More information about the svn-src-projects
mailing list