diff options
| author | Man, Jianting (Meco) <[email protected]> | 2023-02-25 13:52:37 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-25 13:52:37 -0500 |
| commit | 1acef4277b02e5084310ecd7028656ae535178f5 (patch) | |
| tree | 03b6b6f0b3df75a1cef301e1e7b2b3d234213390 /libcpu/risc-v/virt64/trap.c | |
| parent | 759192f5f5af23ae360818483d35974ef5b91c78 (diff) | |
| parent | e63e33a3c64327aef3556fa811df0a8ec1e0e7ee (diff) | |
Merge pull request #6981 from RT-Thread/masterserialX-dev
sync from master
Diffstat (limited to 'libcpu/risc-v/virt64/trap.c')
| -rw-r--r-- | libcpu/risc-v/virt64/trap.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libcpu/risc-v/virt64/trap.c b/libcpu/risc-v/virt64/trap.c index 7b3bafae88..b9f30ed715 100644 --- a/libcpu/risc-v/virt64/trap.c +++ b/libcpu/risc-v/virt64/trap.c @@ -274,6 +274,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) { @@ -326,7 +329,7 @@ void handle_trap(rt_size_t scause, rt_size_t stval, rt_size_t sepc, struct rt_hw } #endif /* ENABLE_VECTOR */ #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 |
