Skip to content

Commit 3e54c70

Browse files
ZideChen0lijinxia
authored andcommitted
hv: rework the MMIO handler callback hv_mem_io_handler_t arguments
commit 026ae83 ("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 <dongsheng.x.zhang@intel.com> Signed-off-by: Zide Chen <zide.chen@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent ec5b90f commit 3e54c70

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

hypervisor/arch/x86/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ hv_emulate_mmio(struct vcpu *vcpu, struct io_request *io_req)
257257
return -EIO;
258258
} else {
259259
/* Handle this MMIO operation */
260-
status = mmio_handler->read_write(vcpu, io_req);
260+
status = mmio_handler->read_write(io_req, mmio_handler->handler_private_data);
261261
break;
262262
}
263263
}

hypervisor/dm/vioapic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ vioapic_init(struct vm *vm)
511511
vioapic_mmio_access_handler,
512512
(uint64_t)VIOAPIC_BASE,
513513
(uint64_t)VIOAPIC_BASE + VIOAPIC_SIZE,
514-
NULL);
514+
vm);
515515
}
516516

517517
void
@@ -532,9 +532,9 @@ vioapic_pincount(const struct vm *vm)
532532
}
533533
}
534534

535-
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct io_request *io_req)
535+
int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data)
536536
{
537-
struct vm *vm = vcpu->vm;
537+
struct vm *vm = (struct vm *)handler_private_data;
538538
struct acrn_vioapic *vioapic;
539539
struct mmio_request *mmio = &io_req->reqs.mmio;
540540
uint64_t gpa = mmio->address;

hypervisor/include/arch/x86/guest/vioapic.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ void vioapic_update_tmr(struct vcpu *vcpu);
6060
uint32_t vioapic_pincount(const struct vm *vm);
6161
void vioapic_process_eoi(struct vm *vm, uint32_t vector);
6262
void vioapic_get_rte(struct vm *vm, uint32_t pin, union ioapic_rte *rte);
63-
int vioapic_mmio_access_handler(struct vcpu *vcpu,
64-
struct io_request *io_req);
63+
int vioapic_mmio_access_handler(struct io_request *io_req, void *handler_private_data);
6564

6665
#ifdef HV_DEBUG
6766
void get_vioapic_info(char *str_arg, size_t str_max, uint16_t vmid);

hypervisor/include/arch/x86/ioreq.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ struct vm_io_handler {
9494

9595
/* Typedef for MMIO handler and range check routine */
9696
struct mmio_request;
97-
typedef int (*hv_mem_io_handler_t)(struct vcpu *vcpu,
98-
struct io_request *io_req);
97+
typedef int (*hv_mem_io_handler_t)(struct io_request *io_req, void *handler_private_data);
9998

10099
/* Structure for MMIO handler node */
101100
struct mem_io_node {

0 commit comments

Comments
 (0)