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



##########
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:
       https://developer.arm.com/documentation/dui0497/a/BABCAEDD
   
   `The accesses happens in order of increasing register numbers, with the 
lowest numbered register using the lowest memory address and the highest number 
register using the highest memory address. `
   
   
   `ldmia r14, {r13, r14, r15}^`
   
   If this syntax is used, R15 will be pushed first, which will immediately 
change the PC, and R13 and R14 will not be updated:
   
   ```
   [    2.380000] [ 4] [ ALERT] SYSCALL Entry: regs: 0x80202708 cmd: 4
   [    2.380000] [ 4] [ ALERT]   R0: 00000004 80001939 00000001 80202018 
00000000 00000000 00000000 802027d0
   [    2.380000] [ 4] [ ALERT]   R8: 00000000 00000000 00000000 00000000 
00000000 802027d0 1080f738 1080f738
   [    2.380000] [ 4] [ ALERT] CPSR: 00000073
   [    2.380000] [ 4] [ ALERT] SYSCALL Exit: regs: 0x80202708
   [    2.380000] [ 4] [ ALERT]   R0: 1 80202018 1 80202018 0 0 0 802027d0
   [    2.380000] [ 4] [ ALERT]   R8: 0 0 0 0 0 802027d0 1080f738 80001939
   [    2.380000] [ 4] [ ALERT] CPSR: 00000070
   [    2.390000] [ 4] [ EMERG] arm_dataabort: Data abort. PC: 80001938 DFAR: 
fffffff8 DFSR: 00000805
   [    2.390000] [ 4] [ EMERG] up_assert: Assertion failed at 
file:armv7-a/arm_dataabort.c line: 161 task: /mnt/nfs/bin/init
   [    2.390000] [ 4] [ EMERG] arm_registerdump: R0: 00000001 R1: 80202018 R2: 
00000001  R3: 80202018
   [    2.390000] [ 4] [ EMERG] arm_registerdump: R4: 00000000 R5: 00000000 R6: 
00000000  FP: 802027d0
   [    2.390000] [ 4] [ EMERG] arm_registerdump: R8: 00000000 SB: 00000000 SL: 
00000000 R11: 00000000
   [    2.390000] [ 4] [ EMERG] arm_registerdump: IP: 00000000 SP: 00000000 LR: 
00000000  PC: 80001938
   ```
   
   SP/LR is NULL




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