Skip to content

Commit 4ca7dd8

Browse files
committed
KVM: x86: unify handling of interrupt window
The interrupt window is currently checked twice, once in vmx.c/svm.c and once in dm_request_for_irq_injection. The only difference is the extra check for kvm_arch_interrupt_allowed in dm_request_for_irq_injection, and the different return value (EINTR/KVM_EXIT_INTR for vmx.c/svm.c vs. 0/KVM_EXIT_IRQ_WINDOW_OPEN for dm_request_for_irq_injection). However, dm_request_for_irq_injection is basically dead code! Revive it by removing the checks in vmx.c and svm.c's vmexit handlers, and fixing the returned values for the dm_request_for_irq_injection case. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 35754c9 commit 4ca7dd8

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

arch/x86/kvm/svm.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,24 +3294,11 @@ static int msr_interception(struct vcpu_svm *svm)
32943294

32953295
static int interrupt_window_interception(struct vcpu_svm *svm)
32963296
{
3297-
struct kvm_run *kvm_run = svm->vcpu.run;
3298-
32993297
kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
33003298
svm_clear_vintr(svm);
33013299
svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
33023300
mark_dirty(svm->vmcb, VMCB_INTR);
33033301
++svm->vcpu.stat.irq_window_exits;
3304-
/*
3305-
* If the user space waits to inject interrupts, exit as soon as
3306-
* possible
3307-
*/
3308-
if (!lapic_in_kernel(&svm->vcpu) &&
3309-
kvm_run->request_interrupt_window &&
3310-
!kvm_cpu_has_interrupt(&svm->vcpu)) {
3311-
kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
3312-
return 0;
3313-
}
3314-
33153302
return 1;
33163303
}
33173304

arch/x86/kvm/vmx.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5524,17 +5524,6 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu)
55245524
kvm_make_request(KVM_REQ_EVENT, vcpu);
55255525

55265526
++vcpu->stat.irq_window_exits;
5527-
5528-
/*
5529-
* If the user space waits to inject interrupts, exit as soon as
5530-
* possible
5531-
*/
5532-
if (!lapic_in_kernel(vcpu) &&
5533-
vcpu->run->request_interrupt_window &&
5534-
!kvm_cpu_has_interrupt(vcpu)) {
5535-
vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
5536-
return 0;
5537-
}
55385527
return 1;
55395528
}
55405529

arch/x86/kvm/x86.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6469,8 +6469,8 @@ static int vcpu_run(struct kvm_vcpu *vcpu)
64696469
kvm_inject_pending_timer_irqs(vcpu);
64706470

64716471
if (dm_request_for_irq_injection(vcpu)) {
6472-
r = -EINTR;
6473-
vcpu->run->exit_reason = KVM_EXIT_INTR;
6472+
r = 0;
6473+
vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
64746474
++vcpu->stat.request_irq_exits;
64756475
break;
64766476
}

0 commit comments

Comments
 (0)