[edk2-devel] [PATCH v2 5/5] MdePkg/BaseLib: ensure ARM LongJump never returns 0

Leif Lindholm posted 5 patches 2 years, 4 months ago
[edk2-devel] [PATCH v2 5/5] MdePkg/BaseLib: ensure ARM LongJump never returns 0
Posted by Leif Lindholm 2 years, 4 months ago
The ARM implementation of 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 <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
 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
 
-- 
2.30.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109079): https://edk2.groups.io/g/devel/message/109079
Mute This Topic: https://groups.io/mt/101600811/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 5/5] MdePkg/BaseLib: ensure ARM LongJump never returns 0
Posted by Philippe Mathieu-Daudé 2 years, 4 months ago
On 26/9/23 19:15, Leif Lindholm wrote:
> The ARM implementation of 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 <quic_llindhol@quicinc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> ---
>   MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S   | 2 ++
>   MdePkg/Library/BaseLib/Arm/SetJumpLongJump.asm | 2 ++

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109289): https://edk2.groups.io/g/devel/message/109289
Mute This Topic: https://groups.io/mt/101600811/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 5/5] MdePkg/BaseLib: ensure ARM LongJump never returns 0
Posted by Sami Mujawar 2 years, 4 months ago
Hi Leif,

Thank you for this patch.

There is a minor typo in the commit message, other than that these 
changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 26/09/2023 06:15 pm, Leif Lindholm wrote:
> The ARM implementation of of InternalLongJump always returned the value
[SAMI] Minor typo in that 'of' is repeated twice.
> 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 <quic_llindhol@quicinc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> ---
>   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
>   


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109204): https://edk2.groups.io/g/devel/message/109204
Mute This Topic: https://groups.io/mt/101600811/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-