aboutsummaryrefslogtreecommitdiff
path: root/include/lib/aarch64/arch_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lib/aarch64/arch_helpers.h')
-rw-r--r--include/lib/aarch64/arch_helpers.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
index 1d9202d04..053f8ba67 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -468,4 +468,16 @@ static inline uint64_t el_implemented(unsigned int el)
}
}
+/* Read the count value of the system counter. */
+static inline uint64_t syscounter_read(void)
+{
+ /*
+ * The instruction barrier is needed to guarantee that we read an
+ * accurate value. Otherwise, the CPU might speculatively read it and
+ * return a stale value.
+ */
+ isb();
+ return read_cntpct_el0();
+}
+
#endif /* ARCH_HELPERS_H */