From: Baolong Duan <blduan@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair23@gmail.com,
dbarboza@ventanamicro.com, cxx194832@alibaba-inc.com,
zengxiangyi.zxy@alibaba-inc.com,
Baolong Duan <blduan@linux.alibaba.com>
Subject: [RFC PATCH v1 10/17] target/riscv/kvm: skip unsupported KVM requests for a CoVE guest
Date: Fri, 31 Jul 2026 11:50:04 +0800 [thread overview]
Message-ID: <20260731035011.4178103-11-blduan@linux.alibaba.com> (raw)
In-Reply-To: <20260731035011.4178103-1-blduan@linux.alibaba.com>
A TEE VM has no APLIC and no PLIC, and its timer state lives inside the
TVM where the host cannot read it. Skip the KVM requests that would fail
or return meaningless data: reading the timer back, injecting a wired
interrupt, and the APLIC part of the in-kernel AIA setup.
Note that kvm_mark_guest_state_protected(), which SEV and TDX use, would
cover the vCPU state part of this generically. It is not used here
because it also changes the reset and migration paths, which have not
been evaluated for CoVE yet.
Signed-off-by: Baolong Duan <blduan@linux.alibaba.com>
---
target/riscv/kvm/kvm-cpu.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index 67c99d68ce..23c2ae2214 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -1477,7 +1477,13 @@ static void kvm_riscv_vm_state_change(void *opaque, bool running,
if (running) {
kvm_riscv_put_regs_timer(cs);
} else {
- kvm_riscv_get_regs_timer(cs);
+ /*
+ * The timer state of a CoVE guest is kept inside the TVM and cannot
+ * be read back by the host.
+ */
+ if (!riscv_cove_vm_active()) {
+ kvm_riscv_get_regs_timer(cs);
+ }
}
}
@@ -1791,6 +1797,14 @@ void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
int ret;
unsigned virq = level ? KVM_INTERRUPT_SET : KVM_INTERRUPT_UNSET;
+ /*
+ * A CoVE guest has neither APLIC nor PLIC, so there is no wired
+ * interrupt to inject.
+ */
+ if (riscv_cove_vm_active()) {
+ return;
+ }
+
if (irq != IRQ_S_EXT) {
perror("kvm riscv set irq != IRQ_S_EXT\n");
abort();
@@ -1924,8 +1938,11 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift,
* This is done by leaving KVM_DEV_RISCV_AIA_CONFIG_SRCS
* unset. We can also skip KVM_DEV_RISCV_AIA_ADDR_APLIC
* since KVM won't be using it.
+ *
+ * The same applies to a CoVE guest: KVM does not implement an
+ * APLIC for a TVM, only the IMSIC is used.
*/
- if (!kvm_kernel_irqchip_split()) {
+ if (!kvm_kernel_irqchip_split() && !riscv_cove_vm_active()) {
ret = kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG,
KVM_DEV_RISCV_AIA_CONFIG_SRCS,
&aia_irq_num, true, NULL);
--
2.34.1
next prev parent reply other threads:[~2026-07-31 5:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 3:49 [RFC PATCH v1 00/17] target/riscv: Add KVM CoVE confidential VM support Baolong Duan
2026-07-31 3:49 ` [RFC PATCH v1 01/17] docs/system/riscv/virt: document the cove-vm machine option Baolong Duan
2026-07-31 3:49 ` [RFC PATCH v1 02/17] hw/riscv/virt: add the cove-vm machine property Baolong Duan
2026-07-31 3:49 ` [RFC PATCH v1 03/17] target/riscv/kvm: create and measure a CoVE TEE VM Baolong Duan
2026-07-31 3:49 ` [RFC PATCH v1 04/17] accel/kvm: add kvm_gpa_to_userspace_addr() Baolong Duan
2026-07-31 3:49 ` [RFC PATCH v1 05/17] hw/riscv/boot: load and measure the images of a CoVE guest Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 06/17] hw/riscv/virt: measure the device tree " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 07/17] hw/riscv: adapt " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 08/17] hw/riscv/virt: use MSIs only for " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 09/17] hw/intc/riscv_aplic: emulate the APLIC " Baolong Duan
2026-07-31 3:50 ` Baolong Duan [this message]
2026-07-31 3:50 ` [RFC PATCH v1 11/17] hw/virtio: force modern virtio " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 12/17] hw/net/virtio-net: do not use vhost " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 13/17] accel/kvm: only register the DRAM slot of " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 14/17] accel/kvm: skip MSI route updates for " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 15/17] accel/kvm: pin the vCPU threads of " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 16/17] accel/kvm: terminate on a system event " Baolong Duan
2026-07-31 3:50 ` [RFC PATCH v1 17/17] hw/core/machine-qmp-cmds: shut down a CoVE guest on reset Baolong Duan
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=20260731035011.4178103-11-blduan@linux.alibaba.com \
--to=blduan@linux.alibaba.com \
--cc=alistair23@gmail.com \
--cc=cxx194832@alibaba-inc.com \
--cc=dbarboza@ventanamicro.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zengxiangyi.zxy@alibaba-inc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.