Skip to content

Commit bc3d5c0

Browse files
committed
Limit Linux RISC-V address bits
Linux RISC-V systems may run with an Sv39 user address space. The generic AAL default reports 48 address bits for 64-bit targets, which makes the default pagemap cover a much larger range than the process can reserve on those systems. On an Sv39 Linux host, allocator initialisation tried to reserve a 256 GiB pagemap and mmap returned ENOMEM. Use the same conservative 38-bit RISC-V limit that the FreeBSD PAL already uses so the Linux PAL sizes its pagemap for the usable lower address range.
1 parent 526c55b commit bc3d5c0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/snmalloc/pal/pal_linux.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ namespace snmalloc
4242
static constexpr size_t page_size =
4343
Aal::aal_name == PowerPC ? 0x10000 : PALPOSIX::page_size;
4444

45+
static constexpr size_t address_bits =
46+
Aal::aal_name == RISCV ? 38 : PALPOSIX::address_bits;
47+
4548
/**
4649
* Linux requires an explicit no-reserve flag in `mmap` to guarantee lazy
4750
* commit if /proc/sys/vm/overcommit_memory is set to `heuristic` (0).

0 commit comments

Comments
 (0)