[RFC PATCH v1 16/17] accel/kvm: terminate on a system event of a CoVE guest

Baolong Duan <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
The TSM does not honour a power off request for a TEE VM: the vCPU
re-enters KVM_RUN and reports the same system event again, so QEMU never
shuts the guest down.  Terminate the process instead.

This works around a missing piece of the TSM ABI rather than something
QEMU should be doing.

Signed-off-by: Baolong Duan <[email protected]>
---
 accel/kvm/kvm-all.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 7b33a9aa3a..938bbebcd1 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3613,6 +3613,17 @@ int kvm_cpu_exec(CPUState *cpu)
             break;
         case KVM_EXIT_SYSTEM_EVENT:
             trace_kvm_run_exit_system_event(cpu->cpu_index, run->system_event.type);
+            /*
+             * The TSM does not honour power_off for a TVM: the vCPU would
+             * re-enter KVM_RUN and report the same event forever, so
+             * terminate QEMU right away.
+             */
+            if (riscv_cove_vm_active()) {
+                warn_report("CoVE VM: system event %d, terminating",
+                            run->system_event.type);
+                exit(run->system_event.type == KVM_SYSTEM_EVENT_SHUTDOWN ?
+                     0 : 1);
+            }
             switch (run->system_event.type) {
             case KVM_SYSTEM_EVENT_SHUTDOWN:
                 qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.