feat(libc): export __fe_dfl_env as measured on a PS5 #11177
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11177"
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 orezraey on 2026-10-25T20:40:07Z.
What
This exports
__fe_dfl_env, the default floating-point environment thatFE_DFL_ENVpoints at, with the 32 bytes the systemlibSceLibcInternalof a retail PS5 (firmware 13.60) exports. Until now the debt file said the object "remains unimplemented" and its initializer was unknown. A title that callsfesetenv(FE_DFL_ENV)orfeupdateenv(FE_DFL_ENV)imports it.Measured with a homebrew probe from a payload process; the source and console log are in this gist (
pfeupdate).libSceLibcInternal.sprxexports__fe_dfl_env. Its bytes are7f03ffff 0000ffff ffffffff 00000000 00000000 00000000 0000ffff c09f0000: x87 control0xffff037f, status0xffff0000, tag0xffffffff,0xffffat offset 26 of thefnstenvblock, and MXCSR0x9fc0.feupdateenv(&__fe_dfl_env)succeeds there. The same probe confirmed whatfeupdateenvalready does here: the flags pending before the call are raised in both units, and an unmasked pending flag traps.SIGSEGV) and for MXCSR0xffff9fc0(SIGBUS); AnyPS5 keeps throwing for both. The debt entry, which said that fault behaviour was unknown, now records it with the gap first.The object is a
const GuestFloatingPointEnvironment __fe_dfl_env_nid_postfixnext tofeholdexceptinMath.cpp, with its declaration inApi.hpp.Before and after
__fe_dfl_envexportfeupdateenv(&__fe_dfl_env)0xffff9fc0Tested
Windows 11, WinLibs GCC 15.2. The 19
guest_update_envtests pass 3 times out of 3. The newDefaultEnvironmentcheck looks the export up by name in the built libc, compares its 32 bytes with the console's, and callsfeupdateenvwith it from a disturbed environment (round toward zero, precision 24-bit). It then checks that the x87 control is0x037fand MXCSR0x9fc0with no flags.tools/check_conventions.pypasses.Head
2fd60d3ebdonmain5a2744c55e. Linux (WSL, GCC 16.2.1, Release) at the same head: the 19guest_update_envtests pass 3 times out of 3.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)feholdexceptentry next to this one) and #10903 (it edits the end ofGuestUpdateEnv.cpp); merge order only. #8937 (fesetenv) merges cleanly with this PR.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:46:22Z.
Review: COMMENTED
Reviewed head
2fd60d3ebd309f137ae2a838af30e7c401f34ff1. I checked the linked probe log: it resolves__fe_dfl_envfromlibSceLibcInternal.sprxand reports7f03ffff0000ffffffffffff0000000000000000000000000000ffffc09f0000, matching the 32-byte initializer and the test's expected bytes. The dependencies named in the PR (#11121, #10903, #8937) are currently open and clean; the declared merge-order dependencies are explicit.Local C++20 syntax compilation of
Math.cppandGuestUpdateEnv.cpp, conventions, andgit diff --checkpassed. Hosted Linux relinker, ASan, and Ubuntu register-context checks pass; Windows and macOS jobs remain pending. The author reports three passing runs of the 19 focusedguest_update_envtests on Windows. I found no concrete issue, and am leaving a comment-only review until the remaining checks complete.