BUGFIX: arm: armv7: data abort in get_bad_stack_swi
PATCH 1/1 BUGFIX: arm: armv7: data abort in get_bad_stack_swi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as do_software_interrupt() in arch/arm/lib/interrupts.c. Actually it causes data abort in get_bad_stack_swi macro in arch/arm/cpu/v7/start.S.
This patch fixes this problem.
---
Hello, I found this bug on KZM-A9-GT board (aka. kzm9g) on v2013.04-rc2. And tested this patch on the board.
I found the same typo in arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.
arch/arm/cpu/armv7/start.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv7/start.S +1 -1
@@ -465,7 +465,7 @@ ENDPROC(cpu_init_crit) @ spots for abort stack str lr, [r0] @ save caller lr in position 0 @ of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of @ saved stack ldr r0, [r13] @ restore r0
Signature · 1 line
1.7.9.5
PATCH 1/1 BUGFIX: arm: armv7: data abort in get_bad_stack_swi
Hi Tetsuyuki,
Quoted 7 lines · Tetsuyuki Kobayashi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as
do_software_interrupt()inarch/arm/lib/interrupts.c. Actually it causes data abort inget_bad_stack_swimacro inarch/arm/cpu/v7/start.S.
This patch fixes this problem.
Quoted 5 lines
Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Hello, I found this bug on KZM-A9-GT board (aka. kzm9g) on v2013.04-rc2. And tested this patch on the board.
I found the same typo inarch/arm/cpu/{arm1136,arm1176,pxa}/start.S.
The can you please submit a V2 patch fixing all four of them?
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 BUGFIX: arm: armv7: data abort in get_bad_stack_swi
Quoted 1 line
The can you please submit a V2 patch fixing all four of them?
s/The/Then/ (and s//coffee, too)
Amicalement,
Signature · 1 line
Albert.
PATCH 1/1 BUGFIX: arm: armv7: data abort in get_bad_stack_swi
Quoted 6 lines · Albert ARIBAUD
Quoted 1 line
The can you please submit a V2 patch fixing all four of them?
s/The/Then/ (and s//coffee, too)
Amicalement,
OK. I will do it tomorrow.
PATCH v2 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
In reply to Tetsuyuki KobayashiWhen swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as do_software_interrupt() in arch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address in get_bad_stack_swi macro in arch/arm/cpu/v7/start.S.
This patch fixes this problem.
The same mistake in arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.
---
Changes for v2:
- added arch/arm/cpu/{arm1136,arm1176,pxa}/start.S (But not tested, because I don't have test boards of them) arm/arm/cpu/armv7/start.S is tested on KZM-A9-GT board.
arch/arm/cpu/arm1136/start.S | 2 +- arch/arm/cpu/arm1176/start.S | 2 +- arch/arm/cpu/armv7/start.S | 2 +- arch/arm/cpu/pxa/start.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/cpu/arm1136/start.S +1 -1
@@ -392,7 +392,7 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry
arch/arm/cpu/arm1176/start.S +1 -1
@@ -480,7 +480,7 @@ phy_last_jump: /* save caller lr in position 0 of saved stack */ str lr, [r0] /* get the spsr */ - mrs r0, spsr + mrs lr, spsr /* save spsr in position 1 of saved stack */ str lr, [r0, #4] /* restore r0 */
arch/arm/cpu/armv7/start.S +1 -1
@@ -465,7 +465,7 @@ ENDPROC(cpu_init_crit) @ spots for abort stack str lr, [r0] @ save caller lr in position 0 @ of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of @ saved stack ldr r0, [r13] @ restore r0
arch/arm/cpu/pxa/start.S +1 -1
@@ -387,7 +387,7 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry
Signature · 1 line
1.7.9.5
PATCH v2 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
Hi Tetsuyuki,
Quoted 27 lines · Tetsuyuki Kobayashi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as
do_software_interrupt()inarch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address inget_bad_stack_swimacro inarch/arm/cpu/v7/start.S.
This patch fixes this problem.The same mistake in
arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Changes for v2:
- addedarch/arm/cpu/{arm1136,arm1176,pxa}/start.S(But not tested, because I don't have test boards of them)arm/arm/cpu/armv7/start.Sis tested on KZM-A9-GT board.arch/arm/cpu/arm1136/start.S | 2 +- arch/arm/cpu/arm1176/start.S | 2 +- arch/arm/cpu/armv7/start.S | 2 +- arch/arm/cpu/pxa/start.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)arch/arm/cpu/arm1136/start.S +0
-0
arch/arm/cpu/arm1136/start.S cpu_init_crit: · line 398
Quoted 8 lines
arch/arm/cpu/arm1136/start.S +1
-1@@ -392,7 +392,7 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry
Sorry for not checking this in V1, but I see that get_bad_stack_swi does not preserve lr, so when bad_save_user_regs is expanded, it will save the wrong value for lr. You need to restore lr from [r0] before you restore r0 from [r13].
arch/arm/cpu/pxa/start.S
Quoted 5 lines
arch/arm/cpu/arm1176/start.S +0
-0arch/arm/cpu/armv7/start.S +0
-0arch/arm/cpu/pxa/start.S +0
-0
Ditto for all four files, of course.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
Hi Albert
Quoted 37 lines · Albert ARIBAUD
Hi Tetsuyuki,
Quoted 32 lines · Tetsuyuki Kobayashi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as
do_software_interrupt()inarch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address inget_bad_stack_swimacro inarch/arm/cpu/v7/start.S.
This patch fixes this problem.The same mistake in
arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Changes for v2:
- addedarch/arm/cpu/{arm1136,arm1176,pxa}/start.S(But not tested, because I don't have test boards of them)arm/arm/cpu/armv7/start.Sis tested on KZM-A9-GT board.arch/arm/cpu/arm1136/start.S | 2 +- arch/arm/cpu/arm1176/start.S | 2 +- arch/arm/cpu/armv7/start.S | 2 +- arch/arm/cpu/pxa/start.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)arch/arm/cpu/arm1136/start.S +1
-1@@ -392,7 +392,7 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr
Quoted 8 lines
arch/arm/cpu/arm1136/start.S cpu_init_crit: · line 398
Quoted 3 lines
arch/arm/cpu/arm1136/start.S +0
-0str lr, [r0, #4] @ save spsr in position 1 of saved stack ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entrySorry for not checking this in V1, but I see that
get_bad_stack_swidoes not preserve lr, so whenbad_save_user_regsis expanded, it will save the wrong value for lr. You need to restore lr from [r0] before you restore r0 from [r13].
Thank you, I was not aware that.
The dumped lr value was wrong.
I am going to post V3 patch for all 4 files.
Quoted 11 lines
arch/arm/cpu/pxa/start.S
Quoted 6 lines
arch/arm/cpu/arm1176/start.S +0
-0arch/arm/cpu/armv7/start.S +0
-0arch/arm/cpu/pxa/start.S +0
-0Ditto for all four files, of course.
Amicalement,
PATCH v3 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
In reply to Tetsuyuki KobayashiWhen swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as do_software_interrupt() in arch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address in get_bad_stack_swi macro in arch/arm/cpu/v7/start.S.
This patch fixes this problem.
The same mistake in arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.
---
Changes for v2:
- added arch/arm/cpu/{arm1136,arm1176,pxa}/start.S Changes for v3:
- restore lr register in all 4 files.
Only arm/arm/cpu/armv7/start.S is tested on KZM-A9-GT board.
arch/arm/cpu/arm1136/start.S | 3 ++- arch/arm/cpu/arm1176/start.S | 4 +++- arch/arm/cpu/armv7/start.S | 3 ++- arch/arm/cpu/pxa/start.S | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-)
arch/arm/cpu/arm1136/start.S +2 -1
@@ -392,8 +392,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endm
arch/arm/cpu/arm1176/start.S +3 -1
@@ -480,9 +480,11 @@ phy_last_jump: /* save caller lr in position 0 of saved stack */ str lr, [r0] /* get the spsr */ - mrs r0, spsr + mrs lr, spsr /* save spsr in position 1 of saved stack */ str lr, [r0, #4] + /* restore lr */ + ldr lr, [r0] /* restore r0 */ ldr r0, [r13] /* pop stack entry */
arch/arm/cpu/armv7/start.S +2 -1
@@ -465,9 +465,10 @@ ENDPROC(cpu_init_crit) @ spots for abort stack str lr, [r0] @ save caller lr in position 0 @ of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of @ saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endm
arch/arm/cpu/pxa/start.S +2 -1
@@ -387,8 +387,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endm
Signature · 1 line
1.7.9.5
PATCH v3 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
Hello Albert
How about this patch?
Quoted 87 lines · Tetsuyuki Kobayashi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as
do_software_interrupt()inarch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address inget_bad_stack_swimacro inarch/arm/cpu/v7/start.S.
This patch fixes this problem.The same mistake in
arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Changes for v2:
- addedarch/arm/cpu/{arm1136,arm1176,pxa}/start.SChanges for v3:
- restore lr register in all 4 files.
Onlyarm/arm/cpu/armv7/start.Sis tested on KZM-A9-GT board.arch/arm/cpu/arm1136/start.S | 3 ++- arch/arm/cpu/arm1176/start.S | 4 +++- arch/arm/cpu/armv7/start.S | 3 ++- arch/arm/cpu/pxa/start.S | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-)arch/arm/cpu/arm1136/start.S +2
-1@@ -392,8 +392,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endmarch/arm/cpu/arm1176/start.S +3
-1@@ -480,9 +480,11 @@ phy_last_jump: /* save caller lr in position 0 of saved stack */ str lr, [r0] /* get the spsr */ - mrs r0, spsr + mrs lr, spsr /* save spsr in position 1 of saved stack */ str lr, [r0, #4] + /* restore lr */ + ldr lr, [r0] /* restore r0 */ ldr r0, [r13] /* pop stack entry */arch/arm/cpu/armv7/start.S +2
-1@@ -465,9 +465,10 @@ ENDPROC(cpu_init_crit) @ spots for abort stack str lr, [r0] @ save caller lr in position 0 @ of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of @ saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endmarch/arm/cpu/pxa/start.S +2
-1@@ -387,8 +387,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endm
PATCH v3 1/1 BUGFIX: arm: data abort in get_bad_stack_swi
In reply to Tetsuyuki KobayashiHi Tetsuyuki,
Quoted 76 lines · Tetsuyuki Kobayashi
When swi instruction is executed, it is expected to get message "software interrupt" in console and dump registers and reboot, as
do_software_interrupt()inarch/arm/lib/interrupts.c.
But, actually it causes data abort accessing wrong address inget_bad_stack_swimacro inarch/arm/cpu/v7/start.S.
This patch fixes this problem.The same mistake in
arch/arm/cpu/{arm1136,arm1176,pxa}/start.S.Signed-off-by Tetsuyuki Kobayashi <[email protected]>---
Changes for v2:
- addedarch/arm/cpu/{arm1136,arm1176,pxa}/start.SChanges for v3:
- restore lr register in all 4 files.
Onlyarm/arm/cpu/armv7/start.Sis tested on KZM-A9-GT board.arch/arm/cpu/arm1136/start.S | 3 ++- arch/arm/cpu/arm1176/start.S | 4 +++- arch/arm/cpu/armv7/start.S | 3 ++- arch/arm/cpu/pxa/start.S | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-)arch/arm/cpu/arm1136/start.S +2
-1@@ -392,8 +392,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endmarch/arm/cpu/arm1176/start.S +3
-1@@ -480,9 +480,11 @@ phy_last_jump: /* save caller lr in position 0 of saved stack */ str lr, [r0] /* get the spsr */ - mrs r0, spsr + mrs lr, spsr /* save spsr in position 1 of saved stack */ str lr, [r0, #4] + /* restore lr */ + ldr lr, [r0] /* restore r0 */ ldr r0, [r13] /* pop stack entry */arch/arm/cpu/armv7/start.S +2
-1@@ -465,9 +465,10 @@ ENDPROC(cpu_init_crit) @ spots for abort stack str lr, [r0] @ save caller lr in position 0 @ of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of @ saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endmarch/arm/cpu/pxa/start.S +0
-0
arch/arm/cpu/pxa/start.S cpu_init_crit: · line 395
Quoted 10 lines
arch/arm/cpu/pxa/start.S +2
-1@@ -387,8 +387,9 @@ cpu_init_crit: str r0, [r13] @ save R0's value. ldr r0, IRQ_STACK_START_IN @ get data regions start str lr, [r0] @ save caller lr in position 0 of saved stack - mrs r0, spsr @ get the spsr + mrs lr, spsr @ get the spsr str lr, [r0, #4] @ save spsr in position 1 of saved stack + ldr lr, [r0] @ restore lr ldr r0, [r13] @ restore r0 add r13, r13, #4 @ pop stack entry .endm
Applied to u-boot-arm/master, thanks!
Amicalement,
Signature · 1 line
Albert.