* 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. In most cases * just checking the vm_map_entry is sufficient within the kernel's address * space. */
| 117 | * space. |
| 118 | */ |
| 119 | int |
| 120 | kernacc(void *addr, int len, int rw) |
| 121 | { |
| 122 | boolean_t rv; |
| 123 | vm_offset_t saddr, eaddr; |
| 124 | vm_prot_t prot; |
| 125 | |
| 126 | KASSERT((rw & ~VM_PROT_ALL) == 0, |
| 127 | ("illegal ``rw'' argument to kernacc (%x)\n", rw)); |
| 128 | |
| 129 | if ((vm_offset_t)addr + len > vm_map_max(kernel_map) || |
| 130 | (vm_offset_t)addr + len < (vm_offset_t)addr) |
| 131 | return (FALSE); |
| 132 | |
| 133 | prot = rw; |
| 134 | saddr = trunc_page((vm_offset_t)addr); |
| 135 | eaddr = round_page((vm_offset_t)addr + len); |
| 136 | vm_map_lock_read(kernel_map); |
| 137 | rv = vm_map_check_protection(kernel_map, saddr, eaddr, prot); |
| 138 | vm_map_unlock_read(kernel_map); |
| 139 | return (rv == TRUE); |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 | * MPSAFE |