KytyPS5/tests
Bartłomiej Wołyńczyk 35c6e8fff6
loader: enable the AMD CPU instruction patcher on macOS (#1014)
* loader: enable AMD CPU instruction patching on macOS

The guest instruction patcher was compiled out on macOS and runtimeLinker forced emulate_amd off,
so under Rosetta every SSE4a EXTRQ/INSERTQ took the SIGILL path (about 18 us each). Build the
patcher on all hosts and let --amd-cpu enable it on macOS like on Windows and Linux. The host
feature probe already reports no SSE4a under Rosetta, so EXTRQ becomes a native trampoline and the
remaining fallbacks keep using the x64 instruction emulator through the host exception handler.

* tests: macos_sse4a covers the guest instruction patcher on macOS

Patch EXTRQ/INSERTQ blobs in an RWX area with a trampoline page behind it, with the host features of
Rosetta (no SSE4a/RDPID/CLWB), and compare against the SIGILL emulator: EXTRQ must become a native
trampoline without SIGILL, INSERTQ stays a trap handled by the emulator, and nothing is touched
without emulate_amd.

* loader: emulate the patcher's VRSQRTPS trap and MWAITX on macOS

The AMD CPU patcher marks VRSQRTPS it cannot relocate by clearing a reserved
VEX.vvvv bit, which raises #UD on every host including Rosetta. The macOS build
left TryEmulateReciprocalSquareRoot and TryEmulateMonitorxMwaitx out, so the
guest died with an unhandled SIGILL at the first such site.

Both are plain SSE2/libc, so enable them on macOS. The Darwin context also
gains ClearUpperYmm so the VEX.128 result zeroes YMM[255:128] when the thread
has the AVX context. macos_sse4a covers the trapped VRSQRTPS and MWAITX.

* tests: macos_sse4a runs a plain VEX.128 VRSQRTPS through the patcher

The existing case started from an instruction that was already marked as a trap. The
new cases feed the ordinary encoding to PatchGuestInstructions and compare the result
with the emulated reference, both through a native trampoline and, when the instruction
cannot be relocated, through the trap mark and the signal emulator.

* loader: compact macOS instruction patcher coverage

Share the emulator dispatch chain while keeping SHA emulation limited to non-Apple hosts and preserving handler order. Remove a duplicate VRSQRTPS signal test already covered by both native and trapped patcher cases, plus blank lines left by removed platform guards.

---------

Co-authored-by: nmzik <Nmzik@mail.ru>
2026-10-06 21:55:11 +04:00
..
ArchiveFileTests.cpp Zarchive Loading (#724) 2026-09-29 00:06:44 +04:00
ArchiveTestFixture.h Zarchive Loading (#724) 2026-09-29 00:06:44 +04:00
AudioOut2PortTests.cpp audio: implement AudioOut2 user capability queries 2026-09-28 22:17:43 +04:00
AudioOutTimingTests.cpp controller: cycle DualSense speaker volume, vibration and trigger intensity in game (#946) 2026-10-02 15:11:34 +04:00
AvPlayerFileTests.cpp Zarchive Loading (#724) 2026-09-29 00:06:44 +04:00
BitArrayTests.cpp graphics: perf - batch GPU page watcher updates at 4 MiB granularity 2026-08-02 08:39:50 +02:00
CesTests.cpp libCes CP932 fix for Windows/macOS, fix SaveDataDialog lockups (#878) 2026-09-28 18:42:22 +04:00
ControllerSettingsTests.cpp launcher: Raise DualSense speaker volume range for SpeakerFX (#1043) 2026-10-04 19:48:25 +04:00
EventQueueLifetimeTests.cpp kernel: deliver persistent user events once per wait 2026-10-06 14:53:17 +04:00
HttpUriParseTests.cpp libNet: honour the option mask in sceHttpUriBuild (#1069) 2026-10-05 21:31:45 +04:00
ImagePageTableTests.cpp gpu: address extended guest memory without widening dense cache tables 2026-09-28 18:01:49 +04:00
ImeDialogTests.cpp remove unused helpers and the -64 suffix 2026-09-17 20:35:36 +04:00
KernelFileSystemTests.cpp net: export connect, getsockopt, sendto, and recvfrom 2026-10-06 21:32:46 +04:00
LruCacheTests.cpp tests: add LeastRecentlyUsedCache regression tests (#671) 2026-09-26 02:42:31 +04:00
MemoryTrackerTests.cpp Skip clean memory tracker ranges during buffer synchronization 2026-10-03 14:19:33 +04:00
Ngs2SamplerTests.cpp audio: prevent ATRAC9 vibration configuration heap corruption 2026-09-28 22:17:43 +04:00
PadHapticsTests.cpp launcher: Raise DualSense speaker volume range for SpeakerFX (#1043) 2026-10-04 19:48:25 +04:00
PageManagerTests.cpp DualSense haptics and controller speaker sound bluethooth (#969) 2026-10-02 14:55:00 +04:00
PngEncTests.cpp libs: libScePngEnc on stb_image_write 2026-09-30 17:06:41 +04:00
ResourceMaterializationTests.cpp Revert "shader: keep scalar data native and preserve raw addresses" 2026-10-05 18:39:31 +04:00
ResourceTrackingTests.cpp shader: limit broad image tables to compatible views 2026-10-06 14:59:05 +04:00
SaveDataDialogTests.cpp libCes CP932 fix for Windows/macOS, fix SaveDataDialog lockups (#878) 2026-09-28 18:42:22 +04:00
SaveDataMemoryTests.cpp loader: wrap elapsed time in Timer::GetTime (#679) 2026-09-24 22:02:19 +04:00
ScalarProvenanceTests.cpp Remove dead shader instruction cycles with linear liveness traversal 2026-10-02 15:49:43 +04:00
ShaderRayTracingGpuTests.inc shader: support RDNA2 BVH64 ray intersections with shared traversal 2026-10-04 18:39:34 +04:00
ShaderRayTracingTests.inc shader: support RDNA2 BVH64 ray intersections with shared traversal 2026-10-04 18:39:34 +04:00
ShaderRecompilerComputeTests.cpp shader: sample mixed bindless images through contiguous native arrays 2026-10-06 14:53:17 +04:00
ShaderVertexMetadataTests.cpp graphics: consume vertex semantics directly from shader metadata 2026-09-29 13:57:32 +04:00
SyncOnAddressTests.cpp kernel: support timed umtx waits through shared address deadlines 2026-09-14 06:58:32 +04:00
TrophySystemTests.cpp Map UDS events to trophies from dumped metadata; trophy viewer/overview improvements (#1088) 2026-10-06 17:45:26 +04:00
VirtualMemoryAllocationTests.cpp memory: replace live direct mappings without exposing an inaccessible gap 2026-10-04 18:39:34 +04:00
macosSse4aTests.cpp loader: enable the AMD CPU instruction patcher on macOS (#1014) 2026-10-06 21:55:11 +04:00
shaderCfgTests.cpp shader: emit native 64-bit operations where compatible 2026-10-05 20:41:03 +04:00