public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: "Marvin Häuser" <mhaeuser@posteo.de>,
	devel@edk2.groups.io,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Sami Mujawar" <sami.mujawar@arm.com>,
	"Vitaly Cheptsov" <vit9696@protonmail.com>
Subject: Re: [PATCH 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN()
Date: Mon, 17 Apr 2023 23:18:22 +0200	[thread overview]
Message-ID: <CAMj1kXHMbafkf8WMm0xRUUHvdtq3crEM8c_fcnfX_jUQGvkgFQ@mail.gmail.com> (raw)
In-Reply-To: <ZD2jYgUi/Lmtxnkh@qc-i7.hemma.eciton.net>

On Mon, 17 Apr 2023 at 21:52, Leif Lindholm <quic_llindhol@quicinc.com> wrote:
>
> Hi Marvin,
>
> First of all - many thanks for tracking down the bug that creates the
> need for this.
>
> On Mon, Apr 17, 2023 at 18:09:15 +0000, Marvin Häuser wrote:
> > 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)       \
>
> I like this solution, but I'd like to hear Ard's opinion.
>
> I probably want to bikeshed some of the implementation details:
> Although I generally dislike duplicate definitions, I think I would
> prefer having _ASM_FUNC and _ASM_FUNC_ALIGN defined self-contained,
> without _HDR and _FTR.
> If we do keep the reused primitives, we need better language; the
> footer of the header is not a footer of the function.
>

Agree with all of this.

And thanks for tracking this down - must not have been fun :-)

  reply	other threads:[~2023-04-17 21:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=CAMj1kXHMbafkf8WMm0xRUUHvdtq3crEM8c_fcnfX_jUQGvkgFQ@mail.gmail.com \
    --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