From 1a66bd51ca21f341281d8e3157d3d3f4a94fd26c Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Thu, 1 Oct 2020 19:37:12 +0100 Subject: [PATCH] MdePkg/BaseLib: ensure ARM LongJump never returns 0 The ARM implementation of InternalLongJump always returned the value Value - but it is not supposed to ever return 0. Add the test to prevent that, and return 1 if Value is 0 - as is already present in AArch64. Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar Reviewed-by: Sami Mujawar --- MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S | 2 ++ MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S b/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S index e91320252255..14006c6123e3 100644 --- a/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S +++ b/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S @@ -57,6 +57,8 @@ ASM_PFX(SetJump): ASM_PFX(InternalLongJump): ldmia r0, {r3-r12,r14} mov r13, r3 + cmp r1, #0 + moveq r1, #1 mov r0, r1 bx lr diff --git a/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm b/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm index ef02d85e0e66..15eb3dc28fb7 100644 --- a/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm +++ b/MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm @@ -57,6 +57,8 @@ SetJump InternalLongJump LDM R0, {R3-R12,R14} MOV R13, R3 + CMP R1, #0 + MOVEQ R1, #1 MOV R0, R1 BX LR