Skip to content

Commit f525999

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64: Avoid enabling KPTI unnecessarily
Commit 42c5a3b refactored the KPTI init code in a way that results in the use of non-global kernel mappings even on systems that have no need for it, and even when KPTI has been disabled explicitly via the command line. Ensure that this only happens when we have decided (based on the detected system-wide CPU features) that KPTI should be enabled. Fixes: 42c5a3b ("arm64: Split kpti_install_ng_mappings()") Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Will Deacon <will@kernel.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Link: https://lore.kernel.org/r/20231127120049.2258650-6-ardb@google.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent c0a8574 commit f525999

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,10 @@ static int __init __kpti_install_ng_mappings(void *__unused)
18391839

18401840
static void __init kpti_install_ng_mappings(void)
18411841
{
1842+
/* Check whether KPTI is going to be used */
1843+
if (!cpus_have_cap(ARM64_UNMAP_KERNEL_AT_EL0))
1844+
return;
1845+
18421846
/*
18431847
* We don't need to rewrite the page-tables if either we've done
18441848
* it already or we have KASLR enabled and therefore have not

0 commit comments

Comments
 (0)