public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN()
@ 2023-04-17 18:09 Marvin Häuser
  2023-04-17 18:09 ` [PATCH 2/2] ArmPkg/ArmMmuLib: Fix ArmReplaceLiveTranslationEntry() alignment Marvin Häuser
  2023-04-17 19:52 ` [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN() Leif Lindholm
  0 siblings, 2 replies; 22+ messages in thread
From: Marvin Häuser @ 2023-04-17 18:09 UTC (permalink / raw)
  To: devel
  Cc: Marvin Häuser, Leif Lindholm, Ard Biesheuvel, Sami Mujawar,
	Vitaly Cheptsov

With the current ASM_FUNC() macro, there is no good way to declare an
alignment constraint for a function. As ASM_FUNC() switches sections,
declaring the constraint before the macro invocation applies it to the
current location in the previous section. Declaring the constraint after
the macro invocation lets the function label point to the location prior
to alignment. Depending on toolchain behaviour, this may cause the label
to point to alignment padding preceding the actual function definition.

To address these issues, introduce the ASM_FUNC_ALIGN() macro, which
declares the alignment constraint right before the function label.

Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
---
 ArmPkg/Include/AsmMacroIoLibV8.h | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h
index 135aaeca5d0b..919edc70384d 100644
--- a/ArmPkg/Include/AsmMacroIoLibV8.h
+++ b/ArmPkg/Include/AsmMacroIoLibV8.h
@@ -34,15 +34,29 @@
         cbnz   SAFE_XREG, 1f        ;\
         b      .                    ;// We should never get here
 
-#define _ASM_FUNC(Name, Section)    \
-  .global   Name                  ; \
-  .section  #Section, "ax"        ; \
-  .type     Name, %function       ; \
+#define _ASM_FUNC_HDR(Name, Section) \
+  .global   Name                   ; \
+  .section  #Section, "ax"         ; \
+  .type     Name, %function
+
+#define _ASM_FUNC_FTR(Name)         \
   Name:                           ; \
   AARCH64_BTI(c)
 
+#define _ASM_FUNC(Name, Section)    \
+  _ASM_FUNC_HDR(Name, Section)    ; \
+  _ASM_FUNC_FTR(Name)
+
+#define _ASM_FUNC_ALIGN(Name, Section, Align)       \
+  _ASM_FUNC_HDR(Name, Section)                    ; \
+  .balign Align                                   ; \
+  _ASM_FUNC_FTR(Name)
+
 #define ASM_FUNC(Name)  _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
 
+#define ASM_FUNC_ALIGN(Name, Align)  \
+  _ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align)
+
 #define MOV32(Reg, Val)                   \
   movz      Reg, (Val) >> 16, lsl #16   ; \
   movk      Reg, (Val) & 0xffff
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-04-19 22:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-17 18:09 [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN() Marvin Häuser
2023-04-17 18:09 ` [PATCH 2/2] ArmPkg/ArmMmuLib: Fix ArmReplaceLiveTranslationEntry() alignment Marvin Häuser
2023-04-17 19:53   ` Leif Lindholm
2023-04-17 19:52 ` [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN() Leif Lindholm
2023-04-17 21:18   ` Ard Biesheuvel
2023-04-18  6:40     ` Marvin Häuser
2023-04-18  8:10       ` Ard Biesheuvel
2023-04-18  8:18         ` Marvin Häuser
2023-04-18  8:59           ` Ard Biesheuvel
2023-04-19 17:13           ` Marvin Häuser
2023-04-19 17:40             ` [edk2-devel] " Ard Biesheuvel
2023-04-19 17:45               ` Marvin Häuser
2023-04-19 18:03                 ` Ard Biesheuvel
2023-04-19 18:25                   ` Marvin Häuser
2023-04-19 18:26                     ` Ard Biesheuvel
2023-04-19 18:31                       ` Marvin Häuser
2023-04-19 19:48                         ` Ard Biesheuvel
2023-04-19 20:10                           ` Marvin Häuser
2023-04-19 21:42                             ` Marvin Häuser
2023-04-19 21:55                             ` Ard Biesheuvel
2023-04-19 22:15                               ` Marvin Häuser
2023-04-19 22:27                               ` Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox