public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bp@alien8.de
Subject: Re: [PATCH] KVM: fix spin_lock_init order on x86
Date: Mon, 21 Mar 2016 16:19:14 +0100	[thread overview]
Message-ID: <56F010F2.3060306@redhat.com> (raw)
In-Reply-To: <1458571635.10868.18.camel@edumazet-glaptop3.roam.corp.google.com>



On 21/03/2016 15:47, Eric Dumazet wrote:
> On Mon, 2016-03-21 at 10:24 +0100, Paolo Bonzini wrote:
>> kvm_arch_init_vm is now using mmu_lock, causing lockdep to
>> complain:
> ...
>>
>> Reported-by: Borislav Petkov <bp@alien8.de>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  virt/kvm/kvm_main.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> index 7ba1d10ffed2..cb45b86a1c48 100644
>> --- a/virt/kvm/kvm_main.c
>> +++ b/virt/kvm/kvm_main.c
>> @@ -536,6 +536,16 @@ static struct kvm *kvm_create_vm(unsigned long type)
>>  	if (!kvm)
>>  		return ERR_PTR(-ENOMEM);
>>  
>> +	spin_lock_init(&kvm->mmu_lock);
>> +	kvm->mm = current->mm;
>> +	atomic_inc(&kvm->mm->mm_count);
> 
> current->mm->mm_count is incremented here.
> 
>> +	kvm_eventfd_init(kvm);
>> +	mutex_init(&kvm->lock);
>> +	mutex_init(&kvm->irq_lock);
>> +	mutex_init(&kvm->slots_lock);
>> +	atomic_set(&kvm->users_count, 1);
>> +	INIT_LIST_HEAD(&kvm->devices);
>> +
>>  	r = kvm_arch_init_vm(kvm, type);
>>  	if (r)
>>  		goto out_err_no_disable;
> 
> 
> But out_err_no_disable wont decrement it in case of an error.
> 
> This is not clear to me where the cleanup is done ?

Indeed, a slightly more complex patch is necessary.  Will try again,
this time not doing this as the first thing in the morning.

Paolo

>> @@ -568,16 +578,6 @@ static struct kvm *kvm_create_vm(unsigned long type)
>>  			goto out_err;
>>  	}
>>  
>> -	spin_lock_init(&kvm->mmu_lock);
>> -	kvm->mm = current->mm;
>> -	atomic_inc(&kvm->mm->mm_count);
>> -	kvm_eventfd_init(kvm);
>> -	mutex_init(&kvm->lock);
>> -	mutex_init(&kvm->irq_lock);
>> -	mutex_init(&kvm->slots_lock);
>> -	atomic_set(&kvm->users_count, 1);
>> -	INIT_LIST_HEAD(&kvm->devices);
>> -
>>  	r = kvm_init_mmu_notifier(kvm);
>>  	if (r)
>>  		goto out_err;
> 
> 

  reply	other threads:[~2016-03-21 15:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21  9:24 [PATCH] KVM: fix spin_lock_init order on x86 Paolo Bonzini
2016-03-21 14:47 ` Eric Dumazet
2016-03-21 15:19   ` Paolo Bonzini [this message]
2016-03-21 17:42     ` Paolo Bonzini

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=56F010F2.3060306@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bp@alien8.de \
    --cc=eric.dumazet@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.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