Skip to content

Commit 3024c8a

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents a8b174b + 309b929 commit 3024c8a

File tree

22 files changed

+692
-287
lines changed

22 files changed

+692
-287
lines changed

make/autoconf/flags-cflags.m4

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -936,15 +936,13 @@ AC_DEFUN_ONCE([FLAGS_SETUP_BRANCH_PROTECTION],
936936
937937
if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
938938
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
939-
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${BRANCH_PROTECTION_FLAG}],
939+
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$BRANCH_PROTECTION_FLAG],
940940
IF_TRUE: [BRANCH_PROTECTION_AVAILABLE=true])
941941
fi
942942
fi
943943
944-
BRANCH_PROTECTION_CFLAGS=""
945944
UTIL_ARG_ENABLE(NAME: branch-protection, DEFAULT: false,
946-
RESULT: USE_BRANCH_PROTECTION, AVAILABLE: $BRANCH_PROTECTION_AVAILABLE,
945+
RESULT: BRANCH_PROTECTION_ENABLED, AVAILABLE: $BRANCH_PROTECTION_AVAILABLE,
947946
DESC: [enable branch protection when compiling C/C++],
948-
IF_ENABLED: [ BRANCH_PROTECTION_CFLAGS=${BRANCH_PROTECTION_FLAG}])
949-
AC_SUBST(BRANCH_PROTECTION_CFLAGS)
947+
IF_ENABLED: [BRANCH_PROTECTION_CFLAGS=$BRANCH_PROTECTION_FLAG])
950948
])

make/autoconf/flags-other.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,9 @@ AC_DEFUN([FLAGS_SETUP_ASFLAGS_CPU_DEP],
150150
$2JVM_ASFLAGS="${$2JVM_ASFLAGS} $ARM_ARCH_TYPE_ASFLAGS $ARM_FLOAT_TYPE_ASFLAGS"
151151
fi
152152
153+
if test "x$BRANCH_PROTECTION_ENABLED" = "xtrue"; then
154+
$2JVM_ASFLAGS="${$2JVM_ASFLAGS} $BRANCH_PROTECTION_FLAG"
155+
fi
156+
153157
AC_SUBST($2JVM_ASFLAGS)
154158
])

make/autoconf/spec.gmk.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ ENABLE_LIBFFI_BUNDLING := @ENABLE_LIBFFI_BUNDLING@
429429
LIBFFI_LIB_FILE := @LIBFFI_LIB_FILE@
430430
FILE_MACRO_CFLAGS := @FILE_MACRO_CFLAGS@
431431
REPRODUCIBLE_CFLAGS := @REPRODUCIBLE_CFLAGS@
432-
BRANCH_PROTECTION_CFLAGS := @BRANCH_PROTECTION_CFLAGS@
433432

434433
STATIC_LIBS_CFLAGS := @STATIC_LIBS_CFLAGS@
435434

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ void LIR_Assembler::osr_entry() {
275275
// verify the interpreter's monitor has a non-null object
276276
{
277277
Label L;
278-
__ ldr(rscratch1, Address(OSR_buf, slot_offset + 1*BytesPerWord));
278+
__ ldr(rscratch1, __ form_address(rscratch1, OSR_buf, slot_offset + 1*BytesPerWord, 0));
279279
__ cbnz(rscratch1, L);
280280
__ stop("locked object is null");
281281
__ bind(L);
282282
}
283283
#endif
284-
__ ldr(r19, Address(OSR_buf, slot_offset));
285-
__ ldr(r20, Address(OSR_buf, slot_offset + BytesPerWord));
284+
__ ldr(r19, __ form_address(rscratch1, OSR_buf, slot_offset, 0));
285+
__ ldr(r20, __ form_address(rscratch1, OSR_buf, slot_offset + BytesPerWord, 0));
286286
__ str(r19, frame_map()->address_for_monitor_lock(i));
287287
__ str(r20, frame_map()->address_for_monitor_object(i));
288288
}

src/hotspot/cpu/aarch64/copy_aarch64.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -64,28 +64,34 @@ static void pd_zero_to_bytes(void* to, size_t count) {
6464
" br %[t0];\n" \
6565
" .align 5;\n" \
6666
"0:" \
67+
" hint #0x24; // bti j\n" \
6768
" b 1f;\n" \
6869
" .align 5;\n" \
70+
" hint #0x24; // bti j\n" \
6971
" ldr %[t0], [%[s], #0];\n" \
7072
" str %[t0], [%[d], #0];\n" \
7173
" b 1f;\n" \
7274
" .align 5;\n" \
75+
" hint #0x24; // bti j\n" \
7376
" ldp %[t0], %[t1], [%[s], #0];\n" \
7477
" stp %[t0], %[t1], [%[d], #0];\n" \
7578
" b 1f;\n" \
7679
" .align 5;\n" \
80+
" hint #0x24; // bti j\n" \
7781
" ldp %[t0], %[t1], [%[s], #0];\n" \
7882
" ldr %[t2], [%[s], #16];\n" \
7983
" stp %[t0], %[t1], [%[d], #0];\n" \
8084
" str %[t2], [%[d], #16];\n" \
8185
" b 1f;\n" \
8286
" .align 5;\n" \
87+
" hint #0x24; // bti j\n" \
8388
" ldp %[t0], %[t1], [%[s], #0];\n" \
8489
" ldp %[t2], %[t3], [%[s], #16];\n" \
8590
" stp %[t0], %[t1], [%[d], #0];\n" \
8691
" stp %[t2], %[t3], [%[d], #16];\n" \
8792
" b 1f;\n" \
8893
" .align 5;\n" \
94+
" hint #0x24; // bti j\n" \
8995
" ldp %[t0], %[t1], [%[s], #0];\n" \
9096
" ldp %[t2], %[t3], [%[s], #16];\n" \
9197
" ldr %[t4], [%[s], #32];\n" \
@@ -94,6 +100,7 @@ static void pd_zero_to_bytes(void* to, size_t count) {
94100
" str %[t4], [%[d], #32];\n" \
95101
" b 1f;\n" \
96102
" .align 5;\n" \
103+
" hint #0x24; // bti j\n" \
97104
" ldp %[t0], %[t1], [%[s], #0];\n" \
98105
" ldp %[t2], %[t3], [%[s], #16];\n" \
99106
" ldp %[t4], %[t5], [%[s], #32];\n" \
@@ -103,13 +110,15 @@ static void pd_zero_to_bytes(void* to, size_t count) {
103110
" stp %[t4], %[t5], [%[d], #32];\n" \
104111
" b 1f;\n" \
105112
" .align 5;\n" \
113+
" hint #0x24; // bti j\n" \
106114
" ldr %[t6], [%[s], #0];\n" \
107115
" ldp %[t0], %[t1], [%[s], #8];\n" \
108116
" ldp %[t2], %[t3], [%[s], #24];\n" \
109117
" ldp %[t4], %[t5], [%[s], #40];\n" \
110118
" str %[t6], [%[d]], #8;\n" \
111119
" b 2b;\n" \
112120
" .align 5;\n" \
121+
" hint #0x24; // bti j\n" \
113122
" ldp %[t0], %[t1], [%[s], #0];\n" \
114123
" ldp %[t2], %[t3], [%[s], #16];\n" \
115124
" ldp %[t4], %[t5], [%[s], #32];\n" \

src/hotspot/os_cpu/linux_aarch64/atomic_linux_aarch64.S

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
.align 5
2828
DECLARE_FUNC(aarch64_atomic_fetch_add_8_default_impl):
29+
hint #0x22 // bti c
2930
#ifdef __ARM_FEATURE_ATOMICS
3031
ldaddal x1, x2, [x0]
3132
#else
@@ -41,6 +42,7 @@ DECLARE_FUNC(aarch64_atomic_fetch_add_8_default_impl):
4142

4243
.align 5
4344
DECLARE_FUNC(aarch64_atomic_fetch_add_4_default_impl):
45+
hint #0x22 // bti c
4446
#ifdef __ARM_FEATURE_ATOMICS
4547
ldaddal w1, w2, [x0]
4648
#else
@@ -56,8 +58,9 @@ DECLARE_FUNC(aarch64_atomic_fetch_add_4_default_impl):
5658

5759
.align 5
5860
DECLARE_FUNC(aarch64_atomic_fetch_add_8_relaxed_default_impl):
61+
hint #0x22 // bti c
5962
#ifdef __ARM_FEATURE_ATOMICS
60-
ldadd x1, x2, [x0]
63+
ldadd x1, x2, [x0]
6164
#else
6265
prfm pstl1strm, [x0]
6366
0: ldxr x2, [x0]
@@ -70,8 +73,9 @@ DECLARE_FUNC(aarch64_atomic_fetch_add_8_relaxed_default_impl):
7073

7174
.align 5
7275
DECLARE_FUNC(aarch64_atomic_fetch_add_4_relaxed_default_impl):
76+
hint #0x22 // bti c
7377
#ifdef __ARM_FEATURE_ATOMICS
74-
ldadd w1, w2, [x0]
78+
ldadd w1, w2, [x0]
7579
#else
7680
prfm pstl1strm, [x0]
7781
0: ldxr w2, [x0]
@@ -84,6 +88,7 @@ DECLARE_FUNC(aarch64_atomic_fetch_add_4_relaxed_default_impl):
8488

8589
.align 5
8690
DECLARE_FUNC(aarch64_atomic_xchg_4_default_impl):
91+
hint #0x22 // bti c
8792
#ifdef __ARM_FEATURE_ATOMICS
8893
swpal w1, w2, [x0]
8994
#else
@@ -98,6 +103,7 @@ DECLARE_FUNC(aarch64_atomic_xchg_4_default_impl):
98103

99104
.align 5
100105
DECLARE_FUNC(aarch64_atomic_xchg_8_default_impl):
106+
hint #0x22 // bti c
101107
#ifdef __ARM_FEATURE_ATOMICS
102108
swpal x1, x2, [x0]
103109
#else
@@ -112,6 +118,7 @@ DECLARE_FUNC(aarch64_atomic_xchg_8_default_impl):
112118

113119
.align 5
114120
DECLARE_FUNC(aarch64_atomic_cmpxchg_1_default_impl):
121+
hint #0x22 // bti c
115122
#ifdef __ARM_FEATURE_ATOMICS
116123
mov x3, x1
117124
casalb w3, w2, [x0]
@@ -131,6 +138,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_1_default_impl):
131138

132139
.align 5
133140
DECLARE_FUNC(aarch64_atomic_cmpxchg_4_default_impl):
141+
hint #0x22 // bti c
134142
#ifdef __ARM_FEATURE_ATOMICS
135143
mov x3, x1
136144
casal w3, w2, [x0]
@@ -149,6 +157,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_4_default_impl):
149157

150158
.align 5
151159
DECLARE_FUNC(aarch64_atomic_cmpxchg_8_default_impl):
160+
hint #0x22 // bti c
152161
#ifdef __ARM_FEATURE_ATOMICS
153162
mov x3, x1
154163
casal x3, x2, [x0]
@@ -167,6 +176,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_8_default_impl):
167176

168177
.align 5
169178
DECLARE_FUNC(aarch64_atomic_cmpxchg_4_release_default_impl):
179+
hint #0x22 // bti c
170180
#ifdef __ARM_FEATURE_ATOMICS
171181
mov x3, x1
172182
casl w3, w2, [x0]
@@ -183,6 +193,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_4_release_default_impl):
183193

184194
.align 5
185195
DECLARE_FUNC(aarch64_atomic_cmpxchg_8_release_default_impl):
196+
hint #0x22 // bti c
186197
#ifdef __ARM_FEATURE_ATOMICS
187198
mov x3, x1
188199
casl x3, x2, [x0]
@@ -199,6 +210,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_8_release_default_impl):
199210

200211
.align 5
201212
DECLARE_FUNC(aarch64_atomic_cmpxchg_4_seq_cst_default_impl):
213+
hint #0x22 // bti c
202214
#ifdef __ARM_FEATURE_ATOMICS
203215
mov x3, x1
204216
casal w3, w2, [x0]
@@ -215,6 +227,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_4_seq_cst_default_impl):
215227

216228
.align 5
217229
DECLARE_FUNC(aarch64_atomic_cmpxchg_8_seq_cst_default_impl):
230+
hint #0x22 // bti c
218231
#ifdef __ARM_FEATURE_ATOMICS
219232
mov x3, x1
220233
casal x3, x2, [x0]
@@ -231,6 +244,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_8_seq_cst_default_impl):
231244

232245
.align 5
233246
DECLARE_FUNC(aarch64_atomic_cmpxchg_1_relaxed_default_impl):
247+
hint #0x22 // bti c
234248
#ifdef __ARM_FEATURE_ATOMICS
235249
mov x3, x1
236250
casb w3, w2, [x0]
@@ -248,6 +262,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_1_relaxed_default_impl):
248262

249263
.align 5
250264
DECLARE_FUNC(aarch64_atomic_cmpxchg_4_relaxed_default_impl):
265+
hint #0x22 // bti c
251266
#ifdef __ARM_FEATURE_ATOMICS
252267
mov x3, x1
253268
cas w3, w2, [x0]
@@ -264,6 +279,7 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_4_relaxed_default_impl):
264279

265280
.align 5
266281
DECLARE_FUNC(aarch64_atomic_cmpxchg_8_relaxed_default_impl):
282+
hint #0x22 // bti c
267283
#ifdef __ARM_FEATURE_ATOMICS
268284
mov x3, x1
269285
cas x3, x2, [x0]
@@ -277,3 +293,35 @@ DECLARE_FUNC(aarch64_atomic_cmpxchg_8_relaxed_default_impl):
277293
#endif
278294
1: mov x0, x3
279295
ret
296+
297+
/* Emit .note.gnu.property section in case of PAC or BTI being enabled.
298+
* For more details see "ELF for the Arm® 64-bit Architecture (AArch64)".
299+
* https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst
300+
*/
301+
#ifdef __ARM_FEATURE_BTI_DEFAULT
302+
#ifdef __ARM_FEATURE_PAC_DEFAULT
303+
#define GNU_PROPERTY_AARCH64_FEATURE 3
304+
#else
305+
#define GNU_PROPERTY_AARCH64_FEATURE 1
306+
#endif
307+
#else
308+
#ifdef __ARM_FEATURE_PAC_DEFAULT
309+
#define GNU_PROPERTY_AARCH64_FEATURE 2
310+
#else
311+
#define GNU_PROPERTY_AARCH64_FEATURE 0
312+
#endif
313+
#endif
314+
315+
#if (GNU_PROPERTY_AARCH64_FEATURE != 0)
316+
.pushsection .note.gnu.property, "a"
317+
.align 3
318+
.long 4 /* name length */
319+
.long 0x10 /* data length */
320+
.long 5 /* note type: NT_GNU_PROPERTY_TYPE_0 */
321+
.string "GNU" /* vendor name */
322+
.long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
323+
.long 4 /* pr_datasze */
324+
.long GNU_PROPERTY_AARCH64_FEATURE
325+
.long 0
326+
.popsection
327+
#endif

0 commit comments

Comments
 (0)