Page MenuHomeFreeBSD

D13780.id37575.diff
No OneTemporary

D13780.id37575.diff

Index: sys/amd64/vmm/amd/svm.c
===================================================================
--- sys/amd64/vmm/amd/svm.c
+++ sys/amd64/vmm/amd/svm.c
@@ -1559,6 +1559,8 @@
struct svm_vcpu *vcpustate;
uint8_t v_tpr;
int vector, need_intr_window, pending_apic_vector;
+ int extint_pending;
+ int avic;
state = svm_get_vmcb_state(sc, vcpu);
ctrl = svm_get_vmcb_ctrl(sc, vcpu);
@@ -1566,6 +1568,7 @@
need_intr_window = 0;
pending_apic_vector = 0;
+ avic = 0;
if (vcpustate->nextrip != state->rip) {
ctrl->intr_shadow = 0;
@@ -1635,9 +1638,11 @@
}
}
- if (!vm_extint_pending(sc->vm, vcpu)) {
+ extint_pending = vm_extint_pending(sc->vm, vcpu);
+ if (!extint_pending) {
/*
- * APIC interrupts are delivered using the V_IRQ offload.
+ * APIC interrupts are delivered using the V_IRQ offload
+ * if Local APIC is emulated by AVIC.
*
* The primary benefit is that the hypervisor doesn't need to
* deal with the various conditions that inhibit interrupts.
@@ -1656,19 +1661,21 @@
* hypervisor. The higher priority vector will be injected on
* the next VMRUN.
*/
- if (vlapic_pending_intr(vlapic, &vector)) {
- KASSERT(vector >= 16 && vector <= 255,
- ("invalid vector %d from local APIC", vector));
+ if (!vlapic_pending_intr(vlapic, &vector))
+ goto done;
+ KASSERT(vector >= 16 && vector <= 255,
+ ("invalid vector %d from local APIC", vector));
+ if (avic) {
pending_apic_vector = vector;
+ goto done;
}
- goto done;
+ } else {
+ /* Ask the legacy pic for a vector to inject */
+ vatpic_pending_intr(sc->vm, &vector);
+ KASSERT(vector >= 0 && vector <= 255,
+ ("invalid vector %d from INTR", vector));
}
- /* Ask the legacy pic for a vector to inject */
- vatpic_pending_intr(sc->vm, &vector);
- KASSERT(vector >= 0 && vector <= 255, ("invalid vector %d from INTR",
- vector));
-
/*
* If the guest has disabled interrupts or is in an interrupt shadow
* then we cannot inject the pending interrupt.
@@ -1694,14 +1701,14 @@
goto done;
}
- /*
- * Legacy PIC interrupts are delivered via the event injection
- * mechanism.
- */
svm_eventinject(sc, vcpu, VMCB_EVENTINJ_TYPE_INTR, vector, 0, false);
- vm_extint_clear(sc->vm, vcpu);
- vatpic_intr_accepted(sc->vm, vector);
+ if (!extint_pending) {
+ vlapic_intr_accepted(vlapic, vector);
+ } else {
+ vm_extint_clear(sc->vm, vcpu);
+ vatpic_intr_accepted(sc->vm, vector);
+ }
/*
* Force a VM-exit as soon as the vcpu is ready to accept another

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 23, 10:33 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35417981
Default Alt Text
D13780.id37575.diff (2 KB)

Event Timeline