From 6ee9d0f35f925c0d41813635ec220a60033db11c Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 24 Dec 2021 20:19:24 +0200 Subject: [PATCH] sys_rsx: Outlaw mapping sys_vm memory to RSX IO address-space --- rpcs3/Emu/Cell/lv2/sys_process.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_rsx.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_process.cpp b/rpcs3/Emu/Cell/lv2/sys_process.cpp index 24c48653b4..90b4764128 100644 --- a/rpcs3/Emu/Cell/lv2/sys_process.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_process.cpp @@ -231,7 +231,7 @@ CellError process_is_spu_lock_line_reservation_address(u32 addr, u64 flags) return CELL_EPERM; default: { - if (auto vm0 = idm::get(sys_vm_t::find_id(addr & -0x1000'0000))) + if (auto vm0 = idm::get(sys_vm_t::find_id(addr))) { // sys_vm area was not covering the address specified but made a reservation on the entire 256mb region if (vm0->addr + vm0->size - 1 < addr) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index f3c9eb5ed1..d41f0ccac9 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -6,7 +6,9 @@ #include "Emu/Cell/timers.hpp" #include "Emu/Memory/vm_locking.h" #include "Emu/RSX/RSXThread.h" +#include "util/asm.hpp" #include "sys_event.h" +#include "sys_vm.h" LOG_CHANNEL(sys_rsx); @@ -324,6 +326,12 @@ error_code sys_rsx_context_iomap(cpu_thread& cpu, u32 context_id, u32 io, u32 ea { return CELL_EINVAL; } + + if ((addr == ea || !(addr % 0x1000'0000)) && idm::check(sys_vm_t::find_id(addr))) + { + // Virtual memory is disallowed + return CELL_EINVAL; + } } io >>= 20, ea >>= 20, size >>= 20;