summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-05 14:22:57 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-02-10 21:39:45 -0800
commitb911bb0d42622147c687a4856e29a34c22643bba (patch)
tree653fbf54ddfe232ecb46c7feb671997c8ebc08f8
parent6ab4623cad39bec935f76e366f3f262922bde94a (diff)
qsimd_p.h: move the ARM Crypto (AES) disabling on Linux
Commit 8179d7edf6cb2b06666634d0cafddbca974931e1 added the check in two places. Move to a central one, disabling the bits in qCompilerCpuFeatures. Change-Id: I50e2158aeade4256ad1dfffd17b117afcb93c126 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/corelib/global/qsimd.cpp5
-rw-r--r--src/corelib/global/qsimd_p.h7
-rw-r--r--src/corelib/tools/qhash.cpp6
3 files changed, 7 insertions, 11 deletions
diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp
index a8e99b0df8..8bc5381591 100644
--- a/src/corelib/global/qsimd.cpp
+++ b/src/corelib/global/qsimd.cpp
@@ -561,11 +561,6 @@ QT_FUNCTION_TARGET_BASELINE
uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)()
{
auto minFeatureTest = minFeature;
-#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM_64)
- // Yocto hard-codes CRC32+AES on. Since they are unlikely to be used
- // automatically by compilers, we can just add runtime check.
- minFeatureTest &= ~(CpuFeatureAES|CpuFeatureCRC32);
-#endif
#if defined(Q_PROCESSOR_X86_64) && defined(cpu_feature_shstk)
// Controlflow Enforcement Technology (CET) is an OS-assisted
// hardware-feature, meaning the CPUID bit may be disabled if the OS
diff --git a/src/corelib/global/qsimd_p.h b/src/corelib/global/qsimd_p.h
index 3b74ff6d3c..012eb6cf4f 100644
--- a/src/corelib/global/qsimd_p.h
+++ b/src/corelib/global/qsimd_p.h
@@ -325,12 +325,19 @@ static const uint64_t qCompilerCpuFeatures = 0
#if defined __ARM_NEON__
| CpuFeatureNEON
#endif
+#if !(defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM_64))
+ // Yocto Project recipes enable Crypto extension for all ARMv8 configs,
+ // even for targets without the Crypto extension. That's wrong, but as
+ // the compiler never generates the code for them on their own, most
+ // code never notices the problem. But we would. By not setting the
+ // bits here, we force a runtime detection.
#if defined __ARM_FEATURE_CRC32
| CpuFeatureCRC32
#endif
#if defined __ARM_FEATURE_CRYPTO
| CpuFeatureAES
#endif
+#endif // Q_OS_LINUX && Q_PROCESSOR_ARM64
#if defined __mips_dsp
| CpuFeatureDSP
#endif
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 1a0d281284..56de45fd32 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -937,13 +937,7 @@ size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
if (seed && qCpuHasFeature(AES) && qCpuHasFeature(SSE4_2))
return aeshash(reinterpret_cast<const uchar *>(p), size, seed, seed2);
#elif defined(Q_PROCESSOR_ARM) && QT_COMPILER_SUPPORTS_HERE(AES) && !defined(QHASH_AES_SANITIZER_BUILD) && !defined(QT_BOOTSTRAPPED)
-# if defined(Q_OS_LINUX)
- // Do specific runtime-only check as Yocto hard enables Crypto extension for
- // all armv8 configs
- if (seed && (qCpuFeatures() & CpuFeatureAES))
-# else
if (seed && qCpuHasFeature(AES))
-# endif
return aeshash(reinterpret_cast<const uchar *>(p), size, seed, seed2);
#endif