Skip to content

Commit 7f2b9a1

Browse files
ywan170wenlingz
authored andcommitted
hv: virq: update apicv irr/rvi before handle vmcs event injection
From SDM Vol3 26.3.2.5: Once the virtual interrupt is recognized, it will be delivered in VMX non-root operation immediately after VM entry(including any specified event injection) completes. So the hardware can handle vmcs event injection and evaluation/delivery of apicv virtual interrupts in one time vm-entry. This patch move the apicv irr/rvi sync before handle vmcs events injection. The old code cause the apicv virtual interrupt evaluation and delivery be handled until next vm-exit if met pending exceptions. Tracked-On: #1443 Signed-off-by: Yu Wang <yu1.wang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 90eca21 commit 7f2b9a1

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

hypervisor/arch/x86/virq.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,25 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
430430
goto INTR_WIN;
431431
}
432432

433+
/*
434+
* From SDM Vol3 26.3.2.5:
435+
* Once the virtual interrupt is recognized, it will be delivered
436+
* in VMX non-root operation immediately after VM entry(including
437+
* any specified event injection) completes.
438+
*
439+
* So the hardware can handle vmcs event injection and
440+
* evaluation/delivery of apicv virtual interrupts in one time
441+
* vm-entry.
442+
*
443+
* Here to sync the pending interrupts to irr and update rvi if
444+
* needed. And then try to handle vmcs event injection.
445+
*/
446+
if (is_apicv_intr_delivery_supported() &&
447+
bitmap_test_and_clear_lock(ACRN_REQUEST_EVENT,
448+
pending_req_bits)) {
449+
vlapic_apicv_inject_pir(vlapic);
450+
}
451+
433452
/* SDM Vol 3 - table 6-2, inject high priority exception before
434453
* maskable hardware interrupt */
435454
if (vcpu_inject_hi_exception(vcpu) != 0) {
@@ -458,19 +477,6 @@ int acrn_handle_pending_request(struct vcpu *vcpu)
458477
goto INTR_WIN;
459478
}
460479

461-
/*
462-
* If the "virtual-interrupt delivery" is enabled,
463-
* sync the pending interrupts to irr and update rvi if needed.
464-
* Then CPU will start evaluate the pending virtual interrupts
465-
* in the later vm-entry.
466-
*
467-
*/
468-
if (is_apicv_intr_delivery_supported() &&
469-
bitmap_test_and_clear_lock(ACRN_REQUEST_EVENT,
470-
pending_req_bits)) {
471-
vlapic_apicv_inject_pir(vlapic);
472-
}
473-
474480
/* Guest interruptable or not */
475481
if (is_guest_irq_enabled(vcpu)) {
476482
/* Inject external interrupt first */

0 commit comments

Comments
 (0)