summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-03-27 12:32:42 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-30 11:05:22 +0000
commite504b3917e2b5b0cdd6a381141efb7e303eeb6c1 (patch)
tree4c932ba94ace4298abfbe224179fb9976ea9b772 /MdePkg
parentea1312a5b443b0d3691d825c2dc8cf2227120ba3 (diff)
downloadedk2-e504b3917e2b5b0cdd6a381141efb7e303eeb6c1.tar.gz
edk2-e504b3917e2b5b0cdd6a381141efb7e303eeb6c1.tar.bz2
edk2-e504b3917e2b5b0cdd6a381141efb7e303eeb6c1.zip
MdePkg/BaseLib AARCH64: Make LongJump() BTI compatible
Currently, the AArch64 implementation of LongJump() avoids using the RET instruction to perform the jump, even though the target address is held in the link register X30, as the nature of a long jump implies that the ordinary return address prediction machinery will not be able to make a correct prediction. However, LongJump() is rarely used, and the return stack will be out of sync in any case, so this optimization has little value in practice, and given that indirect calls other than function returns require a BTI landing pad at the call site, this optimization is not compatible with BTI. So let's just use RET instead. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S3
1 files changed, 1 insertions, 2 deletions
diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S
index deefdf526b..1d5cfbf644 100644
--- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S
+++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S
@@ -85,7 +85,6 @@ ASM_PFX(InternalLongJump):
cmp w1, #0
mov w0, #1
csel w0, w1, w0, ne
- // use br not ret, as ret is guaranteed to mispredict
- br x30
+ ret
ASM_FUNCTION_REMOVE_IF_UNREFERENCED