fix(tests): compare the floating-point exception masks with the ones the host keeps #8287

Merged
mugurc merged 2 commits from upstream-pr/8287 into main 2026-10-23 14:28:00 +00:00
mugurc commented 2026-10-20 08:48:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mugurc on 2026-10-20T08:48:21Z.


What

guest_floating_point (#6985) fails on macOS with "flag updates preserve exception masks". The check unmasks the overflow exception in the x87 control word and in MXCSR, calls fesetexceptflag and feclearexcept, and expects both to equal the values it wrote. Under Rosetta 2 the six MXCSR exception masks always read back set, so MXCSR never held the value the test wrote, although the two functions left the masks alone. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298).

  • The test now compares with the environment read back after the write. On a host that keeps the write, that is the value written, so the check is the same there; under Rosetta it still checks the x87 mask and the rest of MXCSR.
  • The debt entry for the floating-point functions notes that an SSE exception the guest unmasks stays masked under Rosetta.

The trap checks that #8442 added since fail on macOS for the same reason, the first one with "enable unmasks the SSE exceptions". They unmask exceptions with feenableexcept and its relatives, expect MXCSR to hold the new masks, and expect the enable and disable results to report the traps enabled on both units. Under Rosetta no SSE trap is ever enabled, so MXCSR keeps all six masks and every result reports none. A second commit:

  • asks the host once whether it keeps an unmasked MXCSR exception and, where it does not, expects all six SSE masks set and no trap on both units. On other hosts the expectations are the same as before;
  • adds a debt entry: the trap functions change only the x87 masks under Rosetta.

Tested

macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series. The first commit ran on main 3fd1cc393 with the series (ci/macos-series-2 on my fork), #8279, #8284, the open macOS fixes #7524 and #7937, and three changes from #7332; the second on main 7e2ba73e4 with the series, which now includes #7937, and the libSceSsl change of #7332. Both commits are now on main cc0078595.

  • A probe built for x86-64, run under Rosetta: clearing any one of the six MXCSR mask bits of 0x1f80 reads back 0x1f80. Flush-to-zero with denormals-are-zero (0x9fc0) and rounding mode 3 (0x7f80) read back as written, and so does an x87 control word with the overflow mask cleared (0x0377).
  • guest_floating_point fails without this PR and passes with it, 5 runs of 5, before and after #8442's trap checks (with the second commit for those).
  • Linux and Windows: not run for the second commit. There the host keeps the unmasked MXCSR exception, so the trap checks expect the same values as before. @ycbuzi ran the first commit on Windows: guest_floating_point passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4933326680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8287). Originally posted by [mugurc](https://github.com/mugurc) on 2026-10-20T08:48:21Z. --- ### What `guest_floating_point` (#6985) fails on macOS with "flag updates preserve exception masks". The check unmasks the overflow exception in the x87 control word and in MXCSR, calls `fesetexceptflag` and `feclearexcept`, and expects both to equal the values it wrote. Under Rosetta 2 the six MXCSR exception masks always read back set, so MXCSR never held the value the test wrote, although the two functions left the masks alone. Part of the macOS series announced on #1 (https://github.com/boykopovar/AnyPS5/issues/1#issuecomment-6124344298). - The test now compares with the environment read back after the write. On a host that keeps the write, that is the value written, so the check is the same there; under Rosetta it still checks the x87 mask and the rest of MXCSR. - The debt entry for the floating-point functions notes that an SSE exception the guest unmasks stays masked under Rosetta. The trap checks that #8442 added since fail on macOS for the same reason, the first one with "enable unmasks the SSE exceptions". They unmask exceptions with `feenableexcept` and its relatives, expect MXCSR to hold the new masks, and expect the enable and disable results to report the traps enabled on both units. Under Rosetta no SSE trap is ever enabled, so MXCSR keeps all six masks and every result reports none. A second commit: - asks the host once whether it keeps an unmasked MXCSR exception and, where it does not, expects all six SSE masks set and no trap on both units. On other hosts the expectations are the same as before; - adds a debt entry: the trap functions change only the x87 masks under Rosetta. ### Tested macOS 26.5.1, Apple M5 Max, Apple clang 21, x86-64 build under Rosetta 2. The libraries do not link on macOS without the rest of the macOS series. The first commit ran on `main` 3fd1cc393 with the series (`ci/macos-series-2` on my fork), #8279, #8284, the open macOS fixes #7524 and #7937, and three changes from #7332; the second on `main` 7e2ba73e4 with the series, which now includes #7937, and the libSceSsl change of #7332. Both commits are now on `main` cc0078595. - A probe built for x86-64, run under Rosetta: clearing any one of the six MXCSR mask bits of `0x1f80` reads back `0x1f80`. Flush-to-zero with denormals-are-zero (`0x9fc0`) and rounding mode 3 (`0x7f80`) read back as written, and so does an x87 control word with the overflow mask cleared (`0x0377`). - `guest_floating_point` fails without this PR and passes with it, 5 runs of 5, before and after #8442's trap checks (with the second commit for those). - Linux and Windows: not run for the second commit. There the host keeps the unmasked MXCSR exception, so the trap checks expect the same values as before. @ycbuzi ran the first commit on Windows: `guest_floating_point` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
ycbuzi commented 2026-10-21 06:58:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T06:58:38Z.


Windows run of 9415d8f574 merged onto main ec7eacc62d (6dcb085765, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built guest_floating_point_tests with no errors or warnings; ctest --repeat until-fail:2 on guest_floating_point: passes on both repeats. Not run: Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310063323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8287#issuecomment-6310063323). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T06:58:38Z. --- Windows run of 9415d8f574 merged onto `main` ec7eacc62d (6dcb085765, clean), one of the hosts the description lists as not run. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `guest_floating_point_tests` with no errors or warnings; `ctest --repeat until-fail:2` on `guest_floating_point`: passes on both repeats. Not run: Linux.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8287
No description provided.