hv:change register_mmio_emulation_handler to void

change this api to void type

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
This commit is contained in:
Mingqiang Chi 2019-04-18 12:08:19 +08:00 committed by wenlingz
parent f1aa35a27c
commit a4c9cb997e
4 changed files with 28 additions and 38 deletions

View File

@ -596,7 +596,8 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
/** /**
* @brief Register a MMIO handler * @brief Register a MMIO handler
* *
* This API registers a MMIO handler to \p vm before it is launched. * This API registers a MMIO handler to \p vm before it is Started
* For Pre-launched VMs, this API can be called after it is Started
* *
* @param vm The VM to which the MMIO handler is registered * @param vm The VM to which the MMIO handler is registered
* @param read_write The handler for emulating accesses to the given range * @param read_write The handler for emulating accesses to the given range
@ -604,50 +605,40 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
* @param end The end of the range (exclusive) \p read_write can emulate * @param end The end of the range (exclusive) \p read_write can emulate
* @param handler_private_data Handler-specific data which will be passed to \p read_write when called * @param handler_private_data Handler-specific data which will be passed to \p read_write when called
* *
* @retval 0 Registration succeeds * @return None
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
*/ */
int32_t register_mmio_emulation_handler(struct acrn_vm *vm, void register_mmio_emulation_handler(struct acrn_vm *vm,
hv_mem_io_handler_t read_write, uint64_t start, hv_mem_io_handler_t read_write, uint64_t start,
uint64_t end, void *handler_private_data) uint64_t end, void *handler_private_data)
{ {
int32_t status = -EINVAL;
struct mem_io_node *mmio_node; struct mem_io_node *mmio_node;
if ((vm->hw.created_vcpus > 0U) && (vm->hw.vcpu_array[0].launched)) { /* Ensure both a read/write handler and range check function exist */
pr_err("register mmio handler after vm launched"); if ((read_write != NULL) && (end > start)) {
} else { if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) {
/* Ensure both a read/write handler and range check function exist */ pr_err("the emulated mmio region is out of range");
if ((read_write != NULL) && (end > start)) { } else {
if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) { mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]);
pr_err("the emulated mmio region is out of range"); /* Fill in information for this node */
} else { mmio_node->read_write = read_write;
mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]); mmio_node->handler_private_data = handler_private_data;
/* Fill in information for this node */ mmio_node->range_start = start;
mmio_node->read_write = read_write; mmio_node->range_end = end;
mmio_node->handler_private_data = handler_private_data;
mmio_node->range_start = start;
mmio_node->range_end = end;
(vm->emul_mmio_regions)++; (vm->emul_mmio_regions)++;
/* /*
* SOS would map all its memory at beginning, so we * SOS would map all its memory at beginning, so we
* should unmap it. But UOS will not, so we shouldn't * should unmap it. But UOS will not, so we shouldn't
* need to unmap it. * need to unmap it.
*/ */
if (is_sos_vm(vm)) { if (is_sos_vm(vm)) {
ept_mr_del(vm, (uint64_t *)vm->arch_vm.nworld_eptp, start, end - start); ept_mr_del(vm, (uint64_t *)vm->arch_vm.nworld_eptp, start, end - start);
}
/* Return success */
status = 0;
} }
} }
} }
/* Return status to caller */
return status;
} }
/** /**

View File

@ -457,7 +457,7 @@ vioapic_init(struct acrn_vm *vm)
vioapic_reset(vm); vioapic_reset(vm);
(void)register_mmio_emulation_handler(vm, register_mmio_emulation_handler(vm,
vioapic_mmio_access_handler, vioapic_mmio_access_handler,
(uint64_t)VIOAPIC_BASE, (uint64_t)VIOAPIC_BASE,
(uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE, (uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE,

View File

@ -163,7 +163,7 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
addr_lo = round_page_down(msix->mmio_gpa + msix->table_offset); addr_lo = round_page_down(msix->mmio_gpa + msix->table_offset);
} }
(void)register_mmio_emulation_handler(vdev->vpci->vm, vmsix_table_mmio_access_handler, register_mmio_emulation_handler(vdev->vpci->vm, vmsix_table_mmio_access_handler,
addr_lo, addr_hi, vdev); addr_lo, addr_hi, vdev);
} }
} }

View File

@ -265,10 +265,9 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
* @param end The end of the range (exclusive) \p read_write can emulate * @param end The end of the range (exclusive) \p read_write can emulate
* @param handler_private_data Handler-specific data which will be passed to \p read_write when called * @param handler_private_data Handler-specific data which will be passed to \p read_write when called
* *
* @retval 0 Registration succeeds * @return None
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
*/ */
int32_t register_mmio_emulation_handler(struct acrn_vm *vm, void register_mmio_emulation_handler(struct acrn_vm *vm,
hv_mem_io_handler_t read_write, uint64_t start, hv_mem_io_handler_t read_write, uint64_t start,
uint64_t end, void *handler_private_data); uint64_t end, void *handler_private_data);