Thumb-2: Implementation of the unified start-up and exceptions code
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/11 Thumb-2: Implementation of the unified start-up and exceptions code
Quoted 41 lines · Catalin Marinas
arch/arm/kernel/entry-common.S +2
-16@@ -33,14 +33,7 @@ ret_fast_syscall: /* perform architecture specific actions before user return */ arch_ret_to_user r1, lr - @ fast_restore_user_regs - ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr - ldr lr, [sp, #S_OFF + S_PC]! @ get pc - msr spsr_cxsf, r1 @ save in spsr_svc - ldmdb sp, {r1 - lr}^ @ get calling r1 - lr - mov r0, r0 - add sp, sp, #S_FRAME_SIZE - S_PC - movs pc, lr @ return & move spsr_svc into cpsr + restore_user_regs fast = 1, offset = S_OFF UNWIND(.fnend ) /*@@ -73,14 +66,7 @@ no_work_pending: /* perform architecture specific actions before user return */ arch_ret_to_user r1, lr - @ slow_restore_user_regs - ldr r1, [sp, #S_PSR] @ get calling cpsr - ldr lr, [sp, #S_PC]! @ get pc - msr spsr_cxsf, r1 @ save in spsr_svc - ldmdb sp, {r0 - lr}^ @ get calling r0 - lr - mov r0, r0 - add sp, sp, #S_FRAME_SIZE - S_PC - movs pc, lr @ return & move spsr_svc into cpsr + restore_user_regs fast = 0, offset = 0 ENDPROC(ret_to_user) /*arch/arm/kernel/entry-header.S +3
-0+ + .macro restore_user_regs, fast = 0, offset = 0 + ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr
arch/arm/kernel/entry-header.S
Quoted 10 lines
arch/arm/kernel/entry-header.S +10
-0+ ldr lr, [sp, #\offset + S_PC]! @ get pc + msr spsr_cxsf, r1 @ save in spsr_svc + .if \fast + ldmdb sp, {r1 - lr}^ @ get calling r1 - lr + .else + ldmdb sp, {r0 - lr}^ @ get calling r0 - lr + .endif + add sp, sp, #S_FRAME_SIZE - S_PC + movs pc, lr @ return & move spsr_svc into cpsr + .endm
This commit seems to have broken things for ARM720T and it looks like the removal of the "mov r0, r0" instruction in restore_user_regs is what caused it.
The patch below makes it work again but why?
arch/arm/kernel/entry-header.S +1 -0
@@ -102,6 +102,7 @@ .else ldmdb sp, {r0 - lr}^ @ get calling r0 - lr .endif + mov r0, r0 add sp, sp, #S_FRAME_SIZE - S_PC movs pc, lr @ return & move spsr_svc into cpsr .endm
PATCH 3/11 Thumb-2: Implementation of the unified start-up and exceptions code
Quoted 5 lines · Anders Grafstr?m
This commit seems to have broken things for ARM720T and it looks like the removal of the "mov r0, r0" instruction in
restore_user_regsis what caused it.The patch below makes it work again but why?
Because the 'add' instruction will end up touching the _userspace_ stack pointer, not the SVC stack pointer.
It's a question of timing in the core - the ldmdb instruction accesses the user sp+lr, which is still in progress when the following instruction is executed. So, referencing 'sp' in the following instruction ends up hitting the user mode stack pointer.
I'm surprised this hasn't caused more problems - there is a stipulated requirement that banked registers are _NOT_ accessed by the instruction following a ldm { }^ instruction - this requirement goes all the way up to V5T as defined by DDI0100I and below:
In ARM architecture versions earlier than ARMv6, this form of LDM must not be followed by an instruction that accesses banked registers. A following NOP is a good way to ensure this.
So yes, your patch is absolutely required - all ARMv5 and below are facing a hazard as the kernel stands. It might explain some of the weird behaviours people have been reporting as well.
Please cleanup the description and submit to the patch system.
PATCH 3/11 Thumb-2: Implementation of the unified start-up and exceptions code
Quoted 5 lines · Russell King - ARM Linux
So yes, your patch is absolutely required - all ARMv5 and below are facing a hazard as the kernel stands. It might explain some of the weird behaviours people have been reporting as well.
Please cleanup the description and submit to the patch system.
And please add a small comment along side the otherwise seemingly useless nop.
Nicolas
PATCH 3/11 Thumb-2: Implementation of the unified start-up and exceptions code
Quoted 10 lines · Nicolas Pitre
Quoted 5 lines · Russell King - ARM Linux
So yes, your patch is absolutely required - all ARMv5 and below are facing a hazard as the kernel stands. It might explain some of the weird behaviours people have been reporting as well.
Please cleanup the description and submit to the patch system.
And please add a small comment along side the otherwise seemingly useless nop.
Done.
http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=5991/1
PATCH 3/11 Thumb-2: Implementation of the unified start-up and exceptions code
Quoted 7 lines · Anders Grafstr?m
Quoted 6 lines · Nicolas Pitre
Quoted 4 lines · Russell King - ARM Linux
So yes, your patch is absolutely required - all ARMv5 and below are facing a hazard as the kernel stands. It might explain some of the weird behaviours people have been reporting as well.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Please cleanup the description and submit to the patch system.
And please add a small comment along side the otherwise seemingly useless nop.
Done.
http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=5991/1
BTW, should we have an #ifdef for __LINUX_ARM_ARCH__ >= 6? Not that it would make a noticeable difference in speed.
Signature · 1 line
Catalin