[PATCH 03/16] mm: add vma_desc_size(), vma_desc_pages() helpers
Lorenzo Stoakes
lorenzo.stoakes at oracle.com
Mon Sep 8 07:47:34 PDT 2025
On Mon, Sep 08, 2025 at 11:20:11AM -0300, Jason Gunthorpe wrote:
> On Mon, Sep 08, 2025 at 03:09:43PM +0100, Lorenzo Stoakes wrote:
> > > Perhaps
> > >
> > > !vma_desc_cowable()
> > >
> > > Is what many drivers are really trying to assert.
> >
> > Well no, because:
> >
> > static inline bool is_cow_mapping(vm_flags_t flags)
> > {
> > return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
> > }
> >
> > Read-only means !CoW.
>
> What drivers want when they check SHARED is to prevent COW. It is COW
> that causes problems for whatever the driver is doing, so calling the
> helper cowable and making the test actually right for is a good thing.
>
> COW of this VMA, and no possibilty to remap/mprotect/fork/etc it into
> something that is COW in future.
But you can't do that if !VM_MAYWRITE.
I mean probably the driver's just wrong and should use is_cow_mapping() tbh.
>
> Drivers have commonly various things with VM_SHARED to establish !COW,
> but if that isn't actually right then lets fix it to be clear and
> correct.
I think we need to be cautious of scope here :) I don't want to accidentally
break things this way.
OK I think a sensible way forward - How about I add desc_is_cowable() or
vma_desc_cowable() and only set this if I'm confident it's correct?
That way I can achieve both aims at once.
>
> Jason
Cheers, Lorenzo
More information about the kexec
mailing list