switch: arm rec EntryPoints need rx. fix arm & dsp cache flush
This commit is contained in:
parent
8a0a0bcdfc
commit
855836d9aa
|
@ -328,7 +328,7 @@ public:
|
|||
FinalizeCode();
|
||||
|
||||
vmem_platform_flush_cache(
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>(),
|
||||
GetBuffer()->GetStartAddress<char*>() + rx_offset, GetBuffer()->GetEndAddress<char*>() + rx_offset,
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>());
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ void dsp_recompile()
|
|||
void dsp_rec_init()
|
||||
{
|
||||
#ifdef FEAT_NO_RWX_PAGES
|
||||
verify(vmem_platform_prepare_jit_block(dsp.DynCode, sizeof(dsp.DynCode), (void**)&pCodeBuffer, (uintptr_t *)&rx_offset));
|
||||
verify(vmem_platform_prepare_jit_block(dsp.DynCode, sizeof(dsp.DynCode), (void**)&pCodeBuffer, &rx_offset));
|
||||
#else
|
||||
verify(vmem_platform_prepare_jit_block(dsp.DynCode, sizeof(dsp.DynCode), (void**)&pCodeBuffer));
|
||||
#endif
|
||||
|
|
|
@ -562,7 +562,7 @@ void compile()
|
|||
// also the size of the EntryPoints table. This way the dynarec
|
||||
// main loop doesn't have to worry about the actual aica
|
||||
// ram size. The aica ram always wraps to 8 MB anyway.
|
||||
EntryPoints[(pc & (ARAM_SIZE_MAX - 1)) / 4] = (void (*)())rv;
|
||||
EntryPoints[(pc & (ARAM_SIZE_MAX - 1)) / 4] = (void (*)())writeToExec(rv);
|
||||
|
||||
block_ops.clear();
|
||||
|
||||
|
@ -657,7 +657,7 @@ void flush()
|
|||
void init()
|
||||
{
|
||||
#ifdef FEAT_NO_RWX_PAGES
|
||||
verify(vmem_platform_prepare_jit_block(ARM7_TCB, ICacheSize, (void**)&ICache, (uintptr_t *)&rx_offset));
|
||||
verify(vmem_platform_prepare_jit_block(ARM7_TCB, ICacheSize, (void**)&ICache, &rx_offset));
|
||||
#else
|
||||
verify(vmem_platform_prepare_jit_block(ARM7_TCB, ICacheSize, (void**)&ICache));
|
||||
#endif
|
||||
|
|
|
@ -602,7 +602,7 @@ public:
|
|||
FinalizeCode();
|
||||
verify(GetBuffer()->GetCursorOffset() <= GetBuffer()->GetCapacity());
|
||||
vmem_platform_flush_cache(
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>(),
|
||||
recompiler::writeToExec(GetBuffer()->GetStartAddress<void*>()), recompiler::writeToExec(GetBuffer()->GetEndAddress<void*>()),
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>());
|
||||
recompiler::advance(GetBuffer()->GetSizeInBytes());
|
||||
|
||||
|
@ -683,7 +683,7 @@ public:
|
|||
|
||||
FinalizeCode();
|
||||
vmem_platform_flush_cache(
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>(),
|
||||
recompiler::writeToExec(GetBuffer()->GetStartAddress<void*>()), recompiler::writeToExec(GetBuffer()->GetEndAddress<void*>()),
|
||||
GetBuffer()->GetStartAddress<void*>(), GetBuffer()->GetEndAddress<void*>());
|
||||
recompiler::advance(GetBuffer()->GetSizeInBytes());
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void vmem_platform_destroy();
|
|||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rwx);
|
||||
// Same as above but uses two address spaces one with RX and RW protections.
|
||||
// Note: this function doesnt have to be implemented, it's a fallback for the above one.
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, uintptr_t *rx_offset);
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, ptrdiff_t *rx_offset);
|
||||
// This might not need an implementation (ie x86/64 cpus).
|
||||
void vmem_platform_flush_cache(void *icache_start, void *icache_end, void *dcache_start, void *dcache_end);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ u8 SH4_TCB[CODE_SIZE + TEMP_CODE_SIZE + 4096]
|
|||
|
||||
u8* CodeCache;
|
||||
u8* TempCodeCache;
|
||||
uintptr_t cc_rx_offset;
|
||||
ptrdiff_t cc_rx_offset;
|
||||
|
||||
u32 LastAddr;
|
||||
u32 LastAddr_min;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
// (ie. exceptions) are RX pointers. These two macros convert between them by
|
||||
// sub/add the pointer offset. CodeCache will point to the RW pointer for simplicity.
|
||||
#ifdef FEAT_NO_RWX_PAGES
|
||||
extern uintptr_t cc_rx_offset;
|
||||
extern ptrdiff_t cc_rx_offset;
|
||||
#define CC_RW2RX(ptr) (void*)(((uintptr_t)(ptr)) + cc_rx_offset)
|
||||
#define CC_RX2RW(ptr) (void*)(((uintptr_t)(ptr)) - cc_rx_offset)
|
||||
#else
|
||||
|
|
|
@ -206,13 +206,9 @@ bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code
|
|||
}
|
||||
|
||||
// Use two addr spaces: need to remap something twice, therefore use allocate_shared_filemem()
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, uintptr_t *rx_offset)
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, ptrdiff_t *rx_offset)
|
||||
{
|
||||
const unsigned size_aligned = ((size + PAGE_SIZE) & (~(PAGE_SIZE-1)));
|
||||
void *ptr_rx = code_area;
|
||||
|
||||
if (ptr_rx != code_area)
|
||||
return false;
|
||||
|
||||
virtmemLock();
|
||||
void* ptr_rw = virtmemFindAslr(size_aligned, 0);
|
||||
|
@ -226,8 +222,8 @@ bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code
|
|||
}
|
||||
|
||||
*code_area_rw = ptr_rw;
|
||||
*rx_offset = (char*)ptr_rx - (char*)ptr_rw;
|
||||
INFO_LOG(DYNAREC, "Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %lu\n", ptr_rx, ptr_rw, (unsigned long)*rx_offset);
|
||||
*rx_offset = (char*)code_area - (char*)ptr_rw;
|
||||
INFO_LOG(DYNAREC, "Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %ld\n", code_area, ptr_rw, (long)*rx_offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code
|
|||
}
|
||||
|
||||
// Use two addr spaces: need to remap something twice, therefore use allocate_shared_filemem()
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, uintptr_t *rx_offset) {
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, ptrdiff_t *rx_offset) {
|
||||
shmem_fd2 = allocate_shared_filemem(size);
|
||||
if (shmem_fd2 < 0)
|
||||
return false;
|
||||
|
@ -278,7 +278,7 @@ bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code
|
|||
|
||||
*code_area_rw = ptr_rw;
|
||||
*rx_offset = (char*)ptr_rx - (char*)ptr_rw;
|
||||
INFO_LOG(DYNAREC, "Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %lu", ptr_rx, ptr_rw, (unsigned long)*rx_offset);
|
||||
INFO_LOG(DYNAREC, "Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %ld", ptr_rx, ptr_rw, (long)*rx_offset);
|
||||
|
||||
return (ptr_rw != MAP_FAILED);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ static void* mem_file_map(void *addr, unsigned size) {
|
|||
}
|
||||
|
||||
// Use two addr spaces: need to remap something twice, therefore use CreateFileMapping()
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, uintptr_t *rx_offset) {
|
||||
bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code_area_rw, ptrdiff_t *rx_offset) {
|
||||
mem_handle2 = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_EXECUTE_READWRITE, 0, size, 0);
|
||||
|
||||
// Get the RX page close to the code_area
|
||||
|
|
Loading…
Reference in New Issue