| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uvm_device.c,v 1.58 2011/02/02 15:13:34 chuck Exp $ */ | | 1 | /* $NetBSD: uvm_device.c,v 1.59 2011/02/11 23:05:55 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | | 4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | | 26 | * |
27 | * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp | | 27 | * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | /* | | 30 | /* |
31 | * uvm_device.c: the device pager. | | 31 | * uvm_device.c: the device pager. |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.58 2011/02/02 15:13:34 chuck Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.59 2011/02/11 23:05:55 jmcneill Exp $"); |
36 | | | 36 | |
37 | #include "opt_uvmhist.h" | | 37 | #include "opt_uvmhist.h" |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/conf.h> | | 41 | #include <sys/conf.h> |
42 | #include <sys/proc.h> | | 42 | #include <sys/proc.h> |
43 | #include <sys/malloc.h> | | 43 | #include <sys/malloc.h> |
44 | | | 44 | |
45 | #include <uvm/uvm.h> | | 45 | #include <uvm/uvm.h> |
46 | #include <uvm/uvm_device.h> | | 46 | #include <uvm/uvm_device.h> |
47 | | | 47 | |
48 | /* | | 48 | /* |
| @@ -345,26 +345,27 @@ again: | | | @@ -345,26 +345,27 @@ again: |
345 | */ | | 345 | */ |
346 | | | 346 | |
347 | static int | | 347 | static int |
348 | udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, struct vm_page **pps, | | 348 | udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, struct vm_page **pps, |
349 | int npages, int centeridx, vm_prot_t access_type, | | 349 | int npages, int centeridx, vm_prot_t access_type, |
350 | int flags) | | 350 | int flags) |
351 | { | | 351 | { |
352 | struct vm_map_entry *entry = ufi->entry; | | 352 | struct vm_map_entry *entry = ufi->entry; |
353 | struct uvm_object *uobj = entry->object.uvm_obj; | | 353 | struct uvm_object *uobj = entry->object.uvm_obj; |
354 | struct uvm_device *udv = (struct uvm_device *)uobj; | | 354 | struct uvm_device *udv = (struct uvm_device *)uobj; |
355 | vaddr_t curr_va; | | 355 | vaddr_t curr_va; |
356 | off_t curr_offset; | | 356 | off_t curr_offset; |
357 | paddr_t paddr, mdpgno; | | 357 | paddr_t paddr, mdpgno; |
| | | 358 | u_int mmapflags; |
358 | int lcv, retval; | | 359 | int lcv, retval; |
359 | dev_t device; | | 360 | dev_t device; |
360 | vm_prot_t mapprot; | | 361 | vm_prot_t mapprot; |
361 | UVMHIST_FUNC("udv_fault"); UVMHIST_CALLED(maphist); | | 362 | UVMHIST_FUNC("udv_fault"); UVMHIST_CALLED(maphist); |
362 | UVMHIST_LOG(maphist," flags=%d", flags,0,0,0); | | 363 | UVMHIST_LOG(maphist," flags=%d", flags,0,0,0); |
363 | | | 364 | |
364 | /* | | 365 | /* |
365 | * we do not allow device mappings to be mapped copy-on-write | | 366 | * we do not allow device mappings to be mapped copy-on-write |
366 | * so we kill any attempt to do so here. | | 367 | * so we kill any attempt to do so here. |
367 | */ | | 368 | */ |
368 | | | 369 | |
369 | if (UVM_ET_ISCOPYONWRITE(entry)) { | | 370 | if (UVM_ET_ISCOPYONWRITE(entry)) { |
370 | UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)", | | 371 | UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)", |
| @@ -405,32 +406,33 @@ udv_fault(struct uvm_faultinfo *ufi, vad | | | @@ -405,32 +406,33 @@ udv_fault(struct uvm_faultinfo *ufi, vad |
405 | curr_va += PAGE_SIZE) { | | 406 | curr_va += PAGE_SIZE) { |
406 | if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx) | | 407 | if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx) |
407 | continue; | | 408 | continue; |
408 | | | 409 | |
409 | if (pps[lcv] == PGO_DONTCARE) | | 410 | if (pps[lcv] == PGO_DONTCARE) |
410 | continue; | | 411 | continue; |
411 | | | 412 | |
412 | mdpgno = cdev_mmap(device, curr_offset, access_type); | | 413 | mdpgno = cdev_mmap(device, curr_offset, access_type); |
413 | if (mdpgno == -1) { | | 414 | if (mdpgno == -1) { |
414 | retval = EIO; | | 415 | retval = EIO; |
415 | break; | | 416 | break; |
416 | } | | 417 | } |
417 | paddr = pmap_phys_address(mdpgno); | | 418 | paddr = pmap_phys_address(mdpgno); |
| | | 419 | mmapflags = pmap_mmap_flags(mdpgno); |
418 | mapprot = ufi->entry->protection; | | 420 | mapprot = ufi->entry->protection; |
419 | UVMHIST_LOG(maphist, | | 421 | UVMHIST_LOG(maphist, |
420 | " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d", | | 422 | " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d", |
421 | ufi->orig_map->pmap, curr_va, paddr, mapprot); | | 423 | ufi->orig_map->pmap, curr_va, paddr, mapprot); |
422 | if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, | | 424 | if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, mapprot, |
423 | mapprot, PMAP_CANFAIL | mapprot) != 0) { | | 425 | PMAP_CANFAIL | mapprot | mmapflags) != 0) { |
424 | /* | | 426 | /* |
425 | * pmap_enter() didn't have the resource to | | 427 | * pmap_enter() didn't have the resource to |
426 | * enter this mapping. Unlock everything, | | 428 | * enter this mapping. Unlock everything, |
427 | * wait for the pagedaemon to free up some | | 429 | * wait for the pagedaemon to free up some |
428 | * pages, and then tell uvm_fault() to start | | 430 | * pages, and then tell uvm_fault() to start |
429 | * the fault again. | | 431 | * the fault again. |
430 | * | | 432 | * |
431 | * XXX Needs some rethinking for the PGO_ALLPAGES | | 433 | * XXX Needs some rethinking for the PGO_ALLPAGES |
432 | * XXX case. | | 434 | * XXX case. |
433 | */ | | 435 | */ |
434 | pmap_update(ufi->orig_map->pmap); /* sync what we have so far */ | | 436 | pmap_update(ufi->orig_map->pmap); /* sync what we have so far */ |
435 | uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, | | 437 | uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, |
436 | uobj, NULL); | | 438 | uobj, NULL); |