I didn't take many test since our PTS system stop working now due to KVM userspace build changes. But since the logic is pretty simple, so I want to post here to see comments. Thx, eddie If there is pending irq after an virtual exception is injected, KVM needs to enable IRQ window to trap back earlier once the exception is handled. Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 308d8e9..f8ceaea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3154,15 +3154,18 @@ static void inject_irq(struct kvm_vcpu *vcpu) } } -static void inject_pending_irq(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) +static void inject_pending_irq(struct kvm_vcpu *vcpu) { - bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && - kvm_run->request_interrupt_window; - if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) kvm_x86_ops->drop_interrupt_shadow(vcpu); inject_irq(vcpu); +} + +static void set_pending_virq(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) +{ + bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && + kvm_run->request_interrupt_window; /* enable NMI/IRQ window open exits if needed */ if (vcpu->arch.nmi_pending) @@ -3229,7 +3232,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) if (vcpu->arch.exception.pending) __queue_exception(vcpu); else - inject_pending_irq(vcpu, kvm_run); + inject_pending_irq(vcpu); + + set_pending_virq(vcpu, kvm_run); if (kvm_lapic_enabled(vcpu)) { if (!vcpu->arch.apic->vapic_addr)
Attachment:
irq_windows.patch
Description: irq_windows.patch