* MPSAFE * * WARNING! This code calls vm_map_check_protection() which only checks * the associated vm_map_entry range. It does not determine whether the * contents of the memory is actually readable or writable. vmapbuf(), * vm_fault_quick(), or copyin()/copout()/su*()/fu*() functions should be * used in conjunction with this call. */
| 149 | * used in conjunction with this call. |
| 150 | */ |
| 151 | int |
| 152 | useracc(void *addr, int len, int rw) |
| 153 | { |
| 154 | boolean_t rv; |
| 155 | vm_prot_t prot; |
| 156 | vm_map_t map; |
| 157 | |
| 158 | KASSERT((rw & ~VM_PROT_ALL) == 0, |
| 159 | ("illegal ``rw'' argument to useracc (%x)\n", rw)); |
| 160 | prot = rw; |
| 161 | map = &curproc->p_vmspace->vm_map; |
| 162 | if ((vm_offset_t)addr + len > vm_map_max(map) || |
| 163 | (vm_offset_t)addr + len < (vm_offset_t)addr) { |
| 164 | return (FALSE); |
| 165 | } |
| 166 | vm_map_lock_read(map); |
| 167 | rv = vm_map_check_protection(map, trunc_page((vm_offset_t)addr), |
| 168 | round_page((vm_offset_t)addr + len), prot); |
| 169 | vm_map_unlock_read(map); |
| 170 | return (rv == TRUE); |
| 171 | } |
| 172 | |
| 173 | int |
| 174 | vslock(void *addr, size_t len) |
no test coverage detected