On 29/04/2026 16:23, Ard Biesheuvel wrote:
> On Wed, 29 Apr 2026, at 12:54, Kevin Brodsky wrote:
>> On 27/04/2026 17:34, Ard Biesheuvel wrote:
>>> From: Ard Biesheuvel <[email protected]>
>>>
>>> Now that the DRAM mapping routines respect existing table mappings and
>>> contiguous block and page mappings, it is no longer needed to fiddle
>>> with the memblock tables to set and clear the NOMAP attribute in order
>>> to omit text and rodata when creating the linear map.
>>>
>>> Instead, map the kernel text and rodata alias first with the desired
>>> attributes, so that they will not be remapped later with different
>>> attributes when mapping the memblocks.
>>>
>>> Signed-off-by: Ard Biesheuvel <[email protected]>
>>> ---
>>>  arch/arm64/mm/mmu.c | 24 +++++++-------------
>>>  1 file changed, 8 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>>> index 5e2348b15783..1a4b4337d29a 100644
>>> --- a/arch/arm64/mm/mmu.c
>>> +++ b/arch/arm64/mm/mmu.c
>>> @@ -1148,12 +1148,15 @@ static void __init map_mem(void)
>>>             flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
>>>  
>>>     /*
>>> -    * Take care not to create a writable alias for the
>>> -    * read-only text and rodata sections of the kernel image.
>>> -    * So temporarily mark them as NOMAP to skip mappings in
>>> -    * the following for-loop
>>> +    * Map the linear alias of the [_text, __init_begin) interval
>>> +    * as non-executable now, and remove the write permission in
>>> +    * mark_linear_text_alias_ro() above (which will be called after
>>> +    * alternative patching has completed). This makes the contents
>>> +    * of the region accessible to subsystems such as hibernate,
>>> +    * but protects it from inadvertent modification or execution.
>>>      */
>>> -   memblock_mark_nomap(kernel_start, kernel_end - kernel_start);
>>> +   __map_memblock(kernel_start, kernel_end, pgprot_tagged(PAGE_KERNEL),
>> Is it now necessary for that mapping to be tagged? If so, it should
>> probably be called out in the commit message.
>>
> As you've pointed out, the initial r/w mapping of the linear alias of rodata
> will need to be mapped tagged before moving the zero page there. So this patch
> will just preserve that, rather than remapping the region tagged explicitly as
> it does now.

Right! I got lost in all the mappings :)

- Kevin

Reply via email to