From nobody Thu Jan 02 16:05:05 2025
X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YPBPF2zbhz5jNT3;
Thu, 02 Jan 2025 16:05:05 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
client-signature RSA-PSS (4096 bits) client-digest SHA256)
(Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK))
by mx1.freebsd.org (Postfix) with ESMTPS id 4YPBPF2Gxjz4YnY;
Thu, 2 Jan 2025 16:05:05 +0000 (UTC)
(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
t=1735833905;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=VLO+VVCdTjY+9JVe9I8oPQwEQiMa6okzPttpwZlCGnI=;
b=KpxAfKBnDhMlICzZl0PayYx/LTeDA3msNJehBfcyC5UcKMq5NKazSC/kH7dWNr1RlreQ2c
JaJyVAuDXpwn+DdlCpiyuE4CVaO/BQYZlHSeKlaPwZMZaZuHd9CUTL9/uPTg/GdTIluO6D
2AsPuPLWK7NXQ6UEzkiF5zxhhoB23Qmxii74wXS1vMjb4UeTpIj15WsfC0MQML654J2SZ3
w61LFny73YvVSH70fIbSv0k2w6s7KX9Y9blyQhTycoPnRGRJn5V9m1zT0pzI62o4Nlpihf
RjSOqOhTozdZryldzCd7foy0OmAYb9ONiYoKbjKsm2MKlP39jyBJPN18A2zIyA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
s=dkim; t=1735833905;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=VLO+VVCdTjY+9JVe9I8oPQwEQiMa6okzPttpwZlCGnI=;
b=Id9xiPJf2m9d7m/kV2Wvt96Ojr6wL7+PZFaZl8FAlwwpZmAcBvSbCCfzqlOrtZucbute/a
ptqiaUXnh2hrHvC5WCrGH0sgtGk45fK0CxTVuRYoEkx1/Mwq/4wFQ//S/kIw4P3sKu6LGx
FoHwKaJfjF1btx+rP5pR3sE8QUYAZvktgPNpbMZs2rsKgmR1PrisnIrKNOXE0jVb4b0Dtd
s16Zdml05U0lZ4HqwguRZJD3iwMgRTEUXMg513tNJdCx3ypTDJv5BIlJoPnEFOxkyJiD0W
zfmMCk4pG5PPvUS6yBSh6dy/EFvjJuoXvjjbsjrYbiobgujNSR7xJqHVS1ymxA==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735833905; a=rsa-sha256; cv=none;
b=BZQONtMvrtVZYR3t+xUIedRSQ5bQlEhzUN6L8Bv+SL0WKkxjFPX6kRaTMK5WoS/Wa0lKem
fMGCPTXLDZc7oEW1RkGu4nf1W0V4m2/D24G8TIFXp3pNcFV4vGlZa9a0lhS01JAbTgHN1x
47zH0SzFV2vF8bOH96mX3XbIGMXsdnZybWUFkGk7QvIrX3+JmIPOqa5FkFYQZ624/09DBL
e3kuGB5cx5s5EPuT2XTJsJbu+J6ochQFEIvVHLxyY9zh74G1cenGp6mXF5/vXXaNO9jDlg
QFEEIJiUKWdOu3WIyGRS6cs8YKUsMrQxSGuYm1Fa8dLzhHO/0SZAJdDTwdP79g==
ARC-Authentication-Results: i=1;
mx1.freebsd.org;
none
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
(Client did not present a certificate)
by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YPBPF1WmtzkXx;
Thu, 02 Jan 2025 16:05:05 +0000 (UTC)
(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 502G555P000562;
Thu, 2 Jan 2025 16:05:05 GMT
(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 502G55eR000559;
Thu, 2 Jan 2025 16:05:05 GMT
(envelope-from git)
Date: Thu, 2 Jan 2025 16:05:05 GMT
Message-Id: <202501021605.502G55eR000559@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
dev-commits-src-main@FreeBSD.org
From: Ruslan Bukin
Subject: git: 9be0058ea0fc - main - riscv vmm: virtual timer support.
List-Id: Commit messages for all branches of the src repository
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all
List-Help:
List-Post:
List-Subscribe:
List-Unsubscribe:
X-BeenThere: dev-commits-src-all@freebsd.org
Sender: owner-dev-commits-src-all@FreeBSD.org
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: br
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: 9be0058ea0fc6fd098b9e2ab54f94c86fe7eb69a
Auto-Submitted: auto-generated
The branch main has been updated by br:
URL: https://cgit.FreeBSD.org/src/commit/?id=9be0058ea0fc6fd098b9e2ab54f94c86fe7eb69a
commit 9be0058ea0fc6fd098b9e2ab54f94c86fe7eb69a
Author: Ruslan Bukin
AuthorDate: 2025-01-02 15:42:34 +0000
Commit: Ruslan Bukin
CommitDate: 2025-01-02 16:02:39 +0000
riscv vmm: virtual timer support.
Add a virtual timer implementation based on SBI Time extension.
This is needed for Eswin EIC7700 SoC which does not include the newer SSTC
extension.
Timer interrupt pending bit (STIP) could not be cleared in the guest system,
so rework interrupts handling: add new "interrupts_pending" field. Use it
for timer interrupt only for now, but later we can extend to store all
pending interrupts (Timer, IPI and External).
With this I'm able to boot FreeBSD (SMP) guest on HiFive Premier P550,
which is the first real hardware with RISC-V 'H'-spec included.
Differential Revision: https://reviews.freebsd.org/D48133
---
sys/conf/files.riscv | 1 +
sys/modules/vmm/Makefile | 3 +-
sys/riscv/vmm/riscv.h | 5 ++
sys/riscv/vmm/vmm.c | 3 ++
sys/riscv/vmm/vmm_riscv.c | 47 +++++++++++-------
sys/riscv/vmm/vmm_sbi.c | 26 ++++++++++
sys/riscv/vmm/vmm_vtimer.c | 117 +++++++++++++++++++++++++++++++++++++++++++++
sys/riscv/vmm/vmm_vtimer.h | 47 ++++++++++++++++++
usr.sbin/bhyve/riscv/fdt.c | 3 +-
9 files changed, 233 insertions(+), 19 deletions(-)
diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv
index 6186ae9b3371..534fe5013c56 100644
--- a/sys/conf/files.riscv
+++ b/sys/conf/files.riscv
@@ -83,6 +83,7 @@ riscv/vmm/vmm_instruction_emul.c optional vmm
riscv/vmm/vmm_riscv.c optional vmm
riscv/vmm/vmm_sbi.c optional vmm
riscv/vmm/vmm_switch.S optional vmm
+riscv/vmm/vmm_vtimer.c optional vmm
riscv/thead/thead.c standard
diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile
index 0ec1147d0d4b..7c34dd92939b 100644
--- a/sys/modules/vmm/Makefile
+++ b/sys/modules/vmm/Makefile
@@ -154,7 +154,8 @@ svm_genassym.o: offset.inc
SRCS+= vmm_aplic.c \
vmm_riscv.c \
vmm_sbi.c \
- vmm_switch.S
+ vmm_switch.S \
+ vmm_vtimer.c
.endif
diff --git a/sys/riscv/vmm/riscv.h b/sys/riscv/vmm/riscv.h
index ed4b65003f94..f3665d33a386 100644
--- a/sys/riscv/vmm/riscv.h
+++ b/sys/riscv/vmm/riscv.h
@@ -38,6 +38,8 @@
#include
#include
+#include
+
struct hypregs {
uint64_t hyp_ra;
uint64_t hyp_sp;
@@ -78,6 +80,8 @@ struct hypctx {
bool has_exception;
int cpu_id;
int ipi_pending;
+ int interrupts_pending;
+ struct vtimer vtimer;
};
struct hyp {
@@ -128,5 +132,6 @@ int vmm_sbi_ecall(struct vcpu *, bool *);
void riscv_send_ipi(struct hypctx *hypctx, int hart_id);
int riscv_check_ipi(struct hypctx *hypctx, bool clear);
+bool riscv_check_interrupts_pending(struct hypctx *hypctx);
#endif /* !_VMM_RISCV_H_ */
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
index 33a0cb5fe420..0596e0de2e43 100644
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -1414,6 +1414,9 @@ vm_handle_wfi(struct vcpu *vcpu, struct vm_exit *vme, bool *retu)
if (riscv_check_ipi(vcpu->cookie, false))
break;
+ if (riscv_check_interrupts_pending(vcpu->cookie))
+ break;
+
if (vcpu_should_yield(vcpu))
break;
diff --git a/sys/riscv/vmm/vmm_riscv.c b/sys/riscv/vmm/vmm_riscv.c
index e276f8583e37..6ac945dfa1d0 100644
--- a/sys/riscv/vmm/vmm_riscv.c
+++ b/sys/riscv/vmm/vmm_riscv.c
@@ -107,11 +107,6 @@ vmmops_modinit(void)
return (ENXIO);
}
- if (!has_sstc) {
- printf("vmm: riscv hart doesn't support SSTC extension.\n");
- return (ENXIO);
- }
-
return (0);
}
@@ -229,6 +224,7 @@ vmmops_vcpu_init(void *vmi, struct vcpu *vcpu1, int vcpuid)
hyp->ctx[vcpuid] = hypctx;
aplic_cpuinit(hypctx);
+ vtimer_cpuinit(hypctx);
return (hypctx);
}
@@ -561,29 +557,36 @@ riscv_check_ipi(struct hypctx *hypctx, bool clear)
return (val);
}
+bool
+riscv_check_interrupts_pending(struct hypctx *hypctx)
+{
+
+ if (hypctx->interrupts_pending)
+ return (true);
+
+ return (false);
+}
+
static void
riscv_sync_interrupts(struct hypctx *hypctx)
{
int pending;
pending = aplic_check_pending(hypctx);
-
if (pending)
hypctx->guest_csrs.hvip |= HVIP_VSEIP;
else
hypctx->guest_csrs.hvip &= ~HVIP_VSEIP;
- csr_write(hvip, hypctx->guest_csrs.hvip);
-}
-
-static void
-riscv_sync_ipi(struct hypctx *hypctx)
-{
-
/* Guest clears VSSIP bit manually. */
if (riscv_check_ipi(hypctx, true))
hypctx->guest_csrs.hvip |= HVIP_VSSIP;
+ if (riscv_check_interrupts_pending(hypctx))
+ hypctx->guest_csrs.hvip |= HVIP_VSTIP;
+ else
+ hypctx->guest_csrs.hvip &= ~HVIP_VSTIP;
+
csr_write(hvip, hypctx->guest_csrs.hvip);
}
@@ -594,6 +597,7 @@ vmmops_run(void *vcpui, register_t pc, pmap_t pmap, struct vm_eventinfo *evinfo)
struct vm_exit *vme;
struct vcpu *vcpu;
register_t val;
+ uint64_t hvip;
bool handled;
hypctx = (struct hypctx *)vcpui;
@@ -615,7 +619,8 @@ vmmops_run(void *vcpui, register_t pc, pmap_t pmap, struct vm_eventinfo *evinfo)
__asm __volatile("hfence.gvma" ::: "memory");
csr_write(hgatp, pmap->pm_satp);
- csr_write(henvcfg, HENVCFG_STCE);
+ if (has_sstc)
+ csr_write(henvcfg, HENVCFG_STCE);
csr_write(hie, HIE_VSEIE | HIE_VSSIE | HIE_SGEIE);
/* TODO: should we trap rdcycle / rdtime? */
csr_write(hcounteren, HCOUNTEREN_CY | HCOUNTEREN_TM);
@@ -653,9 +658,7 @@ vmmops_run(void *vcpui, register_t pc, pmap_t pmap, struct vm_eventinfo *evinfo)
*/
riscv_set_active_vcpu(hypctx);
aplic_flush_hwstate(hypctx);
-
riscv_sync_interrupts(hypctx);
- riscv_sync_ipi(hypctx);
dprintf("%s: Entering guest VM, vsatp %lx, ss %lx hs %lx\n",
__func__, csr_read(vsatp), hypctx->guest_regs.hyp_sstatus,
@@ -666,8 +669,18 @@ vmmops_run(void *vcpui, register_t pc, pmap_t pmap, struct vm_eventinfo *evinfo)
dprintf("%s: Leaving guest VM, hstatus %lx\n", __func__,
hypctx->guest_regs.hyp_hstatus);
+ /* Guest can clear VSSIP. It can't clear VSTIP or VSEIP. */
+ hvip = csr_read(hvip);
+ if ((hypctx->guest_csrs.hvip ^ hvip) & HVIP_VSSIP) {
+ if (hvip & HVIP_VSSIP) {
+ /* TODO: VSSIP was set by guest. */
+ } else {
+ /* VSSIP was cleared by guest. */
+ hypctx->guest_csrs.hvip &= ~HVIP_VSSIP;
+ }
+ }
+
aplic_sync_hwstate(hypctx);
- riscv_sync_interrupts(hypctx);
/*
* TODO: deactivate stage 2 pmap here if needed.
diff --git a/sys/riscv/vmm/vmm_sbi.c b/sys/riscv/vmm/vmm_sbi.c
index 6444b8c9e396..63dcf9b4a7ae 100644
--- a/sys/riscv/vmm/vmm_sbi.c
+++ b/sys/riscv/vmm/vmm_sbi.c
@@ -95,6 +95,31 @@ vmm_sbi_handle_rfnc(struct vcpu *vcpu, struct hypctx *hypctx)
return (0);
}
+static int
+vmm_sbi_handle_time(struct vcpu *vcpu, struct hypctx *hypctx)
+{
+ uint64_t func_id;
+ uint64_t next_val;
+ int ret;
+
+ func_id = hypctx->guest_regs.hyp_a[6];
+ next_val = hypctx->guest_regs.hyp_a[0];
+
+ switch (func_id) {
+ case SBI_TIME_SET_TIMER:
+ vtimer_set_timer(hypctx, next_val);
+ ret = 0;
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+
+ hypctx->guest_regs.hyp_a[0] = ret;
+
+ return (0);
+}
+
static int
vmm_sbi_handle_ipi(struct vcpu *vcpu, struct hypctx *hypctx)
{
@@ -166,6 +191,7 @@ vmm_sbi_ecall(struct vcpu *vcpu, bool *retu)
vmm_sbi_handle_rfnc(vcpu, hypctx);
break;
case SBI_EXT_ID_TIME:
+ vmm_sbi_handle_time(vcpu, hypctx);
break;
case SBI_EXT_ID_IPI:
vmm_sbi_handle_ipi(vcpu, hypctx);
diff --git a/sys/riscv/vmm/vmm_vtimer.c b/sys/riscv/vmm/vmm_vtimer.c
new file mode 100644
index 000000000000..0dadc962114f
--- /dev/null
+++ b/sys/riscv/vmm/vmm_vtimer.c
@@ -0,0 +1,117 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Ruslan Bukin
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory (Department of Computer Science and Technology) under Innovate
+ * UK project 105694, "Digital Security by Design (DSbD) Technology Platform
+ * Prototype".
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "riscv.h"
+
+#define VTIMER_DEFAULT_FREQ 1000000
+
+static int
+vtimer_get_timebase(uint32_t *freq)
+{
+ phandle_t node;
+ int len;
+
+ node = OF_finddevice("/cpus");
+ if (node == -1)
+ return (ENXIO);
+
+ len = OF_getproplen(node, "timebase-frequency");
+ if (len != 4)
+ return (ENXIO);
+
+ OF_getencprop(node, "timebase-frequency", freq, len);
+
+ return (0);
+}
+
+void
+vtimer_cpuinit(struct hypctx *hypctx)
+{
+ struct vtimer *vtimer;
+ uint32_t freq;
+ int error;
+
+ vtimer = &hypctx->vtimer;
+ mtx_init(&vtimer->mtx, "vtimer callout mutex", NULL, MTX_DEF);
+ callout_init_mtx(&vtimer->callout, &vtimer->mtx, 0);
+
+ error = vtimer_get_timebase(&freq);
+ if (error)
+ freq = VTIMER_DEFAULT_FREQ;
+
+ vtimer->freq = freq;
+}
+
+static void
+vtimer_inject_irq_callout(void *arg)
+{
+ struct hypctx *hypctx;
+ struct hyp *hyp;
+
+ hypctx = arg;
+ hyp = hypctx->hyp;
+
+ atomic_set_32(&hypctx->interrupts_pending, HVIP_VSTIP);
+ vcpu_notify_event(vm_vcpu(hyp->vm, hypctx->cpu_id));
+}
+
+int
+vtimer_set_timer(struct hypctx *hypctx, uint64_t next_val)
+{
+ struct vtimer *vtimer;
+ sbintime_t time;
+ uint64_t curtime;
+ uint64_t delta;
+
+ vtimer = &hypctx->vtimer;
+
+ curtime = rdtime();
+ if (curtime < next_val) {
+ delta = next_val - curtime;
+ time = delta * SBT_1S / vtimer->freq;
+ atomic_clear_32(&hypctx->interrupts_pending, HVIP_VSTIP);
+ callout_reset_sbt(&vtimer->callout, time, 0,
+ vtimer_inject_irq_callout, hypctx, 0);
+ } else
+ atomic_set_32(&hypctx->interrupts_pending, HVIP_VSTIP);
+
+ return (0);
+}
diff --git a/sys/riscv/vmm/vmm_vtimer.h b/sys/riscv/vmm/vmm_vtimer.h
new file mode 100644
index 000000000000..6deca322ce99
--- /dev/null
+++ b/sys/riscv/vmm/vmm_vtimer.h
@@ -0,0 +1,47 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Ruslan Bukin
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory (Department of Computer Science and Technology) under Innovate
+ * UK project 105694, "Digital Security by Design (DSbD) Technology Platform
+ * Prototype".
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _VMM_VTIMER_H_
+#define _VMM_VTIMER_H_
+
+struct hypctx;
+
+struct vtimer {
+ struct callout callout;
+ struct mtx mtx;
+ uint32_t freq;
+};
+
+void vtimer_cpuinit(struct hypctx *hypctx);
+int vtimer_set_timer(struct hypctx *hypctx, uint64_t next_val);
+
+#endif /* !_VMM_VTIMER_H_ */
diff --git a/usr.sbin/bhyve/riscv/fdt.c b/usr.sbin/bhyve/riscv/fdt.c
index bef3f64b0c64..81296714e013 100644
--- a/usr.sbin/bhyve/riscv/fdt.c
+++ b/usr.sbin/bhyve/riscv/fdt.c
@@ -118,7 +118,8 @@ add_cpus(void *fdt, int ncpu, const char *isa)
/* XXX: Needed given the root #address-cells? */
fdt_property_u32(fdt, "#address-cells", 1);
fdt_property_u32(fdt, "#size-cells", 0);
- fdt_property_u32(fdt, "timebase-frequency", 10000000);
+ /* TODO: take timebase from kernel? */
+ fdt_property_u32(fdt, "timebase-frequency", 1000000);
for (cpuid = 0; cpuid < ncpu; cpuid++)
add_cpu(fdt, cpuid, isa);