Re: [PATCH v7 1/3] mm: make persistent huge zero folio read-only
From: Mike Rapoport
Date: Mon Sep 07 2026 - 10:43:32 EST
On Mon, Sep 07, 2026 at 01:18:42PM +0200, David Hildenbrand (Arm) wrote:
> On 9/7/26 08:03, Mike Rapoport wrote:
> > Hi Xueyuan,
> >
> > On Mon, Sep 07, 2026 at 09:11:14AM +0800, Xueyuan Chen wrote:
> >> On Sun, Sep 6, 2026 at 6:00 PM Mike Rapoport <rppt@xxxxxxxxxx> wrote:
> >>>
> >>>
> >>> I believe this is an historical artifact. change_memory_common() already
> >>> updates the linear map when a vmalloc mapping switches to RO and the system
> >>> supports it.
> >>
> >> On x86, set_memory_ro() does work on direct-map addresses.
> >>
> >>>
> >>> I believe arm64::set_memory_ro() can change the linear map in the general
> >>> case as well as long as can_set_direct_map() is true.
> >>>
> >>
> >> On arm64, I'm reading arch/arm64/mm/pageattr.c, and the linear-map
> >> update in change_memory_common() is only reachable for vmalloc
> >> addresses:
> >>
> >> set_memory_ro
> >> change_memory_common
> >> area = find_vm_area((void *)addr);
> >> if (!area || ...)
> >> return -EINVAL;
> >>
> >> So set_memory_ro() on a linear-map address returns -EINVAL on arm64.
> >
> > And I believe this is an historical artifact rather than necessity. For
> > configurations that allow set_direct_map on arm64, change_memory_common can
> > update direct map too, it just need to be implemented there.
> >
>
> Are we sure the other architectures do what we want in their set_memory_ro?
It's a zoo right now :(
Although most of them do.
But we need to sort it out anyway because of increasingly growing demand
for modifications of the kernel page tables.
I started something here:
https://lore.kernel.org/linux-mm/20260721-generic-set-memory-v0-1-v1-0-2c1fc62306b3@xxxxxxxxxx/
Now that x86 CPA is nearly fixed, I can look into the next iteration.
> Having a dedicated set_direct_map_ro() with clear (documented ;)) semantics does
> not sound too crazy to me.
It's not too crazy, no.
Still making arm64 more aligned with x86 and other arches that update the
direct/linear map in the set_memory_ro() seem a good thing on it's own.
> --
> Cheers,
>
> David
--
Sincerely yours,
Mike.