[PR #943] [MERGED] Patch extrq #1843

Closed
opened 2026-02-27 21:14:10 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/943
Author: @OFFTKP
Created: 9/16/2024
Status: Merged
Merged: 9/23/2024
Merged by: @georgemoralis

Base: mainHead: pat


📝 Commits (6)

📊 Changes

9 files changed (+371 additions, -67 deletions)

View changed files

📝 CMakeLists.txt (+4 -2)
📝 src/common/decoder.cpp (+11 -6)
📝 src/common/decoder.h (+8 -3)
src/common/signal_context.cpp (+92 -0)
src/common/signal_context.h (+18 -0)
📝 src/core/cpu_patches.cpp (+216 -10)
📝 src/core/signals.cpp (+15 -41)
📝 src/core/signals.h (+4 -4)
📝 src/video_core/page_manager.cpp (+3 -1)

📄 Description

Patches EXTRQ (SSE4A instruction) on cpus that don't support it.
If the EXTRQ is less than 5 bytes (can be 4 bytes sometimes), it handles it directly in the illegal instruction handler and doesn't patch it because 5 bytes at least are needed for a relative jump (trampoline)

Another method for dealing with this would be copying the next instruction to run after the trampoline injected code to make more space for the relative jump. This would be faster but less safe (what happens if something jumps to the area you clobbered and replaced with a jump) (also tedious because displacements in rip relative memory access/jumps would need to be changed)

Thus this method of handling smaller than jmp near instructions is employed here

Infamous First Light seems to get further with this patch and it doesn't seem to cause performance issues due to the signal handler.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/943 **Author:** [@OFFTKP](https://github.com/OFFTKP) **Created:** 9/16/2024 **Status:** ✅ Merged **Merged:** 9/23/2024 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `pat` --- ### 📝 Commits (6) - [`9242ad4`](https://github.com/shadps4-emu/shadPS4/commit/9242ad4acac49e4b4aa084fda1927f30404881c9) Use a singleton for instruction decoding - [`b42034d`](https://github.com/shadps4-emu/shadPS4/commit/b42034dad11d47acb6ec9a069301eeab4f50ad20) Use singleton class - [`75ce774`](https://github.com/shadps4-emu/shadPS4/commit/75ce77468b6a3c90029a116dd938328837f8ad6c) Patch `EXTRQ` - [`7037924`](https://github.com/shadps4-emu/shadPS4/commit/7037924a3a36fb68d370e55430618264d4c0a190) Fixup signal context functions - [`4978346`](https://github.com/shadps4-emu/shadPS4/commit/497834644378a15684ed7e08323c861965aa2828) Merge branch 'main' into pat - [`2ac4992`](https://github.com/shadps4-emu/shadPS4/commit/2ac49928b38f6b6ad4dca7f9673309e9390369db) Update CMakeLists.txt ### 📊 Changes **9 files changed** (+371 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+4 -2) 📝 `src/common/decoder.cpp` (+11 -6) 📝 `src/common/decoder.h` (+8 -3) ➕ `src/common/signal_context.cpp` (+92 -0) ➕ `src/common/signal_context.h` (+18 -0) 📝 `src/core/cpu_patches.cpp` (+216 -10) 📝 `src/core/signals.cpp` (+15 -41) 📝 `src/core/signals.h` (+4 -4) 📝 `src/video_core/page_manager.cpp` (+3 -1) </details> ### 📄 Description Patches EXTRQ (SSE4A instruction) on cpus that don't support it. If the EXTRQ is less than 5 bytes (can be 4 bytes sometimes), it handles it directly in the illegal instruction handler and doesn't patch it because 5 bytes at least are needed for a relative jump (trampoline) Another method for dealing with this would be copying the next instruction to run after the trampoline injected code to make more space for the relative jump. This would be faster but less safe (what happens if something jumps to the area you clobbered and replaced with a jump) (also tedious because displacements in rip relative memory access/jumps would need to be changed) Thus this method of handling smaller than jmp near instructions is employed here Infamous First Light seems to get further with this patch and it doesn't seem to cause performance issues due to the signal handler. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:14:10 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/shadPS4#1843
No description provided.