From a98887589d64c47c635962072c8d5a30e5134ce2 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 17 Dec 2024 13:22:20 +0100 Subject: [BOX32] Improved pre-reserve highmem, and use that memory for dynablocks --- src/custommem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/custommem.c b/src/custommem.c index b6af88cc..3380bdb5 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "box64context.h" #include "elfloader.h" @@ -821,6 +822,7 @@ dynablock_t* FindDynablockFromNativeAddress(void* p) void* box32_dynarec_mmap(size_t size) { // find a block that was prereserve before and big enough + size = (size+box64_pagesize-1)&~(box64_pagesize-1); uint32_t flag; static uintptr_t cur = 0x100000000LL; uintptr_t bend = 0; @@ -1597,7 +1599,12 @@ void allocProtection(uintptr_t addr, size_t size, uint32_t prot) size = ALIGN(size); addr &= ~(box64_pagesize-1); LOCK_PROT(); - rb_set(mapallmem, addr, addr+size, 1); + uint32_t val; + uintptr_t endb; + int there = rb_get_end(mapallmem, addr, &val, &endb); + // block is here or absent, no half-block handled.. + if(!there) + rb_set(mapallmem, addr, addr+size, 1); UNLOCK_PROT(); // don't need to add precise tracking probably } @@ -1859,7 +1866,7 @@ void reverveHigMem32(void) // printf_log(LOG_DEBUG, " Failed to reserve %zx sized block\n", cur_size); cur_size>>=1; } else { - rb_set(mapallmem, (uintptr_t)cur, (uintptr_t)cur+cur_size, 1); + rb_set(mapallmem, (uintptr_t)cur, (uintptr_t)cur+cur_size, 2); //printf_log(LOG_DEBUG, "Reserved high %p (%zx)\n", cur, cur_size); } } @@ -1904,6 +1911,7 @@ void reverveHigMem32(void) start = bend; } } + personality(ADDR_LIMIT_32BIT); } #endif void my_reserveHighMem() -- cgit 1.4.1