Skip to content

Commit f4e976a

Browse files
jsun26intelacrnsi
authored andcommitted
HV: return -1 with invalid vcpuid in pt icr access
vm_apicid2vcpu_id() might return invalid vcpu id, when this happens we should return -1 in vlapic_x2apic_pt_icr_access(); Tracked-On: #3214 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent ae7dcf4 commit f4e976a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ static uint16_t vm_apicid2vcpu_id(struct acrn_vm *vm, uint32_t lapicid)
140140
}
141141

142142
if (cpu_id == INVALID_CPU_ID) {
143-
cpu_id = get_pcpu_nums();
144143
pr_err("%s: bad lapicid %lu", __func__, lapicid);
145144
}
146145

@@ -2006,15 +2005,14 @@ vlapic_x2apic_pt_icr_access(struct acrn_vm *vm, uint64_t val)
20062005
struct acrn_vcpu *target_vcpu;
20072006
bool phys;
20082007
uint32_t shorthand;
2009-
int32_t ret = 0;
2008+
int32_t ret = -1;
20102009

20112010
phys = ((icr_low & APIC_DESTMODE_LOG) == 0UL);
20122011
shorthand = icr_low & APIC_DEST_MASK;
20132012

20142013
if ((phys == false) || (shorthand != APIC_DEST_DESTFLD)) {
20152014
pr_err("Logical destination mode or shorthands \
20162015
not supported in ICR forpartition mode\n");
2017-
ret = -1;
20182016
} else {
20192017
vcpu_id = vm_apicid2vcpu_id(vm, vapic_id);
20202018
if ((vcpu_id < vm->hw.created_vcpus) && (vm->hw.vcpu_array[vcpu_id].state != VCPU_OFFLINE)) {
@@ -2036,6 +2034,7 @@ vlapic_x2apic_pt_icr_access(struct acrn_vm *vm, uint64_t val)
20362034
msr_write(MSR_IA32_EXT_APIC_ICR, (((uint64_t)papic_id) << 32U) | icr_low);
20372035
break;
20382036
}
2037+
ret = 0;
20392038
}
20402039
}
20412040
return ret;

0 commit comments

Comments
 (0)