hv: vlapic: minor fix about dereference vcpu from vlapic

Since vcpu if remove from vlapic, we could not dereference it directly.

Tracked-On: #4550
Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
Li Fei1 2020-03-31 11:39:44 +08:00 committed by wenlingz
parent 2b7168da9e
commit ea2616fbbf

View File

@ -1689,8 +1689,8 @@ vlapic_reset(struct acrn_vlapic *vlapic, const struct acrn_apicv_ops *ops, enum
} }
/** /**
* @pre vlapic-...->vm != NULL * @pre vlapic2vcpu(vlapic)->vm != NULL
* @pre vlapic-...->vcpu->vcpu_id < MAX_VCPUS_PER_VM * @pre vlapic2vcpu(vlapic)->vcpu_id < MAX_VCPUS_PER_VM
*/ */
void void
vlapic_init(struct acrn_vlapic *vlapic) vlapic_init(struct acrn_vlapic *vlapic)
@ -2208,7 +2208,7 @@ void vlapic_free(struct acrn_vcpu *vcpu)
/** /**
* APIC-v functions * APIC-v functions
* @pre get_pi_desc(vlapic->vcpu) != NULL * @pre get_pi_desc(vlapic2vcpu(vlapic)) != NULL
*/ */
static bool static bool
apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector) apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector)
@ -2217,7 +2217,7 @@ apicv_set_intr_ready(struct acrn_vlapic *vlapic, uint32_t vector)
uint32_t idx; uint32_t idx;
bool notify = false; bool notify = false;
pid = get_pi_desc(vlapic->vcpu); pid = get_pi_desc(vlapic2vcpu(vlapic));
idx = vector >> 6U; idx = vector >> 6U;
if (!bitmap_test_and_set_lock((uint16_t)(vector & 0x3fU), &pid->pir[idx])) { if (!bitmap_test_and_set_lock((uint16_t)(vector & 0x3fU), &pid->pir[idx])) {
notify = (bitmap_test_and_set_lock(POSTED_INTR_ON, &pid->control.value) == false); notify = (bitmap_test_and_set_lock(POSTED_INTR_ON, &pid->control.value) == false);
@ -2268,7 +2268,7 @@ static bool apicv_basic_inject_intr(struct acrn_vlapic *vlapic,
/* /*
* Transfer the pending interrupts in the PIR descriptor to the IRR * Transfer the pending interrupts in the PIR descriptor to the IRR
* in the virtual APIC page. * in the virtual APIC page.
* @pre get_pi_desc(vlapic->vcpu) != NULL * @pre get_pi_desc(vlapic2vcpu(vlapic)) != NULL
*/ */
static void vlapic_apicv_inject_pir(struct acrn_vlapic *vlapic) static void vlapic_apicv_inject_pir(struct acrn_vlapic *vlapic)
{ {
@ -2279,7 +2279,7 @@ static void vlapic_apicv_inject_pir(struct acrn_vlapic *vlapic)
uint16_t intr_status_old, intr_status_new; uint16_t intr_status_old, intr_status_new;
struct lapic_reg *irr = NULL; struct lapic_reg *irr = NULL;
pid = get_pi_desc(vlapic->vcpu); pid = get_pi_desc(vlapic2vcpu(vlapic));
if (bitmap_test_and_clear_lock(POSTED_INTR_ON, &pid->control.value)) { if (bitmap_test_and_clear_lock(POSTED_INTR_ON, &pid->control.value)) {
pirval = 0UL; pirval = 0UL;
lapic = &(vlapic->apic_page); lapic = &(vlapic->apic_page);