Skip to content

Commit

Permalink
KVM: x86: Move kvm_{before,after}_interrupt() calls to vendor code
Browse files Browse the repository at this point in the history
VMX can conditionally call kvm_{before,after}_interrupt() since KVM
always uses "ack interrupt on exit" and therefore explicitly handles
interrupts as opposed to blindly enabling irqs.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Jun 18, 2019
1 parent 2342080 commit 165072b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions arch/x86/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6174,13 +6174,15 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu,

static void svm_handle_external_intr(struct kvm_vcpu *vcpu)
{
kvm_before_interrupt(vcpu);
local_irq_enable();
/*
* We must have an instruction with interrupts enabled, so
* the timer interrupt isn't delayed by the interrupt shadow.
*/
asm("nop");
local_irq_disable();
kvm_after_interrupt(vcpu);
}

static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/kvm/vmx/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6145,6 +6145,8 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu)
desc = (gate_desc *)host_idt_base + vector;
entry = gate_offset(desc);

kvm_before_interrupt(vcpu);

asm volatile(
#ifdef CONFIG_X86_64
"mov %%" _ASM_SP ", %[sp]\n\t"
Expand All @@ -6165,6 +6167,8 @@ static void vmx_handle_external_intr(struct kvm_vcpu *vcpu)
[ss]"i"(__KERNEL_DS),
[cs]"i"(__KERNEL_CS)
);

kvm_after_interrupt(vcpu);
}
STACK_FRAME_NON_STANDARD(vmx_handle_external_intr);

Expand Down
2 changes: 0 additions & 2 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -7999,9 +7999,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
vcpu->mode = OUTSIDE_GUEST_MODE;
smp_wmb();

kvm_before_interrupt(vcpu);
kvm_x86_ops->handle_external_intr(vcpu);
kvm_after_interrupt(vcpu);

++vcpu->stat.exits;

Expand Down

0 comments on commit 165072b

Please sign in to comment.