pussuw commented on a change in pull request #5831:
URL: https://github.com/apache/incubator-nuttx/pull/5831#discussion_r833237211
##########
File path: arch/risc-v/src/common/riscv_swint.c
##########
@@ -440,6 +472,22 @@ int riscv_swint(int irq, void *context, void *arg)
regs[REG_INT_CTX] |= MSTATUS_MPPM; /* Machine mode */
rtcb->xcp.sigreturn = 0;
+
+#ifdef CONFIG_ARCH_KERNEL_STACK
+ /* We must enter here be using the user stack. We need to switch
+ * to back to the kernel user stack before returning to the kernel
+ * mode signal trampoline.
+ */
+
+ if (rtcb->xcp.kstack != NULL)
+ {
+ DEBUGASSERT(rtcb->xcp.kstkptr != NULL &&
+ (uintptr_t)rtcb->xcp.ustkptr == regs[REG_SP]);
Review comment:
I assume the test is here to ensure that the user stack has been fully
unwound by the userspace signal handler, i.e. when we return here the SP when
dispatching the signal handler should be the same as when returning from the
signal handler.
I cannot say for sure as I did not write this code.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]