diff options
| author | JosJuice <josjuice@gmail.com> | 2022-08-05 12:12:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-05 12:12:34 +0200 |
| commit | 939fa1ed1c19f972cdc6f86fd914a582254a8cc7 (patch) | |
| tree | 58642d75829e0ce528dbd77ec0943d9e766a2fa1 /Source | |
| parent | e638bb658fa2bbaa6e46148816598fe3ab79dc6e (diff) | |
| parent | bf5076eb010a0c8928d7fb823b35105e9e9dc0c6 (diff) | |
Merge pull request #10941 from shuffle2/crypto-cleanup
Crypto cleanup
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Common/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | Source/Core/Common/Crypto/AES.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/Common/Crypto/SHA1.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/DolphinLib.props | 7 |
4 files changed, 18 insertions, 28 deletions
diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index f9e5109d17..134d38062c 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -136,9 +136,18 @@ add_library(common WorkQueueThread.h ) +if(MSVC AND _M_ARM_64) + # Workaround msvc arm64 optimizer bug + # TODO remove after updating to VS 17.4 + set_source_files_properties( + Crypto/SHA1.cpp + PROPERTIES COMPILE_FLAGS "/d2ssa-peeps-post-color-") +endif() + if(NOT MSVC AND _M_ARM_64) set_source_files_properties( Crypto/AES.cpp + Crypto/SHA1.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto") endif() diff --git a/Source/Core/Common/Crypto/AES.cpp b/Source/Core/Common/Crypto/AES.cpp index 7c67766ed4..fe8f4ec728 100644 --- a/Source/Core/Common/Crypto/AES.cpp +++ b/Source/Core/Common/Crypto/AES.cpp @@ -264,7 +264,7 @@ public: template <size_t RoundIdx> inline constexpr void StoreRoundKey(const u32* rk) { - const uint8x16_t rk_block = vld1q_u32(rk); + const uint8x16_t rk_block = vreinterpretq_u8_u32(vld1q_u32(rk)); if constexpr (AesMode == Mode::Encrypt) round_keys[RoundIdx] = rk_block; else diff --git a/Source/Core/Common/Crypto/SHA1.cpp b/Source/Core/Common/Crypto/SHA1.cpp index 4f0ef6b491..57c45b09f3 100644 --- a/Source/Core/Common/Crypto/SHA1.cpp +++ b/Source/Core/Common/Crypto/SHA1.cpp @@ -19,14 +19,6 @@ #ifdef _M_X86_64 #include <immintrin.h> #elif defined(_M_ARM_64) -#if defined(__clang__) -// This is a bit of a hack to get clang to accept the sha1 intrinsics without modifying cmdline -// flags. Note __ARM_FEATURE_CRYPTO is deprecated and "SHA2" flag is the lowest one which includes -// SHA1. -#define __ARM_FEATURE_SHA2 -// ...needed for older clang before they made the switchover to more granular flags. -#define __ARM_FEATURE_CRYPTO -#endif #include <arm_acle.h> #include <arm_neon.h> #endif @@ -259,17 +251,6 @@ private: #ifdef _M_ARM_64 -// The armv8 flags are very annoying: -// clang inserts "+" prefixes itself, gcc does not. -// clang has deprecated "crypto" (removed in clang 13), gcc has not. -#ifdef _MSC_VER -#define TARGET_ARMV8_SHA1 -#elif defined(__clang__) -#define TARGET_ARMV8_SHA1 [[gnu::target("sha2")]] -#elif defined(__GNUC__) -#define TARGET_ARMV8_SHA1 [[gnu::target("+crypto")]] -#endif - class ContextNeon final : public BlockContext { public: @@ -290,7 +271,6 @@ private: u32 e{}; }; - TARGET_ARMV8_SHA1 static inline uint32x4_t MsgSchedule(WorkBlock* wblock, size_t i) { auto& w = *wblock; @@ -302,7 +282,7 @@ private: } template <size_t Func> - TARGET_ARMV8_SHA1 static inline constexpr uint32x4_t f(State state, uint32x4_t w) + static inline constexpr uint32x4_t f(State state, uint32x4_t w) { const auto wk = vaddq_u32(w, vdupq_n_u32(K[Func])); if constexpr (Func == 0) @@ -314,12 +294,8 @@ private: } template <size_t Func> - TARGET_ARMV8_SHA1 static inline constexpr State FourRounds(State state, uint32x4_t w) + static inline constexpr State FourRounds(State state, uint32x4_t w) { -#ifdef _MSC_VER - // FIXME it seems the msvc optimizer gets a little too happy - _ReadBarrier(); -#endif return {f<Func>(state, w), vsha1h_u32(vgetq_lane_u32(state.abcd, 0))}; } diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 592b423164..4c08f0a6d8 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -724,7 +724,12 @@ <ClCompile Include="Common\Crypto\AES.cpp" /> <ClCompile Include="Common\Crypto\bn.cpp" /> <ClCompile Include="Common\Crypto\ec.cpp" /> - <ClCompile Include="Common\Crypto\SHA1.cpp" /> + <ClCompile Include="Common\Crypto\SHA1.cpp"> + <!--Workaround msvc arm64 optimizer bug + TODO remove after updating to VS 17.4 + --> + <AdditionalOptions Condition="'$(Platform)'=='ARM64'">/d2ssa-peeps-post-color- %(AdditionalOptions)</AdditionalOptions> + </ClCompile> <ClCompile Include="Common\Debug\MemoryPatches.cpp" /> <ClCompile Include="Common\Debug\Watches.cpp" /> <ClCompile Include="Common\DynamicLibrary.cpp" /> |
