Re: [PATCH] arm64: mm: Move KPTI helpers to mmu.c

Ard Biesheuvel
2025-09-11T11:01:38Z

On Thu, 11 Sept 2025 at 12:52, Kevin Brodsky <kevin.brodsky@arm.com> wrote:
>
> On 11/09/2025 11:19, Ard Biesheuvel wrote:
> >> diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
> >> index 49f1a810df16..624edd6c4964 100644
> >> --- a/arch/arm64/include/asm/mmu.h
> >> +++ b/arch/arm64/include/asm/mmu.h
> >> @@ -104,5 +104,11 @@ static inline bool kaslr_requires_kpti(void)
> >> return true;
> >> }
> >>
> >> +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
> >> +void kpti_install_ng_mappings(void);
> >> +#else
> >> +static inline void kpti_install_ng_mappings(void) {}
> >> +#endif
> >> +
> > Nit: you might just keep the former declaration, and check for
> > IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0) in the function, rather than
> > propagating this distinction to the header file.
> > But either is fine with me.
>
> That's an option, but that would mean removing the #ifdef around the
> functions defined in mmu.c. They would probably get eliminated by the
> linker if the CONFIG isn't defined, but I'm not so sure about the static
> variable (kpti_ng_temp_alloc). Probably not a big deal but I feel
> keeping the #ifdef is more self-documenting as well.
>

Fair enough.