From: "Yicong Yang" <yang.yicong@picoheart.com>
To: <sunilvl@ventanamicro.com>, <palmer@dabbelt.com>,
<alistair.francis@wdc.com>
Cc: <qemu-riscv@nongnu.org>, <qemu-devel@nongnu.org>,
<geshijian@picoheart.com>, <wangziang.ok@picoheart.com>,
"Yicong Yang" <yang.yicong@picoheart.com>
Subject: [PATCH] hw/riscv/virt-acpi-build.c: Use kvm timer frequency when kvm enabled
Date: Wed, 25 Mar 2026 16:13:14 +0800 [thread overview]
Message-ID: <20260325081314.57089-1-yang.yicong@picoheart.com> (raw)
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
reply other threads:[~2026-03-25 12:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325081314.57089-1-yang.yicong@picoheart.com \
--to=yang.yicong@picoheart.com \
--cc=alistair.francis@wdc.com \
--cc=geshijian@picoheart.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=sunilvl@ventanamicro.com \
--cc=wangziang.ok@picoheart.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox