From 17287cd595bbfdb9680471a965598ec86120fdfb Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Wed, 11 Feb 2026 20:35:50 -0700 Subject: [PATCH] wolfEntropy: Add ARM Generic Timer virtual counter as time src --- wolfcrypt/src/wolfentropy.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wolfcrypt/src/wolfentropy.c b/wolfcrypt/src/wolfentropy.c index eb25d4a534..4c2bfaec0b 100644 --- a/wolfcrypt/src/wolfentropy.c +++ b/wolfcrypt/src/wolfentropy.c @@ -155,6 +155,20 @@ static WC_INLINE word64 Entropy_TimeHiRes(void) QueryPerformanceCounter(&count); return (word64)(count.QuadPart); } +#elif !defined(ENTROPY_MEMUSE_THREAD) && defined(__arm__) +/* Get time counter from arch_sys_counter clocksource. + * + * @return 64-bit timer count. + */ +static WC_INLINE word64 Entropy_TimeHiRes(void) +{ + word32 lo, hi; + __asm__ __volatile__ ( + "mrrc p15, 1, %[lo], %[hi], c14" + : [lo] "=r"(lo), [hi] "=r"(hi) + ); + return ((word64)hi << 32) | lo; +} #elif defined(WOLFSSL_THREAD_NO_JOIN) /* Start and stop thread that counts as a proxy for time counter. */