public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Borislav Petkov <bp@alien8.de>, Tom Lendacky <thomas.lendacky@amd.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, "Joerg Roedel" <joro@8bytes.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [RFC PATCH 1/2] KVM: x86: Add a framework for supporting MSR-based features
Date: Wed, 14 Feb 2018 17:58:57 +0100	[thread overview]
Message-ID: <c5ede174-9fd7-3303-41b8-a14673d8edca@redhat.com> (raw)
In-Reply-To: <20180214164438.GI18349@pd.tnic>

On 14/02/2018 17:44, Borislav Petkov wrote:
> On Thu, Feb 08, 2018 at 04:58:46PM -0600, Tom Lendacky wrote:
>> @@ -2681,11 +2731,15 @@ static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs,
>>  {
>>  	int i, idx;
>>  
>> -	idx = srcu_read_lock(&vcpu->kvm->srcu);
>> +	if (vcpu)
>> +		idx = srcu_read_lock(&vcpu->kvm->srcu);
>> +
>>  	for (i = 0; i < msrs->nmsrs; ++i)
>>  		if (do_msr(vcpu, entries[i].index, &entries[i].data))
>>  			break;
>> -	srcu_read_unlock(&vcpu->kvm->srcu, idx);
>> +
>> +	if (vcpu)
>> +		srcu_read_unlock(&vcpu->kvm->srcu, idx);
> 
> 
> ./include/linux/srcu.h:175:2: warning: ‘idx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>   __srcu_read_unlock(sp, idx);
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> arch/x86/kvm/x86.c:2739:9: note: ‘idx’ was declared here
>   int i, idx;
>          ^~~
> 
> I know, silly gcc.
> 

Nice point---even better, just push srcu_read_lock/unlock to msr_io or
even msr_io's callers.

Thanks,

Paolo

  reply	other threads:[~2018-02-14 16:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 22:58 [RFC PATCH 0/2] KVM: MSR-based features Tom Lendacky
2018-02-08 22:58 ` [RFC PATCH 1/2] KVM: x86: Add a framework for supporting " Tom Lendacky
2018-02-13 16:21   ` Paolo Bonzini
2018-02-14  4:23     ` Tom Lendacky
2018-02-13 16:25   ` Paolo Bonzini
2018-02-14  4:42     ` Tom Lendacky
2018-02-14 16:41       ` Paolo Bonzini
2018-02-14 16:44   ` Borislav Petkov
2018-02-14 16:58     ` Paolo Bonzini [this message]
2018-02-08 22:58 ` [RFC PATCH 2/2] KVM: SVM: Add MSR feature support for serializing LFENCE Tom Lendacky
2018-02-13 16:22   ` Paolo Bonzini
2018-02-14  4:39     ` Tom Lendacky
2018-02-14 10:08       ` Paolo Bonzini
2018-02-08 23:03 ` [RFC PATCH 0/2] KVM: MSR-based features Tom Lendacky

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=c5ede174-9fd7-3303-41b8-a14673d8edca@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox