From bed746d7d61af2026b41a90f16055e55c3634c26 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 1 Jul 2019 06:56:16 +0000 Subject: [PATCH] Using BSD new PROT_MAX mmap to block page address wider promotions --- src/os.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/os.c b/src/os.c index 1fa6319..f6ca2ae 100644 --- a/src/os.c +++ b/src/os.c @@ -105,7 +105,11 @@ static void* mi_mmap(void* addr, size_t size, int extra_flags, mi_stats_t* stats flags |= MAP_FIXED; #endif } - p = mmap(addr, size, (PROT_READ | PROT_WRITE), flags, -1, 0); + int pflags = PROT_READ | PROT_WRITE; +#if defined(PROT_MAX) + pflags |= PROT_MAX(PROT_READ | PROT_WRITE); // BSD +#endif + p = mmap(addr, size, pflags, flags, -1, 0); if (p == MAP_FAILED) p = NULL; if (addr != NULL && p != addr) { mi_munmap(p, size);