hw/riscv/virt-acpi-build.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
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>
---
hw/riscv/virt-acpi-build.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c
index f1406cb68339..fd6ca5dbc4ff 100644
--- a/hw/riscv/virt-acpi-build.c
+++ b/hw/riscv/virt-acpi-build.c
@@ -35,9 +35,11 @@
#include "hw/riscv/virt.h"
#include "hw/riscv/numa.h"
#include "hw/virtio/virtio-acpi.h"
+#include "kvm/kvm_riscv.h"
#include "migration/vmstate.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
+#include "system/kvm.h"
#include "system/reset.h"
#define ACPI_BUILD_TABLE_SIZE 0x20000
@@ -296,7 +298,10 @@ static void build_rhct(GArray *table_data,
/* Time Base Frequency */
build_append_int_noprefix(table_data,
- RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, 8);
+ kvm_enabled() ?
+ kvm_riscv_get_timebase_frequency(&s->soc->harts[0]) :
+ RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ,
+ 8);
/* ISA + N hart info */
num_rhct_nodes = 1 + ms->smp.cpus;
--
2.34.1
On Wed, Mar 25, 2026 at 10:34 PM Yicong Yang <yang.yicong@picoheart.com> wrote:
>
> 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>
Thanks!
Applied to riscv-to-apply.next
Alistair
> ---
> hw/riscv/virt-acpi-build.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c
> index f1406cb68339..fd6ca5dbc4ff 100644
> --- a/hw/riscv/virt-acpi-build.c
> +++ b/hw/riscv/virt-acpi-build.c
> @@ -35,9 +35,11 @@
> #include "hw/riscv/virt.h"
> #include "hw/riscv/numa.h"
> #include "hw/virtio/virtio-acpi.h"
> +#include "kvm/kvm_riscv.h"
> #include "migration/vmstate.h"
> #include "qapi/error.h"
> #include "qemu/error-report.h"
> +#include "system/kvm.h"
> #include "system/reset.h"
>
> #define ACPI_BUILD_TABLE_SIZE 0x20000
> @@ -296,7 +298,10 @@ static void build_rhct(GArray *table_data,
>
> /* Time Base Frequency */
> build_append_int_noprefix(table_data,
> - RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, 8);
> + kvm_enabled() ?
> + kvm_riscv_get_timebase_frequency(&s->soc->harts[0]) :
> + RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ,
> + 8);
>
> /* ISA + N hart info */
> num_rhct_nodes = 1 + ms->smp.cpus;
> --
> 2.34.1
>
On Wed, Mar 25, 2026 at 04:13:14PM +0800, Yicong Yang wrote:
> 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>
> ---
> hw/riscv/virt-acpi-build.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c
> index f1406cb68339..fd6ca5dbc4ff 100644
> --- a/hw/riscv/virt-acpi-build.c
> +++ b/hw/riscv/virt-acpi-build.c
> @@ -35,9 +35,11 @@
> #include "hw/riscv/virt.h"
> #include "hw/riscv/numa.h"
> #include "hw/virtio/virtio-acpi.h"
> +#include "kvm/kvm_riscv.h"
> #include "migration/vmstate.h"
> #include "qapi/error.h"
> #include "qemu/error-report.h"
> +#include "system/kvm.h"
> #include "system/reset.h"
>
> #define ACPI_BUILD_TABLE_SIZE 0x20000
> @@ -296,7 +298,10 @@ static void build_rhct(GArray *table_data,
>
> /* Time Base Frequency */
> build_append_int_noprefix(table_data,
> - RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, 8);
> + kvm_enabled() ?
> + kvm_riscv_get_timebase_frequency(&s->soc->harts[0]) :
> + RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ,
> + 8);
>
> /* ISA + N hart info */
> num_rhct_nodes = 1 + ms->smp.cpus;
> --
> 2.34.1
>
Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
© 2016 - 2026 Red Hat, Inc.