Skip to content

Commit 72cd406

Browse files
murzinvRussell King
authored andcommitted
ARM: 8830/1: NOMMU: Toggle only bits in EXC_RETURN we are really care of
ARMv8M introduces support for Security extension to M class, among other things it affects exception handling, especially, encoding of EXC_RETURN. The new bits have been added: Bit [6] Secure or Non-secure stack Bit [5] Default callee register stacking Bit [0] Exception Secure which conflicts with hard-coded value of EXC_RETURN: In fact, we only care of few bits: Bit [3] Mode (0 - Handler, 1 - Thread) Bit [2] Stack pointer selection (0 - Main, 1 - Process) We can toggle only those bits and left other bits as they were on exception entry. It is basically, what patch does - saves EXC_RETURN when we do transition form Thread to Handler mode (it is first svc), so later saved value is used instead of EXC_RET_THREADMODE_PROCESSSTACK. Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent eb7ff90 commit 72cd406

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎arch/arm/include/asm/v7m.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01.
5050
*/
5151
#define EXC_RET_STACK_MASK 0x00000004
52-
#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd
52+
#define EXC_RET_THREADMODE_PROCESSSTACK (3 << 2)
5353

5454
/* Cache related definitions */
5555

‎arch/arm/kernel/entry-header.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@
127127
*/
128128
.macro v7m_exception_slow_exit ret_r0
129129
cpsid i
130-
ldr lr, =EXC_RET_THREADMODE_PROCESSSTACK
130+
ldr lr, =exc_ret
131+
ldr lr, [lr]
131132

132133
@ read original r12, sp, lr, pc and xPSR
133134
add r12, sp, #S_IP

‎arch/arm/kernel/entry-v7m.S‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,7 @@ ENTRY(vector_table)
146146
.rept CONFIG_CPU_V7M_NUM_IRQ
147147
.long __irq_entry @ External Interrupts
148148
.endr
149+
.align 2
150+
.globl exc_ret
151+
exc_ret:
152+
.space 4

‎arch/arm/mm/proc-v7m.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ __v7m_setup_cont:
139139
cpsie i
140140
svc #0
141141
1: cpsid i
142+
ldr r0, =exc_ret
143+
orr lr, lr, #EXC_RET_THREADMODE_PROCESSSTACK
144+
str lr, [r0]
142145
ldmia sp, {r0-r3, r12}
143146
str r5, [r12, #11 * 4] @ restore the original SVC vector entry
144147
mov lr, r6 @ restore LR

0 commit comments

Comments
 (0)