public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Kevin Brodsky <kevin.brodsky@arm•com>
To: Ard Biesheuvel <ardb+git@google•com>,
	linux-arm-kernel@lists•infradead.org
Cc: linux-kernel@vger•kernel.org, will@kernel•org,
	catalin.marinas@arm•com, mark.rutland@arm•com,
	Ard Biesheuvel <ardb@kernel•org>,
	Ryan Roberts <ryan.roberts@arm•com>,
	Anshuman Khandual <anshuman.khandual@arm•com>,
	Liz Prucka <lizprucka@google•com>,
	Seth Jenkins <sethjenkins@google•com>,
	Kees Cook <kees@kernel•org>, Mike Rapoport <rppt@kernel•org>,
	David Hildenbrand <david@kernel•org>,
	Andrew Morton <akpm@linux-foundation•org>,
	Jann Horn <jannh@google•com>,
	linux-mm@kvack•org, linux-hardening@vger•kernel.org,
	linuxppc-dev@lists•ozlabs.org, linux-sh@vger•kernel.org
Subject: Re: [PATCH v7 07/15] arm64: kfence: Avoid NOMAP tricks when mapping the early pool
Date: Mon, 1 Jun 2026 12:42:52 +0200	[thread overview]
Message-ID: <502eadae-089f-41cb-a871-9ad6b8169e0d@arm.com> (raw)
In-Reply-To: <20260529150150.1670604-24-ardb+git@google.com>

On 29/05/2026 17:01, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel•org>
>
> Now that the map_mem() routines respect existing page mappings and
> contiguous granule sized blocks with the contiguous bit cleared, there
> is no longer a reason to play tricks with the memblock NOMAP attribute.
>
> Instead, the kfence pool can be allocated and mapped with page
> granularity first, and this granularity will be respected when the rest
> of DRAM is mapped later, even if block and contiguous mappings are
> allowed for the remainder of those mappings.
>
> Add the NO_EXEC_MAPPINGS flag to ensure that hierarchical XN attributes
> are set on the intermediate page tables that are allocated when mapping
> the pool.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel•org>

Reviewed-by: Kevin Brodsky <kevin.brodsky@arm•com>

> ---
>  arch/arm64/mm/mmu.c | 27 +++++---------------
>  1 file changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index d7a6991e1844..cdf8b3510229 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1083,36 +1083,24 @@ static int __init parse_kfence_early_init(char *arg)
>  }
>  early_param("kfence.sample_interval", parse_kfence_early_init);
>  
> -static phys_addr_t __init arm64_kfence_alloc_pool(void)
> +static void __init arm64_kfence_map_pool(void)
>  {
>  	phys_addr_t kfence_pool;
>  
>  	if (!kfence_early_init)
> -		return 0;
> +		return;
>  
>  	kfence_pool = memblock_phys_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
>  	if (!kfence_pool) {
>  		pr_err("failed to allocate kfence pool\n");
>  		kfence_early_init = false;
> -		return 0;
> -	}
> -
> -	/* Temporarily mark as NOMAP. */
> -	memblock_mark_nomap(kfence_pool, KFENCE_POOL_SIZE);
> -
> -	return kfence_pool;
> -}
> -
> -static void __init arm64_kfence_map_pool(phys_addr_t kfence_pool)
> -{
> -	if (!kfence_pool)
>  		return;
> +	}
>  
>  	/* KFENCE pool needs page-level mapping. */
>  	__map_memblock(kfence_pool, kfence_pool + KFENCE_POOL_SIZE,
>  			pgprot_tagged(PAGE_KERNEL),
> -			NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
> -	memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE);
> +			NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS | NO_EXEC_MAPPINGS);
>  	__kfence_pool = phys_to_virt(kfence_pool);
>  }
>  
> @@ -1144,8 +1132,7 @@ bool arch_kfence_init_pool(void)
>  }
>  #else /* CONFIG_KFENCE */
>  
> -static inline phys_addr_t arm64_kfence_alloc_pool(void) { return 0; }
> -static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool) { }
> +static inline void arm64_kfence_map_pool(void) { }
>  
>  #endif /* CONFIG_KFENCE */
>  
> @@ -1155,7 +1142,6 @@ static void __init map_mem(void)
>  	phys_addr_t kernel_start = __pa_symbol(_text);
>  	phys_addr_t kernel_end = __pa_symbol(__init_begin);
>  	phys_addr_t start, end;
> -	phys_addr_t early_kfence_pool;
>  	int flags = NO_EXEC_MAPPINGS;
>  	u64 i;
>  
> @@ -1172,7 +1158,7 @@ static void __init map_mem(void)
>  	BUILD_BUG_ON(pgd_index(direct_map_end - 1) == pgd_index(direct_map_end) &&
>  		     pgd_index(_PAGE_OFFSET(VA_BITS_MIN)) != PTRS_PER_PGD - 1);
>  
> -	early_kfence_pool = arm64_kfence_alloc_pool();
> +	arm64_kfence_map_pool();
>  
>  	linear_map_requires_bbml2 = !force_pte_mapping() && can_set_direct_map();
>  
> @@ -1210,7 +1196,6 @@ static void __init map_mem(void)
>  	 */
>  	__map_memblock(kernel_start, kernel_end, PAGE_KERNEL, NO_CONT_MAPPINGS);
>  	memblock_clear_nomap(kernel_start, kernel_end - kernel_start);
> -	arm64_kfence_map_pool(early_kfence_pool);
>  }
>  
>  void mark_rodata_ro(void)


  reply	other threads:[~2026-06-01 10:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 15:01 [PATCH v7 00/15] arm64: Unmap linear alias of kernel data/bss Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 01/15] arm64: mm: Remove bogus stop condition from map_mem() loop Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 02/15] arm64: mm: Drop redundant pgd_t* argument from map_mem() Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 03/15] arm64: mm: Check for pud_/pmd_set_huge() failures on kernel mappings Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 04/15] arm64: mm: Preserve existing table mappings when mapping DRAM Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 05/15] arm64: mm: Preserve non-contiguous descriptors " Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 06/15] arm64: mm: Permit contiguous descriptors to be manipulated Ard Biesheuvel
2026-05-29 15:01 ` [PATCH v7 07/15] arm64: kfence: Avoid NOMAP tricks when mapping the early pool Ard Biesheuvel
2026-06-01 10:42   ` Kevin Brodsky [this message]
2026-05-29 15:01 ` [PATCH v7 08/15] arm64: mm: Permit contiguous attribute for preliminary mappings Ard Biesheuvel
2026-05-29 15:02 ` [PATCH v7 09/15] arm64: Move fixmap and kasan page tables to end of kernel image Ard Biesheuvel
2026-05-29 15:02 ` [PATCH v7 10/15] arm64: mm: Don't abuse memblock NOMAP to check for overlaps Ard Biesheuvel
2026-06-01 10:43   ` Kevin Brodsky
2026-05-29 15:02 ` [PATCH v7 11/15] powerpc/code-patching: Avoid r/w mapping of the zero page Ard Biesheuvel
2026-06-03 18:03   ` Mukesh Kumar Chaurasiya
2026-06-04  7:43   ` Christophe Leroy (CS GROUP)
2026-05-29 15:02 ` [PATCH v7 12/15] sh: Drop cache flush of the zero page at boot Ard Biesheuvel
2026-05-30 16:19   ` Mike Rapoport
2026-06-01  8:11   ` Geert Uytterhoeven
2026-05-29 15:02 ` [PATCH v7 13/15] mm: Make empty_zero_page[] const Ard Biesheuvel
2026-05-29 15:02 ` [PATCH v7 14/15] arm64: mm: Map the kernel data/bss read-only in the linear map Ard Biesheuvel
2026-05-29 15:02 ` [PATCH v7 15/15] arm64: mm: Unmap kernel data/bss entirely from " Ard Biesheuvel
2026-06-01 10:43   ` Kevin Brodsky
2026-06-02 20:34 ` [PATCH v7 00/15] arm64: Unmap linear alias of kernel data/bss Will Deacon
2026-06-03  8:57   ` Ard Biesheuvel
2026-06-03 11:22     ` Will Deacon
2026-06-03 11:24       ` Ard Biesheuvel

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=502eadae-089f-41cb-a871-9ad6b8169e0d@arm.com \
    --to=kevin.brodsky@arm$(echo .)com \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=anshuman.khandual@arm$(echo .)com \
    --cc=ardb+git@google$(echo .)com \
    --cc=ardb@kernel$(echo .)org \
    --cc=catalin.marinas@arm$(echo .)com \
    --cc=david@kernel$(echo .)org \
    --cc=jannh@google$(echo .)com \
    --cc=kees@kernel$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-hardening@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-mm@kvack$(echo .)org \
    --cc=linux-sh@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=lizprucka@google$(echo .)com \
    --cc=mark.rutland@arm$(echo .)com \
    --cc=rppt@kernel$(echo .)org \
    --cc=ryan.roberts@arm$(echo .)com \
    --cc=sethjenkins@google$(echo .)com \
    --cc=will@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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