From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751923AbdIUITO (ORCPT ); Thu, 21 Sep 2017 04:19:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6532 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751528AbdIUITN (ORCPT ); Thu, 21 Sep 2017 04:19:13 -0400 Message-ID: <59C37579.8010308@huawei.com> Date: Thu, 21 Sep 2017 16:16:57 +0800 From: "Longpeng (Mike)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: Peng Hao CC: , , , , Subject: Re: [PATCH] KVM: VMX: add encapsulation kvm_vcpu_pi_need_handle References: <1506006890-45866-1-git-send-email-peng.hao2@zte.com.cn> In-Reply-To: <1506006890-45866-1-git-send-email-peng.hao2@zte.com.cn> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.246.209] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010201.59C375FC.0030,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 11fdfb68c437cf72e0fff272e024881b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peng, There are two bugs in current code and Paolo already fixed them, please see: https://www.spinics.net/lists/kvm/msg150896.html -- Regards, Longpeng(Mike) On 2017/9/21 23:14, Peng Hao wrote: > use kvm_vcpu_pi_need_handle encapsulation simply coede > > Signed-off-by: Peng Hao > --- > arch/x86/kvm/vmx.c | 27 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 4253ade..26b99f4 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -559,6 +559,13 @@ static inline int pi_test_sn(struct pi_desc *pi_desc) > (unsigned long *)&pi_desc->control); > } > > +static inline bool kvm_vcpu_pi_need_handle(struct kvm_vcpu *vcpu) > +{ > + return kvm_arch_has_assigned_device(vcpu->kvm) && > + irq_remapping_cap(IRQ_POSTING_CAP) && > + kvm_vcpu_apicv_active(vcpu); > +} > + > struct vcpu_vmx { > struct kvm_vcpu vcpu; > unsigned long host_rsp; > @@ -2202,9 +2209,7 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) > struct pi_desc old, new; > unsigned int dest; > > - if (!kvm_arch_has_assigned_device(vcpu->kvm) || > - !irq_remapping_cap(IRQ_POSTING_CAP) || > - !kvm_vcpu_apicv_active(vcpu)) > + if (!kvm_vcpu_pi_need_handle(vcpu)) > return; > > do { > @@ -2323,9 +2328,7 @@ static void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu) > { > struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > > - if (!kvm_arch_has_assigned_device(vcpu->kvm) || > - !irq_remapping_cap(IRQ_POSTING_CAP) || > - !kvm_vcpu_apicv_active(vcpu)) > + if (!kvm_vcpu_pi_need_handle(vcpu)) > return; > > /* Set SN when the vCPU is preempted */ > @@ -11691,9 +11694,7 @@ static int pi_pre_block(struct kvm_vcpu *vcpu) > struct pi_desc old, new; > struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > > - if (!kvm_arch_has_assigned_device(vcpu->kvm) || > - !irq_remapping_cap(IRQ_POSTING_CAP) || > - !kvm_vcpu_apicv_active(vcpu)) > + if (!kvm_vcpu_pi_need_handle(vcpu)) > return 0; > > vcpu->pre_pcpu = vcpu->cpu; > @@ -11769,9 +11770,7 @@ static void pi_post_block(struct kvm_vcpu *vcpu) > unsigned int dest; > unsigned long flags; > > - if (!kvm_arch_has_assigned_device(vcpu->kvm) || > - !irq_remapping_cap(IRQ_POSTING_CAP) || > - !kvm_vcpu_apicv_active(vcpu)) > + if (!kvm_vcpu_pi_need_handle(vcpu)) > return; > > do { > @@ -11831,9 +11830,7 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq, > struct vcpu_data vcpu_info; > int idx, ret = -EINVAL; > > - if (!kvm_arch_has_assigned_device(kvm) || > - !irq_remapping_cap(IRQ_POSTING_CAP) || > - !kvm_vcpu_apicv_active(kvm->vcpus[0])) > + if (!kvm_vcpu_pi_need_handle(kvm->vcpus[0])) > return 0; > > idx = srcu_read_lock(&kvm->irq_srcu); -- Regards, Longpeng(Mike)