From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752502AbbJOSNR (ORCPT ); Thu, 15 Oct 2015 14:13:17 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35552 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517AbbJOSNQ (ORCPT ); Thu, 15 Oct 2015 14:13:16 -0400 Subject: Re: [PATCH v9 17/18] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked To: David Matlack , "Wu, Feng" References: <1442586596-5920-1-git-send-email-feng.wu@intel.com> <1442586596-5920-18-git-send-email-feng.wu@intel.com> Cc: "alex.williamson@redhat.com" , Joerg Roedel , Marcelo Tosatti , "eric.auger@linaro.org" , kvm list , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" From: Paolo Bonzini Message-ID: <561FECB7.6080503@redhat.com> Date: Thu, 15 Oct 2015 20:13:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/10/2015 19:39, David Matlack wrote: > But after spending more time reading the source code this morning I > found that kvm_vcpu_check_block() eventually calls into > vmx_sync_pir_to_irr(), which copies PIR to IRR and clears ON. And then > apic_find_highest_irr() detects the pending posted interrupt. Right. And related to this, Feng, can you check if this is still necessary on kvm/queue: @@ -6518,6 +6523,20 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) kvm_vcpu_reload_apic_access_page(vcpu); } + /* + * KVM_REQ_EVENT is not set when posted interrupts are set by + * VT-d hardware, so we have to update RVI unconditionally. + */ + if (kvm_lapic_enabled(vcpu)) { + /* + * Update architecture specific hints for APIC + * virtual interrupt delivery. + */ + if (kvm_x86_ops->hwapic_irr_update) + kvm_x86_ops->hwapic_irr_update(vcpu, + kvm_lapic_find_highest_irr(vcpu)); + } + if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) { kvm_apic_accept_events(vcpu); if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) { @@ -6534,13 +6553,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) kvm_x86_ops->enable_irq_window(vcpu); if (kvm_lapic_enabled(vcpu)) { - /* - * Update architecture specific hints for APIC - * virtual interrupt delivery. - */ - if (kvm_x86_ops->hwapic_irr_update) - kvm_x86_ops->hwapic_irr_update(vcpu, - kvm_lapic_find_highest_irr(vcpu)); update_cr8_intercept(vcpu); kvm_lapic_sync_to_vapic(vcpu); } It may be obsolete now that we have the patch from Radim to set KVM_REQ_EVENT in vmx_sync_pir_to_irr (http://permalink.gmane.org/gmane.linux.kernel/2057138). Thanks, Paolo