You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/10 23:20:41 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5558: armv7-a/r: fix SVC's sp restore in arm_vectors.S

pkarashchenko commented on a change in pull request #5558:
URL: https://github.com/apache/incubator-nuttx/pull/5558#discussion_r824257401



##########
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:
       Why we can't just `ldmia r14, {r13, r14, r15}^` here instead of
   ```
   	ldmia		r14, {r13, r14}^		/* Restore user mode r13/r14 */
   	add		r14, r14, #(4*2)		/* (SVC) r14=address of r15 storage */
   	ldmia r14, {r15}^ /* Return */
   ```
   I see that PC was stored right after LR
   ```
   sub r3, lr, #4
   ...
   add r0, sp, #(4*REG_SP) /* Offset to sp/lr storage */
   stmia r0, {r13, r14}^ /* Save user mode r13(sp) and r14(lr) */
   add r0, sp, #(4*REG_R15) /* Offset to pc/cpsr storage */
   stmia r0, {r3, r4} /* Save r15(pc), and the CPSR */
   ```
   Or I'm missing something?




-- 
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-unsubscribe@nuttx.apache.org

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