lkml.org 
[lkml]   [2021]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 19/24] kvm: x86/mmu: Protect tdp_mmu_pages with a lock
On Tue, Jan 26, 2021 at 5:37 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 12/01/21 19:10, Ben Gardon wrote:
> > + * May be acquired under the MMU lock in read mode or non-overlapping
> > + * with the MMU lock.
> > + */
> > + spinlock_t tdp_mmu_pages_lock;
>
> Is this correct? My understanding is that:
>
> - you can take tdp_mmu_pages_lock from a shared MMU lock critical section
>
> - you don't need to take tdp_mmu_pages_lock from an exclusive MMU lock
> critical section, because you can't be concurrent with a shared critical
> section
>
> - but then, you can't take tdp_mmu_pages_lock outside the MMU lock,
> because you could have
>
> write_lock(mmu_lock)
> spin_lock(tdp_mmu_pages_lock)
> do tdp_mmu_pages_lock stuff !!! do tdp_mmu_pages_lock stuff
> write_unlock(mmu_lock)
> spin_unlock(tdp_mmu_pages_lock)
>

You're absolutely right, that would cause a problem. I'll amend the
comment to specify that the lock should only be held under the mmu
lock in read mode.

> Paolo
>

\
 
 \ /
  Last update: 2021-01-27 04:41    [W:0.133 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site