[PATCH v4] arm64: Enable permission change on arm64 kernel block mappings
Andrew Morton
akpm at linux-foundation.org
Sat Jul 19 16:29:30 PDT 2025
On Sat, 19 Jul 2025 19:22:20 +0530 Dev Jain <dev.jain at arm.com> wrote:
> Gentle ping
>
> On 03/07/25 8:44 pm, Dev Jain wrote:
> > This patch paves the path to enable huge mappings in vmalloc space and
> > linear map space by default on arm64. For this we must ensure that we can
> > handle any permission games on the kernel (init_mm) pagetable. Currently,
> > __change_memory_common() uses apply_to_page_range() which does not support
> > changing permissions for block mappings. We attempt to move away from this
> > by using the pagewalk API, similar to what riscv does right now; however,
> > it is the responsibility of the caller to ensure that we do not pass a
> > range overlapping a partial block mapping or cont mapping; in such a case,
> > the system must be able to support range splitting.
> >
>
> ...
>
> > arch/arm64/mm/pageattr.c | 155 +++++++++++++++++++++++++++++++--------
> > include/linux/pagewalk.h | 3 +
> > mm/pagewalk.c | 24 ++++++
> > 3 files changed, 150 insertions(+), 32 deletions(-)
I'm assuming this is an arm patch - the pagewalk.c bits are simple.
However, I have nits!
> > --- a/mm/pagewalk.c
> > +++ b/mm/pagewalk.c
> > @@ -633,6 +633,30 @@ int walk_kernel_page_table_range(unsigned long start, unsigned long end,
> > return walk_pgd_range(start, end, &walk);
> > }
> >
> > +/*
> > + * Use this function to walk the kernel page tables locklessly. It should be
> > + * guaranteed that the caller has exclusive access over the range they are
> > + * operating on - that there should be no concurrent access, for example,
> > + * changing permissions for vmalloc objects.
> > + */
All the other function documenation in there is in kerneldoc form.
> > +int walk_kernel_page_table_range_lockless(unsigned long start, unsigned long end,
> > + const struct mm_walk_ops *ops, void *private)
> > +{
> > + struct mm_walk walk = {
> > + .ops = ops,
> > + .mm = &init_mm,
> > + .private = private,
> > + .no_vma = true
> > + };
> > +
> > + if (start >= end)
> > + return -EINVAL;
> > + if (!check_ops_valid(ops))
> > + return -EINVAL;
> > +
> > + return walk_pgd_range(start, end, &walk);
> > +}
> > +
If we were being stingy with the bytes we could wrap this in some
`#ifdef CONFIG_ARM' thing,
This is awfully similar to walk_page_range_novma(). We could combine
them in some fashion but the results would be a bit messy.
More information about the linux-arm-kernel
mailing list