1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Replaces page fault triggers with assembly

This commit is contained in:
RipleyTom 2024-01-16 04:35:28 +01:00 committed by Elad.Ash
parent fa7ef870dd
commit 7d55a85fa6
3 changed files with 13 additions and 3 deletions

View File

@ -3721,7 +3721,7 @@ bool spu_thread::do_putllc(const spu_mfc_cmd& args)
if (!vm::check_addr(addr, vm::page_writable))
{
vm::_ref<atomic_t<u8>>(addr) += 0; // Access violate
utils::trigger_write_page_fault(vm::base(addr));
}
raddr = 0;
@ -3823,7 +3823,7 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write)
else if (!g_use_rtm)
{
// Provoke page fault
vm::_ref<atomic_t<u32>>(addr) += 0;
utils::trigger_write_page_fault(vm::base(addr));
// Hard lock
auto spu = cpu ? cpu->try_get<spu_thread>() : nullptr;

View File

@ -237,7 +237,7 @@ namespace vm
// Try triggering a page fault (write)
// TODO: Read memory if needed
vm::_ref<atomic_t<u8>>(test / 4096 == begin / 4096 ? begin : test) += 0;
utils::trigger_write_page_fault(vm::base(test / 4096 == begin / 4096 ? begin : test));
continue;
}
}

View File

@ -2,6 +2,7 @@
#include "util/types.hpp"
#include "util/tsc.hpp"
#include "util/atomic.hpp"
#include <functional>
extern bool g_use_rtm;
@ -435,6 +436,15 @@ namespace utils
return factor1 > 0 && T{umax} / factor1 < factor2 ? T{umax} : static_cast<T>(factor1 * factor2);
}
inline void trigger_write_page_fault(void* ptr)
{
#if defined(ARCH_X64) && !defined(_MSC_VER)
__asm__ volatile("lock orl $0, 0(%0)" :: "r" (ptr));
#else
*static_cast<atomic_t<u32> *>(ptr) += 0;
#endif
}
inline void trap()
{
#ifdef _M_X64