summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-04-19 14:07:21 -0400
committerBen Gamari <ben@smart-cactus.org>2021-05-12 15:44:45 -0400
commitb9ee7011f1d1988726a4e0efec330bfa3a08fd38 (patch)
tree18b1422eee5d02d1baaeebf860980ddb816795d7
parent86fab4113c26d450ef8160c2e153e128b65bef7d (diff)
downloadhaskell-b9ee7011f1d1988726a4e0efec330bfa3a08fd38.tar.gz
rts/m32: Fix bounds check
Previously we would check only that the *start* of the mapping was in the bottom 32-bits of address space. However, we need the *entire* mapping to be in low memory. Fix this. Noticed by @Phyx. (cherry picked from commit 72c1812feecd2aff2a96b629063ba90a2f4cdb7b)
-rw-r--r--rts/linker/M32Alloc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/rts/linker/M32Alloc.c b/rts/linker/M32Alloc.c
index 1a19df8471..ae4d1ae891 100644
--- a/rts/linker/M32Alloc.c
+++ b/rts/linker/M32Alloc.c
@@ -256,11 +256,12 @@ m32_alloc_page(void)
m32_free_page_pool_size --;
return page;
} else {
- struct m32_page_t *page = mmapForLinker(getPageSize(),MAP_ANONYMOUS,-1,0);
- if (page > (struct m32_page_t *) 0xffffffff) {
+ const size_t map_sz = getPageSize();
+ uint8_t *page = mmapForLinker(map_sz,MAP_ANONYMOUS,-1,0);
+ if (page + map_sz > (uint8_t *) 0xffffffff) {
barf("m32_alloc_page: failed to get allocation in lower 32-bits");
}
- return page;
+ return (struct m32_page_t *) page;
}
}