pussuw commented on a change in pull request #5831:
URL: https://github.com/apache/incubator-nuttx/pull/5831#discussion_r833236049



##########
File path: arch/risc-v/src/common/riscv_swint.c
##########
@@ -415,6 +429,24 @@ int riscv_swint(int irq, void *context, void *arg)
           regs[REG_A1]         = regs[REG_A2]; /* signal */
           regs[REG_A2]         = regs[REG_A3]; /* info */
           regs[REG_A3]         = regs[REG_A4]; /* ucontext */
+
+#ifdef CONFIG_ARCH_KERNEL_STACK
+          /* If we are signalling a user process, then we must be operating
+           * on the kernel stack now.  We need to switch back to the user
+           * stack before dispatching the signal handler to the user code.
+           * The existence of an allocated kernel stack is sufficient
+           * information to make this decision.
+           */
+
+          if (rtcb->xcp.kstack != NULL)
+            {
+              DEBUGASSERT(rtcb->xcp.kstkptr == NULL &&
+                          rtcb->xcp.ustkptr != NULL);
+
+              rtcb->xcp.kstkptr = (uintptr_t *)regs[REG_SP];
+              regs[REG_SP]      = (uintptr_t)rtcb->xcp.ustkptr;

Review comment:
       I think the assert test you mentioned below is to ensure that the stack 
pointer has been fully unwound to what was set here?




-- 
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