Skip to content

RISC-V: detect virtual address space at runtime using hwprobe#1296

Open
aurel32 wants to merge 1 commit into
microsoft:mainfrom
aurel32:main
Open

RISC-V: detect virtual address space at runtime using hwprobe#1296
aurel32 wants to merge 1 commit into
microsoft:mainfrom
aurel32:main

Conversation

@aurel32
Copy link
Copy Markdown

@aurel32 aurel32 commented May 18, 2026

The virtual address space on RISC-V is currently detected at build time by parsing /proc/cpuinfo. This works when the binary runs on the same hardware it was built, however running such a binary on a system with a larger address space just causes a segmentation fault.

Replace the build time check with a runtime detection using the hwprobe interface (available since Linux 6.11, commit c9b8cd139c1d "riscv: hwprobe export highest virtual userspace address"). For older kernels, fallback to the default 48 bits. This is suboptimal on SV39 MMUs but still works.

@aurel32
Copy link
Copy Markdown
Author

aurel32 commented May 18, 2026

@microsoft-github-policy-service agree

Comment thread CMakeLists.txt
The virtual address space on RISC-V is currently detected at build time
by parsing /proc/cpuinfo. This works when the binary runs on the same
hardware it was built, however running such a binary on a system with a
larger address space just causes a segmentation fault.

Replace the build time check with a runtime detection using the hwprobe
interface (available since Linux 6.11, commit c9b8cd139c1d "riscv:
hwprobe export highest virtual userspace address"), with a fallback to
parsing /proc/cpuinfo on older kernels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants