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>
This commit is contained in:
Song Gao 2024-07-16 11:15:00 +08:00 committed by Paolo Bonzini
parent 57a8a80d1a
commit d16ccfea23

View File

@ -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