Module memory

Module memory 

Source
Expand description

Wrapper functions for memory syscalls such as mmap, mprotect, etc.

Macrosยง

mmap_anno_test
Construct an MmapAnnotation::Test with the current file name and line number.

Structsยง

MmapStrategy
Strategy for performing mmap

Enumsยง

HugePageSupport
Support for huge pages
MmapAnnotation
Annotation for an mmap entry.
MmapProtection
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.