-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Implementations of Mmapper
keep a map from chunks to MapState
values. Obviously it works at the granularity of chunks internally.
But some methods of Mmapper
take the number of pages as arguments. Concretely:
quarantine_address_range(start, pages, strategy, anno)
ensure_mapped(start, pages, strategy, anno)
protect(start, pages)
I don't think Mmapper
can maintain MapState
at the granularity of pages because that would be too fine-grained. To handle large address ranges up to 48 bits, we would need to switch to a different data structure, such as segment tree which is slower to query than chunk-grained arrays.
If we want Mmapper
to keep working at chunk granularity, we should change the public interface in order not to give its user a false impression that it may work at page granularity. We should remove all mentions of "page" and use one of the following strategies:
quarantine_address_ranges(start: Address, bytes: usize, ...)
while requiring bothstart
andbytes
to be chunk-aligned.quarantine_address_ranges(start_chunk_index: usize, num_chunks: usize, ...)
where bothstart_chunk_index
andnum_chunks
are chunk indices counted from address 0. That is,chunk_index = address >> LOG_BYTES_IN_CHUNK
.quarantine_address_ranges(chunk_range: ChunkRange, ...)
wherechunk_range
is a dedicated data structure that refers to whole chunks.
I personally prefer method 3. Regardless of the internal representation of ChunkRange
(whether it uses aligned addresses or chunk indices), there is no way the user can supply an unaligned range.