From 53440ad69a803dca06b8dcfd3ce332e36631d48b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 20 Sep 2024 22:10:22 -0400 Subject: [PATCH] src/os.c: skip aligned hinting when MI_SV39_MMU=1 is defined This constant will be defined when the host has an SV39 MMU. The usual 2TiB+ hinting strategy will not work on those systems, so we skip it, just as we would if the system was not "64-bit." --- src/os.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os.c b/src/os.c index ce104273..f5f1ef28 100644 --- a/src/os.c +++ b/src/os.c @@ -77,8 +77,10 @@ bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats -------------------------------------------------------------- */ // On 64-bit systems, we can do efficient aligned allocation by using -// the 2TiB to 30TiB area to allocate those. -#if (MI_INTPTR_SIZE >= 8) +// the 2TiB to 30TiB area to allocate those. The one exception is on +// 64-bit RISC-V systems that have an SV39 MMU; there the 256GiB+ +// range (and specifically the 2TiB+ range) will not be usable. +#if (MI_INTPTR_SIZE >= 8) && (!defined(MI_SV39_MMU) || MI_SV39_MMU == 0) static mi_decl_cache_align _Atomic(uintptr_t)aligned_base; // Return a MI_SEGMENT_SIZE aligned address that is probably available.