aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Murzin <vladimir.murzin@arm.com>2019-01-25 09:18:37 -0500
committerRussell King <rmk+kernel@armlinux.org.uk>2019-02-01 16:44:19 -0500
commit72cd4064fccaae15ab84d40d4be23667402df4ed (patch)
treedbd4813fa104ed4e0359e5a546acee47fb5ef613
parenteb7ff9023e4f2998d527b37bffe794759800332a (diff)
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>
-rw-r--r--arch/arm/include/asm/v7m.h2
-rw-r--r--arch/arm/kernel/entry-header.S3
-rw-r--r--arch/arm/kernel/entry-v7m.S4
-rw-r--r--arch/arm/mm/proc-v7m.S3
4 files changed, 10 insertions, 2 deletions
diff --git a/arch/arm/include/asm/v7m.h b/arch/arm/include/asm/v7m.h
index 187ccf6496ad..2cb00d15831b 100644
--- a/arch/arm/include/asm/v7m.h
+++ b/arch/arm/include/asm/v7m.h
@@ -49,7 +49,7 @@
49 * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01. 49 * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01.
50 */ 50 */
51#define EXC_RET_STACK_MASK 0x00000004 51#define EXC_RET_STACK_MASK 0x00000004
52#define EXC_RET_THREADMODE_PROCESSSTACK 0xfffffffd 52#define EXC_RET_THREADMODE_PROCESSSTACK (3 << 2)
53 53
54/* Cache related definitions */ 54/* Cache related definitions */
55 55
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 773424843d6e..62db1c9746cb 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -127,7 +127,8 @@
127 */ 127 */
128 .macro v7m_exception_slow_exit ret_r0 128 .macro v7m_exception_slow_exit ret_r0
129 cpsid i 129 cpsid i
130 ldr lr, =EXC_RET_THREADMODE_PROCESSSTACK 130 ldr lr, =exc_ret
131 ldr lr, [lr]
131 132
132 @ read original r12, sp, lr, pc and xPSR 133 @ read original r12, sp, lr, pc and xPSR
133 add r12, sp, #S_IP 134 add r12, sp, #S_IP
diff --git a/arch/arm/kernel/entry-v7m.S b/arch/arm/kernel/entry-v7m.S
index abcf47848525..19d2dcd6530d 100644
--- a/arch/arm/kernel/entry-v7m.S
+++ b/arch/arm/kernel/entry-v7m.S
@@ -146,3 +146,7 @@ ENTRY(vector_table)
146 .rept CONFIG_CPU_V7M_NUM_IRQ 146 .rept CONFIG_CPU_V7M_NUM_IRQ
147 .long __irq_entry @ External Interrupts 147 .long __irq_entry @ External Interrupts
148 .endr 148 .endr
149 .align 2
150 .globl exc_ret
151exc_ret:
152 .space 4
diff --git a/arch/arm/mm/proc-v7m.S b/arch/arm/mm/proc-v7m.S
index 47a5acc64433..92e84181933a 100644
--- a/arch/arm/mm/proc-v7m.S
+++ b/arch/arm/mm/proc-v7m.S
@@ -139,6 +139,9 @@ __v7m_setup_cont:
139 cpsie i 139 cpsie i
140 svc #0 140 svc #0
1411: cpsid i 1411: cpsid i
142 ldr r0, =exc_ret
143 orr lr, lr, #EXC_RET_THREADMODE_PROCESSSTACK
144 str lr, [r0]
142 ldmia sp, {r0-r3, r12} 145 ldmia sp, {r0-r3, r12}
143 str r5, [r12, #11 * 4] @ restore the original SVC vector entry 146 str r5, [r12, #11 * 4] @ restore the original SVC vector entry
144 mov lr, r6 @ restore LR 147 mov lr, r6 @ restore LR