summary refs log tree commit diff stats
path: root/include/qemu/timer.h
diff options
context:
space:
mode:
authorSong Gao <gaosong@loongson.cn>2024-07-16 11:15:00 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2024-07-16 18:18:24 +0200
commitd16ccfea238e51a17650c6e32f7c4a1e43cfaa09 (patch)
tree2dacd3f728f0bfbd928d96c25e1eafff951ca606 /include/qemu/timer.h
parent57a8a80d1a5b28797b21d30bfc60601945820e51 (diff)
downloadfocaccia-qemu-d16ccfea238e51a17650c6e32f7c4a1e43cfaa09.tar.gz
focaccia-qemu-d16ccfea238e51a17650c6e32f7c4a1e43cfaa09.zip
qemu/timer: Add host ticks function for LoongArch
Signed-off-by: Song Gao <gaosong@loongson.cn>
Link: https://lore.kernel.org/r/20240716031500.4193498-1-gaosong@loongson.cn
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/timer.h')
-rw-r--r--include/qemu/timer.h9
1 files changed, 9 insertions, 0 deletions
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