pmap_kextract,
vtophys —
extract a physical address from the
kernel page table
#include
<sys/param.h>
#include <vm/vm.h>
#include <vm/pmap.h>
vm_paddr_t
pmap_kextract(vm_offset_t
va);
vm_paddr_t
vtophys(vm_offset_t va);
The
()
function retrieves the underlying physical memory address corresponding to
the given kernel virtual address va. The caller is
responsible for ensuring that va belongs to a valid
mapping in the kernel address space. The returned physical address is only
meaningful as long as the mapping remains stable, so the caller must also
have some knowledge or guarantee of the mapping's lifetime. For example, it
is invalid to call pmap_kextract() with the address
of a malloc'd object while there is a possibility for that object to be
freed concurrently.
vtophys()
is an alias for pmap_kextract() and behaves
identically.
The pmap_kextract() function returns the
physical address of memory mapped at the kernel virtual address
va.
pmap_kextract() generally does not fail.
However, if supplied with an illegitimate value for
va, the function may return zero, an invalid non-zero
value, or call
panic(9).