-
Notifications
You must be signed in to change notification settings - Fork 4
feat: implement msync syscall as no-op #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
+216
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since litebox only supports MAP_PRIVATE mappings (not MAP_SHARED), changes to memory-mapped regions are never written back to the underlying file. Therefore, msync is implemented as a no-op that validates arguments and returns success. Implementation: - Add MsyncFlags bitflags (MS_ASYNC, MS_INVALIDATE, MS_SYNC) - Add Msync variant to SyscallRequest enum - Add Sysno::msync dispatch in try_from_raw - Implement sys_msync in litebox_shim_linux and litebox_common_linux Validation per Linux semantics: - addr must be page-aligned (EINVAL) - MS_ASYNC and MS_SYNC are mutually exclusive (EINVAL) - Invalid flags return EINVAL - Overflow in addr+len returns ENOMEM Tests: - test_msync_basic: validates MS_SYNC, MS_ASYNC, MS_INVALIDATE, and combinations - test_msync_invalid_flags: validates MS_ASYNC|MS_SYNC returns EINVAL - test_msync_unaligned_addr: validates unaligned address returns EINVAL
- Remove Clone, Copy derives from MsyncFlags to match other memory flags - Add test for MS_ASYNC | MS_INVALIDATE combination - Add test for invalid flag bits (undefined bits return EINVAL)
|
🤖 SemverChecks 🤖 Click for details |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements the
msyncsyscall as a no-op that validates arguments and returns success.Background
Since litebox only supports
MAP_PRIVATEmappings (notMAP_SHARED), changes to memory-mapped regions are never written back to the underlying file. Therefore,msyncis implemented as a no-op - this is correct per Linux semantics wheremsyncon private mappings has implementation-defined behavior.This approach is consistent with other advisory syscalls in litebox like
readaheadandfadvise64which are also implemented as no-ops.Implementation
New Types
MsyncFlagsbitflags withMS_ASYNC,MS_INVALIDATE,MS_SYNCFiles Modified
litebox_common_linux/src/lib.rs: AddedMsyncFlags,Msyncvariant, and dispatchlitebox_common_linux/src/mm.rs: Implementedsys_msyncwith validation logiclitebox_shim_linux/src/lib.rs: Added dispatch caselitebox_shim_linux/src/syscalls/mm.rs: Addedsys_msyncwrapper and unit testsValidation (per Linux semantics)
addrmust be page-aligned →EINVALMS_ASYNCandMS_SYNCare mutually exclusive →EINVALEINVALaddr + len→ENOMEMTests
test_msync_basic: ValidatesMS_SYNC,MS_ASYNC,MS_INVALIDATE, combinations, and zero lengthtest_msync_invalid_flags: ValidatesMS_ASYNC | MS_SYNCreturnsEINVALtest_msync_unaligned_addr: Validates unaligned address returnsEINVALReferences
mm/msync.c