Skip to content

Commit

Permalink
kvm: svm/avic: Do not send AVIC doorbell to self
Browse files Browse the repository at this point in the history
AVIC doorbell is used to notify a running vCPU that interrupts
has been injected into the vCPU AVIC backing page. Current logic
checks only if a VCPU is running before sending a doorbell.
However, the doorbell is not necessary if the destination
CPU is itself.

Add logic to check currently running CPU before sending doorbell.

Signed-off-by: Suravee Suthikulpanit <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
ssuthiku-amd authored and bonzini committed Jun 4, 2019
1 parent b6c4bc6 commit 0532dd5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions arch/x86/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5163,10 +5163,13 @@ static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec)
kvm_lapic_set_irr(vec, vcpu->arch.apic);
smp_mb__after_atomic();

if (avic_vcpu_is_running(vcpu))
wrmsrl(SVM_AVIC_DOORBELL,
kvm_cpu_get_apicid(vcpu->cpu));
else
if (avic_vcpu_is_running(vcpu)) {
int cpuid = vcpu->cpu;

if (cpuid != get_cpu())
wrmsrl(SVM_AVIC_DOORBELL, kvm_cpu_get_apicid(cpuid));
put_cpu();
} else
kvm_vcpu_wake_up(vcpu);
}

Expand Down

0 comments on commit 0532dd5

Please sign in to comment.