xiaoxiang781216 commented on code in PR #19123: URL: https://github.com/apache/nuttx/pull/19123#discussion_r3417652623
########## arch/arm/src/armv7-m/arm_sigdeliver.c: ########## @@ -163,6 +164,27 @@ void arm_sigdeliver(void) leave_critical_section(up_irq_save()); #endif + /* If the signal handler modified SP (REG_R13), relocate the saved + * context so that the hardware exception return produces the correct SP. + * + * On ARMv7-M, the exception return path sets PSP to the HW frame address + * and hardware computes final SP = PSP + frame_size. The implied SP is + * determined by the physical location of the context, not by REG_R13. + * To honor a modified SP, we memmove the entire context frame to the + * address where the end of the frame equals the desired SP. + */ + + uint32_t desired_sp = regs[REG_R13]; + uint32_t implied_sp = (uint32_t)regs + XCPTCONTEXT_SIZE; Review Comment: move the variable definition to the begin of function to confirm c89 spec ########## arch/arm/src/armv8-m/arm_sigdeliver.c: ########## @@ -163,6 +164,27 @@ void arm_sigdeliver(void) leave_critical_section(up_irq_save()); #endif + /* If the signal handler modified SP (REG_R13), relocate the saved + * context so that the hardware exception return produces the correct SP. + * + * On ARMv8-M, the exception return path sets PSP to the HW frame address + * and hardware computes final SP = PSP + frame_size. The implied SP is + * determined by the physical location of the context, not by REG_R13. + * To honor a modified SP, we memmove the entire context frame to the + * address where the end of the frame equals the desired SP. + */ + + uint32_t desired_sp = regs[REG_R13]; + uint32_t implied_sp = (uint32_t)regs + XCPTCONTEXT_SIZE; Review Comment: ditto -- 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]
