[compiler-rt] [scudo] limit VMA size for riscv64 for DefaultConfig (PR #76013)

Icenowy Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 22:00:12 PST 2023


https://github.com/Icenowy created https://github.com/llvm/llvm-project/pull/76013

The VMA size for RISC-V 64-bit Sv39 virtual address map is currently only defined in FuchsiaConfig, which leads to scudo failure on RISC-V Linux Sv39 systems, and most current available RISC-V Linux systems support only Sv39 in hardware.

Copy the reduced VMA size definition to DefaultConfig.

>From e16e653a227187b1eae8748c9e818d3bc4753d97 Mon Sep 17 00:00:00 2001
From: Icenowy Zheng <uwu at icenowy.me>
Date: Wed, 20 Dec 2023 13:52:45 +0800
Subject: [PATCH] [scudo] limit VMA size for riscv64 for DefaultConfig

The VMA size for RISC-V 64-bit Sv39 virtual address map is currently
only defined in FuchsiaConfig, which leads to scudo failure on RISC-V
Linux Sv39 systems, and most current available RISC-V Linux systems
support only Sv39 in hardware.

Copy the reduced VMA size definition to DefaultConfig.

Signed-off-by: Icenowy Zheng <uwu at icenowy.me>
---
 compiler-rt/lib/scudo/standalone/allocator_config.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler-rt/lib/scudo/standalone/allocator_config.h b/compiler-rt/lib/scudo/standalone/allocator_config.h
index 3c6aa3acb0e45b..3b2ac5f86b6f8c 100644
--- a/compiler-rt/lib/scudo/standalone/allocator_config.h
+++ b/compiler-rt/lib/scudo/standalone/allocator_config.h
@@ -124,8 +124,14 @@ struct DefaultConfig {
   struct Primary {
     using SizeClassMap = DefaultSizeClassMap;
 #if SCUDO_CAN_USE_PRIMARY64
+#if SCUDO_RISCV64
+    // Support 39-bit VMA for riscv-64
+    static const uptr RegionSizeLog = 30U;
+    static const uptr GroupSizeLog = 19U;
+#else
     static const uptr RegionSizeLog = 32U;
     static const uptr GroupSizeLog = 21U;
+#endif
     typedef uptr CompactPtrT;
     static const uptr CompactPtrScale = 0;
     static const bool EnableRandomOffset = true;



More information about the llvm-commits mailing list