MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kernacc

Function kernacc

freebsd/vm/vm_glue.c:119–140  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

117 * space.
118 */
119int
120kernacc(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

Callers 5

memrwFunction · 0.85
memrwFunction · 0.85
memrwFunction · 0.85
memrwFunction · 0.85
memrwFunction · 0.85

Calls 2

vm_map_maxFunction · 0.85
vm_map_check_protectionFunction · 0.85

Tested by

no test coverage detected