Skip to content

Commit a189be2

Browse files
yakuizhaolijinxia
authored andcommitted
HV: Add one hcall to set the upcall vector passed from sos_kernel
Currently the acrn-hypervisor is using the PLATFORM_IPI vector to notify the sos_kernel. And then sos_kernel will handle the notification from acrn hypervisor in PLATFORM_IPI ISR. But as the PLATFORM_IPI ISR can be registered by the other modules, it will have the conflict when trying to register acrn intr ISR. So the HYPERVISOR_CALLBACK_VECTOR will be used instead. In order to switch the notification vector from PLATFORM_IPI to HYPERVISOR_CALLBACK_VECTOR, one API is added so that sos can configure the up-notifier interrrupt vector. Tracked-On: #1325 Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 2286991 commit a189be2

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

hypervisor/arch/x86/guest/vmcall.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
5050
ret = hcall_get_api_version(vm, param1);
5151
break;
5252

53+
case HC_SET_CALLBACK_VECTOR:
54+
ret = hcall_set_callback_vector(vm, param1);
55+
56+
break;
57+
5358
case HC_CREATE_VM:
5459
ret = hcall_create_vm(vm, param1);
5560
break;

hypervisor/common/hypercall.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,3 +1036,23 @@ int32_t hcall_vm_intr_monitor(struct vm *vm, uint16_t vmid, uint64_t param)
10361036

10371037
return 0;
10381038
}
1039+
1040+
/**
1041+
*@pre Pointer vm shall point to VM0
1042+
*/
1043+
int32_t hcall_set_callback_vector(struct vm *vm, uint64_t param)
1044+
{
1045+
if (!is_vm0(vm)) {
1046+
pr_err("%s: Targeting to service vm", __func__);
1047+
return -EPERM;
1048+
}
1049+
1050+
if ((param > NR_MAX_VECTOR) || (param < VECTOR_DYNAMIC_START)) {
1051+
pr_err("%s: Invalid passed vector\n");
1052+
return -EINVAL;
1053+
}
1054+
1055+
acrn_vhm_vector = param;
1056+
1057+
return 0;
1058+
}

hypervisor/include/common/hypercall.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,21 @@ int64_t hcall_save_restore_sworld_ctx(struct vcpu *vcpu);
455455
* @}
456456
*/ // End of trusty_hypercall
457457

458+
/**
459+
* @brief set upcall notifier vector
460+
*
461+
* This is the API that helps to switch the notifer vecotr. If this API is
462+
* not called, the hypervisor will use the default notifier vector(0xF7)
463+
* to notify the SOS kernel.
464+
*
465+
* @param vm Pointer to VM data structure
466+
* @param the expected notifier vector from guest
467+
*
468+
* @pre Pointer vm shall point to VM0
469+
* @return 0 on success, non-zero on error.
470+
*/
471+
int32_t hcall_set_callback_vector(struct vm *vm, uint64_t param);
472+
458473
/**
459474
* @}
460475
*/ // End of acrn_hypercall

hypervisor/include/public/acrn_hv_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define HC_ID_GEN_BASE 0x0UL
2828
#define HC_GET_API_VERSION BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x00UL)
2929
#define HC_SOS_OFFLINE_CPU BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x01UL)
30+
#define HC_SET_CALLBACK_VECTOR BASE_HC_ID(HC_ID, HC_ID_GEN_BASE + 0x02UL)
3031

3132
/* VM management */
3233
#define HC_ID_VM_BASE 0x10UL

0 commit comments

Comments
 (0)