anchao commented on a change in pull request #5558: URL: https://github.com/apache/incubator-nuttx/pull/5558#discussion_r825669289
########## File path: arch/arm/src/armv7-a/arm_vectors.S ########## @@ -239,15 +239,16 @@ arm_vectorirq: cmp r2, #PSR_MODE_USR /* User mode? */ bne .Lirqleavesvc /* Branch if not user mode */ + add sp, sp, #XCPTCONTEXT_SIZE /* Restore SVC's sp */ + /* ldmia with ^ will return the user mode registers (provided that r15 * is not in the register list). */ - mov r13, r0 /* (SVC) R13=Register storage area */ - ldmia r13, {r0-r12} /* Restore common R0-R12 */ - add r14, r13, #(4*REG_R13) /* (SVC) R14=address of R13/R14 storage */ - ldmia r14, {r13, r14}^ /* Restore user mode R13/R14 */ - add r14, r13, #(4*REG_R15) /* (SVC) R14=address of R15 storage */ + mov r14, r0 /* (SVC) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ Review comment: I think here is an answer: https://developer.arm.com/documentation/dui0588/b/ARM-and-Thumb-Instructions/LDM-and-STM ``` ^ is an optional suffix, available in ARM state only. You must not use it in User mode or System mode. It has the following purposes: If the instruction is LDM (with any addressing mode) and reglist contains the PC (R15), in addition to the normal multiple register transfer, the SPSR is copied into the CPSR. This is for returning from exception handlers. Use this only from exception modes. Otherwise, data is transferred into or out of the User mode registers instead of the current mode registers. ``` -- 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