From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [RFC PATCH 5/5] KVM: PPC: Take the SRCU lock around memslot use Date: Thu, 9 Aug 2012 15:27:17 -0300 Message-ID: <20120809182717.GC12285@amt.cnet> References: <20120806100207.GA8980@bloggs.ozlabs.ibm.com> <20120806100816.GF8980@bloggs.ozlabs.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Graf , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org To: Paul Mackerras Return-path: Content-Disposition: inline In-Reply-To: <20120806100816.GF8980@bloggs.ozlabs.ibm.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, Aug 06, 2012 at 08:08:16PM +1000, Paul Mackerras wrote: > The generic KVM code uses SRCU (sleeping RCU) to protect accesses > to the memslots data structures against updates due to userspace > adding, modifying or removing memory slots. We need to do that too, > both to avoid accessing stale copies of the memslots and to avoid > lockdep warnings. This therefore adds srcu_read_lock/unlock pairs > around code that accesses and uses memslots in the Book 3S PR code > and the Book E (44x and e500) code. > > Signed-off-by: Paul Mackerras > --- > Compile-tested only. > > arch/powerpc/kvm/44x_tlb.c | 6 ++++++ > arch/powerpc/kvm/book3s_pr.c | 6 ++++++ > arch/powerpc/kvm/e500_tlb.c | 6 ++++++ > 3 files changed, 18 insertions(+) On top of the previous comment: x86 calls srcu_read_lock at the beginning of the KVM_RUN ioctl handler (__vcpu_run in arch/x86/kvm/x86.c), unlocks srcu on guest entry, locks on guest exit before any potential use of memslots, and unlocks on exit to userspace. This has the advantage of not sprinkling srcu lock/unlock calls all over (except from other ioctls, of course). Its low maintenance. Perhaps doing the same on PPC is not a bad idea.