diff mbox series

qemu/timer: Add host ticks function for LoongArch

Message ID 20240716031500.4193498-1-gaosong@loongson.cn (mailing list archive)
State New, archived
Headers show
Series qemu/timer: Add host ticks function for LoongArch | expand

Commit Message

gaosong July 16, 2024, 3:15 a.m. UTC
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 include/qemu/timer.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Paolo Bonzini July 16, 2024, 8:51 a.m. UTC | #1
Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 5ce83c7911..fa56ec9481 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -1016,6 +1016,15 @@  static inline int64_t cpu_get_host_ticks(void)
     return val;
 }
 
+#elif defined(__loongarch64)
+static inline int64_t cpu_get_host_ticks(void)
+{
+    uint64_t val;
+
+    asm volatile("rdtime.d %0, $zero" : "=r"(val));
+    return val;
+}
+
 #else
 /* The host CPU doesn't have an easily accessible cycle counter.
    Just return a monotonically increasing value.  This will be