feat(libkernel): sceKernelRaiseException on macOS hosts #4630
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4630"
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 mugurc on 2026-10-12T17:03:23Z.
What
Delivers
sceKernelRaiseExceptionon macOS hosts the way Linux does: the host SIGUSR1 interrupts the target thread and the handler runs on it, with the interrupted registers and float state in the guest context; changes the handler makes to the context are applied when it returns.Darwin hands the signal handler an
mcontext_tthat points to a general register structure and a float state structure, instead of holding the registers (gregs,fpregs) as glibc does. The registers are copied one by one. The float state of x86-64 Darwin starts with an FXSAVE image; astatic_assertchecks the offsets of the control word, MXCSR and the first and last XMM register against the FXSAVE layout, so the 512 bytes of the guest context are copied from and to it. Rosetta 2 applies a modified context on return.The test used
constexpr int SIGUSR1 = 30, which is a macro on macOS; the constant is renamed, and the spin function of the test usesAPS5_ASM_FUNCTION. The debt entry says Linux and macOS. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).Tested
main7e2ba73e4with the rest of the macOS series (ci/macos-series-2on my fork, which now includes #7937) and the libSceSsl change of #7332. The libraries do not link on macOS without the series.ninja,ninja libsandctest -j4: 1798 tests, 1123 passed, 25 failed, the rest skipped (no Vulkan loader in the environment);guest_raise_exceptionpasses.main7e2ba73e4. The conflicts were the test's constants, where #8390 loweredRepeatsto 50 (kept, with the constant still namedGuestSigUsr1), and the debt entry, wheremainadded the Windows entry after the Linux one (both kept, the Linux one saying Linux and macOS).guest_raise_exceptionpassed 25 runs in a row on macOS (ctest --repeat until-fail:25); the test checks the registers, XMM8 and MXCSR the handler sees, nested waits and wake-ups.Exception.cppis unchanged (the Darwin code is under#ifdef __APPLE__). An earlier version ran on my fork's CI with the rest of the series: 960 tests on Linux and 966 on Windows pass (https://github.com/mugurc/AnyPS5/actions/runs/38256280627).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)Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T21:07:29Z.
Review: COMMENTED
Checked on Apple M2 Max, macOS 27.2, Xcode 27.0 (Apple clang 21.0.0), x86-64 full build under Rosetta. Head cc064ec78 on
main41cc655b8, together with #4627, #4629 and #5735.mainincore/libs/tests/GuestRaiseException.cpponly, against the Windows address-lock block from #5756. Takingmain's block and renamingSIGUSR1toGuestSigUsr1resolves it. That includes the two new uses inside#ifdef _WIN32, at lines 417 and 469 of the merged file.Exception.cppmerges cleanly with the Windows change.System/src/Exception.cppand the test compile on macOS. Onmainthey fail with theucontext.h_XOPEN_SOURCEerror,gregs/REG_*and theSIGUSR1macro.guest_raise_exception.libcandlibkerneldo not link on currentmainyet (GuestAllocations.cpplink.h, and the libkernel host APIs), so the test cannot link. Details are in #1.Written with AI assistance (Claude Code). I ran the builds above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T15:45:24Z.
Follow-up to my earlier review, where
guest_raise_exceptioncould not link yet. Headf17e3d3e4.Machine: Apple M2 Max, macOS 27.2, Apple clang 21, full x86-64 build under Rosetta 2. Base:
maine5f18ea99with yourci/macos-series-2(fa6d8ae0b) and the open macOS fixes it uses (#6928, #6667, #6668, #6969, #6853, #6836, #6620, #7524). Everything merges without conflicts.guest_raise_exceptionpasses 25 runs in a row (ctest --repeat until-fail:25), so it holds on a second chip and on macOS 27.2.maingained aftera62c724c3do not break anything in the series:guest_app_info,guest_thread_self,guest_kernel_fcntl,guest_file_vector,guest_file_timestamps,param_sfo_parser, thedownload_data_mount_*tests andsce_module_code_extentpass.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-24T16:16:15Z.
Review: COMMENTED
Tested head
50dafe9523on Apple M4 Pro, macOS 27.0.1, Apple clang, x86-64 Release under Rosetta 2.Alone on
main3fcb5e4d76:System/src/Exception.cppnow compiles.GuestRaiseException.cppconflicts withmain. #9074 removed the#ifdef _WIN32around the holding-handler block and addedHandlerRunsInUnboundedAddressWait(), and both still useSIGUSR1, which this PR renames. To resolve it locally I keptmain's block and switched its twoSIGUSR1uses, and the one inHandlerRunsInUnboundedAddressWait(line 505), toGuestSigUsr1.With that and the other open macOS build PRs (the same stack as in my review of #7631),
guest_raise_exceptionpasses 20 runs in a row (ctest --repeat until-fail:20).AI-assisted: yes