| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uvm_device.c,v 1.55 2008/12/17 20:51:39 cegger Exp $ */ | | 1 | /* $NetBSD: uvm_device.c,v 1.56 2009/06/20 19:24:27 mrg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * | | 4 | * |
5 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | | 5 | * Copyright (c) 1997 Charles D. Cranor and Washington University. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | * | | 33 | * |
34 | * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp | | 34 | * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | /* | | 37 | /* |
38 | * uvm_device.c: the device pager. | | 38 | * uvm_device.c: the device pager. |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.55 2008/12/17 20:51:39 cegger Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.56 2009/06/20 19:24:27 mrg Exp $"); |
43 | | | 43 | |
44 | #include "opt_uvmhist.h" | | 44 | #include "opt_uvmhist.h" |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/systm.h> | | 47 | #include <sys/systm.h> |
48 | #include <sys/conf.h> | | 48 | #include <sys/conf.h> |
49 | #include <sys/proc.h> | | 49 | #include <sys/proc.h> |
50 | #include <sys/malloc.h> | | 50 | #include <sys/malloc.h> |
51 | #include <sys/vnode.h> | | 51 | #include <sys/vnode.h> |
52 | | | 52 | |
53 | #include <uvm/uvm.h> | | 53 | #include <uvm/uvm.h> |
54 | #include <uvm/uvm_device.h> | | 54 | #include <uvm/uvm_device.h> |
55 | | | 55 | |
| @@ -133,27 +133,28 @@ udv_attach(void *arg, vm_prot_t accesspr | | | @@ -133,27 +133,28 @@ udv_attach(void *arg, vm_prot_t accesspr |
133 | cdev = cdevsw_lookup(device); | | 133 | cdev = cdevsw_lookup(device); |
134 | if (cdev == NULL) { | | 134 | if (cdev == NULL) { |
135 | return (NULL); | | 135 | return (NULL); |
136 | } | | 136 | } |
137 | mapfn = cdev->d_mmap; | | 137 | mapfn = cdev->d_mmap; |
138 | if (mapfn == NULL || mapfn == nommap || mapfn == nullmmap) { | | 138 | if (mapfn == NULL || mapfn == nommap || mapfn == nullmmap) { |
139 | return(NULL); | | 139 | return(NULL); |
140 | } | | 140 | } |
141 | | | 141 | |
142 | /* | | 142 | /* |
143 | * Negative offsets on the object are not allowed. | | 143 | * Negative offsets on the object are not allowed. |
144 | */ | | 144 | */ |
145 | | | 145 | |
146 | if (off != UVM_UNKNOWN_OFFSET && off < 0) | | 146 | if ((cdev->d_flag & D_NEGOFFSAFE) == 0 && |
| | | 147 | off != UVM_UNKNOWN_OFFSET && off < 0) |
147 | return(NULL); | | 148 | return(NULL); |
148 | | | 149 | |
149 | /* | | 150 | /* |
150 | * Check that the specified range of the device allows the | | 151 | * Check that the specified range of the device allows the |
151 | * desired protection. | | 152 | * desired protection. |
152 | * | | 153 | * |
153 | * XXX assumes VM_PROT_* == PROT_* | | 154 | * XXX assumes VM_PROT_* == PROT_* |
154 | * XXX clobbers off and size, but nothing else here needs them. | | 155 | * XXX clobbers off and size, but nothing else here needs them. |
155 | */ | | 156 | */ |
156 | | | 157 | |
157 | while (size != 0) { | | 158 | while (size != 0) { |
158 | if (cdev_mmap(device, off, accessprot) == -1) { | | 159 | if (cdev_mmap(device, off, accessprot) == -1) { |
159 | return (NULL); | | 160 | return (NULL); |