Received: by 10.213.65.68 with SMTP id h4csp1292045imn; Wed, 4 Apr 2018 16:35:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/GIjqdIPi3nYWacIjvCCMUO//MKRYcswx0YfNzz3d49fwJE6qT+7rG+KMyz6p/0yBEM4Yv X-Received: by 10.99.144.199 with SMTP id a190mr13101569pge.359.1522884944941; Wed, 04 Apr 2018 16:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522884944; cv=none; d=google.com; s=arc-20160816; b=dtapqh9NN6M1JXH37CA0kHfSaE8d5ka7R8f+fRETsMImGpFLjuggKoyNJpBKah7uda CCqS0JDVCv+wFtjfXayay2x3RX4cop/OaH6ozsHhwUmKuTpibAedN4n/5GN0D2r/Xb7V sGK9Cw1ciKNNVYb9yNEQ4iuHz7z81AQUPKQTOGbBHl8tQGcRa3RMsWWm6PZo+KJkT2Rx 3c8eUkS4BKGFm6vLK4nuQUMeserak/MN7YTFVAinqjmxIeGTus2I9UKRAVW1+PFalgWq vHjxqIdIpVSWGbwxw4chBJmBvpC/4WctKwFMurK8wkC30nc1MjoI3MGz7GqALv1DjiaM 2l+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=HhK2ABhK96zOF/Nz5SaTzX3nPbOwLoCOJmKqdCiFt6g=; b=him9U0V8Xs3QbAQ8TARHyS6wCkDS1/a0QzVsrEiT9ycH+m6VYrHXhbLkqoxwj9feO9 6dmG9iDGepPM0M9xF2Kw1zqMJacR23lUqYycsbdV6IuTve7dSJWYilyWrzhzbP8Tweyq o7N7pQiGgqgXbs4PqCITY7ebXe4H9fkbgVkIuZuxROfxoLUan2cA4/EzARvKXzk14GUu 2m0xErZBu5CwM6hSeoL80PVPTBPFzOGfiqIg9j3Ig4VWLAQskiudaPqLyhgzyp6TlckT NCJ9MrdzxBm8Icb2PznFkrYQ6NcMbQWKyWmwmDEBnn23lO1WjEknXBX6aeBYgjcRq6RB evAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1-v6si4423424plb.430.2018.04.04.16.35.30; Wed, 04 Apr 2018 16:35:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbeDDXc7 (ORCPT + 99 others); Wed, 4 Apr 2018 19:32:59 -0400 Received: from terminus.zytor.com ([198.137.202.136]:57665 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbeDDXc5 (ORCPT ); Wed, 4 Apr 2018 19:32:57 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w34NVUxs4132950; Wed, 4 Apr 2018 16:31:30 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w34NVSjG4132947; Wed, 4 Apr 2018 16:31:28 -0700 Date: Wed, 4 Apr 2018 16:31:28 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sai Praneeth Message-ID: Cc: jlee@suse.com, ravi.v.shankar@intel.com, matt@codeblueprint.co.uk, a.p.zijlstra@chello.nl, luto@kernel.org, akpm@linux-foundation.org, tony.luck@intel.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, dave.hansen@intel.com, mst@redhat.com, ricardo.neri@intel.com, sai.praneeth.prakhya@intel.com, hpa@zytor.com, ard.biesheuvel@linaro.org, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de Reply-To: hpa@zytor.com, ard.biesheuvel@linaro.org, tglx@linutronix.de, peterz@infradead.org, bp@alien8.de, a.p.zijlstra@chello.nl, matt@codeblueprint.co.uk, jlee@suse.com, ravi.v.shankar@intel.com, luto@kernel.org, tony.luck@intel.com, akpm@linux-foundation.org, mingo@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, sai.praneeth.prakhya@intel.com, ricardo.neri@intel.com, mst@redhat.com, dave.hansen@intel.com In-Reply-To: <1522870459-7432-1-git-send-email-sai.praneeth.prakhya@intel.com> References: <1522870459-7432-1-git-send-email-sai.praneeth.prakhya@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/urgent] x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush() Git-Commit-ID: 162ee5a8ab49be40d253f90e94aef712470a3a24 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 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 162ee5a8ab49be40d253f90e94aef712470a3a24 Gitweb: https://git.kernel.org/tip/162ee5a8ab49be40d253f90e94aef712470a3a24 Author: Sai Praneeth AuthorDate: Wed, 4 Apr 2018 12:34:19 -0700 Committer: Ingo Molnar CommitDate: Thu, 5 Apr 2018 01:27:49 +0200 x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush() Linus reported the following boot warning: WARNING: CPU: 0 PID: 0 at arch/x86/include/asm/tlbflush.h:134 load_new_mm_cr3+0x114/0x170 [...] Call Trace: switch_mm_irqs_off+0x267/0x590 switch_mm+0xe/0x20 efi_switch_mm+0x3e/0x50 efi_enter_virtual_mode+0x43f/0x4da start_kernel+0x3bf/0x458 secondary_startup_64+0xa5/0xb0 ... after merging: 03781e40890c: x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3 When the platform supports PCID and if CONFIG_DEBUG_VM=y is enabled, build_cr3_noflush() (called via switch_mm()) does a sanity check to see if X86_FEATURE_PCID is set. Presently, build_cr3_noflush() uses "this_cpu_has(X86_FEATURE_PCID)" to perform the check but this_cpu_has() works only after SMP is initialized (i.e. per cpu cpu_info's should be populated) and this happens to be very late in the boot process (during rest_init()). As efi_runtime_services() are called during (early) kernel boot time and run time, modify build_cr3_noflush() to use boot_cpu_has() all the time. As suggested by Dave Hansen, this should be OK because all CPU's have same capabilities on x86. With this change the warning is fixed. ( Dave also suggested that we put a warning in this_cpu_has() if it's used early in the boot process. This is still work in progress as it affects MCE. ) Reported-by: Linus Torvalds Signed-off-by: Sai Praneeth Prakhya Cc: Andrew Morton Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Dave Hansen Cc: Lee Chun-Yi Cc: Matt Fleming Cc: Michael S. Tsirkin Cc: Peter Zijlstra Cc: Peter Zijlstra Cc: Ravi Shankar Cc: Ricardo Neri Cc: Thomas Gleixner Cc: Tony Luck Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1522870459-7432-1-git-send-email-sai.praneeth.prakhya@intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/tlbflush.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 84137c22fdfa..6690cd3fc8b1 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -131,7 +131,12 @@ static inline unsigned long build_cr3(pgd_t *pgd, u16 asid) static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid) { VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE); - VM_WARN_ON_ONCE(!this_cpu_has(X86_FEATURE_PCID)); + /* + * Use boot_cpu_has() instead of this_cpu_has() as this function + * might be called during early boot. This should work even after + * boot because all CPU's the have same capabilities: + */ + VM_WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_PCID)); return __sme_pa(pgd) | kern_pcid(asid) | CR3_NOFLUSH; }