MmapRegion: relax mmap size constraints #178
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the build_raw() alternative of the MmapRegion,
the implementation was validating that the length of
the mapping was a multiple of the page size.
This generally makes sense, since the OS will round up
to the nearest multiple anyway and only allocate full
pages.
There is one corner case though where this needs to be
relaxed: when mapping a file with a length not divisible
by the pagesize.
According to the POSIX reference, the length will be rounded
up and the extra memory zero-ed. Memory accesses will work
as expected, even beyond the actual file length (but within the
allocated memory), but any writes will not be persisted to the
filesystem and the backing device.
This is a use case where mapping an "uneven" length makes sense,
so that such "out-of-bounds" checks can be caught by accesses
via vm-memory primitives.
This commit removes this constraint.
Signed-off-by: alindima [email protected]