Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/windows-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
20 changes: 20 additions & 0 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
#include <wolfssl/wolfcrypt/asn.h>
#include <wolfssl/version.h>

#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 <intrin.h>
#endif

#ifdef WOLFSSL_LINUXKM
/* remap current_time() -- collides with a function in kernel linux/fs.h */
#define current_time benchmark_current_time
Expand Down Expand Up @@ -4867,13 +4873,20 @@ 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"
: [freq] "=r" (tick_freq)
:
:
);
#endif
if (tick_freq != 0 && actual_freq != 0) {
printf("Tick frequency: %ld Hz, Clock frequency: %ld Hz\n", tick_freq,
actual_freq);
Expand Down Expand Up @@ -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__
Expand All @@ -17326,6 +17345,7 @@ void bench_mldsaKeySign(byte level)
:
:
);
#endif
if ((tick_freq != 0) && (actual_freq != 0)) {
ticks *= actual_freq / tick_freq;
}
Expand Down
74 changes: 74 additions & 0 deletions wolfcrypt/benchmark/benchmark.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
Expand All @@ -38,6 +46,12 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
Expand Down Expand Up @@ -71,6 +85,18 @@
<IntDir>Release\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<!-- ARM64 outputs land beside testsuite.exe when built via the solution;
standalone builds resolve relative to this directory (SolutionDir empty). -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
<IntDir>$(Configuration)\$(Platform)\$(ProjectName)_obj\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
<IntDir>$(Configuration)\$(Platform)\$(ProjectName)_obj\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
Expand Down Expand Up @@ -149,6 +175,54 @@
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../..;../../IDE/WIN;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<AdditionalIncludeDirectories>../..;../../IDE/WIN;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(WolfSSLIntelAsm)'=='true' And '$(Platform)'=='x64'">
<ClCompile>
<PreprocessorDefinitions>USE_INTEL_SPEEDUP;WOLFSSL_X86_64_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<!-- Keep WOLFSSL_ARMASM consistent with the library (set by
/p:WolfSSLAarch64Asm=true) so struct layouts match. -->
<ItemDefinitionGroup Condition="'$(WolfSSLAarch64Asm)'=='true' And '$(Platform)'=='ARM64'">
<ClCompile>
<PreprocessorDefinitions>WOLFSSL_ARMASM;WOLFSSL_ARMASM_CRYPTO_SHA3;WOLFSSL_ARMASM_CRYPTO_SHA512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="benchmark.c" />
</ItemGroup>
Expand Down
Loading