Skip to content

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

Open
aurel32 wants to merge 1 commit into
microsoft:dev3from
aurel32:dev3
Open

RISC-V: detect virtual address space at runtime using hwprobe#1299
aurel32 wants to merge 1 commit into
microsoft:dev3from
aurel32:dev3

Conversation

@aurel32
Copy link
Copy Markdown

@aurel32 aurel32 commented May 25, 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"), with a fallback to parsing /proc/cpuinfo on older kernels.

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.

1 participant