Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2262220imm; Mon, 28 May 2018 05:01:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp3yAz9aGEgaTg/9tTaoKnm0+65nUChJceYotYtW3Ymr+WfCeDWWM8RsTNj9sADv8LlYXPD X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr10335959pge.169.1527508890300; Mon, 28 May 2018 05:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527508890; cv=none; d=google.com; s=arc-20160816; b=QZ0LCk6IS0sQo4vu487kVLsTdTgapNfuH76++ZKBUASqjx9mQS63We2/bkefmVYi93 jROtsvvE89oEcadYJh3zzas1VYrb7C+tc77tgU7OLFvFrX4jPdaPGmIk8OMSybsjCzHu eSjhxNaMNeL3Qbk8+fci2IHECjrCQIpipbYyfr6SjoTSun8OCCp9D9K2carwZZFbHGCk o0fRx6vF732tZzdq3k6R5zrSy1tZGLOp+XoDSdT+rs3JMylmuD9NpfeH010q/SodPt7T hMh4ugJknEODLVstGCxTvar5CdLQCWFty6dqauADasgfGCY6e8JAzPiR7/nO3D3xUINT ofSg== 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=9ryDp1FlmddKvWt06XoJpN9GGbiPt22Df8wvX8KMh74=; b=b/6lLS3X20On6OnzZ7DRZgtovcmqeXIL7GshS3WooieGgX7dfSd35cGYtVCrNhJ1rk DQVKOWkahWr+f2+PHc0GnZAX0kCH70A9/BCqi2P6kCbSFENSO6yhhI5QtYz8QzauYNKK Y+iXcoD8f7B1bFRS391NsFX1hX3dPVlJ0FjowpYjLv1ZnBo6WgDaquVvrhpwnZqTnXfx /pINS8Ul3r/mPGqnfEDN7KSFt+pB7S44crMqcYkgPtpcu3vE+0HYc9taR+6y3wD53TlV TZ0nzokd+0QOhidrN0djuwI/Nv/z1LqVdea3TX4E/GYjJkiqnmo6Q1Pt9NL9VVo3edq1 OSBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bVc2es6J; 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 q23-v6si4045309pls.101.2018.05.28.05.01.14; Mon, 28 May 2018 05:01:30 -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=bVc2es6J; 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 S938502AbeE1MAS (ORCPT + 99 others); Mon, 28 May 2018 08:00:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423441AbeE1LHc (ORCPT ); Mon, 28 May 2018 07:07:32 -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 D7034206B7; Mon, 28 May 2018 11:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505651; bh=/+L+s1VxSDku5rctSzWsO+ssiOhNo6Bwzpz7qSDDbKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVc2es6JATh7c95oCeqa0dJ8wrdylnICMPjBeMJZiIZRJ86EAGXPiM0dF2+WDw10B OVn5X2RYaCPjM4blaviqjxQcX65Bikn2uu5d47ownR0AWhJ+h+MqGJze2cI8VFI+C1 yTUNkwqEZ50AXneiVE2vqy42ZVsXw7+TPSbkMXcE= 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.16 078/272] 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:01:51 +0200 Message-Id: <20180528100247.645864018@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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; }