about summary refs log tree commit diff stats
path: root/src/custommem.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-01-16 10:20:16 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-01-16 10:20:16 +0100
commite5649d90e7deb3e7388475d62f4174b4bd64063f (patch)
tree896e3b02944878922793473fa684e32047fd8e32 /src/custommem.c
parentd22e6f28a1a155737b57e7c6a3c1c29136bdb66d (diff)
downloadbox64-e5649d90e7deb3e7388475d62f4174b4bd64063f.tar.gz
box64-e5649d90e7deb3e7388475d62f4174b4bd64063f.zip
Round size to pagesize on the tracked memory
Diffstat (limited to 'src/custommem.c')
-rw-r--r--src/custommem.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/custommem.c b/src/custommem.c
index 77ea14f6..a389b32b 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -1217,6 +1217,7 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot)
 
 void setProtection(uintptr_t addr, size_t size, uint32_t prot)
 {
+    size = ALIGN(size);
     mutex_lock(&mutex_prot);
     addMapMem(mapallmem, addr, addr+size-1);
     uintptr_t cur = addr & ~(box64_pagesize-1);
@@ -1229,7 +1230,7 @@ void setProtection_mmap(uintptr_t addr, size_t size, uint32_t prot)
 {
     if(!size)
         return;
-    size = (size+box64_pagesize-1)&~(box64_pagesize-1); // round size
+    size = ALIGN(size);
     mutex_lock(&mutex_prot);
     addMapMem(mmapmem, addr, addr+size-1);
     mutex_unlock(&mutex_prot);
@@ -1244,6 +1245,7 @@ void setProtection_mmap(uintptr_t addr, size_t size, uint32_t prot)
 
 void setProtection_elf(uintptr_t addr, size_t size, uint32_t prot)
 {
+    size = ALIGN(size);
     if(prot)
         setProtection(addr, size, prot);
     else {
@@ -1308,6 +1310,7 @@ void loadProtectionFromMap()
 
 void freeProtection(uintptr_t addr, size_t size)
 {
+    size = ALIGN(size);
     dynarec_log(LOG_DEBUG, "freeProtection %p:%p\n", (void*)addr, (void*)(addr+size-1));
     mutex_lock(&mutex_prot);
     removeMapMem(mapallmem, addr, addr+size-1);