All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, Yaniv Kamay <yaniv@redhat.com>,
	Sachin P Sant <sachinp@linux.vnet.ibm.com>,
	Balbir Singh <balbir@linux.vnet.ibm.com>
Subject: Re: [PATCH][Resend] Fix Warnining in arch/x86/kvm/vmx.c
Date: Wed, 13 May 2009 12:41:02 +0300	[thread overview]
Message-ID: <4A0A95AE.9090008@redhat.com> (raw)
In-Reply-To: <20090513091643.8216.46699.sendpatchset@subratamodak.linux.ibm.com>

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 ‘vmx_intr_assist’:
> arch/x86/kvm/vmx.c:3233: warning: ‘max_irr’ may be used uninitialized in this function
> arch/x86/kvm/vmx.c:3233: note: ‘max_irr’ was declared here
>
> Investigation found that:
>
> 3231 static void update_tpr_threshold(struct kvm_vcpu *vcpu)
> 3232 {
> 3233         int max_irr, tpr;
> 3234 
> 3235         if (!vm_need_tpr_shadow(vcpu->kvm))
> 3236                 return;
> 3237 
> 3238         if (!kvm_lapic_enabled(vcpu) ||
> 3239             ((max_irr = kvm_lapic_find_highest_irr(vcpu)) == -1)) {
>
>   

This function no longer exists; can you check if the current code is 
susceptible?

> 	(max_irr = kvm_lapic_find_highest_irr(vcpu)) == -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 
> 3244         tpr = (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 initialized can
> cause trouble.
>   

With !kvm_lapic_enabled(), TPR_THRESHOLD is meaningless.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


      reply	other threads:[~2009-05-13  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13  9:16 [PATCH][Resend] Fix Warnining in arch/x86/kvm/vmx.c Subrata Modak
2009-05-13  9:41 ` Avi Kivity [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A0A95AE.9090008@redhat.com \
    --to=avi@redhat.com \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=sachinp@linux.vnet.ibm.com \
    --cc=subrata@linux.vnet.ibm.com \
    --cc=yaniv@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.