mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 17:58:30 +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:
@@ -475,7 +475,7 @@ hv_emulate_mmio(struct acrn_vcpu *vcpu, struct io_request *io_req)
|
||||
size = mmio_req->size;
|
||||
|
||||
spinlock_obtain(&vcpu->vm->emul_mmio_lock);
|
||||
for (idx = 0U; idx <= vcpu->vm->max_emul_mmio_regions; idx++) {
|
||||
for (idx = 0U; idx <= vcpu->vm->nr_emul_mmio_regions; idx++) {
|
||||
mmio_handler = &(vcpu->vm->emul_mmio[idx]);
|
||||
if (mmio_handler->read_write != NULL) {
|
||||
base = mmio_handler->range_start;
|
||||
@@ -657,8 +657,8 @@ static inline struct mem_io_node *find_free_mmio_node(struct acrn_vm *vm)
|
||||
|
||||
if (mmio_node != NULL) {
|
||||
idx = (uint16_t)(uint64_t)(mmio_node - &(vm->emul_mmio[0U]));
|
||||
if (vm->max_emul_mmio_regions < idx) {
|
||||
vm->max_emul_mmio_regions = idx;
|
||||
if (vm->nr_emul_mmio_regions < idx) {
|
||||
vm->nr_emul_mmio_regions = idx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,3 +724,9 @@ void unregister_mmio_emulation_handler(struct acrn_vm *vm,
|
||||
}
|
||||
spinlock_release(&vm->emul_mmio_lock);
|
||||
}
|
||||
|
||||
void deinit_emul_io(struct acrn_vm *vm)
|
||||
{
|
||||
(void)memset(vm->emul_mmio, 0U, sizeof(vm->emul_mmio));
|
||||
(void)memset(vm->emul_pio, 0U, sizeof(vm->emul_pio));
|
||||
}
|
||||
|
Reference in New Issue
Block a user