mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 01:37:44 +00:00
HV: validate target vm in hypercall
- The target vm in most of hypercalls should be a NORMAL_VM, in some exceptions it might be a SOS_VM, we should validate them. - Please be aware that some hypercall might have limitation on specific target vm like RT or SAFETY VMs, this leaves "TODO" in future; - Unify the coding style: int32_t hcall_foo(vm, target_vm_id, ...) { int32_t ret = -1; ... if ((is_valid_vm(target_vm) && is_normal_vm(target_vm)) { ret = .... } return ret; } Tracked-On: #2978 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -57,6 +57,15 @@ bool is_sos_vm(const struct acrn_vm *vm)
|
||||
return (vm != NULL) && (get_vm_config(vm->vm_id)->type == SOS_VM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vm != NULL
|
||||
* @pre vm->vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
bool is_normal_vm(const struct acrn_vm *vm)
|
||||
{
|
||||
return (get_vm_config(vm->vm_id)->type == NORMAL_VM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vm != NULL
|
||||
* @pre vm->vmid < CONFIG_MAX_VM_NUM
|
||||
|
Reference in New Issue
Block a user