From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mx.groups.io with SMTP id smtpd.web10.35858.1679926362316626132 for ; Mon, 27 Mar 2023 07:12:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D3aGjVB7; spf=pass (domain: gmail.com, ip: 209.85.215.181, mailfrom: pedro.falcato@gmail.com) Received: by mail-pg1-f181.google.com with SMTP id y19so5229098pgk.5 for ; Mon, 27 Mar 2023 07:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679926361; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tpoctPJmEljGKcZH2214uBefwurUKyt0cv1xxjH1aXw=; b=D3aGjVB7/JJXCCiAR7GnMM2YsB63RW/Uu62jntonxRFwpATDG8A4kiXSsv5kV3ACQk QpQHJwSR8hD09gzHRelCwmQGWVHQj5lZDMoeHhD0yGwwftdjzYnat5nxUdKuZOepAE8S al/tA70Su9BddG880tm8HQAaTN/GrWj0HLeda3DqiBj9PLJ7RMcm3GFQeh+rFvii1U61 N2+jDuJzjODpDoLw7JNCqN0MemS+8Sdp+n/Xhx7UwAWgtZkhBHWSwuLO+ma97jTFw4wb +KU8DkWDO5vfD/KV9IZsipf+G/tL3K4YjRXKKeOKDD8QWcq4HfJbOJ5q3GS2KMjN4P1z lKlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679926361; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tpoctPJmEljGKcZH2214uBefwurUKyt0cv1xxjH1aXw=; b=dCDwxzcriJgoPWd+sZiv8dsJ3QLaMYZTjZ/ujUzebhRt7coMNqUBIu+NgW3liskib+ 472qv8z99e1WEXyOdEkyFUjV6z4uz/GoFYHlvgp9kL6pp83byv0cYfMiXXjrqG/+OCf/ 9jQWjL7Bd0d5IBv2KY0VfUhjIebXVpFprVSBFItKE0XoeJ76+h8BOo34WNR0ufl73e5e Xjh4wjetOuya1PSm0k0wxPE77mjD7N+l6jBT+Yz8ejA70l6vqjg87ozAb3kRq03WWxqs E+Sl59JAXK0v+j9AOJgAA4S+f3Wmos1nVn3xtOkmUjyYlGQzywtc87WHNwiFpkCoyXyG kTqw== X-Gm-Message-State: AAQBX9e+W4HnbHo/o44YaKQUXnkN+kwd1eI+5SILKlfOm32qf9vu8A8s 72cBs14r7jpb4Yc9WSW74q6mTsPA5c3IblBuNuX3eIv3acY= X-Google-Smtp-Source: AKy350Yy+mzHjdTZg2UXajRkzPU9Y5eQp9EuC4pWi75/X9daS7GOQEeHQoz7G+kulVhZ7jiH/0Up9dafu+4mQm/ZGgg= X-Received: by 2002:a05:6a00:10ce:b0:622:65cc:d87b with SMTP id d14-20020a056a0010ce00b0062265ccd87bmr5687465pfu.5.1679926360995; Mon, 27 Mar 2023 07:12:40 -0700 (PDT) MIME-Version: 1.0 References: <20230327110112.262503-1-ardb@kernel.org> <20230327110112.262503-2-ardb@kernel.org> In-Reply-To: <20230327110112.262503-2-ardb@kernel.org> From: "Pedro Falcato" Date: Mon, 27 Mar 2023 15:12:29 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note To: devel@edk2.groups.io, ardb@kernel.org Cc: Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe , =?UTF-8?Q?Marvin_H=C3=A4user?= , Bob Feng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 27, 2023 at 12:01=E2=80=AFPM Ard Biesheuvel w= rote: > > 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 > --- > MdePkg/Include/AArch64/ProcessorBind.h | 31 ++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArc= h64/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 =3D= =3D 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 > + > +#ifndef AARCH64_BTI > +#define AARCH64_BTI(__type) > #endif > > /** > -- > 2.39.2 Patch-set wide comment: is there any chance we could take this opportunity to introduce a global ASM_FUNC (or a more Linux-named ENTRY(FuncName))? It seems to be that the current way is a bit error prone and you end up repeating yourself quite a bit with: ASM_PFX(Foo): AARCH64_BTI(c) having a: ASM_FUNC(Foo) that does proper PFX and BTI expansion internally seems better to me. --=20 Pedro