Subject: Re: [PATCH v4 4/4] arm64: Use a variable to store non-global mappings decision

From: Catalin Marinas <[email-masked]>
Date: Wed, 30 Oct 2019 12:13:08 +0000

On Thu, Oct 24, 2019 at 10:42:07PM +0100, Mark Brown wrote:
> Refactor the code which checks to see if we need to use non-global
> mappings to use a variable instead of checking with the CPU capabilities
> each time, doing the initial check for KPTI early in boot before we
> start allocating memory so we still avoid transitioning to non-global
> mappings in common cases.
> 
> Since this variable always matches our decision about non-global
> mappings this means we can also combine arm64_kernel_use_ng_mappings()
> and arm64_unmap_kernel_at_el0() into a single function, the variable
> simply stores the result and the decision code is elsewhere. We could
> just have the users check the variable directly but having a function
> makes it clear that these uses are read-only.
> 
> The result is that we simplify the code a bit and reduces the amount of
> code executed at runtime.
> 
> Signed-off-by: Mark Brown <[email-masked]>
> 
> vdfsv

Some random string here.

> @@ -158,6 +87,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 kaslr_requires_kpti(void);

This doesn't seem to be used anywhere else, so we could remove it and
make it static.

> @@ -1051,7 +1087,7 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused)
>  	 * it already or we have KASLR enabled and therefore have not
>  	 * created any global mappings at all.
>  	 */
> -	if (kpti_applied || kaslr_offset() > 0)
> +	if (kpti_applied || arm64_use_ng_mappings)
>  		return;

Can we get rid of kpti_applied? I think arm64_use_ng_mappings serves the
same purpose.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel