HomeFreeBSD

riscv: Avoid passing invalid addresses to pmap_fault()

Description

riscv: Avoid passing invalid addresses to pmap_fault()

After the addition of SV48 support, VIRT_IS_VALID() did not exclude
addresses that are in the SV39 address space hole but not in the SV48
address space hole. This can result in mishandling of accesses to that
range when in SV39 mode.

Fix the problem by modifying VIRT_IS_VALID() to use the runtime address
space bounds. Then, if the address is invalid, and pcb_onfault is set,
give vm_fault_trap() a chance to veto the access instead of panicking.

PR: 265439
Reviewed by: jhb
Reported and tested by: Robert Morris <rtm@lcs.mit.edu>
Fixes: 31218f3209ac ("riscv: Add support for enabling SV48 mode")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 828ea49debe34fddf63cb648b9e57871a34158b6)

Details

Provenance
markjAuthored on Jul 28 2022, 1:38 PM
Parents
rG2817d3ac2a0a: hidbus(4): Align refcount checks for hidbus_intr_start() and hidbus_intr_stop().
Branches
Unknown
Tags
Unknown