Files
AnyPS5/docs/dev/debt/changes/fix-libkernel-handler-context-fpformat.md
MoandClaude Fable 5.2 96adac001b fix(libkernel): mark exception handler contexts as XMM-format FPU state
Every context handed to a guest exception handler carried a 512-byte
FXSAVE image but left mc_fpformat and mc_ownedfp at 0. The tree's own
sigreturn rejects a context whose format is not _MC_FPFMT_XMM, so a
handler that resumed through sigreturn of the context it was given got
EINVAL. FreeBSD 11.4's sendsig fills both fields through get_fpcontext.

CallHandler now sets mc_fpformat to _MC_FPFMT_XMM (0x10002) and
mc_ownedfp to _MC_FPOWNED_FPU (0x20001), as getcontext here already
does. The constants move from UserContext.cpp to UserContext.hpp.

Tests check the two fields in raise and fault handlers and resume a
fault handler through sigreturn of its own context. The debt entry for
handler contexts states what is still unmeasured or different.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 02:42:44 -08:00

1.0 KiB

libkernel

change builds the handler's

  • sceKernelRaiseException handler contexts are verified on the console only in the fields PS5Util reads; mc_fpformat and mc_ownedfp are not measured. A handler leaving through sigreturn or setcontext unblocks every guest signal on its thread, as uc_sigmask is empty where FreeBSD's sendsig saves the old mask; after a raise it keeps host SIGUSR1 blocked on Linux and macOS, losing later raises to that thread, and on Windows, after a raise on the calling thread or in a libkernel wait, resumes before the delivery and runs again (untested). Every handler context has getcontext's layout (mcontext at 0x40, mc_rsp at 0xf8), sets mc_fpformat and mc_ownedfp to _MC_FPFMT_XMM and _MC_FPOWNED_FPU (FreeBSD reports _MC_FPOWNED_PCB when the FPU state was not live) and leaves mc_flags 0, where FreeBSD sets _MC_HASSEGS and, with XSAVE, _MC_HASFPXSTATE. Returning loads mc_fpstate whatever the two fields say