Fix missing BTI_PLT flag in aarch64
Resolves: RHEL-50807
This commit is contained in:
parent
26efbe24e0
commit
e86333e6fb
106
0001-OpenMP-AArch64-Fix-branch-protection-in-microtasks-1.patch
Normal file
106
0001-OpenMP-AArch64-Fix-branch-protection-in-microtasks-1.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From b2e2ff20da88df60d2b435e384a8aece217c747e Mon Sep 17 00:00:00 2001
|
||||
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
|
||||
Date: Tue, 13 Aug 2024 21:57:33 -0300
|
||||
Subject: [PATCH] [OpenMP][AArch64] Fix branch protection in microtasks
|
||||
(#102317)
|
||||
|
||||
Start __kmp_invoke_microtask with PACBTI in order to identify the
|
||||
function as a valid branch target. Before returning, SP is
|
||||
authenticated.
|
||||
Also add the BTI and PAC markers to z_Linux_asm.S.
|
||||
|
||||
With this patch, libomp.so can now be generated with DT_AARCH64_BTI_PLT
|
||||
when built with -mbranch-protection=standard.
|
||||
|
||||
The implementation is based on the code available in compiler-rt.
|
||||
|
||||
(cherry picked from commit 0aa22dcd2f6ec5f46b8ef18fee88066463734935)
|
||||
---
|
||||
openmp/runtime/src/z_Linux_asm.S | 53 ++++++++++++++++++++++++++++++++
|
||||
1 file changed, 53 insertions(+)
|
||||
|
||||
diff --git a/openmp/runtime/src/z_Linux_asm.S b/openmp/runtime/src/z_Linux_asm.S
|
||||
index 14987c298fa5..7ef2de900471 100644
|
||||
--- a/openmp/runtime/src/z_Linux_asm.S
|
||||
+++ b/openmp/runtime/src/z_Linux_asm.S
|
||||
@@ -176,6 +176,53 @@ KMP_PREFIX_UNDERSCORE(\proc):
|
||||
.endm
|
||||
# endif // KMP_OS_DARWIN
|
||||
|
||||
+# if KMP_OS_LINUX
|
||||
+// BTI and PAC gnu property note
|
||||
+# define NT_GNU_PROPERTY_TYPE_0 5
|
||||
+# define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
|
||||
+# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 1
|
||||
+# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 2
|
||||
+
|
||||
+# define GNU_PROPERTY(type, value) \
|
||||
+ .pushsection .note.gnu.property, "a"; \
|
||||
+ .p2align 3; \
|
||||
+ .word 4; \
|
||||
+ .word 16; \
|
||||
+ .word NT_GNU_PROPERTY_TYPE_0; \
|
||||
+ .asciz "GNU"; \
|
||||
+ .word type; \
|
||||
+ .word 4; \
|
||||
+ .word value; \
|
||||
+ .word 0; \
|
||||
+ .popsection
|
||||
+# endif
|
||||
+
|
||||
+# if defined(__ARM_FEATURE_BTI_DEFAULT)
|
||||
+# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
|
||||
+# else
|
||||
+# define BTI_FLAG 0
|
||||
+# endif
|
||||
+# if __ARM_FEATURE_PAC_DEFAULT & 3
|
||||
+# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
|
||||
+# else
|
||||
+# define PAC_FLAG 0
|
||||
+# endif
|
||||
+
|
||||
+# if (BTI_FLAG | PAC_FLAG) != 0
|
||||
+# if PAC_FLAG != 0
|
||||
+# define PACBTI_C hint #25
|
||||
+# define PACBTI_RET hint #29
|
||||
+# else
|
||||
+# define PACBTI_C hint #34
|
||||
+# define PACBTI_RET
|
||||
+# endif
|
||||
+# define GNU_PROPERTY_BTI_PAC \
|
||||
+ GNU_PROPERTY(GNU_PROPERTY_AARCH64_FEATURE_1_AND, BTI_FLAG | PAC_FLAG)
|
||||
+# else
|
||||
+# define PACBTI_C
|
||||
+# define PACBTI_RET
|
||||
+# define GNU_PROPERTY_BTI_PAC
|
||||
+# endif
|
||||
#endif // (KMP_OS_LINUX || KMP_OS_DARWIN || KMP_OS_WINDOWS) && (KMP_ARCH_AARCH64 || KMP_ARCH_ARM)
|
||||
|
||||
.macro COMMON name, size, align_power
|
||||
@@ -1292,6 +1339,7 @@ __tid = 8
|
||||
// mark_begin;
|
||||
.text
|
||||
PROC __kmp_invoke_microtask
|
||||
+ PACBTI_C
|
||||
|
||||
stp x29, x30, [sp, #-16]!
|
||||
# if OMPT_SUPPORT
|
||||
@@ -1355,6 +1403,7 @@ KMP_LABEL(kmp_1):
|
||||
ldp x19, x20, [sp], #16
|
||||
# endif
|
||||
ldp x29, x30, [sp], #16
|
||||
+ PACBTI_RET
|
||||
ret
|
||||
|
||||
DEBUG_INFO __kmp_invoke_microtask
|
||||
@@ -2465,3 +2514,7 @@ __kmp_unnamed_critical_addr:
|
||||
.4byte .gomp_critical_user_
|
||||
.size __kmp_unnamed_critical_addr, 4
|
||||
#endif
|
||||
+
|
||||
+#if KMP_OS_LINUX && (KMP_ARCH_AARCH64 || KMP_ARCH_AARCH64_32)
|
||||
+GNU_PROPERTY_BTI_PAC
|
||||
+#endif
|
||||
--
|
||||
2.45.2
|
||||
|
||||
12
libomp.spec
12
libomp.spec
@ -35,7 +35,7 @@
|
||||
|
||||
Name: libomp
|
||||
Version: %{libomp_version}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: OpenMP runtime for clang
|
||||
|
||||
License: Apache-2.0 WITH LLVM-exception OR NCSA
|
||||
@ -49,6 +49,10 @@ Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{libomp
|
||||
Source2: release-keys.asc
|
||||
%endif
|
||||
|
||||
# Backported from https://github.com/llvm/llvm-project/pull/102317
|
||||
# LLVM 19.0 PR under review at https://github.com/llvm/llvm-project/pull/103491
|
||||
Patch: 0001-OpenMP-AArch64-Fix-branch-protection-in-microtasks-1.patch
|
||||
|
||||
BuildRequires: clang >= %{maj_ver}
|
||||
# For clang-offload-packager
|
||||
BuildRequires: clang-tools-extra
|
||||
@ -90,6 +94,9 @@ OpenMP header files.
|
||||
%autosetup -n %{libomp_srcdir} -p2
|
||||
|
||||
%build
|
||||
# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files.
|
||||
export ASMFLAGS=$CFLAGS
|
||||
|
||||
%cmake -GNinja \
|
||||
-DLIBOMP_INSTALL_ALIASES=OFF \
|
||||
-DCMAKE_MODULE_PATH=%{_datadir}/llvm/cmake/Modules \
|
||||
@ -159,6 +166,9 @@ rm -rf %{buildroot}%{_libdir}/libarcher_static.a
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Aug 14 2024 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 18.1.8-2
|
||||
- Fix missing BTI_PLT flag in aarch64 (RHEL-50807)
|
||||
|
||||
* Wed Jul 24 2024 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 18.1.8-1
|
||||
- Update to LLVM 18.1.8 (RHEL-28056)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user