feat(libSceNKWebKit): implement WTF::FileSystemImpl::MappedFileData #14932
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14932"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by w4rc0n on 2026-11-02T01:33:10Z.
What
WTF::FileSystemImpl::MappedFileDatawas a set ofNotImplementedstubs, so guest WebKit code that memory-mapped a file threw. Its seven exports now follow the pinned PS5 WebKit 11.xFileSystem.cpp:313-368:mapFileHandle, the four constructors and both destructors.unsignedsize, 16 bytes (FileSystem.h:270). It is pinned withstatic_assertand isn't a host handle.fstat,mmapandmunmap, so flags, alignment and bookkeeping follow the rest of the guest, as for #14931's handles.UINT_MAX, fails.The debt entry records two gaps:
mmapisnoexcept, and libkernel's archive refusal throws throughNotImplemented_nid_no_patch. The pinned source reports a failed mapping withsuccess = falseinstead. #11625 adds archive-backed mapping.mmapthrough an SDK wrapper (OptionsPlayStation.cmake). That wrapper isn't in the pinned source, so anything extra it does is unverified.isSafeToUseMemoryMapForPathandmakeSafeToUseMemoryMapForPathare left to #13930.tools/pr_overlap.pyon this head, withmainat0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge withmain, GitHub's file lists show none of them changing these exports either. #13947, #13992, #14172, #14607, #14981, #15011, #15214, #15215, #15241 and #15498 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14949, in the same stack.Tested
Debian 12, GCC 12.2, Linux 6.18, Release, at the head
037877846880dfc8aba13ef6fd84bc1382189f2d, which is on #14931's head0efdf47930434f6317c4a572ea0af7cf501e0095. The selection was the thirteen NKWebKit tests (nkwebkit_constantsand upstream's newernkwebkit_fastbitvector,nkwebkit_resourceresponse,guest_nkwebkit_urlsandnkwebkit_palsessionidincluded),public_headersandpatched_libraries. The fulllibstarget was built.patched_libraries.nkwebkit_wtfaborts withguest path: process_vm_readv failed with errno 38, because this machine's kernel has noprocess_vm_readv. The Linux CI run below reaches it.nkwebkit_wtfcases cover:mapFileHandle;unsignedbeing rejected (not run on Windows).libSceNKWebKit.prxlistslibkernel.prxas needed, andldd -rreports no undefined symbols.tools/progress.py: the seven exports count as implemented (libSceNKWebKit 1325, against 1318 with #14931).tools/check_conventions.pypasses.597d4921755bc7184edc292d2fd80210f030af69. It is AnyPS5'sBuildworkflow, dispatched in the author's fork withselect=true: the branch merged intomainat93dbd0f82aea684e95f15f06e7d42c0064af18cf, built onwindows-latestwith WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, whichcheck_skips.pyaccepts. That includes the nine NKWebKit tests,public_headersandpatched_libraries. The later rebases ontomain(now0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #14479, #15228, #13766, #14925 and #15911) and the debt wording change from review changed onlydocs/dev/debt/libSceNKWebKit.md, sogit range-diffshows the code and tests under test are the same as at that run. A fork-internal pull request existed only to give the workflow a number.e403b976014319fc79978786c071579efd2ee79awith the fulllibstarget onubuntu-latest(Ubuntu 24.04, kernel 7.0, GCC 13.3). 13 of 13 pass, includingnkwebkit_wtfandpatched_libraries. The later rebases ontomain(now0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #13766, #14925 and #15911) changed onlydocs/dev/debt/libSceNKWebKit.md, sogit range-diffshows the code and tests under test are the same as at that run.Local fallback used for the second run (not in this PR)
Not built or run: macOS. No title or homebrew was run.
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)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:06:04Z.
Review: APPROVED
Reviewed — approved
The seven
MappedFileDataexports follow WebKit's POSIX implementation step for step. They go through the guestfstat/mmap/munmapwith the right protection and sharing constants, and the newnkwebkit_wtfcases pass here and fail when the shared and private flags are swapped.What I ran
5f9423c0bc35cd54027b2b13d9942870e05924b2merged intomain4f41f4c375f5abb487dbd184fbc150f31994d762with--no-ff, in a clean worktree.Results
git diff --checkcheck_conventions.pylibs(script)unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group) also fails onmain.patched_libraries(my run)nkwebkit_wtftook 0.02 smain)nkwebkit_wtf_testsdoesn't compile ('MappedFileData' is not a member of 'WTF', missing signatures)nkwebkit_wtfabortsnkwebkit_wtfpasses;git status --porcelainis empty; the test leaves no temporary directory behindNegative control 2 output
Negative control
Export.cpp,Api.hpp,InventoryExports.hpp,WtfExports.hpp,WtfMemoryTypes.hppandWtfSystem.cppfrommain.CMakeLists.txt. Changing it makes ninja rerun configure, and SDL2'sconfigure_filefails in the sandbox. Its only change is the extralibkernellink.mmapflags inmapFileHandle(mapMode == 0 ? 2 : 1).nkwebkit_wtfaborts. The shared write-through and private isolation checks do test the flag choice.Findings
Blocking
None.
Non-blocking
docs/dev/debt/libSceNKWebKit.md, "WTF mapped files").mmap_nid_postfixisnoexceptand callsFile::RefuseArchivedFile(PosixMemory.cpp:145-146, 192 at the PR head). That function throws throughNotImplemented_nid_no_patch.MappedFileDataon an app0 file terminates the process. Upstream would returnsuccess = falsethere.openAndLockFileignoreslockMode(core/libs/prx/libSceNKWebKit/src/WtfSystem.cpp:150).lockFileonly underUSE(FILE_LOCK). Ignoring the lock is correct only if the PlayStation build leavesUSE(FILE_LOCK)off.3rdparty/submodule). From readingmapFileHandle(WtfSystem.cpp:75-88), I agree with their description: the sequence matches upstreamFileSystem.cppstep for step. The author has said they will apply the answer given on #14921, so this is waiting on a maintainer decision.Checked and fine
Read→1,Write→2,ReadWrite→3, andShared→MAP_SHARED(1),Private→MAP_PRIVATE(2)match FreeBSD's values and the WebKit enum order.UINT_MAX, is rejected. This is the same as upstream'sconvertSafely.MAP_FAILED. The constructors zero*selffirst, which matches the upstream member initializers.sceKernelVirtualQuery.openFile: theCStringreturned byutf8is RAII (WtfStringAbi.hpp:67), so it doesn't leak.Not verified
597d4921…). I didn't check the claim that only the debt doc changed since then.FileSystem.cpp. I compared the code with WebKit's POSIXFileSystemimplementation as I know it.USE(FILE_LOCK): I couldn't check whether the PlayStation build enables it (see non-blocking 2).MappedFileDatalayout or the__wrap_mmapbehaviour against console binaries. The debt entry records both.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T10:51:21Z.
Review: APPROVED
Re-checked — approved
The only change since
5f9423c0is a one-line rewording of the "WTF mapped files" debt entry. It now says that mapping an archived file terminates the process, which matches libkernel's code.What changed since my last review
git range-diffshows that commit 1 (4179fef3b4) is identical.5f9423c0bcby one line indocs/dev/debt/libSceNKWebKit.md.git diff --stat 5f9423c0bc35cd54027b2b13d9942870e05924b2 e403b976014319fc79978786c071579efd2ee79ashows only that file, 1 line added and 1 removed.What I ran
e403b976014319fc79978786c071579efd2ee79amain:4f41f4c375f5abb487dbd184fbc150f31994d762mainwith--no-ffin a clean worktree, then built it and ran the selected tests.git diff --checkcheck_conventions.pylibs(script)unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group, also fails onmain.patched_libraries(my run)git status --porcelainNegative control: I didn't run it again. The tests and production code are byte-identical to
5f9423c0. In my previous review,nkwebkit_wtffailed both with the production files restored frommainand with the shared and private flags swapped.Previous findings
mmap_nid_postfixisnoexceptandFile::RefuseArchivedFilethrows throughNotImplemented_nid_no_patch.mmap_nid_postfix ... noexcept.File::RefuseArchivedFile(descriptor, "mmap").NotImplemented_nid_no_patchfor an archived descriptor.openAndLockFileignoreslockMode: No longer applies to this PR.PlatformUse.h:93in the pinned source:USE(FILE_LOCK)is off for PlayStation, so upstream takes no lock either.3rdparty/submodule): Still open, but not on the author.New findings
Blocking
None.
Non-blocking
None.
Not verified
PlatformUse.h:93citation forUSE(FILE_LOCK).597d4921. The range-diff above confirms that the code is unchanged between5f9423c0and this head. I didn't compare597d4921itself.MappedFileDatalayout and the__wrap_mmapbehaviour haven't been checked against console binaries. The debt entry records both.