From 05442bdb11d90b074d0c9b98f973e7ef2b143c76 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 1 Sep 2017 00:59:25 +0300 Subject: [PATCH] Protect SPU segments --- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 7113a9f842..813147307d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -42,10 +42,12 @@ void sys_spu_image::load(const fs::file& stream) } } + const u32 mem_size = nsegs * sizeof(sys_spu_segment) + ::size32(stream); + type = SYS_SPU_IMAGE_TYPE_KERNEL; entry_point = obj.header.e_entry; nsegs = sys_spu_image::get_nsegs(obj.progs); - segs = vm::cast(vm::alloc(nsegs * sizeof(sys_spu_segment) + ::size32(stream), vm::main)); + segs = vm::cast(vm::alloc(mem_size, vm::main)); const u32 src = segs.addr() + nsegs * sizeof(sys_spu_segment); @@ -56,6 +58,8 @@ void sys_spu_image::load(const fs::file& stream) { fmt::throw_exception("Failed to load SPU segments (%d)" HERE, nsegs); } + + vm::page_protect(segs.addr(), ::align(mem_size, 4096), 0, 0, vm::page_writable); } void sys_spu_image::free()