RT-Thread / RT-Thread/rt-thread
[Bug] riscv interrupt could not be nested
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
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
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with libcpu/risc-v/common/interrupt_gcc.S at lines 101-109 and trace rt_hw_do_after_save_above, focusing on how a higher-priority nested interrupt changes interrupt and task stack selection. Reproduce or reason through nested RISC-V CLIC interrupts with GCC, and consider the issue resolved when nesting no longer risks corrupting the task stack.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100