summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-03-25 17:32:15 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-30 11:05:22 +0000
commit6521e4d2021bc047ef78c5360b9277a699117a0e (patch)
tree6d70b656993ed37d3ae87e11d34ccd17ecd9d386 /MdePkg
parente3e88d90e8d777e38120c32c7b3bbfb9bcf99b79 (diff)
downloadedk2-6521e4d2021bc047ef78c5360b9277a699117a0e.tar.gz
edk2-6521e4d2021bc047ef78c5360b9277a699117a0e.tar.bz2
edk2-6521e4d2021bc047ef78c5360b9277a699117a0e.zip
MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note
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@kernel.org> Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/AArch64/ProcessorBind.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h
index abe2571245..c03594d924 100644
--- a/MdePkg/Include/AArch64/ProcessorBind.h
+++ b/MdePkg/Include/AArch64/ProcessorBind.h
@@ -186,6 +186,40 @@ 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_NOTE() \
+ .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
+
+#define AARCH64_BTI(__type) \
+ AARCH64_BTI_NOTE() ;\
+ bti __type
+
+ #endif
+
+#endif
+
+#ifndef AARCH64_BTI
+#define AARCH64_BTI_NOTE()
+#define AARCH64_BTI(__type)
#endif
/**