From 2e62ad9574008d98188400eff439c65ebf8aebc5 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Fri, 18 Oct 2019 15:40:51 +0800 Subject: [PATCH] hv[v2]: remove registration of default port IO and MMIO handlers - The default behaviors of PIO & MMIO handlers are same for all VMs, no need to expose dedicated APIs to register default hanlders for SOS and prelaunched VM. Tracked-On: #3904 Signed-off-by: Yonghua Huang Reviewed-by: Junjie Mao --- hypervisor/arch/x86/guest/vm.c | 6 ----- hypervisor/dm/io_req.c | 36 +++++++++----------------- hypervisor/include/arch/x86/guest/vm.h | 3 --- hypervisor/include/dm/io_req.h | 14 ---------- 4 files changed, 12 insertions(+), 47 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 249271324..78aaed77a 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -445,12 +445,6 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_ vm->arch_vm.nworld_eptp = vm->arch_vm.ept_mem_ops.get_pml4_page(vm->arch_vm.ept_mem_ops.info); sanitize_pte((uint64_t *)vm->arch_vm.nworld_eptp, &vm->arch_vm.ept_mem_ops); - /* Register default handlers for PIO & MMIO if it is, SOS VM or Pre-launched VM */ - if ((vm_config->load_order == SOS_VM) || (vm_config->load_order == PRE_LAUNCHED_VM)) { - register_pio_default_emulation_handler(vm); - register_mmio_default_emulation_handler(vm); - } - (void)memcpy_s(&vm->uuid[0], sizeof(vm->uuid), &vm_config->uuid[0], sizeof(vm_config->uuid)); diff --git a/hypervisor/dm/io_req.c b/hypervisor/dm/io_req.c index ee37671ce..b7e944d55 100644 --- a/hypervisor/dm/io_req.c +++ b/hypervisor/dm/io_req.c @@ -414,8 +414,13 @@ hv_emulate_pio(struct acrn_vcpu *vcpu, struct io_request *io_req) struct acrn_vm *vm = vcpu->vm; struct pio_request *pio_req = &io_req->reqs.pio; struct vm_io_handler_desc *handler; - io_read_fn_t io_read = vm->default_io_read; - io_write_fn_t io_write = vm->default_io_write; + io_read_fn_t io_read = NULL; + io_write_fn_t io_write = NULL; + + if (is_sos_vm(vcpu->vm) || is_prelaunched_vm(vcpu->vm)) { + io_read = pio_default_read; + io_write = pio_default_write; + } port = (uint16_t)pio_req->address; size = (uint16_t)pio_req->size; @@ -472,9 +477,13 @@ hv_emulate_mmio(struct acrn_vcpu *vcpu, struct io_request *io_req) uint64_t address, size; struct mmio_request *mmio_req = &io_req->reqs.mmio; struct mem_io_node *mmio_handler = NULL; - hv_mem_io_handler_t read_write = vcpu->vm->default_read_write; + hv_mem_io_handler_t read_write = NULL; void *handler_private_data = NULL; + if (is_sos_vm(vcpu->vm) || is_prelaunched_vm(vcpu->vm)) { + read_write = mmio_default_access_handler; + } + address = mmio_req->address; size = mmio_req->size; @@ -654,24 +663,3 @@ void register_mmio_emulation_handler(struct acrn_vm *vm, } } - -/** - * @brief Register port I/O default handler - * - * @param vm The VM to which the port I/O handlers are registered - */ -void register_pio_default_emulation_handler(struct acrn_vm *vm) -{ - vm->default_io_read = pio_default_read; - vm->default_io_write = pio_default_write; -} - -/** - * @brief Register MMIO default handler - * - * @param vm The VM to which the MMIO handler is registered - */ -void register_mmio_default_emulation_handler(struct acrn_vm *vm) -{ - vm->default_read_write = mmio_default_access_handler; -} diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index a74d9001a..6cbe16c63 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -127,11 +127,8 @@ struct acrn_vm { uint16_t emul_mmio_regions; /* Number of emulated mmio regions */ struct mem_io_node emul_mmio[CONFIG_MAX_EMULATED_MMIO_REGIONS]; - hv_mem_io_handler_t default_read_write; struct vm_io_handler_desc emul_pio[EMUL_PIO_IDX_MAX]; - io_read_fn_t default_io_read; - io_write_fn_t default_io_write; uint8_t uuid[16]; struct secure_world_control sworld_control; diff --git a/hypervisor/include/dm/io_req.h b/hypervisor/include/dm/io_req.h index 4b695d57a..5cfb704fd 100644 --- a/hypervisor/include/dm/io_req.h +++ b/hypervisor/include/dm/io_req.h @@ -265,20 +265,6 @@ 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); -/** - * @brief Register port I/O default handler - * - * @param vm The VM to which the port I/O handlers are registered - */ -void register_pio_default_emulation_handler(struct acrn_vm *vm); - -/** - * @brief Register MMIO default handler - * - * @param vm The VM to which the MMIO handler is registered - */ -void register_mmio_default_emulation_handler(struct acrn_vm *vm); - /** * @} */