diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index e57bb600..cf2973ad 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -237,9 +237,16 @@ if(neon) endif() test_compile_with_flags(HAVE_ARM_DIT - GNU_FLAGS -march=armv8.4-a TEST_SOURCE " - int main(void) { asm volatile(\"msr dit, %0\" :: \"r\"(1)); }" + #ifndef __aarch64__ + #error make sure this only even tries to work on AArch64 + #endif + #include + int main(void) { + register uint64_t one asm(\"x8\"); + one = 1; + asm volatile(\".inst 0xd51b42a8\" :: \"r\"(one)); + }" ADD_SOURCES_IF_SUCCESSFUL enable_dit.c) set(HAVE_AES_NI ${HAVE_AES_NI} PARENT_SCOPE) diff --git a/crypto/enable_dit.c b/crypto/enable_dit.c index 7c9ec4b4..65e57078 100644 --- a/crypto/enable_dit.c +++ b/crypto/enable_dit.c @@ -20,5 +20,9 @@ void enable_dit(void) { if (!platform_dit_available()) return; - asm volatile("msr dit, %0" :: "r"(1)); + register uint64_t one asm("x8"); + one = 1; + // This is the binary encoding of "msr dit, x8". You can check via, e.g., + // echo "msr dit,x8" | llvm-mc -triple aarch64 -mattr=+dit -show-encoding + asm volatile(".inst 0xd51b42a8" :: "r"(one)); }