Commit 9025cebf authored by Joey Gouly's avatar Joey Gouly Committed by Catalin Marinas

arm64: vdso: use SYS_CNTVCTSS_EL0 for gettimeofday

If FEAT_ECV is implemented, the self-synchronized counter CNTVCTSS_EL0 can
be used, removing the need for an ISB.
Signed-off-by: default avatarJoey Gouly <joey.gouly@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20220830104833.34636-4-joey.gouly@arm.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 4e3bca8f
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <asm/alternative.h>
#include <asm/barrier.h> #include <asm/barrier.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/sysreg.h>
#define VDSO_HAS_CLOCK_GETRES 1 #define VDSO_HAS_CLOCK_GETRES 1
...@@ -78,11 +80,20 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode, ...@@ -78,11 +80,20 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
return 0; return 0;
/* /*
* This isb() is required to prevent that the counter value * If FEAT_ECV is available, use the self-synchronizing counter.
* Otherwise the isb is required to prevent that the counter value
* is speculated. * is speculated.
*/ */
isb(); asm volatile(
asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory"); ALTERNATIVE("isb\n"
"mrs %0, cntvct_el0",
"nop\n"
__mrs_s("%0", SYS_CNTVCTSS_EL0),
ARM64_HAS_ECV)
: "=r" (res)
:
: "memory");
arch_counter_enforce_ordering(res); arch_counter_enforce_ordering(res);
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment