From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.31886.1679914896025099230 for ; Mon, 27 Mar 2023 04:01:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OToonZK3; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E25861043; Mon, 27 Mar 2023 11:01:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73019C433D2; Mon, 27 Mar 2023 11:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679914895; bh=TkKtM9JG52dNSpDL2ZZPzloc5+ylu6BxpGdGRlOaSHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OToonZK35VhrGDBivydJAeyGoNrUaqgHgabL+sALoL+A+X4R+oIUJ1gGhiNsIF6D+ M0ITAuofVpiRBadzrm8mdmqAguKHSjVEZCXkTsOf4sWS351r88sEnYsDYyfSoEFNjN aJ0A7fWeFG6qW+GvrdErRY/1lDL0NRFk5jApDbgNLGxK6UcJiZhzAqK28T+uPVsXnB VVpI5Y4do2+syVFHf7PBQPeDypd6wHAIDwQ32maPabz9w1UsnL27ivnVay9P5JqUHC WcA8sc5RxtnyVfPDNPW11jzj4y60Um9xJRND7GhnWP1HaPnijgNJBjpl/DC0/ktkSp Ph8SRYrviEMHA== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe , =?UTF-8?q?Marvin=20H=C3=A4user?= , Bob Feng Subject: [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note Date: Mon, 27 Mar 2023 13:00:56 +0200 Message-Id: <20230327110112.262503-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230327110112.262503-1-ardb@kernel.org> References: <20230327110112.262503-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/AArch6= 4/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__) \=0D .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)=0D =0D +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT =3D=3D= 1=0D +#define AARCH64_BTI(__type) \=0D + .ifnc __type, ;\=0D + bti __type ;\=0D + .endif ;\=0D + .ifndef .Lgnu_bti_notesize ;\=0D + .pushsection .note.gnu.property, "a" ;\=0D + .set NT_GNU_PROPERTY_TYPE_0, 0x5 ;\=0D + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 ;\=0D + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\=0D + .align 3 ;\=0D + .long .Lnamesize ;\=0D + .long .Lgnu_bti_notesize ;\=0D + .long NT_GNU_PROPERTY_TYPE_0 ;\=0D +0: .asciz "GNU" ;\=0D + .set .Lnamesize, . - 0b ;\=0D + .align 3 ;\=0D +1: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND ;\=0D + .long .Lvalsize ;\=0D +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI ;\=0D + .set .Lvalsize, . - 2b ;\=0D + .align 3 ;\=0D + .set .Lgnu_bti_notesize, . - 1b ;\=0D + .popsection ;\=0D + .endif=0D +#endif=0D +=0D +#endif=0D +=0D +#ifndef AARCH64_BTI=0D +#define AARCH64_BTI(__type)=0D #endif=0D =0D /**=0D --=20 2.39.2