2016-03-07 16:36+0100, Paolo Bonzini: > On 04/03/2016 21:46, Suravee Suthikulpanit wrote: >> +static void svm_deliver_avic_intr(struct kvm_vcpu *vcpu, int vec) >> +{ >> + struct vcpu_svm *svm = to_svm(vcpu); >> + >> + kvm_lapic_set_vector(vec, avic_get_bk_page_entry(svm, APIC_IRR)); (I think that smp_mb here would make sense, even though we're fine now thanks to re-checking vcpu->mode in kvm_vcpu_kick. A comment explaining this optimization would be nice. I'm thinking about a race where we don't send the doorbell even though the VCPU is in guest mode, because vcpu->mode was read before writing APIC_IRR.) >> + >> + if (vcpu->mode == IN_GUEST_MODE) { >> + wrmsrl(SVM_AVIC_DOORBELL, >> + __default_cpu_present_to_apicid(vcpu->cpu)); >> + } else { >> + kvm_vcpu_kick(vcpu); >> + } > > You also need to add > > kvm_make_request(KVM_REQ_EVENT, vcpu); > > before the "if", similar to vmx_deliver_posted_interrupt. KVM won't do anything in KVM_REQ_EVENT and I think that the request can be avoided because KVM already has to handle IRR writes from AVIC. And what about [...] else if (!vcpu->...->is_running) kvm_vcpu_kick(vcpu); ? The kick isn't needed unless the VCPU is scheduled out. Or maybe just if (vcpu->...->is_running) wrmsrl() else kvm_vcpu_kick(); ? Which doesn't use the information we have on top AVIC, making our logic a bit simpler. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html