Skip to content

Commit 376a3a3

Browse files
ilinpvjroelofs
andauthored
[AArch64][FMV] Enable tests for ACLE FMV on Linux. (#98)
* [AArch64][FMV] Enable tests for ACLE FMV on Linux. Enabling Linux part of #87 * Update SingleSource/UnitTests/AArch64/acle-fmv-features.c Co-authored-by: Jon Roelofs <[email protected]> --------- Co-authored-by: Jon Roelofs <[email protected]>
1 parent 5148f0b commit 376a3a3

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
2+
if(TARGET_OS STREQUAL "Linux")
3+
list(APPEND CFLAGS --rtlib=compiler-rt)
4+
list(APPEND LDFLAGS --rtlib=compiler-rt)
5+
endif()
26
if(ARCH STREQUAL "AArch64")
3-
set(Source )
4-
# TODO: this test is currently only supported on Darwin platforms:
5-
if (TARGET_OS MATCHES "Darwin")
6-
list(APPEND Source acle-fmv-features.c)
7-
endif()
87
llvm_singlesource(PREFIX "aarch64-")
98
endif()
109
endif()

SingleSource/UnitTests/AArch64/acle-fmv-features.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ CHECK(ssbs2, {
196196
CHECK(bti, {
197197
// The only test for this requires reading a register that is only
198198
// accessible to EL1.
199-
#if defined(__APPLE__)
199+
#ifdef __linux__
200+
// On linux, the kernel intercepts the trap, and emulates it for EL0 processes.
201+
int val = 0;
202+
asm volatile("mrs %0, ID_AA64PFR1_EL1" : "=r"(val));
203+
// ID_AA64PFR1_EL1.BT, bits [3:0] = 0b0001 if Branch Target Identification
204+
// mechanism implemented.
205+
if ((val & 0xF) != 0x1)
206+
return false;
207+
#elif defined(__APPLE__)
200208
// On Apple platforms, we need to check a sysctl.
201209
int32_t val = 0;
202210
size_t size = sizeof(val);

0 commit comments

Comments
 (0)