From eaa84fd553eb2288f1e192430a1800bf45e51c56 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Sat, 1 Mar 2014 10:57:55 +0000 Subject: [PATCH] ArmPkg: Replace single dead loop. Several assembler macros use a loop at the label "dead" to trap an error. This is difficult to debug as there is no indication of how one arrived at the loop. This change replaces dead with distinct loops locally in the macro, which means the cause of the hang is detectable to the debugger. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15273 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Include/AsmMacroIoLibV8.h | 24 +++++++++---------- .../Library/ArmLib/AArch64/AArch64Support.S | 3 --- .../ArmLib/Common/AArch64/ArmLibSupport.S | 4 +--- ArmPlatformPkg/PrePeiCore/AArch64/Exception.S | 5 +--- .../PrePeiCore/AArch64/PrePeiCoreEntryPoint.S | 10 +++----- 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h index 78a033cb4f..5ab1b5723e 100644 --- a/ArmPkg/Include/AsmMacroIoLibV8.h +++ b/ArmPkg/Include/AsmMacroIoLibV8.h @@ -106,24 +106,24 @@ _InitializePrimaryStackEnd: // Provide the Macro with a safe temp xreg to use. #define EL1_OR_EL2(SAFE_XREG) \ mrs SAFE_XREG, CurrentEL ;\ - cmp SAFE_XREG, #0x4 ;\ - b.eq 1f ;\ - cmp SAFE_XREG, #0x8 ;\ - b.eq 2f ;\ - b dead ;// We should never get here. + cmp SAFE_XREG, #0x8 ;\ + b.eq 2f ;\ + cmp SAFE_XREG, #0x4 ;\ + b.ne . ;// We should never get here +// EL1 code starts here // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1 // This only selects between EL1 and EL2 and EL3, else we die. // Provide the Macro with a safe temp xreg to use. -#define EL1_OR_EL2_OR_EL3(SAFE_XREG) \ +#define EL1_OR_EL2_OR_EL3(SAFE_XREG) \ mrs SAFE_XREG, CurrentEL ;\ + cmp SAFE_XREG, #0xC ;\ + b.eq 3f ;\ + cmp SAFE_XREG, #0x8 ;\ + b.eq 2f ;\ cmp SAFE_XREG, #0x4 ;\ - b.eq 1f ;\ - cmp SAFE_XREG, #0x8 ;\ - b.eq 2f ;\ - cmp SAFE_XREG, #0xC ;\ - b.eq 3f ;\ - b dead ;// We should never get here. + b.ne . ;// We should never get here +// EL1 code starts here #else diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S index 5901ffacd4..66c310bb31 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S @@ -503,7 +503,4 @@ ASM_PFX(ArmReadCurrentEL): mrs x0, CurrentEL ret -dead: - b dead - ASM_FUNCTION_REMOVE_IF_UNREFERENCED diff --git a/ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S index cf2ec76be9..5dd3fca5e9 100644 --- a/ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S +++ b/ArmPkg/Library/ArmLib/Common/AArch64/ArmLibSupport.S @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-# Copyright (c) 2011 - 2013, ARM Limited. All rights reserved. +# Copyright (c) 2011 - 2014, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -196,7 +196,5 @@ ASM_PFX(ArmCallSEV): sev ret -dead: - b dead ASM_FUNCTION_REMOVE_IF_UNREFERENCED diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S index 9ca422b2f5..1fc39e68a1 100644 --- a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S +++ b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S @@ -1,5 +1,5 @@ # -# Copyright (c) 2011-2013, ARM Limited. All rights reserved. +# Copyright (c) 2011-2014, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -79,6 +79,3 @@ _DefaultFiq_h: _DefaultSError_h: mov x0, #EXCEPT_AARCH64_SERROR TO_HANDLER - -dead: - b dead diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S index 5bdbe4585f..05a823ba21 100644 --- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S +++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S @@ -1,5 +1,5 @@ // -// Copyright (c) 2011-2013, ARM Limited. All rights reserved. +// Copyright (c) 2011-2014, ARM Limited. All rights reserved. // // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License @@ -43,13 +43,12 @@ ASM_PFX(_ModuleEntryPoint): // changes. // Which EL are we running at? Every EL needs some level of setup... - EL1_OR_EL2_OR_EL3(x0) +// We should not run this code in EL3 + EL1_OR_EL2(x0) 1:bl ASM_PFX(SetupExceptionLevel1) b ASM_PFX(MainEntryPoint) 2:bl ASM_PFX(SetupExceptionLevel2) b ASM_PFX(MainEntryPoint) -3:// If we are at EL3 we die. - b dead ASM_PFX(MainEntryPoint): // Identify CPU ID @@ -109,6 +108,3 @@ _SetupPrimaryCoreStack: // 128-bit variable on the stack SetPrimaryStack (x1, x2, x3, x4) b _PrepareArguments - -dead: - b dead -- 2.39.2