[RFC PATCH v1 09/17] hw/intc/riscv_aplic: emulate the APLIC for a CoVE guest

Baolong Duan <[email protected]> Fri, 31 Jul 2026 11:50:03 +0800
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
KVM does not implement an APLIC for a TEE VM, so emulate it in QEMU
while still using the in-kernel IMSIC, exactly like in split irqchip
mode.

Signed-off-by: Baolong Duan <[email protected]>
---
 hw/intc/riscv_aplic.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
index 84606e9f3d..897147c2d5 100644
--- a/hw/intc/riscv_aplic.c
+++ b/hw/intc/riscv_aplic.c
@@ -36,6 +36,7 @@
 #include "kvm/kvm_riscv.h"
 #include "migration/vmstate.h"
 #include "trace.h"
+#include "hw/riscv/cove.h"
 
 #define APLIC_MAX_IDC                  (1UL << 14)
 #define APLIC_MAX_SOURCE               1024
@@ -172,6 +173,14 @@ bool riscv_use_emulated_aplic(bool msimode)
         return true;
     }
 
+    /*
+     * KVM does not implement an APLIC for a CoVE guest, so emulate it in
+     * QEMU while still using the in-kernel IMSIC, like in split mode.
+     */
+    if (riscv_cove_vm_active()) {
+        return true;
+    }
+
     if (!riscv_is_kvm_aia_aplic_imsic(msimode)) {
         return true;
     }
-- 
2.34.1