Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1361898

Re: [PATCH] KVM: fix spin_lock_init order on x86

From Eric Dumazet <eric.dumazet@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] KVM: fix spin_lock_init order on x86
Date 2016-03-21 15:50 +0100
Message-ID <rf9jz-76M-5@gated-at.bofh.it> (permalink)
References <rf4jU-3xO-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 ?

> @@ -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;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] KVM: fix spin_lock_init order on x86 Paolo Bonzini <pbonzini@redhat.com> - 2016-03-21 10:30 +0100
  Re: [PATCH] KVM: fix spin_lock_init order on x86 Eric Dumazet <eric.dumazet@gmail.com> - 2016-03-21 15:50 +0100
    Re: [PATCH] KVM: fix spin_lock_init order on x86 Paolo Bonzini <pbonzini@redhat.com> - 2016-03-21 16:20 +0100
      Re: [PATCH] KVM: fix spin_lock_init order on x86 Paolo Bonzini <pbonzini@redhat.com> - 2016-03-21 18:50 +0100

csiph-web