arm64: ensure CPU clock retrieval issues isb()
authorJens Axboe <axboe@kernel.dk>
Thu, 22 Sep 2022 16:03:51 +0000 (10:03 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 22 Sep 2022 16:03:51 +0000 (10:03 -0600)
This prevents counter value speculation, which will otherwise cause
issues with the CPU clock.

Link: https://github.com/axboe/fio/issues/1472
Signed-off-by: Jens Axboe <axboe@kernel.dk>
arch/arch-aarch64.h

index 951d1718cfabfbe59469c3421b67d4bc8fb5e103..919e57967609b4b077c50396c5aaf0cc6f4a1d05 100644 (file)
@@ -27,10 +27,13 @@ static inline int arch_ffz(unsigned long bitmask)
 
 #define ARCH_HAVE_FFZ
 
 
 #define ARCH_HAVE_FFZ
 
+#define isb()  asm volatile("isb" : : : "memory")
+
 static inline unsigned long long get_cpu_clock(void)
 {
        unsigned long val;
 
 static inline unsigned long long get_cpu_clock(void)
 {
        unsigned long val;
 
+       isb();
        asm volatile("mrs %0, cntvct_el0" : "=r" (val));
        return val;
 }
        asm volatile("mrs %0, cntvct_el0" : "=r" (val));
        return val;
 }