From 29b3d03ac748ade54e8b1b21bd00b0266ff1eb48 Mon Sep 17 00:00:00 2001 From: Wu Zhou Date: Fri, 4 Aug 2023 14:11:32 +0800 Subject: [PATCH] hv: vm_event: send event on triple fault handler In the triple fault handler, post-launched VMs are instantly turned off. Now a vm event is generated simultaneously. So that developers can capture the event and decide what to do with it. (e.g., logging and populating diagnostics, or poweroff VM) Tracked-On: #8547 Signed-off-by: Wu Zhou Reviewed-by: Junjie Mao --- hypervisor/arch/x86/guest/vm_reset.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hypervisor/arch/x86/guest/vm_reset.c b/hypervisor/arch/x86/guest/vm_reset.c index 77cfbdb38..344af3760 100644 --- a/hypervisor/arch/x86/guest/vm_reset.c +++ b/hypervisor/arch/x86/guest/vm_reset.c @@ -10,6 +10,7 @@ #include #include #include +#include /** * @pre vm != NULL @@ -17,6 +18,7 @@ void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu) { struct acrn_vm *vm = vcpu->vm; + struct vm_event trp_event; if (is_postlaunched_vm(vm)) { struct io_request *io_req = &vcpu->req; @@ -28,6 +30,10 @@ void triple_fault_shutdown_vm(struct acrn_vcpu *vcpu) io_req->reqs.pio_request.size = 2UL; io_req->reqs.pio_request.value = (VIRTUAL_PM1A_SLP_EN | (5U << 10U)); + /* Send the tripple fault event to DM. */ + trp_event.type = VM_EVENT_TRIPLE_FAULT; + (void)send_vm_event(vcpu->vm, &trp_event); + /* Inject pm1a S5 request to Service VM to shut down the guest */ (void)emulate_io(vcpu, io_req); } else {