From 80c44090add1e52bfcf013672558de8ea569b885 Mon Sep 17 00:00:00 2001 From: kp Date: Fri, 2 Oct 2020 07:30:11 +0000 Subject: [PATCH] riscv: handle access faults in user mode Access faults in user mode are treated like TLB misses, which leads to an endless loop of faults. It's less serious than the same fault in kernel mode, because we can just terminate the process, but that's not ideal. Treat user mode access faults as a bus error. Suggested by: jrtc27 Reviewed by: br, jhb Sponsored by: Axiado Differential Revision: https://reviews.freebsd.org/D26621 --- sys/riscv/riscv/trap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index 87f088f18fa4..6ea7f7d96d37 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -343,6 +343,10 @@ do_trap_user(struct trapframe *frame) case EXCP_FAULT_LOAD: case EXCP_FAULT_STORE: case EXCP_FAULT_FETCH: + call_trapsignal(td, SIGBUS, BUS_ADRERR, (void *)frame->tf_sepc, + exception); + userret(td, frame); + break; case EXCP_STORE_PAGE_FAULT: case EXCP_LOAD_PAGE_FAULT: case EXCP_INST_PAGE_FAULT: