in fault_handler -> ../../core/linux/common.cpp : 99 ------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- core/linux/common.cpp ------------------------------------------------------------------------------------------------- #if !defined(TARGET_NO_EXCEPTIONS) bool ngen_Rewrite(unat& addr,unat retadr,unat acc); u32* ngen_readm_fail_v2(u32* ptr,u32* regs,u32 saddr); bool VramLockedWrite(u8* address); bool BM_LockedWrite(u8* address); #if HOST_OS == OS_DARWIN void sigill_handler(int sn, siginfo_t * si, void *segfault_ctx) { rei_host_context_t ctx; context_from_segfault(&ctx, segfault_ctx); unat pc = (unat)ctx.pc; bool dyna_cde = (pc>(unat)CodeCache) && (pc<(unat)(CodeCache + CODE_SIZE)); printf("SIGILL @ %08X, fault_handler+0x%08X ... %08X -> was not in vram, %d\n", pc, pc - (unat)sigill_handler, (unat)si->si_addr, dyna_cde); printf("Entering infiniloop"); for (;;); printf("PC is used here %08X\n", pc); } #endif #if !defined(TARGET_NO_EXCEPTIONS) void fault_handler (int sn, siginfo_t * si, void *segfault_ctx) { rei_host_context_t ctx; context_from_segfault(&ctx, segfault_ctx); bool dyna_cde = ((unat)ctx.pc>(unat)CodeCache) && ((unat)ctx.pc<(unat)(CodeCache + CODE_SIZE)); //ucontext_t* ctx=(ucontext_t*)ctxr; //printf("mprot hit @ ptr 0x%08X @@ code: %08X, %d\n",si->si_addr,ctx->uc_mcontext.arm_pc,dyna_cde); if (VramLockedWrite((u8*)si->si_addr) || BM_LockedWrite((u8*)si->si_addr)) return; #if FEAT_SHREC == DYNAREC_JIT #if HOST_CPU==CPU_ARM else if (dyna_cde) { ctx.pc = (u32)ngen_readm_fail_v2((u32*)ctx.pc, ctx.r, (unat)si->si_addr); context_to_segfault(&ctx, segfault_ctx); } #elif HOST_CPU==CPU_X86 else if (ngen_Rewrite((unat&)ctx.pc, *(unat*)ctx.esp, ctx.eax)) { //remove the call from call stack ctx.esp += 4; //restore the addr from eax to ecx so it's valid again ctx.ecx = ctx.eax; context_to_segfault(&ctx, segfault_ctx); } #elif HOST_CPU == CPU_X64 //x64 has no rewrite support #else #error JIT: Not supported arch #endif #endif else { printf("SIGSEGV @ %p (fault_handler+0x%p) ... %p -> was not in vram\n", ctx.pc, ctx.pc - (unat)fault_handler, si->si_addr); die("segfault"); signal(SIGSEGV, SIG_DFL); } } #endif ------------------------------------------------------------------------------------------------- Error on : VramLockedWrite (video-ram - 8MB) || BM_LockedWrite (motherboard-ram - 16MB) ------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------- core/hw/mem/_vmem.cpp ------------------------------------------------------------------------------------------------- bool BM_LockedWrite(u8* address) { if (!_nvmem_enabled()) return false; #if FEAT_SHREC != DYNAREC_NONE u32 addr=address-(u8*)p_sh4rcb->fpcb; address=(u8*)p_sh4rcb->fpcb+ (addr&~PAGE_MASK); if (addrfpcb)) { //printf("Allocated %d PAGES [%08X]\n",++pagecnt,addr); #if HOST_OS==OS_WINDOWS verify(VirtualAlloc(address,PAGE_SIZE,MEM_COMMIT,PAGE_READWRITE)); #else mprotect (address, PAGE_SIZE, PROT_READ | PROT_WRITE); #endif bm_vmem_pagefill((void**)address,PAGE_SIZE); return true; } #else die("BM_LockedWrite and NO REC"); #endif return false; } ------------------------------------------------------------------------------------------------- core/rend/TexCache.cpp ------------------------------------------------------------------------------------------------- bool VramLockedWrite(u8* address) { size_t offset=address-vram.data; if (offset* list=&VramLocks[addr_hash]; { vramlist_lock.Lock(); for (size_t i=0;isize();i++) { if ((*list)[i]) { libPvr_LockedBlockWrite((*list)[i],(u32)offset); if ((*list)[i]) { msgboxf("Error : pvr is supposed to remove lock",MBX_OK); dbgbreak; } } } list->clear(); vram.UnLockRegion((u32)offset&(~(PAGE_SIZE-1)),PAGE_SIZE); //TODO: Fix this for 32M wrap as well if (_nvmem_enabled() && VRAM_SIZE == 0x800000) { vram.UnLockRegion((u32)offset&(~(PAGE_SIZE-1)) + VRAM_SIZE,PAGE_SIZE); } vramlist_lock.Unlock(); } return true; } else return false; } ------------------------------------------------------------------------------------------------- core/rend/TexCache.h ------------------------------------------------------------------------------------------------- void vram_LockedWrite(u32 offset64); ------------------------------------------------------------------------------------------------- core/stdclass.cpp ------------------------------------------------------------------------------------------------- bool VramLockedWrite(u8* address); bool RamLockedWrite(u8* address,u32* sp);