Revision: 19244
http://sourceforge.net/p/edk2/code/19244
Author: abiesheuvel
Date: 2015-12-14 16:08:27 +0000 (Mon, 14 Dec 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Leif Lindholm <[email protected]>
Modified Paths:
--------------
trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.S
trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.asm
Modified: trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.S
===================================================================
--- trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.S 2015-12-14 13:00:30 UTC (rev
19243)
+++ trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.S 2015-12-14 16:08:27 UTC (rev
19244)
@@ -46,20 +46,11 @@
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
Modified: trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.asm
===================================================================
--- trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.asm 2015-12-14 13:00:30 UTC
(rev 19243)
+++ trunk/edk2/ArmPlatformPkg/Sec/Arm/Helper.asm 2015-12-14 16:08:27 UTC
(rev 19244)
@@ -45,10 +45,8 @@
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
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits