mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 11:26:56 +02:00
loader: replace SSE4a EXTRQ with native trampolines on hosts without SSE4a (#839)
loader: add native EXTRQ patches with trap fallback Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
@@ -11,20 +11,34 @@
|
||||
|
||||
namespace Loader {
|
||||
|
||||
struct InstructionPatchCounts {
|
||||
uint64_t found = 0;
|
||||
uint64_t native = 0;
|
||||
uint64_t trapped = 0;
|
||||
|
||||
uint64_t Skipped() const { return found - native - trapped; }
|
||||
|
||||
InstructionPatchCounts& operator+=(const InstructionPatchCounts& other) {
|
||||
found += other.found;
|
||||
native += other.native;
|
||||
trapped += other.trapped;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct GuestInstructionPatchResult {
|
||||
uint64_t function_count = 0;
|
||||
uint64_t instruction_count = 0;
|
||||
uint64_t red_zone_function_count = 0;
|
||||
uint64_t memory_instruction_count = 0;
|
||||
uint64_t short_memory_instruction_count = 0;
|
||||
uint64_t patched_memory_instruction_count = 0;
|
||||
uint64_t stack_dependent_memory_instruction_count = 0;
|
||||
uint64_t control_flow_memory_instruction_count = 0;
|
||||
uint64_t unrelocatable_memory_instruction_count = 0;
|
||||
uint64_t indirect_red_zone_function_count = 0;
|
||||
uint64_t reciprocal_sqrt_instruction_count = 0;
|
||||
uint64_t patched_reciprocal_sqrt_instruction_count = 0;
|
||||
uint64_t trapped_reciprocal_sqrt_instruction_count = 0;
|
||||
uint64_t function_count = 0;
|
||||
uint64_t instruction_count = 0;
|
||||
uint64_t red_zone_function_count = 0;
|
||||
uint64_t memory_instruction_count = 0;
|
||||
uint64_t short_memory_instruction_count = 0;
|
||||
uint64_t patched_memory_instruction_count = 0;
|
||||
uint64_t stack_dependent_memory_instruction_count = 0;
|
||||
uint64_t control_flow_memory_instruction_count = 0;
|
||||
uint64_t unrelocatable_memory_instruction_count = 0;
|
||||
uint64_t indirect_red_zone_function_count = 0;
|
||||
InstructionPatchCounts reciprocal_sqrt;
|
||||
InstructionPatchCounts extrq;
|
||||
};
|
||||
|
||||
void RegisterGuestInstructionPatchModule(void* module_ptr, uint64_t module_size,
|
||||
@@ -34,7 +48,7 @@ void UnregisterGuestInstructionPatchModule(void* module_ptr);
|
||||
// Apply enabled instruction fixes using native trampolines or safe trap fallbacks.
|
||||
GuestInstructionPatchResult PatchGuestInstructions(uint64_t segment_addr, uint64_t segment_size,
|
||||
std::span<const uintptr_t> function_starts,
|
||||
bool protect_memory, bool emulate_rsqrt);
|
||||
bool protect_memory, bool emulate_amd);
|
||||
|
||||
bool DecodeEhFrameFunctionStarts(uint64_t eh_frame_header_addr, uint64_t eh_frame_header_size,
|
||||
std::vector<uintptr_t>* function_starts);
|
||||
|
||||
Reference in New Issue
Block a user