[edk2-devel] [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note

Leif Lindholm quic_llindhol at quicinc.com
Mon Mar 27 12:56:41 UTC 2023


On Mon, Mar 27, 2023 at 14:15:09 +0200, Ard Biesheuvel wrote:
> On Mon, 27 Mar 2023 at 13:53, Leif Lindholm <quic_llindhol at quicinc.com> wrote:
> >
> > On Mon, Mar 27, 2023 at 13:00:56 +0200, Ard Biesheuvel wrote:
> > > Implement a CPP macro that can be called from .S files to emit the .note
> > > section carrying the annotation that informs the linker that the object
> > > file is compatible with BTI control flow integrity checks.
> > >
> > > Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> > > ---
> > >  MdePkg/Include/AArch64/ProcessorBind.h | 31 ++++++++++++++++++++
> > >  1 file changed, 31 insertions(+)
> > >
> > > diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h
> > > index abe2571245c665f3..11814f1ffaef698a 100644
> > > --- a/MdePkg/Include/AArch64/ProcessorBind.h
> > > +++ b/MdePkg/Include/AArch64/ProcessorBind.h
> > > @@ -186,6 +186,37 @@ typedef INT64 INTN;
> > >  #define GCC_ASM_IMPORT(func__)  \
> > >           .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
> > >
> > > +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
> > > +#define AARCH64_BTI(__type)                                        \
> > > +    .ifnc         __type,                                         ;\
> > > +    bti           __type                                          ;\
> > > +    .endif                                                        ;\
> > > +    .ifndef       .Lgnu_bti_notesize                              ;\
> > > +    .pushsection  .note.gnu.property, "a"                         ;\
> > > +    .set          NT_GNU_PROPERTY_TYPE_0, 0x5                     ;\
> > > +    .set          GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000  ;\
> > > +    .set          GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1         ;\
> > > +    .align        3                                               ;\
> > > +    .long         .Lnamesize                                      ;\
> > > +    .long         .Lgnu_bti_notesize                              ;\
> > > +    .long         NT_GNU_PROPERTY_TYPE_0                          ;\
> > > +0:  .asciz        "GNU"                                           ;\
> > > +    .set          .Lnamesize, . - 0b                              ;\
> > > +    .align        3                                               ;\
> > > +1:  .long         GNU_PROPERTY_AARCH64_FEATURE_1_AND              ;\
> > > +    .long         .Lvalsize                                       ;\
> > > +2:  .long         GNU_PROPERTY_AARCH64_FEATURE_1_BTI              ;\
> > > +    .set          .Lvalsize, . - 2b                               ;\
> > > +    .align        3                                               ;\
> > > +    .set          .Lgnu_bti_notesize, . - 1b                      ;\
> > > +    .popsection                                                   ;\
> > > +    .endif
> > > +#endif
> > > +
> > > +#endif
> >
> > Is that second endif superflouous?
> >
> 
> No the diff just turned out a bit odd.

Oh, I see - it's because you add this inside the if __GNUC__ || __clang__
and add the #ifndef AARCH64_BTI outside it. Which is necessary. Moving
on.

/
    Leif




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101952): https://edk2.groups.io/g/devel/message/101952
Mute This Topic: https://groups.io/mt/97879282/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list