summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Sec
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPlatformPkg/Sec')
-rw-r--r--ArmPlatformPkg/Sec/Helper.S8
-rw-r--r--ArmPlatformPkg/Sec/Helper.asm8
2 files changed, 10 insertions, 6 deletions
diff --git a/ArmPlatformPkg/Sec/Helper.S b/ArmPlatformPkg/Sec/Helper.S
index 9e3b13b38f..8bdb66ab87 100644
--- a/ArmPlatformPkg/Sec/Helper.S
+++ b/ArmPlatformPkg/Sec/Helper.S
@@ -24,13 +24,15 @@ GCC_ASM_EXPORT(set_non_secure_mode)
# r1: MpId
# r2: Secure Monitor mode stack
ASM_PFX(enter_monitor_mode):
- mrs r4, cpsr @ Save current mode (SVC) in r1
+ cmp r2, #0 @ If a Secure Monitor stack base has not been defined then use the Secure stack
+ moveq r2, sp
+
+ mrs r4, cpsr @ Save current mode (SVC) in r4
bic r3, r4, #0x1f @ Clear all mode bits
orr r3, r3, #0x16 @ Set bits for Monitor mode
msr cpsr_cxsf, r3 @ We are now in Monitor Mode
- cmp r2, #0 @ If a Secure Monitor stack base has been passed, used it
- movne sp, r2 @ Use the passed sp
+ mov sp, r2 @ Set the stack of the Monitor Mode
mov lr, r0 @ Use the pass entrypoint as lr
diff --git a/ArmPlatformPkg/Sec/Helper.asm b/ArmPlatformPkg/Sec/Helper.asm
index 15b8f47522..a03a90626e 100644
--- a/ArmPlatformPkg/Sec/Helper.asm
+++ b/ArmPlatformPkg/Sec/Helper.asm
@@ -22,13 +22,15 @@
// r1: MpId
// r2: Secure Monitor mode stack
enter_monitor_mode
- mrs r4, cpsr // Save current mode (SVC) in r1
+ cmp r2, #0 // If a Secure Monitor stack base has not been defined then use the Secure stack
+ moveq r2, sp
+
+ mrs r4, cpsr // Save current mode (SVC) in r4
bic r3, r4, #0x1f // Clear all mode bits
orr r3, r3, #0x16 // Set bits for Monitor mode
msr cpsr_cxsf, r3 // We are now in Monitor Mode
- cmp r2, #0 // If a Secure Monitor stack base has been passed, used it
- movne sp, r2 // Use the passed sp
+ mov sp, r2 // Set the stack of the Monitor Mode
mov lr, r0 // Use the pass entrypoint as lr