diff --git a/.github/workflows/windows-arm64.yml b/.github/workflows/windows-arm64.yml index 41627a43434..4a0114fb03d 100644 --- a/.github/workflows/windows-arm64.yml +++ b/.github/workflows/windows-arm64.yml @@ -34,7 +34,7 @@ jobs: # false: pure-C ARM64 build. true: assemble the ARMv8 crypto .asm and # enable the matching WOLFSSL_ARMASM code paths. asm: [ false, true ] - timeout-minutes: 10 + timeout-minutes: 15 env: SOLUTION_FILE_PATH: wolfssl64.sln BUILD_CONFIGURATION: Release @@ -55,3 +55,13 @@ jobs: - name: Run Test working-directory: ${{env.GITHUB_WORKSPACE}} run: Release/ARM64/testsuite.exe + + # Build + run the wolfCrypt benchmark: exercises the MSVC/ARM64 cycle counter + # (and the ARMv8 asm on asm=true), reusing the wolfssl lib the solution built. + - name: Build Benchmark + working-directory: ${{env.GITHUB_WORKSPACE}} + run: msbuild /m /p:PlatformToolset=v143 /p:Platform=ARM64 /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:WolfSSLAarch64Asm=${{matrix.asm}} wolfcrypt/benchmark/benchmark.vcxproj + + - name: Run Benchmark + working-directory: ${{env.GITHUB_WORKSPACE}} + run: wolfcrypt/benchmark/Release/ARM64/benchmark.exe diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index b0f7e79078b..86d73dc7580 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -81,6 +81,12 @@ #include #include +#if defined(_MSC_VER) && defined(_M_ARM64) + /* MSVC has no inline asm on ARM64. Pull in the system register intrinsics + * (_ReadStatusReg, __isb) the AArch64 cycle counter below uses. */ + #include +#endif + #ifdef WOLFSSL_LINUXKM /* remap current_time() -- collides with a function in kernel linux/fs.h */ #define current_time benchmark_current_time @@ -4867,6 +4873,12 @@ static void print_cpu_features(void) static void print_clock_freq(void) { #ifdef __aarch64__ +#if defined(_MSC_VER) + /* MSVC/ARM64: no inline asm. Read CNTFRQ_EL0 (3,3,14,0,0) via the + * system register intrinsic. */ + __isb(_ARM64_BARRIER_SY); + tick_freq = (word64)_ReadStatusReg(ARM64_SYSREG(3, 3, 14, 0, 0)); +#else __asm__ __volatile__ ( "isb\n\t" "mrs %[freq], cntfrq_el0\n\t" @@ -4874,6 +4886,7 @@ static void print_clock_freq(void) : : ); +#endif if (tick_freq != 0 && actual_freq != 0) { printf("Tick frequency: %ld Hz, Clock frequency: %ld Hz\n", tick_freq, actual_freq); @@ -17315,6 +17328,12 @@ void bench_mldsaKeySign(byte level) static WC_INLINE word64 get_aarch64_cycles(void) { word64 ticks; + #if defined(_MSC_VER) + /* MSVC/ARM64: no inline asm. Read CNTVCT_EL0 (3,3,14,0,2) via the + * system register intrinsic. */ + __isb(_ARM64_BARRIER_SY); + ticks = (word64)_ReadStatusReg(ARM64_SYSREG(3, 3, 14, 0, 2)); + #else __asm__ __volatile__ ( "isb\n\t" #ifdef __APPLE__ @@ -17326,6 +17345,7 @@ void bench_mldsaKeySign(byte level) : : ); + #endif if ((tick_freq != 0) && (actual_freq != 0)) { ticks *= actual_freq / tick_freq; } diff --git a/wolfcrypt/benchmark/benchmark.vcxproj b/wolfcrypt/benchmark/benchmark.vcxproj index a194b71cefd..27a5aefc2c3 100644 --- a/wolfcrypt/benchmark/benchmark.vcxproj +++ b/wolfcrypt/benchmark/benchmark.vcxproj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + 17.0 @@ -38,6 +46,12 @@ v143 + + v143 + + + v143 + @@ -71,6 +85,18 @@ Release\ true + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)_obj\ + false + + + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\$(ProjectName)_obj\ + false + Disabled @@ -149,6 +175,54 @@ MachineX64 + + + Disabled + ../..;../../IDE/WIN;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + ProgramDatabase + false + + + Ws2_32.lib;%(AdditionalDependencies) + true + Console + + + + + ../..;../../IDE/WIN;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + Level3 + ProgramDatabase + false + + + Ws2_32.lib;%(AdditionalDependencies) + true + Console + true + true + + + + + USE_INTEL_SPEEDUP;WOLFSSL_X86_64_BUILD;%(PreprocessorDefinitions) + + + + + + WOLFSSL_ARMASM;WOLFSSL_ARMASM_CRYPTO_SHA3;WOLFSSL_ARMASM_CRYPTO_SHA512;%(PreprocessorDefinitions) + +