Thread (62 messages) 62 messages, 9 authors, 2020-11-09

Re: [PATCH v5 08/15] mm: Add unsafe_follow_pfn

From: Daniel Vetter <hidden>
Date: 2020-11-02 16:42:37
Also in: dri-devel, kvm, linux-media, linux-mm, linux-samsung-soc, lkml

On Mon, Nov 2, 2020 at 4:52 PM Jason Gunthorpe [off-list ref] wrote:
On Mon, Nov 02, 2020 at 02:23:58PM +0100, Daniel Vetter wrote:
quoted
On Mon, Nov 2, 2020 at 2:01 PM Jason Gunthorpe [off-list ref] wrote:
quoted
On Mon, Nov 02, 2020 at 01:56:10PM +0100, Daniel Vetter wrote:
quoted
On Mon, Nov 2, 2020 at 8:29 AM Christoph Hellwig [off-list ref] wrote:
quoted
On Fri, Oct 30, 2020 at 11:08:08AM +0100, Daniel Vetter wrote:
quoted
Also mark up follow_pfn as EXPORT_SYMBOL_GPL. The only safe way to use
that by drivers/modules is together with an mmu_notifier, and that's
all _GPL stuff.
I also think it also needs to be renamed to explicitly break any existing
users out of tree or int the submission queue.
Ok I looked at the mmu notifier locking again and noticed that
mm->subscriptions has its own spinlock. Since there usually shouldn't
be a huge pile of these I think it's feasible to check for the mmu
notifier in follow_pfn. And that would stuff this gap for good. I'll
throw that on top as a final patch and see what people think.
Probably the simplest is to just check mm_has_notifiers() when in
lockdep or something very simple like that
lockdep feels wrong, was locking more at CONFIG_DEBUG_VM. And since
generally you only have 1 mmu notifier (especially for kvm) I think we
can also pay the 2nd cacheline miss and actually check the right mmu
notifier is registered.
Need to hold the lock to check that and there are two ways to register
notifiers these days, so it feels to expensive to me.
Uh I mixed stuff up all along, struct mmu_notifier *subcription that
all the mmu notifier users use has the ->mm pointer we want right
there. That's good enough I think.

Now I'm kinda lost in kvm code trying to wire it through, but it's
looking ok-ish thus far :-)
-Daniel
CH's 'export symbol only for kvm' really does seem the most robust way
to handle this though.

Jason


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help