Re: [PATCH v7 1/3] mm: make persistent huge zero folio read-only

From: David Hildenbrand (Arm)

Date: Mon Sep 07 2026 - 07:26:23 EST


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?
Having a dedicated set_direct_map_ro() with clear (documented ;)) semantics does
not sound too crazy to me.

--
Cheers,

David