mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-13 15:19:11 +00:00
cpu_patches: Patch just-in-time using signal handlers. (#852)
* cpu_patches: Patch just-in-time using illegal instruction handler. * core: Add common signal dispatch system and use for on-demand TCB patches. * page_manager: Re-add userfaultfd implementation.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <xbyak/xbyak.h>
|
||||
#include "common/alignment.h"
|
||||
#include "common/arch.h"
|
||||
#include "common/assert.h"
|
||||
@@ -92,9 +91,11 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
||||
LoadOffset += CODE_BASE_INCR * (1 + aligned_base_size / CODE_BASE_INCR);
|
||||
LOG_INFO(Core_Linker, "Loading module {} to {}", name, fmt::ptr(*out_addr));
|
||||
|
||||
#ifdef ARCH_X86_64
|
||||
// Initialize trampoline generator.
|
||||
void* trampoline_addr = std::bit_cast<void*>(base_virtual_addr + aligned_base_size);
|
||||
Xbyak::CodeGenerator c(TrampolineSize, trampoline_addr);
|
||||
RegisterPatchModule(*out_addr, aligned_base_size, trampoline_addr, TrampolineSize);
|
||||
#endif
|
||||
|
||||
LOG_INFO(Core_Linker, "======== Load Module to Memory ========");
|
||||
LOG_INFO(Core_Linker, "base_virtual_addr ......: {:#018x}", base_virtual_addr);
|
||||
@@ -135,7 +136,7 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
||||
add_segment(elf_pheader[i]);
|
||||
#ifdef ARCH_X86_64
|
||||
if (elf_pheader[i].p_flags & PF_EXEC) {
|
||||
PatchInstructions(segment_addr, segment_file_size, c);
|
||||
PrePatchInstructions(segment_addr, segment_file_size);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user