On 6/22/2026 6:12 PM, Philippe Mathieu-Daudé wrote:
On 22/6/26 21:31, Daniel Henrique Barboza wrote:
riscv_cpu_update_mip() is a TCG only call. Its KVM equivalent is
kvm_riscv_set_irq(). cpu.c gates the KVM only function with a
kvm_enabled() check, making it unavailable for TCG only builds. We need
to do the same for riscv_cpu_update_mip() otherwise a KVM only build
will fail because it doesn't know what this function is.
Use tcg_enabled() for the couple of riscv_cpu_update_mip() calls we have
unguarded in cpu.c.
We have way more calls to deal with in time_helper.c which isn't using
kvm_riscv_set_irq() at all. For this file create a riscv_set_irq() local
helper that will choose whether to use the KVM or TCG API.
The reason we're going through all this hassle in time_helper.c is
because hw/int/riscv_aclint.c uses it, and if we don't do something
about we won't have riscv_aclint working for KVM. Whether this is a
real problem or not and we should remove aclint support for KVM is
question for another day.
Signed-off-by: Daniel Henrique Barboza <[email protected]>
---
target/riscv/cpu.c | 19 ++++++++++++++-----
target/riscv/time_helper.c | 33 +++++++++++++++++++++++++--------
2 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/target/riscv/time_helper.c b/target/riscv/time_helper.c
index 400e917354..2679dbba6c 100644
--- a/target/riscv/time_helper.c
+++ b/target/riscv/time_helper.c
@@ -21,19 +21,34 @@
#include "cpu_bits.h"
#include "time_helper.h"
#include "hw/intc/riscv_aclint.h"
+#include "kvm/kvm_riscv.h"
+#include "system/kvm.h"
+#include "system/tcg.h"
+
+static void riscv_set_irq(RISCVCPU *cpu, int irq, int level)
riscv_accel_set_irq? Regardless,
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Renamed. thx!
+{
+ if (kvm_enabled()) {
+ kvm_riscv_set_irq(cpu, irq, level);
+ }
+
+ if (tcg_enabled()) {
+ riscv_cpu_update_mip(&cpu->env, irq, level);
+ }
+}