From 35c8437bbc345057214e405c52574ec15cc30c2a Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Wed, 3 Apr 2019 10:48:18 +0800 Subject: [PATCH] hv:move 'fire_vhm_interrupt' to io_emul.c -- this api is related with arch_x86, then move to x86 folder -- rename 'set_vhm_vector' to 'set_vhm_notification_vector' -- rename 'acrn_vhm_vector' to 'acrn_vhm_notification_vector' -- add an API 'get_vhm_notification_vector' Tracked-On: #1842 Signed-off-by: Mingqiang Chi Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/io_emul.c | 15 +++++++++++ hypervisor/common/hypercall.c | 2 +- hypervisor/common/io_req.c | 28 +++++++-------------- hypervisor/include/arch/x86/guest/io_emul.h | 8 ++++++ hypervisor/include/arch/x86/io_req.h | 8 +++++- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/hypervisor/arch/x86/guest/io_emul.c b/hypervisor/arch/x86/guest/io_emul.c index d15bff2d6..a68eb73c2 100644 --- a/hypervisor/arch/x86/guest/io_emul.c +++ b/hypervisor/arch/x86/guest/io_emul.c @@ -22,6 +22,21 @@ #define MMIO_DEFAULT_VALUE_SIZE_4 (0xFFFFFFFFUL) #define MMIO_DEFAULT_VALUE_SIZE_8 (0xFFFFFFFFFFFFFFFFUL) +void arch_fire_vhm_interrupt(void) +{ + /* + * use vLAPIC to inject vector to SOS vcpu 0 if vlapic is enabled + * otherwise, send IPI hardcoded to BOOT_CPU_ID + */ + struct acrn_vm *sos_vm; + struct acrn_vcpu *vcpu; + + sos_vm = get_sos_vm(); + vcpu = vcpu_from_vid(sos_vm, BOOT_CPU_ID); + + vlapic_set_intr(vcpu, get_vhm_notification_vector(), LAPIC_TRIG_EDGE); +} + /** * @brief General complete-work for port I/O emulation * diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 96b2fab12..ed8d8ec1e 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -1215,7 +1215,7 @@ int32_t hcall_set_callback_vector(const struct acrn_vm *vm, uint64_t param) pr_err("%s: Invalid passed vector\n"); ret = -EINVAL; } else { - set_vhm_vector((uint32_t)param); + set_vhm_notification_vector((uint32_t)param); ret = 0; } diff --git a/hypervisor/common/io_req.c b/hypervisor/common/io_req.c index 839e2aad8..7ed171399 100644 --- a/hypervisor/common/io_req.c +++ b/hypervisor/common/io_req.c @@ -11,22 +11,7 @@ #define ACRN_DBG_IOREQUEST 6U -static uint32_t acrn_vhm_vector = VECTOR_HYPERVISOR_CALLBACK_VHM; - -static void fire_vhm_interrupt(void) -{ - /* - * use vLAPIC to inject vector to SOS vcpu 0 if vlapic is enabled - * otherwise, send IPI hardcoded to BOOT_CPU_ID - */ - struct acrn_vm *sos_vm; - struct acrn_vcpu *vcpu; - - sos_vm = get_sos_vm(); - vcpu = vcpu_from_vid(sos_vm, BOOT_CPU_ID); - - vlapic_set_intr(vcpu, acrn_vhm_vector, LAPIC_TRIG_EDGE); -} +static uint32_t acrn_vhm_notification_vector = VECTOR_HYPERVISOR_CALLBACK_VHM; #if defined(HV_DEBUG) static void acrn_print_request(uint16_t vcpu_id, const struct vhm_request *req) @@ -137,7 +122,7 @@ int32_t acrn_insert_request(struct acrn_vcpu *vcpu, const struct io_request *io_ #endif /* signal VHM */ - fire_vhm_interrupt(); + arch_fire_vhm_interrupt(); /* Polling completion of the request in polling mode */ if (is_polling) { @@ -199,7 +184,12 @@ void set_vhm_req_state(struct acrn_vm *vm, uint16_t vhm_req_id, uint32_t state) } } -void set_vhm_vector(uint32_t vector) +void set_vhm_notification_vector(uint32_t vector) { - acrn_vhm_vector = vector; + acrn_vhm_notification_vector = vector; +} + +uint32_t get_vhm_notification_vector(void) +{ + return acrn_vhm_notification_vector; } diff --git a/hypervisor/include/arch/x86/guest/io_emul.h b/hypervisor/include/arch/x86/guest/io_emul.h index 842590af8..1af3da811 100644 --- a/hypervisor/include/arch/x86/guest/io_emul.h +++ b/hypervisor/include/arch/x86/guest/io_emul.h @@ -97,4 +97,12 @@ void register_pio_default_emulation_handler(struct acrn_vm *vm); * @param vm The VM to which the MMIO handler is registered */ void register_mmio_default_emulation_handler(struct acrn_vm *vm); + +/** + * @brief Fire VHM interrupt to SOS + * + * @return None + */ +void arch_fire_vhm_interrupt(void); + #endif /* IO_EMUL_H */ diff --git a/hypervisor/include/arch/x86/io_req.h b/hypervisor/include/arch/x86/io_req.h index 43adcdd99..cbfbc2584 100644 --- a/hypervisor/include/arch/x86/io_req.h +++ b/hypervisor/include/arch/x86/io_req.h @@ -211,8 +211,14 @@ void set_vhm_req_state(struct acrn_vm *vm, uint16_t vhm_req_id, uint32_t state); * @param vector vector for HV callback VHM * @return None */ -void set_vhm_vector(uint32_t vector); +void set_vhm_notification_vector(uint32_t vector); +/** + * @brief Get the vector for HV callback VHM + * + * @return vector for HV callbakc VH + */ +uint32_t get_vhm_notification_vector(void); /** * @} */