hv: Precondition checks for vcpu_from_vid for lapic passthrough ICR access

Since the vapic_id is from VM, need to check for pre-condition before passing
vcpu_id to vcpu_from_vid. This is in the path of LAPIC passthrough ICR
access

Tracked-On: #3170
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Sainath Grandhi 2019-05-23 07:39:44 -07:00 committed by ACRN System Integration
parent 7f648d75bb
commit a7389686a7

View File

@ -2018,9 +2018,9 @@ vlapic_x2apic_pt_icr_access(struct acrn_vm *vm, uint64_t val)
ret = -1;
} else {
vcpu_id = vm_apicid2vcpu_id(vm, vapic_id);
target_vcpu = vcpu_from_vid(vm, vcpu_id);
if ((vcpu_id < vm->hw.created_vcpus) && (vm->hw.vcpu_array[vcpu_id].state != VCPU_OFFLINE)) {
target_vcpu = vcpu_from_vid(vm, vcpu_id);
if (target_vcpu != NULL) {
switch (mode) {
case APIC_DELMODE_INIT:
vlapic_process_init_sipi(target_vcpu, mode, icr_low, vcpu_id);