Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2306939imm; Mon, 28 May 2018 05:48:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrI7UPuMS29hRoCUHGIFSq801hE36SFjiBx2X3ZSnA6QYD+PKBRnY5zmoQB+5Cwed51Cupe X-Received: by 2002:a63:7f4e:: with SMTP id p14-v6mr10404905pgn.27.1527511681360; Mon, 28 May 2018 05:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511681; cv=none; d=google.com; s=arc-20160816; b=TLQN5mz9vAxq0TgOO8z3CXxwoq2sJCM1fHolELEkqH/JWGqPVenTOuoyZrRtYLoRoo +DQInu3aDM1PuObFkgX3bo0x41v9B0ha4s7yvtVMpiEhMIK8Th0OYKRDapjzz9aBMjyw leqcLcdQLJhHu+J4wEapBtS8GBVyyrVFISutheP8dzvUFBIaQ22vYSzsvPHa+QRC3W1N RnV+U9QUEZ3NPqYo+tIj5G/VanCsRc4Pg6ZmqrdQRpRO/KLgIHL2BKvvvgx8JBkxWtkd Xci5Zq6+XRKErNsEAMXxy9VAmTRP/KvorMeSD+Tf4M67lCD9QSPQjV436k2RE728Gimv 98yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=sfJZjI4rV70GSLOU4E1I3P5BGv9BKI1KiKpH0Uo91u0=; b=cJwMiZVt7Faxs3TQLVY+QA6YshOIqfqaokxYbREblVVlyi1DLep6ZVaj2OEW5PQUr2 juPb7gLacZxTmGynpJrBm59/jpyRBAv8/U2EhwGngWnCrqiHkg0IMk9xJF1W2Sp1U/cD c5oufd3K8VBNV6J58c8mpnJCCz31ZdK2BDbIBAXib246ihX5yn3TIUcjlNRwpxa17/OJ dcgTK0ayFd48qOOyER8THFLaliUMrXBn/25ZsmuxtcF1GxaULd5pJQWhNMjxODvlAvDo 5AMDg5O3TJMo6sAEyVAE9R4xzj23476Uhqcq7ZcipRW3BMhk2mohd215o/FacYOdGtgS HhOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZHM2lhbt; 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 q3-v6si13618256plb.529.2018.05.28.05.47.46; Mon, 28 May 2018 05:48:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZHM2lhbt; 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 S937631AbeE1K5T (ORCPT + 99 others); Mon, 28 May 2018 06:57:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:45266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937377AbeE1K5A (ORCPT ); Mon, 28 May 2018 06:57:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 81739208A1; Mon, 28 May 2018 10:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505020; bh=OWzpU3Vgjx3n723HT2CmmSwA9PGdaPyd4uV40p4RDpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZHM2lhbtz3ONro8h2saRtIf3+Qvtv4pNd1xbkTlD51EpbSe066fhLSB91ZF9/dvAO ZS5N4i45N2uYTG4fIVoWbf4m+abJms+NqMyFeNI10RVjZNiHR85otG7wSTNQUj5aYb RztdPUz3F4WrHCBxDFFfOkflCqAXlTKN+Qduxkis= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds , Sai Praneeth Prakhya , Andrew Morton , Andy Lutomirski , Ard Biesheuvel , Borislav Petkov , Dave Hansen , Lee Chun-Yi , Matt Fleming , "Michael S. Tsirkin" , Peter Zijlstra , Peter Zijlstra , Ravi Shankar , Ricardo Neri , Thomas Gleixner , Tony Luck , linux-efi@vger.kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 345/496] x86/mm: Fix bogus warning during EFI bootup, use boot_cpu_has() instead of this_cpu_has() in build_cr3_noflush() Date: Mon, 28 May 2018 12:02:10 +0200 Message-Id: <20180528100334.344786377@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sai Praneeth [ Upstream commit 162ee5a8ab49be40d253f90e94aef712470a3a24 ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/tlbflush.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -131,7 +131,12 @@ static inline unsigned long build_cr3(pg 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; }