/// Amount of virtual space for malloc
#ifdef __x86_64__
-# define HEAP_REGION (2UL * 1024 * 1024 * 1024) /* 2GB */
+# define HEAP_REGION (3500UL * 1024 * 1024) /* 2GB */
#else
# define HEAP_REGION (512UL * 1024 * 1024) /* 512MB */
#endif
thread_mutex_init(&state->mutex);
+ // setup flags that match the alignment
+ vregion_flags_t morecore_flags = VREGION_FLAGS_READ_WRITE;
+#if __x86_64__
+ morecore_flags |= (alignment == HUGE_PAGE_SIZE ? VREGION_FLAGS_HUGE : 0);
+#endif
+ morecore_flags |= (alignment == LARGE_PAGE_SIZE ? VREGION_FLAGS_LARGE : 0);
+
err = vspace_mmu_aware_init_aligned(&state->mmu_state, HEAP_REGION,
- alignment, VREGION_FLAGS_READ_WRITE | MORECORE_VREGION_FLAGS);
+ alignment, morecore_flags);
if (err_is_fail(err)) {
return err_push(err, LIB_ERR_VSPACE_MMU_AWARE_INIT);
}