@samitouri / QOSamiQemu / commits / 4cb2f91773

hw/riscv/virt-acpi-build.c: Use kvm timer frequency when kvm enabled

The timer frequency is decided by the host(kvm) rather than a fixed RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ on kvm accelerated VM. So build RCHT with KVM provided timer frequency if KVM is enabled, just like how we build the timer node on DT based VM. Fixes: ebfd39289370 ("hw/riscv/virt: virt-acpi-build.c: Add RHCT Table") Signed-off-by: Yicong Yang <yang.yicong@picoheart.com> Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com> Message-ID: <20260325081314.57089-1-yang.yicong@picoheart.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Yicong Yang committed Mar 25, 2026 at 16:13 UTC 4cb2f91773e8ec9511002de851734820f7ba64fe
1 file changed +6 -1
hw/riscv/virt-acpi-build.c
+6 -1
@@ -35,9 +35,11 @@
35 #include "hw/riscv/virt.h"
36 #include "hw/riscv/numa.h"
37 #include "hw/virtio/virtio-acpi.h"
38 +#include "kvm/kvm_riscv.h"
39 #include "migration/vmstate.h"
40 #include "qapi/error.h"
41 #include "qemu/error-report.h"
42 +#include "system/kvm.h"
43 #include "system/reset.h"
44
45 #define ACPI_BUILD_TABLE_SIZE 0x20000
@@ -296,7 +298,10 @@ static void build_rhct(GArray *table_data,
298
299 /* Time Base Frequency */
300 build_append_int_noprefix(table_data,
299 - RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, 8);
301 + kvm_enabled() ?
302 + kvm_riscv_get_timebase_frequency(&s->soc->harts[0]) :
303 + RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ,
304 + 8);
305
306 /* ISA + N hart info */
307 num_rhct_nodes = 1 + ms->smp.cpus;