[PATCH 03/16] mm: add vma_desc_size(), vma_desc_pages() helpers
Lorenzo Stoakes
lorenzo.stoakes at oracle.com
Mon Sep 8 07:09:43 PDT 2025
On Mon, Sep 08, 2025 at 10:32:24AM -0300, Jason Gunthorpe wrote:
> On Mon, Sep 08, 2025 at 02:12:00PM +0100, Lorenzo Stoakes wrote:
> > On Mon, Sep 08, 2025 at 09:51:01AM -0300, Jason Gunthorpe wrote:
> > > On Mon, Sep 08, 2025 at 12:10:34PM +0100, Lorenzo Stoakes wrote:
> > > > static int secretmem_mmap_prepare(struct vm_area_desc *desc)
> > > > {
> > > > - const unsigned long len = desc->end - desc->start;
> > > > + const unsigned long len = vma_desc_size(desc);
> > > >
> > > > if ((desc->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
> > > > return -EINVAL;
> > >
> > > I wonder if we should have some helper for this shared check too, it
> > > is a bit tricky with the two flags. Forced-shared checks are pretty
> > > common.
> >
> > Sure can add.
> >
> > >
> > > vma_desc_must_be_shared(desc) ?
> >
> > Maybe _could_be_shared()?
>
> It is not could, it is must.
I mean VM_MAYSHARE is a nonsense anyway, but _in theory_ VM_MAYSHARE &&
!VM_SHARE means we _could_ share it.
But in reality of course this isn't a real thing.
Perhaps vma_desc_is_shared() or something, I obviously don't want to get stuck
on semantics here :) [he says, while getting obviously stuck on semantics] :P
>
> 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.
Hey we've made a rod for own backs! Again!
>
> Jason
Cheers, Lorenzo
More information about the kexec
mailing list