From 3e54c70d0f32288f7383cd667cdc0181baa6bf1c Mon Sep 17 00:00:00 2001 From: Zide Chen Date: Sun, 7 Oct 2018 17:54:52 -0700 Subject: [PATCH] hv: rework the MMIO handler callback hv_mem_io_handler_t arguments commit 026ae83bd52 ("hv: include: fix 'Unused procedure parameter'") removed the then unused parameter handler_private_data from hv_mem_io_handler_t because MISRA-C requires that there should be no unused parameters in functions. This patch removes vcpu from the parameter list as well since this may not be used by all users. Also it brings back handler_private_data which is more flexible. For example, vioapic_mmio_access_handler() can use it to pass vcpu pointer. Tracked-On: #861 Signed-off-by: dongshen Signed-off-by: Zide Chen Reviewed-by: Li, Fei1 Acked-by: Anthony Xu --- hypervisor/arch/x86/io.c | 2 +- hypervisor/dm/vioapic.c | 6 +++--- hypervisor/include/arch/x86/guest/vioapic.h | 3 +-- hypervisor/include/arch/x86/ioreq.h | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hypervisor/arch/x86/io.c b/hypervisor/arch/x86/io.c index 61a817b63..c2905c233 100644 --- a/hypervisor/arch/x86/io.c +++ b/hypervisor/arch/x86/io.c @@ -257,7 +257,7 @@ hv_emulate_mmio(struct vcpu *vcpu, struct io_request *io_req) return -EIO; } else { /* Handle this MMIO operation */ - status = mmio_handler->read_write(vcpu, io_req); + status = mmio_handler->read_write(io_req, mmio_handler->handler_private_data); break; } } diff --git a/hypervisor/dm/vioapic.c b/hypervisor/dm/vioapic.c index 225a56ced..ea44429be 100644 --- a/hypervisor/dm/vioapic.c +++ b/hypervisor/dm/vioapic.c @@ -511,7 +511,7 @@ vioapic_init(struct vm *vm) vioapic_mmio_access_handler, (uint64_t)VIOAPIC_BASE, (uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE, - NULL); + vm); } void @@ -532,9 +532,9 @@ vioapic_pincount(const struct vm *vm) } } -int vioapic_mmio_access_handler(struct vcpu *vcpu, struct io_request *io_req) +int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data) { - struct vm *vm = vcpu->vm; + struct vm *vm = (struct vm *)handler_private_data; struct acrn_vioapic *vioapic; struct mmio_request *mmio = &io_req->reqs.mmio; uint64_t gpa = mmio->address; diff --git a/hypervisor/include/arch/x86/guest/vioapic.h b/hypervisor/include/arch/x86/guest/vioapic.h index 4738dce59..36f60722c 100644 --- a/hypervisor/include/arch/x86/guest/vioapic.h +++ b/hypervisor/include/arch/x86/guest/vioapic.h @@ -60,8 +60,7 @@ void vioapic_update_tmr(struct vcpu *vcpu); uint32_t vioapic_pincount(const struct vm *vm); void vioapic_process_eoi(struct vm *vm, uint32_t vector); void vioapic_get_rte(struct vm *vm, uint32_t pin, union ioapic_rte *rte); -int vioapic_mmio_access_handler(struct vcpu *vcpu, - struct io_request *io_req); +int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data); #ifdef HV_DEBUG void get_vioapic_info(char *str_arg, size_t str_max, uint16_t vmid); diff --git a/hypervisor/include/arch/x86/ioreq.h b/hypervisor/include/arch/x86/ioreq.h index 31df89580..04d592119 100644 --- a/hypervisor/include/arch/x86/ioreq.h +++ b/hypervisor/include/arch/x86/ioreq.h @@ -94,8 +94,7 @@ struct vm_io_handler { /* Typedef for MMIO handler and range check routine */ struct mmio_request; -typedef int (*hv_mem_io_handler_t)(struct vcpu *vcpu, - struct io_request *io_req); +typedef int (*hv_mem_io_handler_t)(struct io_request *io_req, void *handler_private_data); /* Structure for MMIO handler node */ struct mem_io_node {