patch "virt: acrn: Do hcall_destroy_vm() before resource release" added to char-misc-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
virt: acrn: Do hcall_destroy_vm() before resource release
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 4c4c1257b844ffe5d0933684e612f92c4b78e120 Mon Sep 17 00:00:00 2001
From: Shuo Liu <[email protected]>
Date: Thu, 22 Jul 2021 14:27:36 +0800
Subject: virt: acrn: Do hcall_destroy_vm() before resource release
The ACRN hypervisor has scenarios which could run a real-time guest VM. The real-time guest VM occupies dedicated CPU cores, be assigned with dedicated PCI devices. It can run without the Service VM after boot up. hcall_destroy_vm() returns failure when a real-time guest VM refuses. The clearing of flag ACRN_VM_FLAG_DESTROYED causes some kernel resource double-freed in a later acrn_vm_destroy().
Do hcall_destroy_vm() before resource release to drop this chance to destroy the VM if hypercall fails.
--- drivers/virt/acrn/vm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/virt/acrn/vm.c +8 -8
@@ -64,6 +64,14 @@ int acrn_vm_destroy(struct acrn_vm *vm) test_and_set_bit(ACRN_VM_FLAG_DESTROYED, &vm->flags))return 0 ; + ret =hcall_destroy_vm (vm->vmid); +if (ret <0 ) { +dev_err (acrn_dev.this_device, +"Failed to destroy VM %u\n" , vm->vmid); +clear_bit (ACRN_VM_FLAG_DESTROYED , &vm->flags); +return ret; + } +/* Remove from global VM list */ write_lock_bh (&acrn_vm_list_lock);list_del_init (&vm->list);
@@ -78,14 +86,6 @@ int acrn_vm_destroy(struct acrn_vm *vm) vm->monitor_page =NULL ; } - ret =hcall_destroy_vm (vm->vmid); -if (ret <0 ) { -dev_err (acrn_dev.this_device, -"Failed to destroy VM %u\n" , vm->vmid); -clear_bit (ACRN_VM_FLAG_DESTROYED , &vm->flags); -return ret; - } -acrn_vm_all_ram_unmap (vm);dev_dbg (acrn_dev.this_device,"VM %u destroyed.\n" , vm->vmid);
Signature · 1 line
2.32.0