[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.11] xen/arm: Add an isb() before reading CNTPCT_EL0 to prevent re-ordering
commit ca73ac8e7d36135c21bb9277e2da494a4bc980ab Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Mon Apr 29 15:05:16 2019 +0100 Commit: Julien Grall <julien.grall@xxxxxxx> CommitDate: Fri Jun 14 14:38:40 2019 +0100 xen/arm: Add an isb() before reading CNTPCT_EL0 to prevent re-ordering Per D8.2.1 in ARM DDI 0487C.a, "a read to CNTPCT_EL0 can occur speculatively and out of order relative to other instructions executed on the same PE." Add an instruction barrier to get accurate number of cycles when requested in get_cycles(). For the other users of CNPCT_EL0, replace by a call to get_cycles(). This is part of XSA-295. Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/arch/arm/time.c | 4 ++-- xen/include/asm-arm/time.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index c11fcfeadd..a15b4a0dc7 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -149,7 +149,7 @@ void __init preinit_xen_time(void) if ( res ) panic("Timer: Cannot initialize platform timer"); - boot_count = READ_SYSREG64(CNTPCT_EL0); + boot_count = get_cycles(); } static void __init init_dt_xen_time(void) @@ -190,7 +190,7 @@ int __init init_xen_time(void) /* Return number of nanoseconds since boot */ s_time_t get_s_time(void) { - uint64_t ticks = READ_SYSREG64(CNTPCT_EL0) - boot_count; + uint64_t ticks = get_cycles() - boot_count; return ticks_to_ns(ticks); } diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h index 5b9a31de91..ca30406669 100644 --- a/xen/include/asm-arm/time.h +++ b/xen/include/asm-arm/time.h @@ -1,6 +1,8 @@ #ifndef __ARM_TIME_H__ #define __ARM_TIME_H__ +#include <asm/system.h> + #define DT_MATCH_TIMER \ DT_MATCH_COMPATIBLE("arm,armv7-timer"), \ DT_MATCH_COMPATIBLE("arm,armv8-timer") @@ -9,7 +11,8 @@ typedef unsigned long cycles_t; static inline cycles_t get_cycles (void) { - return 0; + isb(); + return READ_SYSREG64(CNTPCT_EL0); } /* List of timer's IRQ */ -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.11 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |