]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Sec: fix return_from_exception code and comment
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 14 Dec 2015 16:08:27 +0000 (16:08 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Mon, 14 Dec 2015 16:08:27 +0000 (16:08 +0000)
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

ArmPlatformPkg/Sec/Arm/Helper.S
ArmPlatformPkg/Sec/Arm/Helper.asm

index ac40102218752fab4ab78f46610596659b3b7e22..1922321565e4b7a5f2384183c5cf8662efa58058 100644 (file)
@@ -46,20 +46,11 @@ ASM_PFX(enter_monitor_mode):
 \r
     bx      r4\r
 \r
-# We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.\r
-# When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into\r
-# 'pc'; we will not change the CPSR flag and it will crash.\r
-# The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.\r
+# Return-from-exception is not an interworking return, so we must do it\r
+# in two steps, in case r0 has the Thumb bit set.\r
 ASM_PFX(return_from_exception):\r
-    ldr     lr, returned_exception\r
-\r
-    #The following instruction breaks the code.\r
-    #movs    pc, lr\r
-    mrs     r2, cpsr\r
-    bic     r2, r2, #0x1f\r
-    orr     r2, r2, #0x13\r
-    msr     cpsr_c, r2\r
-\r
+    adr     lr, returned_exception\r
+    movs    pc, lr\r
 returned_exception:                           @ We are now in non-secure state\r
     bx      r0\r
 \r
index 8aa7d7840d56459bab93c7b9a8a149237efe77a2..0a2baaf19e36c65afa4a3078e43e612098dcdf04 100644 (file)
@@ -45,10 +45,8 @@ enter_monitor_mode FUNCTION
     bx      r4\r
     ENDFUNC\r
 \r
-// We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.\r
-// When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into\r
-// 'pc'; we will not change the CPSR flag and it will crash.\r
-// The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.\r
+// Return-from-exception is not an interworking return, so we must do it\r
+// in two steps, in case r0 has the Thumb bit set.\r
 return_from_exception\r
     adr     lr, returned_exception\r
     movs    pc, lr\r