diff options
author | Liam <byteslice@airmail.cc> | 2023-12-26 05:21:08 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-12-26 05:30:56 +0100 |
commit | ddda76f9b0d16e8a6fbc92db9e26f25843b647ed (patch) | |
tree | 3fd209d66b8503ca7f0cf6d15c5c065179c66076 /src/core/arm/dynarmic/arm_dynarmic.cpp | |
parent | Merge pull request #12394 from liamwhite/per-process-memory (diff) | |
download | yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar.gz yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar.bz2 yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar.lz yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar.xz yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.tar.zst yuzu-ddda76f9b0d16e8a6fbc92db9e26f25843b647ed.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp new file mode 100644 index 000000000..e6e9fc45b --- /dev/null +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#ifdef __linux__ + +#include "common/signal_chain.h" + +#include "core/arm/dynarmic/arm_dynarmic.h" +#include "core/hle/kernel/k_process.h" +#include "core/memory.h" + +namespace Core { + +namespace { + +thread_local Core::Memory::Memory* g_current_memory{}; +std::once_flag g_registered{}; +struct sigaction g_old_segv {}; + +void HandleSigSegv(int sig, siginfo_t* info, void* ctx) { + if (g_current_memory && g_current_memory->InvalidateSeparateHeap(info->si_addr)) { + return; + } + + return g_old_segv.sa_sigaction(sig, info, ctx); +} + +} // namespace + +ScopedJitExecution::ScopedJitExecution(Kernel::KProcess* process) { + g_current_memory = std::addressof(process->GetMemory()); +} + +ScopedJitExecution::~ScopedJitExecution() { + g_current_memory = nullptr; +} + +void ScopedJitExecution::RegisterHandler() { + std::call_once(g_registered, [] { + struct sigaction sa {}; + sa.sa_sigaction = &HandleSigSegv; + sa.sa_flags = SA_SIGINFO | SA_ONSTACK; + Common::SigAction(SIGSEGV, std::addressof(sa), std::addressof(g_old_segv)); + }); +} + +} // namespace Core + +#endif |