Expand description
Wrapper functions for memory syscalls such as mmap, mprotect, etc.
Macrosยง
- mmap_
anno_ test - Construct an
MmapAnnotation::Testwith the current file name and line number.
Structsยง
- Mmap
Strategy - Strategy for performing mmap
Enumsยง
- Huge
Page Support - Support for huge pages
- Mmap
Annotation - Annotation for an mmap entry.
- Mmap
Protection - The protection flags for Mmap
Constantsยง
- MMAP_
FLAGS ๐
Functionsยง
- dzmmapโ
- Demand-zero mmap: This function mmaps the memory and guarantees to zero all mapped memory. This function WILL overwrite existing memory mapping. The user of this function needs to be aware of this, and use it cautiously.
- dzmmap_
noreplace - Demand-zero mmap (no replace): This function mmaps the memory and guarantees to zero all mapped memory. This function will not overwrite existing memory mapping, and it will result Err if there is an existing mapping.
- get_
process_ memory_ maps - Get the memory maps for the process. The returned string is a multi-line string. This is only meant to be used for debugging. For example, log process memory maps after detecting a clash.
- get_
system_ ๐total_ memory - Returns the total physical memory for the system in bytes.
- handle_
mmap_ error - Properly handle errors from a mmap Result, including invoking the binding code in the case of an OOM error.
- mmap_
fixed ๐ - mmap_
noreserve - mmap with no swap space reserve: This function does not reserve swap space for this mapping, which means there is no guarantee that writes to the mapping can always be successful. In case of out of physical memory, one may get a segfault for writing to the mapping. We can use this to reserve the address range, and then later overwrites the mapping with dzmmap().
- mprotect
- Protect the given memory (in page granularity) to forbid any access (PROT_NONE).
- munmap
- Unmap the given memory (in page granularity). This wraps the unsafe libc munmap call.
- munprotect
- Unprotect the given memory (in page granularity) to allow access (PROT_READ/WRITE/EXEC).
- panic_
if_ ๐unmapped - Checks if the memory has already been mapped. If not, we panic.
- result_
is_ ๐mapped - Check the result from an mmap function in this module. Return true if the mmap has failed due to an existing conflicting mapping.
- set
- Set a range of memory to the given value. Similar to memset.
- wrap_
libc_ ๐call - zero
- Set a range of memory to 0.