mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 08:50:27 +00:00
hv:refine vm & vcpu lock
-- move vm_state_lock to other place in vm structure to avoid the memory waste because of the page-aligned. -- remove the memset from create_vm -- explicitly set max_emul_mmio_regions and vcpuid_entry_nr to 0 inside create_vm to avoid use without initialization. -- rename max_emul_mmio_regions to nr_emul_mmio_regions v1->v2: add deinit_emul_io in shutdown_vm Tracked-On: #4958 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Grandhi, Sainath <sainath.grandhi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -407,8 +407,6 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v
|
||||
|
||||
/* Allocate memory for virtual machine */
|
||||
vm = &vm_array[vm_id];
|
||||
/* the vm_state lock field need to remain unchanged in vm data structure */
|
||||
(void)memset((void *)&vm->arch_vm, 0U, (sizeof(struct acrn_vm) - sizeof(spinlock_t)));
|
||||
vm->vm_id = vm_id;
|
||||
vm->hw.created_vcpus = 0U;
|
||||
|
||||
@@ -457,6 +455,8 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v
|
||||
|
||||
vm->arch_vm.vlapic_mode = VM_VLAPIC_XAPIC;
|
||||
vm->intr_inject_delay_delta = 0UL;
|
||||
vm->nr_emul_mmio_regions = 0U;
|
||||
vm->vcpuid_entry_nr = 0U;
|
||||
|
||||
/* Set up IO bit-mask such that VM exit occurs on
|
||||
* selected IO ranges
|
||||
@@ -611,6 +611,8 @@ int32_t shutdown_vm(struct acrn_vm *vm)
|
||||
|
||||
deinit_vpci(vm);
|
||||
|
||||
deinit_emul_io(vm);
|
||||
|
||||
/* Free EPT allocated resources assigned to VM */
|
||||
destroy_ept(vm);
|
||||
|
||||
|
Reference in New Issue
Block a user