summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-08-28 16:24:47 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 13:13:50 +0200
commitc9e116d055f93222791ec8b80b73b8efa6a04865 (patch)
tree47c08b437b56813c9792e2273abe522ddaa1b7e7 /arch
parent6e46d1f164730d3288d2b09660aa8a2d147106d0 (diff)
downloadlinux-stable-c9e116d055f93222791ec8b80b73b8efa6a04865.tar.gz
linux-stable-c9e116d055f93222791ec8b80b73b8efa6a04865.tar.bz2
linux-stable-c9e116d055f93222791ec8b80b73b8efa6a04865.zip
x86/mm/pti: Do not invoke PTI functions when PTI is disabled
[ Upstream commit 990784b57731192b7d90c8d4049e6318d81e887d ] When PTI is disabled at boot time either because the CPU is not affected or PTI has been disabled on the command line, the boot code still calls into pti_finalize() which then unconditionally invokes: pti_clone_entry_text() pti_clone_kernel_text() pti_clone_kernel_text() was called unconditionally before the 32bit support was added and 32bit added the call to pti_clone_entry_text(). The call has no side effects as cloning the page tables into the available second one, which was allocated for PTI does not create damage. But it does not make sense either and in case that this functionality would be extended later this might actually lead to hard to diagnose issues. Neither function should be called when PTI is runtime disabled. Make the invocation conditional. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Ingo Molnar <mingo@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20190828143124.063353972@linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/mm/pti.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index b196524759ec..ba22b50f4eca 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -666,6 +666,8 @@ void __init pti_init(void)
*/
void pti_finalize(void)
{
+ if (!boot_cpu_has(X86_FEATURE_PTI))
+ return;
/*
* We need to clone everything (again) that maps parts of the
* kernel image.