From 8c090c71ca94f2524a28592969e89bacd60c0a38 Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Mon, 25 May 2020 18:02:56 +0800 Subject: [PATCH] HV: fix bug to clear guest flags after it not used in shutdown_vm, it uses guest flags when handling the phyiscal CPUs whose LAPIC is pass-through. So if it is cleared first, the related vCPUs and pCPUs can not be switched to correct state. so move the clear action after the flags used. Tracked-On: #4848 Signed-off-by: Minggui Cao Reviewed-by: Yin Fengwei --- hypervisor/arch/x86/guest/vm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 8b3bfc50f..bb50e8ca9 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -599,9 +599,6 @@ int32_t shutdown_vm(struct acrn_vm *vm) /* Only allow shutdown paused vm */ vm->state = VM_POWERED_OFF; - vm_config = get_vm_config(vm->vm_id); - vm_config->guest_flags &= ~DM_OWNED_GUEST_FLAG_MASK; - if (is_sos_vm(vm)) { sbuf_reset(); } @@ -622,6 +619,10 @@ int32_t shutdown_vm(struct acrn_vm *vm) offline_vcpu(vcpu); } + /* after guest_flags not used, then clear it */ + vm_config = get_vm_config(vm->vm_id); + vm_config->guest_flags &= ~DM_OWNED_GUEST_FLAG_MASK; + if (is_ready_for_system_shutdown()) { /* If no any guest running, shutdown system */ shutdown_system();