summaryrefslogtreecommitdiff
path: root/libcpu/risc-v/t-head/c906/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpu/risc-v/t-head/c906/trap.c')
-rw-r--r--libcpu/risc-v/t-head/c906/trap.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libcpu/risc-v/t-head/c906/trap.c b/libcpu/risc-v/t-head/c906/trap.c
index aaf5be893f..2600ee0c37 100644
--- a/libcpu/risc-v/t-head/c906/trap.c
+++ b/libcpu/risc-v/t-head/c906/trap.c
@@ -277,6 +277,9 @@ static void handle_nested_trap_panic(
rt_hw_cpu_shutdown();
}
+#define IN_USER_SPACE (stval >= USER_VADDR_START && stval < USER_VADDR_TOP)
+#define PAGE_FAULT (id == EP_LOAD_PAGE_FAULT || id == EP_STORE_PAGE_FAULT)
+
/* Trap entry */
void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw_stack_frame *sp)
{
@@ -314,7 +317,7 @@ void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw
else
{
#ifdef RT_USING_SMART
- if (!(sp->sstatus & 0x100))
+ if (!(sp->sstatus & 0x100) || (PAGE_FAULT && IN_USER_SPACE))
{
handle_user(scause, stval, sepc, sp);
// if handle_user() return here, jump to u mode then