From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web10.3576.1681754985910531744 for ; Mon, 17 Apr 2023 11:09:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@posteo.de header.s=2017 header.b=IBRGnklC; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2303B240258 for ; Mon, 17 Apr 2023 20:09:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1681754984; bh=0fbSv/qfV36SMFp7SgyqmULzW6oFUyBS07JwcUq8jnU=; h=From:To:Cc:Subject:Date:From; b=IBRGnklCCqhFKtmXjlwUWD95mVYM2Oxwl3uhdySTV6/+a1rXTrcqyNiO/id25ve5n PUA5AkPapBkgeWx9XzLmkjgniI7/nT+xGpDvXIdBQPbUgWmwLeCb3DhlI9OYNHRWQL BoSmwyitB90jt5K1DDfhwYJ6NjisJSekgI4zbIPk2x5j6E6vRHoYdj1rWKMo0tHaAy ZAwDvtc8fM8xiAhJNSlN/50meVbK0vitWP9+J5Wu6CqCKafT42nJagzApPSMF9gSyo jlA3kbqL35oxqItOx+2mSaMVBUeL2r6UShYF2v8ILddXl/em3WCWK5D63SlE5szaVv ttAEZsfNfqhdA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Q0Zny6KMyz9rxD; Mon, 17 Apr 2023 20:09:42 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20Ha=CC=88user?= , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Vitaly Cheptsov Subject: [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN() Date: Mon, 17 Apr 2023 18:09:15 +0000 Message-Id: <20230417180916.95237-1-mhaeuser@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=A4user Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Vitaly Cheptsov --- ArmPkg/Include/AsmMacroIoLibV8.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIo= LibV8.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 =20 -#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) =20 +#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) =20 +#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 --=20 2.40.0