The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: catalin.marinas@arm.com, will@kernel.org,
	akpm@linux-foundation.org, m.szyprowski@samsung.com,
	jenswi@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, mark.rutland@arm.com, robin.murphy@arm.com,
	hch@lst.de, ryan.roberts@arm.com, sumit.garg@kernel.org,
	sudeep.holla@kernel.org, ardb@kernel.org,
	thierry.reding@kernel.org, david@kernel.org,
	danielmentz@google.com, linux-arm-kernel@lists.infradead.org,
	linux-mm@kvack.org, iommu@lists.linux.dev,
	op-tee@lists.trustedfirmware.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/8] arm64: Add support for MEMBLOCK_PTEMAP
Date: Sun, 15 Nov 2026 21:20:16 +0200	[thread overview]
Message-ID: <avoF8IbOxVJ9Uh8Y@kernel.org> (raw)
In-Reply-To: <20261111110738.872947-3-vdonnefort@google.com>

On Wed, Nov 11, 2026 at 11:07:32AM +0000, Vincent Donnefort wrote:
> With the MEMBLOCK_PTEMAP flag, force a PTE-level mapping. This also

I'd expand this to "Force a PTE-level mapping for memblock regions with
MEMBLOCK_PTEMAP flag set".

> disables contiguous PTEs to make sure any page from the memblock can be

                                     and memblock region here ^

> safely unmapped from the linear map.
> 
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> ---
>  arch/arm64/mm/mmu.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 140520b351e2..a4cafafa1d82 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1184,9 +1184,8 @@ static void __init map_mem(void)
>  	phys_addr_t init_begin = __pa_symbol(__init_begin);
>  	phys_addr_t init_end = __pa_symbol(__init_end);
>  	phys_addr_t kernel_end = __pa_symbol(__bss_stop);
> -	phys_addr_t start, end;
>  	int flags = NO_EXEC_MAPPINGS;
> -	u64 i;
> +	struct memblock_region *r;
>  
>  	/*
>  	 * Setting hierarchical PXNTable attributes on table entries covering
> @@ -1226,9 +1225,14 @@ static void __init map_mem(void)
>  		       flags);
>  
>  	/* map all the memory banks */
> -	for_each_mem_range(i, &start, &end) {
> +	for_each_mem_region(r) {
> +		phys_addr_t start, end;
> +		int rflags = flags;
> +
> +		if (memblock_is_nomap(r))
> +			continue;
>  		/*
> -		 * for_each_mem_range may return sub-page-aligned boundaries
> +		 * for_each_mem_region may return sub-page-aligned boundaries
>  		 * after memblock_mark_nomap() splits regions at byte precision.
>  		 * __create_pgd_mapping_locked aligns phys down to PAGE_MASK,
>  		 * which could accidentally map no-map memory on the boundary.
> @@ -1237,17 +1241,21 @@ static void __init map_mem(void)
>  		 * regions. The cost is at most one page of unmapped gap at
>  		 * each boundary.
>  		 */
> -		start = PAGE_ALIGN(start);
> -		end = end & PAGE_MASK;
> +		start = PAGE_ALIGN(r->base);
> +		end = (r->base + r->size) & PAGE_MASK;

Nit: as we anyway change the assignment to end, PAGE_ALIGN_DOWN() is
slightly more explicit.

>  		if (start >= end)
>  			continue;
> +
> +		if (memblock_is_ptemap(r))
> +			rflags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
> +
>  		/*
>  		 * The linear map must allow allocation tags reading/writing
>  		 * if MTE is present. Otherwise, it has the same attributes as
>  		 * PAGE_KERNEL.
>  		 */
>  		__map_memblock(start, end, pgprot_tagged(PAGE_KERNEL),
> -			       flags);
> +			       rflags);
>  	}
>  }
>  
> -- 
> 2.56.0.542.g3ef89b7020-goog
> 

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2026-11-15 19:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 11:07 [PATCH v3 0/8] arm64: Unmap FF-A lent memory from direct map Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 1/8] memblock: Introduce MEMBLOCK_PTEMAP Vincent Donnefort
2026-11-15 19:14   ` Mike Rapoport
2026-11-11 11:07 ` [PATCH v3 2/8] arm64: Add support for MEMBLOCK_PTEMAP Vincent Donnefort
2026-11-15 19:20   ` Mike Rapoport [this message]
2026-11-11 11:07 ` [PATCH v3 3/8] dma-contiguous: Expose rmem_cma_ops Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 4/8] dt-bindings: reserved-memory: Add lendable-dma-pool Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 5/8] dma-mapping: Introduce lendable-dma-pool Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 6/8] arm64: Introduce direct_map_is_ptemap() Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 7/8] arm64: Add support for lendable-dma-pool Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 8/8] optee: " Vincent Donnefort

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avoF8IbOxVJ9Uh8Y@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=danielmentz@google.com \
    --cc=david@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=jenswi@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mark.rutland@arm.com \
    --cc=op-tee@lists.trustedfirmware.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=sumit.garg@kernel.org \
    --cc=thierry.reding@kernel.org \
    --cc=vdonnefort@google.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox