xiaoxiang781216 commented on code in PR #15815:
URL: https://github.com/apache/nuttx/pull/15815#discussion_r1950782741


##########
arch/risc-v/src/common/riscv_backtrace.c:
##########
@@ -150,17 +163,10 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int 
size, int skip)
     {
       if (up_interrupt_context())
         {
-#if CONFIG_ARCH_INTERRUPTSTACK > 15
-          ret = backtrace((uintptr_t *)g_intstackalloc,

Review Comment:
   but we need dump the backtrace on interrupt stack too



##########
arch/risc-v/src/common/riscv_exception_common.S:
##########
@@ -207,25 +207,46 @@ handle_irq:
   .cfi_offset x2, 8               /* Toolchain not support macro, is REG_X2 * 
4 */
   .cfi_offset ra, 0               /* Toolchain not support macro, is REG_EPC * 
4 */
 
+  REGLOAD    ra, REG_EPC(sp)
+  REGLOAD    s0, REG_X8(sp)

Review Comment:
   why need save ra/s0



##########
arch/risc-v/src/common/riscv_doirq.c:
##########
@@ -88,13 +88,24 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
       (*running_task)->xcp.regs = regs;
     }
 
-  /* Nested interrupts are not supported */
+  /* Current regs non-zero indicates that we are processing an interrupt;
+   * current_regs is also used to manage interrupt level context switches.
+   *
+   * Nested interrupts are not supported. But an exception may occur while
+   * processing an interrupt. In this case, current_regs will be non-NULL.
+   */
 
-  DEBUGASSERT(!up_interrupt_context());
+  DEBUGASSERT(((irq > RISCV_MAX_EXCEPTION) && !up_interrupt_context()) ||

Review Comment:
   this patch contain unrelated change, please split to the small and independ 
patch for easy review.



##########
arch/risc-v/src/common/riscv_exception_common.S:
##########
@@ -207,25 +207,46 @@ handle_irq:
   .cfi_offset x2, 8               /* Toolchain not support macro, is REG_X2 * 
4 */
   .cfi_offset ra, 0               /* Toolchain not support macro, is REG_EPC * 
4 */
 
+  REGLOAD    ra, REG_EPC(sp)
+  REGLOAD    s0, REG_X8(sp)
+
 #if CONFIG_ARCH_INTERRUPTSTACK > 15
 
   /* Switch to interrupt stack */
 
   setintstack t0, t1
 
+  addi       sp, sp, -16
+  REGSTORE   ra, 12(sp)
+  REGSTORE   s0, 8(sp)
+  add         s0, sp, 16
+
   /* Call interrupt handler in C */
 
   jal        x1, riscv_dispatch_irq
 
+  REGLOAD    ra, 12(sp)
+  REGLOAD    s0, 8(sp)
+  add  sp,sp,16

Review Comment:
   align the second argument at line 222, 230, 238, 248



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to