Skip to content

Commit a4c9cb9

Browse files
mingqiangchiwenlingz
authored andcommitted
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>
1 parent f1aa35a commit a4c9cb9

File tree

4 files changed

+28
-38
lines changed

4 files changed

+28
-38
lines changed

hypervisor/dm/io_req.c

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -596,58 +596,49 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
596596
/**
597597
* @brief Register a MMIO handler
598598
*
599-
* This API registers a MMIO handler to \p vm before it is launched.
599+
* This API registers a MMIO handler to \p vm before it is Started
600+
* For Pre-launched VMs, this API can be called after it is Started
600601
*
601602
* @param vm The VM to which the MMIO handler is registered
602603
* @param read_write The handler for emulating accesses to the given range
603604
* @param start The base address of the range \p read_write can emulate
604605
* @param end The end of the range (exclusive) \p read_write can emulate
605606
* @param handler_private_data Handler-specific data which will be passed to \p read_write when called
606607
*
607-
* @retval 0 Registration succeeds
608-
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
608+
* @return None
609609
*/
610-
int32_t register_mmio_emulation_handler(struct acrn_vm *vm,
610+
void register_mmio_emulation_handler(struct acrn_vm *vm,
611611
hv_mem_io_handler_t read_write, uint64_t start,
612612
uint64_t end, void *handler_private_data)
613613
{
614-
int32_t status = -EINVAL;
615614
struct mem_io_node *mmio_node;
616615

617-
if ((vm->hw.created_vcpus > 0U) && (vm->hw.vcpu_array[0].launched)) {
618-
pr_err("register mmio handler after vm launched");
619-
} else {
620-
/* Ensure both a read/write handler and range check function exist */
621-
if ((read_write != NULL) && (end > start)) {
622-
if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) {
623-
pr_err("the emulated mmio region is out of range");
624-
} else {
625-
mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]);
626-
/* Fill in information for this node */
627-
mmio_node->read_write = read_write;
628-
mmio_node->handler_private_data = handler_private_data;
629-
mmio_node->range_start = start;
630-
mmio_node->range_end = end;
631-
632-
(vm->emul_mmio_regions)++;
616+
/* Ensure both a read/write handler and range check function exist */
617+
if ((read_write != NULL) && (end > start)) {
618+
if (vm->emul_mmio_regions >= CONFIG_MAX_EMULATED_MMIO_REGIONS) {
619+
pr_err("the emulated mmio region is out of range");
620+
} else {
621+
mmio_node = &(vm->emul_mmio[vm->emul_mmio_regions]);
622+
/* Fill in information for this node */
623+
mmio_node->read_write = read_write;
624+
mmio_node->handler_private_data = handler_private_data;
625+
mmio_node->range_start = start;
626+
mmio_node->range_end = end;
633627

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

643-
/* Return success */
644-
status = 0;
630+
/*
631+
* SOS would map all its memory at beginning, so we
632+
* should unmap it. But UOS will not, so we shouldn't
633+
* need to unmap it.
634+
*/
635+
if (is_sos_vm(vm)) {
636+
ept_mr_del(vm, (uint64_t *)vm->arch_vm.nworld_eptp, start, end - start);
645637
}
638+
646639
}
647640
}
648641

649-
/* Return status to caller */
650-
return status;
651642
}
652643

653644
/**

hypervisor/dm/vioapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ vioapic_init(struct acrn_vm *vm)
457457

458458
vioapic_reset(vm);
459459

460-
(void)register_mmio_emulation_handler(vm,
460+
register_mmio_emulation_handler(vm,
461461
vioapic_mmio_access_handler,
462462
(uint64_t)VIOAPIC_BASE,
463463
(uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE,

hypervisor/dm/vpci/pci_pt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
163163
addr_lo = round_page_down(msix->mmio_gpa + msix->table_offset);
164164
}
165165

166-
(void)register_mmio_emulation_handler(vdev->vpci->vm, vmsix_table_mmio_access_handler,
166+
register_mmio_emulation_handler(vdev->vpci->vm, vmsix_table_mmio_access_handler,
167167
addr_lo, addr_hi, vdev);
168168
}
169169
}

hypervisor/include/dm/io_req.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,9 @@ void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
265265
* @param end The end of the range (exclusive) \p read_write can emulate
266266
* @param handler_private_data Handler-specific data which will be passed to \p read_write when called
267267
*
268-
* @retval 0 Registration succeeds
269-
* @retval -EINVAL \p read_write is NULL, \p end is not larger than \p start or \p vm has been launched
268+
* @return None
270269
*/
271-
int32_t register_mmio_emulation_handler(struct acrn_vm *vm,
270+
void register_mmio_emulation_handler(struct acrn_vm *vm,
272271
hv_mem_io_handler_t read_write, uint64_t start,
273272
uint64_t end, void *handler_private_data);
274273

0 commit comments

Comments
 (0)