Repository navigation
feat(libkernel): implement madvise - #1633
Conversation
klosixgaming-arch
left a comment
There was a problem hiding this comment.
LGTM. Clean implementation of madvise following FreeBSD semantics with proper validation (advice range 0-9, address bounds) and correct handling of MADV_PROTECT as unimplemented. The test coverage is excellent - testing all valid advice values, edge cases (zero length, invalid values, wrapping ranges), boundary conditions at the user address limit, and verifying contents remain intact after advisory calls. Good addition to support PPSA99039 and PPSA99001's import requirements.
Progress report (c9da0f9 → d7e52cb)📉 System libraries: 85.67% (-0.03%, +1 declared functions) 🆕 1 declared as stubs
|
d5a4ac1 to
97c5985
Compare
|
Titles that stop on
The "with this branch" build also had my other open PRs merged; only this branch exports |
|
Windows follow-up. The two
|
97c5985 to
73dac43
Compare
|
First Windows run, since the description says it was only compiled with MinGW. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. #1624, #1628, #1633 and #1634 merged together onto
🤖 Addressed by Claude Code |
73dac43 to
888c263
Compare
888c263 to
3d54ddc
Compare
3d54ddc to
7777d98
Compare
7777d98 to
b0e0a74
Compare
b0e0a74 to
d7e52cb
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
feat(libkernel): implement madvise
What
Implements
madvise(Jahsnh4KKkg) in libkernel. Part of #1578: PPSA99039 and PPSA99001 import it.Follows FreeBSD 11
kern_madvise(sys/vm/vm_mmap.c) andvm_map_madvise(sys/vm/vm_map.c):behavoutsideMADV_NORMAL..MADV_CORE(0..9) fails withEINVAL.VM_MAXUSER_ADDRESS(0x800000000000on amd64) fails withEINVAL. Unmapped holes are not an error.MADV_DONTNEEDonly lowers page priority andMADV_FREElets the kernel discard pages, so keeping the contents is valid for both; the call returns 0 without touching memory.MADV_PROTECT(10) goes throughprocctl(PROC_SPROTECT)and its privilege check on FreeBSD, so it callsNotImplemented_nid_no_patch.Tested
Linux (Ubuntu 24.04, GCC 13, Release):
guest_memorypasses with--repeat until-fail:3. It now checks all ten values on anmmaprange with its contents intact afterwards, a zero length, an unmapped range, invalid values (also with zero length), a wrapping range, a start at0x800000000000and a range ending exactly there. The test fails when the range check is removed.check_conventions.pypasses. Windows:PosixMemory.cppcompiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows. No title run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)