summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaslyn Tonelli <caslyn@google.com>2023-04-16 19:07:09 +0000
committerCopybara-Service <copybara-worker@google.com>2023-04-17 13:32:16 -0700
commite5722f4e973e3ebe06bfd0f1959106c0f5c2a4ba (patch)
tree57695395c07bff7bfa0d9634cccd814b4f811242
parent88613ee285ffa1ff019c3ea9311dfa4d1e99c5d9 (diff)
downloadscudo-e5722f4e973e3ebe06bfd0f1959106c0f5c2a4ba.tar.gz
[scudo] Tune FuchsiaConfig for RiscV
Reduce `PrimaryRegionSizeLog` to 28U to be compatible with a 38bit user address space on the fuchsia-riscv platform. `PrimaryGroupSizeLog` is reduced to 19 to preserve 512 BatchGroups per region. This change can be tested on Fuchsia with: ``` fx set --auto-dir bringup.riscv64 --with //bundles:boot_tests \ fx build bundles:boot_tests \ fx run-boot-test --args={-s,1} boot-libc-unittests \ --cmdline='--gtest_filter=-*DeathTest*:PthreadGetSet*:ScudoSecondaryTest*' ``` The gtest filter ignores pthread and death tests due to non-scudo related issues on fuchsia-riscv (ScudoSecondaryTest includes a death check). Related Ticket: https://fxbug.dev/125263 Differential Revision: https://reviews.llvm.org/D148475 GitOrigin-RevId: 96005d75b29df315f74978cb0b7602b35f663b75 Change-Id: If70e46e20cfd40974a429775a90c420dd686cbc5
-rw-r--r--standalone/allocator_config.h6
-rw-r--r--standalone/platform.h6
2 files changed, 12 insertions, 0 deletions
diff --git a/standalone/allocator_config.h b/standalone/allocator_config.h
index 64306066123..d06f6dfe4e0 100644
--- a/standalone/allocator_config.h
+++ b/standalone/allocator_config.h
@@ -169,8 +169,14 @@ struct FuchsiaConfig {
static const bool MaySupportMemoryTagging = false;
typedef SizeClassAllocator64<FuchsiaConfig> Primary;
+// Support 39-bit VMA for riscv-64
+#if SCUDO_RISCV64
+ static const uptr PrimaryRegionSizeLog = 28U;
+ static const uptr PrimaryGroupSizeLog = 19U;
+#else
static const uptr PrimaryRegionSizeLog = 30U;
static const uptr PrimaryGroupSizeLog = 21U;
+#endif
typedef u32 PrimaryCompactPtrT;
static const bool PrimaryEnableRandomOffset = true;
static const uptr PrimaryMapSizeIncrement = 1UL << 18;
diff --git a/standalone/platform.h b/standalone/platform.h
index db4217ddab9..aae3b9ab876 100644
--- a/standalone/platform.h
+++ b/standalone/platform.h
@@ -37,6 +37,12 @@
#define SCUDO_TRUSTY 0
#endif
+#if defined(__riscv) && (__riscv_xlen == 64)
+#define SCUDO_RISCV64 1
+#else
+#define SCUDO_RISCV64 0
+#endif
+
#if defined(__LP64__)
#define SCUDO_WORDSIZE 64U
#else