From 59a2b365ea8797007f8aab0f9e89e2c040a83ae6 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Mon, 26 Mar 2012 10:49:58 +0000 Subject: ArmPlatformPkg/Sec: Fixed monitor stack setup The Secure Monitor stack was not when a stack base was not provided by the Secure SVC world. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13126 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Sec/Helper.S | 8 +++++--- ArmPlatformPkg/Sec/Helper.asm | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'ArmPlatformPkg/Sec') 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 -- cgit v1.2.3