From: Will Deacon <will@kernel.org>
To: Vincent Donnefort <vdonnefort@google.com>
Cc: catalin.marinas@arm.com, rafael@kernel.org, mark.rutland@arm.com,
lenb@kernel.org, pavel@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, thierry.reding@kernel.org,
rppt@kernel.org
Subject: Re: [PATCH v1 3/4] arm64: mm: Introduce linear_map_needs_set() helper
Date: Fri, 27 Nov 2026 15:19:16 +0000 [thread overview]
Message-ID: <awmfdBx229aZCn9Y@willie-the-truck> (raw)
In-Reply-To: <20260918131656.3710047-4-vdonnefort@google.com>
On Fri, Sep 18, 2026 at 02:16:55PM +0100, Vincent Donnefort wrote:
> can_set_direct_map() is intended as an external query function, but is
> also being called internally by map_mem() to initialise
> linear_map_requires_bbml3, duplicating the feature checks already
> present in force_pte_mapping().
>
> Factor the list of features that require modifying linear map attributes
> into a shared helper linear_map_needs_set().
>
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> ---
> arch/arm64/include/asm/mmu.h | 1 +
> arch/arm64/mm/mmu.c | 22 ++++++++++++++++++++--
> arch/arm64/mm/pageattr.c | 12 +-----------
> 3 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
> index 5e1211c540ab..12ed21e2d0d7 100644
> --- a/arch/arm64/include/asm/mmu.h
> +++ b/arch/arm64/include/asm/mmu.h
> @@ -70,6 +70,7 @@ extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
> pgprot_t prot, bool page_mappings_only);
> extern void *fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot);
> extern void mark_linear_text_alias_ro(void);
> +extern bool linear_map_needs_set(void);
> extern int split_kernel_leaf_mapping(unsigned long start, unsigned long end);
> extern void linear_map_maybe_split_to_ptes(void);
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 79d90226fd5d..c18ed601f0a8 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -776,6 +776,24 @@ static int split_kernel_leaf_mapping_locked(unsigned long addr)
> return ret;
> }
>
> +/*
> + * True if the linear map needs to be modified for one of the following
> + * features:
> + *
> + * rodata_full and DEBUG_PAGEALLOC need to protect/unprotect pages in
> + * the linear map.
> + *
> + * KFENCE pool needs to protect/unprotect pages in the linear map if
> + * initialized late.
> + *
> + * Realms need to mark pages shared/protected in the linear map.
> + */
> +bool linear_map_needs_set(void)
> +{
nit: I'm not a big fan of this function name, but see below.
> + return rodata_full || debug_pagealloc_enabled() ||
> + arm64_kfence_can_set_direct_map() || is_realm_world();
> +}
> +
> static inline bool force_pte_mapping(void)
> {
> const bool bbml3 = system_capabilities_finalized() ?
> @@ -785,7 +803,7 @@ static inline bool force_pte_mapping(void)
> return true;
This 'return true' above is part of a check for debug_pagealloc_enabled(),
which is now redundant because you've added that to linear_map_needs_set().
> if (bbml3)
> return false;
> - return rodata_full || arm64_kfence_can_set_direct_map() || is_realm_world();
> + return linear_map_needs_set();
> }
>
> static DEFINE_MUTEX(pgtable_split_lock);
> @@ -1203,7 +1221,7 @@ static void __init map_mem(void)
>
> arm64_kfence_map_pool();
>
> - linear_map_requires_bbml3 = !force_pte_mapping() && can_set_direct_map();
> + linear_map_requires_bbml3 = !force_pte_mapping() && linear_map_needs_set();
That looks pretty odd now that force_pte_mapping() calls
linear_map_needs_set() under the hood.
I wonder if you should avoid introducing the new function and just put
the logic in force_pte_mapping() instead? You could rename it to
linear_map_force_pte_mapping().
Then map_mem() just needs to check force_pte_mapping() whereas
can_set_direct_map() is force_pte_mapping() || has_bbml3().
Will
next prev parent reply other threads:[~2026-11-27 15:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 13:16 [PATCH v1 0/4] arm64: mm: Allow set_direct_map functions on BBML3 systems Vincent Donnefort
2026-09-18 13:16 ` [PATCH v1 1/4] PM: hibernate: Add arch specific hooks for hibernate_map/unmap_page Vincent Donnefort
2026-09-22 5:55 ` Mike Rapoport
2026-11-30 16:31 ` Vincent Donnefort
2026-09-18 13:16 ` [PATCH v1 2/4] arm64: hibernate: Use fixmap " Vincent Donnefort
2026-09-18 13:16 ` [PATCH v1 3/4] arm64: mm: Introduce linear_map_needs_set() helper Vincent Donnefort
2026-11-27 15:19 ` Will Deacon [this message]
2026-09-18 13:16 ` [PATCH v1 4/4] arm64: mm: Allow can_set_direct_map() on BBML3 systems 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=awmfdBx229aZCn9Y@willie-the-truck \
--to=will@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=lenb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=rppt@kernel.org \
--cc=thierry.reding@kernel.org \
--cc=vdonnefort@google.com \
/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