Skip to content
Open
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
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
Loading