From 1dac0dd71cdda2bd7395dd47a6b617ed296d4901 Mon Sep 17 00:00:00 2001 From: Mark Rutland Date: Tue, 15 Jan 2013 11:12:29 +0000 Subject: [PATCH] arm64: arm_generic: prevent reading stale time Currently arch_counter_get_cnt{p,v}ct can be speculated, allowing for stale time values to be read. This could be problematic for the delay loop and other sensitive functions, as the time delta could jump around unexpectedly. This patch adds isbs to arch_counter_get_cnt{p,v}ct, preventing this possibility. Signed-off-by: Mark Rutland Acked-by: Catalin Marinas --- arch/arm64/include/asm/arm_generic.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/arm_generic.h b/arch/arm64/include/asm/arm_generic.h index df2aeb82f74e..6ece2f107fa0 100644 --- a/arch/arm64/include/asm/arm_generic.h +++ b/arch/arm64/include/asm/arm_generic.h @@ -83,6 +83,7 @@ static inline cycle_t arch_counter_get_cntpct(void) { cycle_t cval; + isb(); asm volatile("mrs %0, cntpct_el0" : "=r" (cval)); return cval; @@ -92,6 +93,7 @@ static inline cycle_t arch_counter_get_cntvct(void) { cycle_t cval; + isb(); asm volatile("mrs %0, cntvct_el0" : "=r" (cval)); return cval; -- 2.20.1