From: "Marvin Häuser" <mhaeuser@posteo.de>
To: devel@edk2.groups.io
Cc: "Marvin Häuser" <mhaeuser@posteo.de>,
"Leif Lindholm" <quic_llindhol@quicinc.com>,
"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
"Sami Mujawar" <sami.mujawar@arm.com>,
"Vitaly Cheptsov" <vit9696@protonmail.com>
Subject: [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN()
Date: Mon, 17 Apr 2023 18:09:15 +0000 [thread overview]
Message-ID: <20230417180916.95237-1-mhaeuser@posteo.de> (raw)
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
next reply other threads:[~2023-04-17 18:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 18:09 Marvin Häuser [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230417180916.95237-1-mhaeuser@posteo.de \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox