From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH][Resend] Fix Warnining in arch/x86/kvm/vmx.c Date: Wed, 13 May 2009 12:41:02 +0300 Message-ID: <4A0A95AE.9090008@redhat.com> References: <20090513091643.8216.46699.sendpatchset@subratamodak.linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, Yaniv Kamay , Sachin P Sant , Balbir Singh To: Subrata Modak Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58398 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755117AbZEMJlf (ORCPT ); Wed, 13 May 2009 05:41:35 -0400 In-Reply-To: <20090513091643.8216.46699.sendpatchset@subratamodak.linux.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: Subrata Modak wrote: > Hi Avi/Yaniv, > > With gcc --version 4.4.1 20090429 (prerelease) > > I get the following warning: > arch/x86/kvm/vmx.c: In function =E2=80=98vmx_intr_assist=E2=80=99: > arch/x86/kvm/vmx.c:3233: warning: =E2=80=98max_irr=E2=80=99 may be us= ed uninitialized in this function > arch/x86/kvm/vmx.c:3233: note: =E2=80=98max_irr=E2=80=99 was declared= here > > Investigation found that: > > 3231 static void update_tpr_threshold(struct kvm_vcpu *vcpu) > 3232 { > 3233 int max_irr, tpr; > 3234=20 > 3235 if (!vm_need_tpr_shadow(vcpu->kvm)) > 3236 return; > 3237=20 > 3238 if (!kvm_lapic_enabled(vcpu) || > 3239 ((max_irr =3D kvm_lapic_find_highest_irr(vcpu)) =3D=3D= -1)) { > > =20 This function no longer exists; can you check if the current code is=20 susceptible? > (max_irr =3D kvm_lapic_find_highest_irr(vcpu)) =3D=3D -1 > > may not get a chance to evaluate if: > > !kvm_lapic_enabled(vcpu) > > evaluates to true (as the expressions are Or-ed). > > 3240 vmcs_write32(TPR_THRESHOLD, 0); > 3241 return; > 3242 } > 3243=20 > 3244 tpr =3D (kvm_lapic_get_cr8(vcpu) & 0x0f) << 4; > 3245 vmcs_write32(TPR_THRESHOLD, (max_irr > tpr) ? tpr >> 4 := max_irr >> 4); > > Using (max_irr > tpr) and max_irr >> 4, without max_irr getting initi= alized can > cause trouble. > =20 With !kvm_lapic_enabled(), TPR_THRESHOLD is meaningless. --=20 Do not meddle in the internals of kernels, for they are subtle and quic= k to panic.