Skip to content

Commit

Permalink
hv:change register_mmio_emulation_handler to void
Browse files Browse the repository at this point in the history
change this api to void type

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
  • Loading branch information
mingqiangchi authored and wenlingz committed Apr 19, 2019
1 parent f1aa35a commit a4c9cb9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 38 deletions.
57 changes: 24 additions & 33 deletions hypervisor/dm/io_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,58 +596,49 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
/**
* @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 read_write The handler for emulating accesses to the given range
* @param start The base address of the range \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
*
* @retval 0 Registration succeeds
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
* @return None
*/
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,
uint64_t end, void *handler_private_data)
{
int32_t status = -EINVAL;
struct mem_io_node *mmio_node;

if ((vm->hw.created_vcpus > 0U) && (vm->hw.vcpu_array[0].launched)) {
pr_err("register mmio handler after vm launched");
} else {
/* Ensure both a read/write handler and range check function exist */
if ((read_write != NULL) && (end > start)) {
if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) {
pr_err("the emulated mmio region is out of range");
} else {
mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]);
/* Fill in information for this node */
mmio_node->read_write = read_write;
mmio_node->handler_private_data = handler_private_data;
mmio_node->range_start = start;
mmio_node->range_end = end;

(vm->emul_mmio_regions)++;
/* Ensure both a read/write handler and range check function exist */
if ((read_write != NULL) && (end > start)) {
if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) {
pr_err("the emulated mmio region is out of range");
} else {
mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]);
/* Fill in information for this node */
mmio_node->read_write = read_write;
mmio_node->handler_private_data = handler_private_data;
mmio_node->range_start = start;
mmio_node->range_end = end;

/*
* SOS would map all its memory at beginning, so we
* should unmap it. But UOS will not, so we shouldn't
* need to unmap it.
*/
if (is_sos_vm(vm)) {
ept_mr_del(vm, (uint64_t *)vm->arch_vm.nworld_eptp, start, end - start);
}
(vm->emul_mmio_regions)++;

/* Return success */
status = 0;
/*
* SOS would map all its memory at beginning, so we
* should unmap it. But UOS will not, so we shouldn't
* need to unmap it.
*/
if (is_sos_vm(vm)) {
ept_mr_del(vm, (uint64_t *)vm->arch_vm.nworld_eptp, start, end - start);
}

}
}

/* Return status to caller */
return status;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/dm/vioapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ vioapic_init(struct acrn_vm *vm)

vioapic_reset(vm);

(void)register_mmio_emulation_handler(vm,
register_mmio_emulation_handler(vm,
vioapic_mmio_access_handler,
(uint64_t)VIOAPIC_BASE,
(uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE,
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/dm/vpci/pci_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

(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);
}
}
Expand Down
5 changes: 2 additions & 3 deletions hypervisor/include/dm/io_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 handler_private_data Handler-specific data which will be passed to \p read_write when called
*
* @retval 0 Registration succeeds
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
* @return None
*/
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,
uint64_t end, void *handler_private_data);

Expand Down

0 comments on commit a4c9cb9

Please sign in to comment.