Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755339AbbBBLDV (ORCPT ); Mon, 2 Feb 2015 06:03:21 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36606 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751540AbbBBLDS (ORCPT ); Mon, 2 Feb 2015 06:03:18 -0500 Message-ID: <54CF5971.8090407@redhat.com> Date: Mon, 02 Feb 2015 12:03:13 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Wincy Van , "gleb@kernel.org" , "Zhang, Yang Z" CC: "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , Wanpeng Li , Jan Kiszka Subject: Re: [PATCH v4 6/6] KVM: nVMX: Enable nested posted interrupt processing References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1911 Lines: 64 On 28/01/2015 17:02, Wincy Van wrote: > +static int vmx_deliver_nested_posted_interrupt(struct kvm_vcpu *vcpu, > + int vector) > +{ > + if (is_guest_mode(vcpu) && > + vector == to_vmx(vcpu)->nested.posted_intr_nv && > + vcpu->mode == IN_GUEST_MODE) { > + /* the PIR and ON have been set by L1. */ What happens if there is a L2->L0->L2 exit on the target VCPU, and the guest exits before apic->send_IPI_mask sends the IPI? The L1 hypervisor might "know" somehow that there cannot be a concurrent L2->L1->L2 exit, and not do the equivalent of KVM's kvm_make_request(KVM_REQ_EVENT, vcpu); after it sets ON. So I think you have to do something like static bool vmx_is_nested_posted_interrupt(struct kvm_vcpu *vcpu, int vector) { return (is_guest_mode(vcpu) && vector == to_vmx(vcpu)->nested.posted_intr_nv); } and in vmx_deliver_posted_interrupt: r = 0; if (!vmx_is_nested_posted_interrupt(vcpu, vector)) { if (pi_test_and_set_pir(vector, &vmx->pi_desc)) return; r = pi_test_and_set_on(&vmx->pi_desc); } kvm_make_request(KVM_REQ_EVENT, vcpu); #ifdef CONFIG_SMP if (!r && (vcpu->mode == IN_GUEST_MODE)) apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), POSTED_INTR_VECTOR); else #endif kvm_vcpu_kick(vcpu); What do you think? Paolo > + apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), > + POSTED_INTR_VECTOR); > + return 0; > + } > + return -1; > +} -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/