diff --git a/hypervisor/arch/x86/guest/vmcall.c b/hypervisor/arch/x86/guest/vmcall.c index 4d1e0eb59..93bad2224 100644 --- a/hypervisor/arch/x86/guest/vmcall.c +++ b/hypervisor/arch/x86/guest/vmcall.c @@ -50,6 +50,11 @@ int vmcall_vmexit_handler(struct vcpu *vcpu) ret = hcall_get_api_version(vm, param1); break; + case HC_SET_CALLBACK_VECTOR: + ret = hcall_set_callback_vector(vm, param1); + + break; + case HC_CREATE_VM: ret = hcall_create_vm(vm, param1); break; diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 4f27c8420..a0da1bac9 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -1036,3 +1036,23 @@ int32_t hcall_vm_intr_monitor(struct vm *vm, uint16_t vmid, uint64_t param) return 0; } + +/** + *@pre Pointer vm shall point to VM0 + */ +int32_t hcall_set_callback_vector(struct vm *vm, uint64_t param) +{ + if (!is_vm0(vm)) { + pr_err("%s: Targeting to service vm", __func__); + return -EPERM; + } + + if ((param > NR_MAX_VECTOR) || (param < VECTOR_DYNAMIC_START)) { + pr_err("%s: Invalid passed vector\n"); + return -EINVAL; + } + + acrn_vhm_vector = param; + + return 0; +} diff --git a/hypervisor/include/common/hypercall.h b/hypervisor/include/common/hypercall.h index 609ce0327..7bee75ce5 100644 --- a/hypervisor/include/common/hypercall.h +++ b/hypervisor/include/common/hypercall.h @@ -455,6 +455,21 @@ int64_t hcall_save_restore_sworld_ctx(struct vcpu *vcpu); * @} */ // End of trusty_hypercall +/** + * @brief set upcall notifier vector + * + * This is the API that helps to switch the notifer vecotr. If this API is + * not called, the hypervisor will use the default notifier vector(0xF7) + * to notify the SOS kernel. + * + * @param vm Pointer to VM data structure + * @param the expected notifier vector from guest + * + * @pre Pointer vm shall point to VM0 + * @return 0 on success, non-zero on error. + */ +int32_t hcall_set_callback_vector(struct vm *vm, uint64_t param); + /** * @} */ // End of acrn_hypercall diff --git a/hypervisor/include/public/acrn_hv_defs.h b/hypervisor/include/public/acrn_hv_defs.h index aa4318bb6..32686a4ea 100644 --- a/hypervisor/include/public/acrn_hv_defs.h +++ b/hypervisor/include/public/acrn_hv_defs.h @@ -27,6 +27,7 @@ #define HC_ID_GEN_BASE 0x0UL #define HC_GET_API_VERSION BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x00UL) #define HC_SOS_OFFLINE_CPU BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x01UL) +#define HC_SET_CALLBACK_VECTOR BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x02UL) /* VM management */ #define HC_ID_VM_BASE 0x10UL