From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751946AbdIQSZD (ORCPT ); Sun, 17 Sep 2017 14:25:03 -0400 Received: from terminus.zytor.com ([65.50.211.136]:35339 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751410AbdIQSZB (ORCPT ); Sun, 17 Sep 2017 14:25:01 -0400 Date: Sun, 17 Sep 2017 11:19:53 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: bpetkov@suse.de, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, mingo@kernel.org, torvalds@linux-foundation.org, pmenzel@molgen.mpg.de, linux-kernel@vger.kernel.org, hpa@zytor.com, pavel@ucw.cz, luto@kernel.org Reply-To: mingo@kernel.org, bpetkov@suse.de, peterz@infradead.org, bp@alien8.de, tglx@linutronix.de, pavel@ucw.cz, hpa@zytor.com, luto@kernel.org, torvalds@linux-foundation.org, pmenzel@molgen.mpg.de, linux-kernel@vger.kernel.org In-Reply-To: <30cdfea504682ba3b9012e77717800a91c22097f.1505663533.git.luto@kernel.org> References: <30cdfea504682ba3b9012e77717800a91c22097f.1505663533.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/mm/32: Load a sane CR3 before cpu_init() on secondary CPUs Git-Commit-ID: 4ba55e65f471d011d3ba2ac2022180ea0877d68e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4ba55e65f471d011d3ba2ac2022180ea0877d68e Gitweb: http://git.kernel.org/tip/4ba55e65f471d011d3ba2ac2022180ea0877d68e Author: Andy Lutomirski AuthorDate: Sun, 17 Sep 2017 09:03:51 -0700 Committer: Ingo Molnar CommitDate: Sun, 17 Sep 2017 18:59:09 +0200 x86/mm/32: Load a sane CR3 before cpu_init() on secondary CPUs For unknown historical reasons (i.e. Borislav doesn't recall), 32-bit kernels invoke cpu_init() on secondary CPUs with initial_page_table loaded into CR3. Then they set current->active_mm to &init_mm and call enter_lazy_tlb() before fixing CR3. This means that the x86 TLB code gets invoked while CR3 is inconsistent, and, with the improved PCID sanity checks I added, we warn. Fix it by loading swapper_pg_dir (i.e. init_mm.pgd) earlier. Reported-by: Paul Menzel Reported-by: Pavel Machek Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 72c0098d92ce ("x86/mm: Reinitialize TLB state on hotplug and resume") Link: http://lkml.kernel.org/r/30cdfea504682ba3b9012e77717800a91c22097f.1505663533.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/smpboot.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 0854ff1..ad59edd 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -232,12 +232,6 @@ static void notrace start_secondary(void *unused) */ if (boot_cpu_has(X86_FEATURE_PCID)) __write_cr4(__read_cr4() | X86_CR4_PCIDE); - cpu_init(); - x86_cpuinit.early_percpu_clock_init(); - preempt_disable(); - smp_callin(); - - enable_start_cpu0 = 0; #ifdef CONFIG_X86_32 /* switch away from the initial page table */ @@ -245,6 +239,13 @@ static void notrace start_secondary(void *unused) __flush_tlb_all(); #endif + cpu_init(); + x86_cpuinit.early_percpu_clock_init(); + preempt_disable(); + smp_callin(); + + enable_start_cpu0 = 0; + /* otherwise gcc will move up smp_processor_id before the cpu_init */ barrier(); /*