summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Häuser <mhaeuser@posteo.de>2023-04-20 15:24:15 +0000
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-04-20 16:20:35 +0000
commit8f4ec0cc433a33967cdbbb945acd37b6ae1d3fce (patch)
treed3dc34352f27a31bf77db94eb723c6d1d4019299
parentf433fa59d22480f3ae60ea29e98a6b33227cbd7a (diff)
downloadedk2-8f4ec0cc433a33967cdbbb945acd37b6ae1d3fce.tar.gz
edk2-8f4ec0cc433a33967cdbbb945acd37b6ae1d3fce.tar.bz2
edk2-8f4ec0cc433a33967cdbbb945acd37b6ae1d3fce.zip
ArmPkg/ArmMmuLib: Fix ArmReplaceLiveTranslationEntry() alignment
As the ASM_FUNC() macro performs a section switch, the preceding .balign directive applies the alignment constraint to the current location in the previous section. As the linker may not merge the sections in-order, ArmReplaceLiveTranslationEntry() may be left unaligned. Replace the explicit invocation of .balign with the ASM_FUNC_ALIGN() macro, which guarantees the alignment constraint is applied correctly. To make sure related issues are reliably caught in the future, align the end of the function before checking the total occupied size. This ensures crossing a 0x200 boundary will cause a compilation error. Signed-off-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r--ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S14
1 files changed, 8 insertions, 6 deletions
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
index e936a5be4e..887439bc04 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
@@ -69,17 +69,16 @@
.L2_\@:
.endm
- // Align this routine to a log2 upper bound of its size, so that it is
- // guaranteed not to cross a page or block boundary.
- .balign 0x200
-
//VOID
//ArmReplaceLiveTranslationEntry (
// IN UINT64 *Entry,
// IN UINT64 Value,
// IN UINT64 Address
// )
-ASM_FUNC(ArmReplaceLiveTranslationEntry)
+//
+// Align this routine to a log2 upper bound of its size, so that it is
+// guaranteed not to cross a page or block boundary.
+ASM_FUNC_ALIGN(ArmReplaceLiveTranslationEntry, 0x200)
// disable interrupts
mrs x4, daif
@@ -101,5 +100,8 @@ ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
ASM_PFX(ArmReplaceLiveTranslationEntrySize):
.long . - ArmReplaceLiveTranslationEntry
- // Double check that we did not overrun the assumed maximum size
+ // Double check that we did not overrun the assumed maximum size or cross a
+ // 0x200 boundary (and thus implicitly not any larger power of two, including
+ // the page size).
+ .balign 0x200
.org ArmReplaceLiveTranslationEntry + 0x200