Skip to content

[Bug] riscv interrupt could not be nested #10457

@fanghuaqi

Description

@fanghuaqi

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions