-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Bug] riscv interrupt could not be nested #10457
Copy link
Copy link
Open
Labels
Arch: RISC-VBSP related with risc-vBSP related with risc-v
Description
RT-Thread Version
master
Hardware Type/Architectures
RISC-V with CLIC Interrupt
Develop Toolchain
GCC
Describe the bug
The interrupt handling logic for risc-v, see as below
rt-thread/libcpu/risc-v/common/interrupt_gcc.S
Lines 101 to 109 in fcd0b1e
| csrrw sp,mscratch,sp | |
| /* interrupt handle */ | |
| call rt_interrupt_enter | |
| /* Do the work after saving the above */ | |
| jal rt_hw_do_after_save_above | |
| call rt_interrupt_leave | |
| /* switch to from thread stack */ | |
| csrrw sp,mscratch,sp |
In line 101, if another higher priority interrupt is nested(since in rt_hw_do_after_save_above, it will re-enable interrupt to allow higher priority interrupt), then it will switch from interrupt stack to task stack. I think if interrupt nesting is supported, it is better to nest in the interrupt stack to avoid corrupting the task stack.
Maybe here it should check whether interrupt is nesting or not to determine whether switch between interrupt stack and task stack.
Thanks
Other additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Arch: RISC-VBSP related with risc-vBSP related with risc-v