[PATCH] oslat: Avoid out-of-order memory accesses to precede counter read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In arm64 it's possible for the processor to access memory appearing in
program order after the read of the counter before the counter has been
read. This would skew the counter value to a later point than intended.

Fix this my adding an isb() following the counter read instruction.

Suggested-by: Punit Agrawal <punitagrawal@xxxxxxxxx>
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@xxxxxxxxxx>
---
 src/oslat/oslat.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 5fce223..50ddc81 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -92,6 +92,13 @@ static inline void frc(uint64_t *pval)
 	 */
 	__asm__ __volatile__("isb" : : : "memory");
 	__asm__ __volatile__("mrs %0, cntvct_el0" : "=r" (*pval) :: "memory");
+	/*
+	 * This isb() is required to prevent the processor from accessing
+	 * memory appearing in program order after the read of the counter
+	 * before the counter has been read. Which would skew the counter value
+	 * to a later point than intended.
+	 */
+	__asm__ __volatile__("isb" : : : "memory");
 
 }
 # else
-- 
2.31.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux