mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 01:37:44 +00:00
hv: vmcs: simplify update EOI-exit bitmap
1) The previous implementaion will recalculate the whole EOI-exit bitmap for each RTE once the destination, trigger mode, delivery mode or vector of a RTE has changed and update the EOI-exit bitmap for each vcpu of the VM. In this patch, only set the corresponding bit of EOI-exit bitmap for a vcpu when a level triggered interrupt has accepted in IRR or clear the corresponding bit of EOI-exit bitmap for a vcpu when a dege triggered interrupt has accepted in IRR which means only update a bit of EOI-exit bitmap in a vcpu when updating TMR. 2) Rename set eoi_exit related API to set eoi_exit_bitmap. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -149,13 +149,23 @@ void vcpu_set_vmcs_eoi_exit(struct acrn_vcpu *vcpu)
|
||||
* called with vcpu->arch.lock held
|
||||
* @pre vcpu != NULL && vector <= 255U
|
||||
*/
|
||||
void vcpu_set_eoi_exit(struct acrn_vcpu *vcpu, uint32_t vector)
|
||||
void vcpu_set_eoi_exit_bitmap(struct acrn_vcpu *vcpu, uint32_t vector)
|
||||
{
|
||||
pr_dbg("%s", __func__);
|
||||
|
||||
if (bitmap_test_and_set_nolock((uint16_t)(vector & 0x3fU),
|
||||
if (!bitmap_test_and_set_nolock((uint16_t)(vector & 0x3fU),
|
||||
&(vcpu->arch.eoi_exit_bitmap[(vector & 0xffU) >> 6U]))) {
|
||||
pr_warn("Duplicated vector %u vcpu%u", vector, vcpu->vcpu_id);
|
||||
vcpu_make_request(vcpu, ACRN_REQUEST_EOI_EXIT_BITMAP_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
void vcpu_clear_eoi_exit_bitmap(struct acrn_vcpu *vcpu, uint32_t vector)
|
||||
{
|
||||
pr_dbg("%s", __func__);
|
||||
|
||||
if (bitmap_test_and_clear_nolock((uint16_t)(vector & 0x3fU),
|
||||
&(vcpu->arch.eoi_exit_bitmap[(vector & 0xffU) >> 6U]))) {
|
||||
vcpu_make_request(vcpu, ACRN_REQUEST_EOI_EXIT_BITMAP_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,11 +173,12 @@ void vcpu_set_eoi_exit(struct acrn_vcpu *vcpu, uint32_t vector)
|
||||
* Reset all eoi_exit_bitmaps
|
||||
* called with vcpu->arch.lock held
|
||||
*/
|
||||
void vcpu_reset_eoi_exit_all(struct acrn_vcpu *vcpu)
|
||||
void vcpu_reset_eoi_exit_bitmaps(struct acrn_vcpu *vcpu)
|
||||
{
|
||||
pr_dbg("%s", __func__);
|
||||
|
||||
memset((void *)(vcpu->arch.eoi_exit_bitmap), 0U, sizeof(vcpu->arch.eoi_exit_bitmap));
|
||||
vcpu_make_request(vcpu, ACRN_REQUEST_EOI_EXIT_BITMAP_UPDATE);
|
||||
}
|
||||
|
||||
struct acrn_vcpu *get_ever_run_vcpu(uint16_t pcpu_id)
|
||||
|
@@ -454,7 +454,7 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
|
||||
flush_vpid_single(arch->vpid);
|
||||
}
|
||||
|
||||
if (bitmap_test_and_clear_lock(ACRN_REQUEST_EOI_EXIT_UPDATE, pending_req_bits)) {
|
||||
if (bitmap_test_and_clear_lock(ACRN_REQUEST_EOI_EXIT_BITMAP_UPDATE, pending_req_bits)) {
|
||||
vcpu_set_vmcs_eoi_exit(vcpu);
|
||||
}
|
||||
|
||||
|
@@ -466,9 +466,13 @@ vlapic_set_tmr(struct acrn_vlapic *vlapic, uint32_t vector, bool level)
|
||||
lapic = &(vlapic->apic_page);
|
||||
tmrptr = &lapic->tmr[0];
|
||||
if (level) {
|
||||
bitmap32_set_lock((uint16_t)(vector & 0x1fU), &tmrptr[vector >> 5U].v);
|
||||
if (!bitmap32_test_and_set_lock((uint16_t)(vector & 0x1fU), &tmrptr[vector >> 5U].v)) {
|
||||
vcpu_set_eoi_exit_bitmap(vlapic->vcpu, vector);
|
||||
}
|
||||
} else {
|
||||
bitmap32_clear_lock((uint16_t)(vector & 0x1fU), &tmrptr[vector >> 5U].v);
|
||||
if (bitmap32_test_and_clear_lock((uint16_t)(vector & 0x1fU), &tmrptr[vector >> 5U].v)) {
|
||||
vcpu_clear_eoi_exit_bitmap(vlapic->vcpu, vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,6 +489,8 @@ vlapic_reset_tmr(struct acrn_vlapic *vlapic)
|
||||
for (i = 0; i < 8; i++) {
|
||||
lapic->tmr[i].v = 0U;
|
||||
}
|
||||
|
||||
vcpu_reset_eoi_exit_bitmaps(vlapic->vcpu);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user