Repository navigation
feat(libkernel): report the guest address-space map through kern.proc.vmmap - #7070
Conversation
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows run of head
Titles.
So no local title issues Small points from the diff, none blocking: the records are collected one range at a time under the arena lock, not under one lock for the whole walk, so a concurrent Not checked: Linux, macOS, PS5 hardware, PPSA99030. Written with Claude Code assistance (validation by a subagent, reviewed in this session). |
|
Thanks @screamm, the side-by-side compile against FreeBSD 11's AI-assisted: yes (Claude Code) |
….vmmap
sysctl {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, pid} for the calling process
returns packed FreeBSD 11 kinfo_vmentry records, one per used range of the
guest arena, with the protection sceKernelVirtualQuery reports. Other pids
return ESRCH, a write EPERM, a short buffer ENOMEM. GuestArena gains a
query for the used range at or after an address.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c8b5cec to
5fcb7e8
Compare
|
Checked the |
What
sysctl{CTL_KERN,KERN_PROC,KERN_PROC_VMMAP, pid} (MIB 1.14.32.pid) threwunsupported MIB. It now returns the calling process's map as packed FreeBSD 11kinfo_vmentryrecords, the formatkinfo_getvmmapreads: a size query with no buffer, then the records, each withkve_structsizeset to its packed size.GuestArena's used map), in address order. That map is what a guestmmapis placed against: guest mappings and reservations, plus host mappings and the system-reserved range inside the arena.GuestArenagainsGuestArenaNextUsed_nid_no_patch, which returns the used range at or after an address.sceKernelVirtualQueryreports for the range's first page (0 where it reports none). The type isKVME_TYPE_DEFAULT. Offset, object, resident counts, flags and path are 0, so each record is 144 bytes.ESRCH, including -1, as FreeBSD'spgetgives for this node (unlikekern.proc.pathname). A write returnsEPERM, a MIB of the wrong lengthEINVAL, and a short bufferENOMEMwith the bytes that fit.docs/dev/debt/libkernel.md.Ranges outside the arena are not reported, because guest code cannot map there: a fixed anonymous guest
mmapoutside the arena is refused withEINVAL.Tested
Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti (NVIDIA 595.99.02).
CheckVmmapSysctlinguest_system_configuration:mmapand requires a record that covers the mapping with read and write protection.munmap, it requires that no record overlaps the range.ENOMEM, nothing written past it), a write (EPERM), a foreign pid and -1 (ESRCH), and 3- and 5-element MIBs (EINVAL).main'sSystemConfiguration.cppthe test aborts onsysctl_nid_postfix: unsupported MIB 1.14.32.<pid>. With this change it passes 3 of 3.^guest_|libcpass.sysctl(1.14.32.getpid(), NULL, &len), allocateslen + len / 4, reads the records and walkskve_start/kve_end(offsets 8 and 16) bykve_structsize. It records the 64 KiB-aligned gaps in [0x10000, 0x68000000) as free ranges.mainare covered by open PRs, so I ran it onmainwith feat(libkernel): declare physhm_open and physhm_unlink #6915, fix(libkernel): export sysarch so modules that import it load #6028, fix(libSceSystemService): declare the PsmKit local process exports #6939 and feat(libSceKeyboard): export missing firmware functions from database #6787 merged locally.unsupported MIB 1.14.32.3(2 of 2).ntdll.soloads,wineboot.exe -istarts and reads its NLS files (2 of 2).virtual_alloc_first_teb("failed to map the shared user data"). Wine maps that page at the fixed address 0x7ffe0000, below the guest arena, which a fixed guest mapping cannot reach. That is a separate topic and is not changed here.mainc9e6c45.guest_system_configurationpasses 3 of 3, and withmain'sSystemConfiguration.cppandGuestArena.cppit aborts onunsupported MIB 1.14.32.<pid>. They also compiled FreeBSD 11.0'sstruct kinfo_vmentrynext toGuestVmEntry, and every offset matches. None of their four local titles issueskern.proc.vmmapin 60 s.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code