diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-12-14 16:08:27 +0000 |
---|---|---|
committer | abiesheuvel <abiesheuvel@Edk2> | 2015-12-14 16:08:27 +0000 |
commit | 949973b6c033918489e935869a5d2391e4feacb0 (patch) | |
tree | 32cf31043197fc5e7e69d7a6e0efce4d7a5fe214 /ArmPlatformPkg/Sec | |
parent | aaa0820553db9da8dee3ea562942dce89873886d (diff) | |
download | edk2-949973b6c033918489e935869a5d2391e4feacb0.tar.gz edk2-949973b6c033918489e935869a5d2391e4feacb0.tar.bz2 edk2-949973b6c033918489e935869a5d2391e4feacb0.zip |
ArmPlatformPkg/Sec: fix return_from_exception code and comment
The return_from_exception implementation in Sec/Helper.S (the GCC
version) deviates from the RVCT version, in a way that suggests that
both may have been broken at some point, and that they weren't fixed
in the same way nor at the same time.
So bring the GCC version in line with the RVCT version, and at the
same time, deobfuscate the comment.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19244 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Sec')
-rw-r--r-- | ArmPlatformPkg/Sec/Arm/Helper.S | 17 | ||||
-rw-r--r-- | ArmPlatformPkg/Sec/Arm/Helper.asm | 6 |
2 files changed, 6 insertions, 17 deletions
diff --git a/ArmPlatformPkg/Sec/Arm/Helper.S b/ArmPlatformPkg/Sec/Arm/Helper.S index ac40102218..1922321565 100644 --- a/ArmPlatformPkg/Sec/Arm/Helper.S +++ b/ArmPlatformPkg/Sec/Arm/Helper.S @@ -46,20 +46,11 @@ ASM_PFX(enter_monitor_mode): bx r4
-# We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.
-# When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into
-# 'pc'; we will not change the CPSR flag and it will crash.
-# The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.
+# Return-from-exception is not an interworking return, so we must do it
+# in two steps, in case r0 has the Thumb bit set.
ASM_PFX(return_from_exception):
- ldr lr, returned_exception
-
- #The following instruction breaks the code.
- #movs pc, lr
- mrs r2, cpsr
- bic r2, r2, #0x1f
- orr r2, r2, #0x13
- msr cpsr_c, r2
-
+ adr lr, returned_exception
+ movs pc, lr
returned_exception: @ We are now in non-secure state
bx r0
diff --git a/ArmPlatformPkg/Sec/Arm/Helper.asm b/ArmPlatformPkg/Sec/Arm/Helper.asm index 8aa7d7840d..0a2baaf19e 100644 --- a/ArmPlatformPkg/Sec/Arm/Helper.asm +++ b/ArmPlatformPkg/Sec/Arm/Helper.asm @@ -45,10 +45,8 @@ enter_monitor_mode FUNCTION bx r4
ENDFUNC
-// We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.
-// When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into
-// 'pc'; we will not change the CPSR flag and it will crash.
-// The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.
+// Return-from-exception is not an interworking return, so we must do it
+// in two steps, in case r0 has the Thumb bit set.
return_from_exception
adr lr, returned_exception
movs pc, lr
|