Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2231232pxk; Sat, 19 Sep 2020 18:38:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/Hvlksai8My1S38eREeypIujzOUj/uYz20fC7XRCrX7mS2XM+PVNU5SCGv6OgRlhpTFoa X-Received: by 2002:a17:906:4a19:: with SMTP id w25mr41710045eju.199.1600565929480; Sat, 19 Sep 2020 18:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600565929; cv=none; d=google.com; s=arc-20160816; b=TmOXOzdWNpvq4VFeVsXLyjBVzOonM95NAn4B/JZ3FTO64Ae6kvm0D5DaQ6G4tr/ufd /dSoyBwuylPq7rJdlswWPnJkinqWhdkfS7uS5ExNkQKDdYcFmUFyFmwX2hFAri1+ZJl0 2+mGhfzMSyX2126AswEF+HsFwLX9HOvlW+6hWxbdZYIbpwmsklc93Cr7Ws3Y5VTFnuX+ 7HGPxc0+wpnmlg1MhsXSl/1JLyea7VD84GPpVZ0Q4WOopdQbwKCaZqiCllCGnWcYznHg uLdArXg4YDSS22i9JbltncFIqz2WFz8yPkAqq0NnRu5sUPmj4FtyXBTbfgAlo9jOk6ph ZX0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cFmIoFao/ySNbSe0TIB5jF7x8DCwot6aqu5CUOPipW0=; b=X+wMjITPg+EjCoKXfA5HJ3M5+Qs5iplsHX0QSWay76no+fd8qY8uL0UbhBSu2XUGAS 48ymF7CIYpp7lV2X1Y7MBIepfCxliTkO/YQtfWf8ziNFDXwJO3ZciPKRhDxPVyPJgO8U 37PpIYV5fCsV7G0tWEMnJ1cAsMDdL6wFnKiEw4V/VhtzT/5xrZ4Hfre8XiJIHTn+XpY7 9DGR5bE701SXloQJ+uafQXizVK0DXVg4n/tFYOzlcgHHYDerLG7GPo1qGewO2FGQ9RTo px+iobwN6tlE6GGLdxC4rp33PrmTb9RQGSOqfp46WOSn9mZjwQnfMuydL7ahQE5ijE14 b2cA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re10si2364265ejb.57.2020.09.19.18.38.09; Sat, 19 Sep 2020 18:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgITBfk (ORCPT + 99 others); Sat, 19 Sep 2020 21:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726759AbgITBfj (ORCPT ); Sat, 19 Sep 2020 21:35:39 -0400 X-Greylist: delayed 1916 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 19 Sep 2020 18:35:39 PDT Received: from vuizook.err.no (vuizook.err.no [IPv6:2a02:20c8:2640::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 612A8C061755 for ; Sat, 19 Sep 2020 18:35:39 -0700 (PDT) Received: from [2400:4160:1877:2b00:4503:de6f:d4c3:660f] (helo=glandium.org) by vuizook.err.no with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJnlQ-0003OW-Fh; Sun, 20 Sep 2020 01:03:39 +0000 Received: from glandium by goemon.lan with local (Exim 4.92) (envelope-from ) id 1kJnlK-0002rY-5p; Sun, 20 Sep 2020 10:03:30 +0900 From: Mike Hommey To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Mike Hommey Subject: [PATCH] x86/boot: Delay BSP init until after FPU initialization Date: Sun, 20 Sep 2020 10:03:10 +0900 Message-Id: <20200920010310.10961-1-mh@glandium.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: (score 2.2): No, score=2.2 required=5.0 tests=RDNS_NONE,SPF_FAIL,SPF_HELO_FAIL autolearn=disabled version=3.4.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org FPU initialization handles the clearcpuid command line argument. If it comes after BSP init, clearcpuid cannot be used to disable features that trigger some parts of the BSP init code. Signed-off-by: Mike Hommey --- arch/x86/kernel/cpu/common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) I was trying to use clearcpuid=440 to disable X86_FEATURES_AMD_SSBD to reproduce the behavior that happens on Zen/Zen+ on a Zen2 machine, but that didn't work because the command line is handled after the setup for X86_FEATURE_LS_CFG_SSBD. I tought about either moving the command line handling earlier, but it seems there wasn't a specific reason for BSP init being earlier than FPU initialization so I went with reordering those instead. diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c5d6f17d9b9d..c3bbca91a14b 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1261,9 +1261,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) c->cpu_index = 0; filter_cpuid_features(c, false); - - if (this_cpu->c_bsp_init) - this_cpu->c_bsp_init(c); } else { setup_clear_cpu_cap(X86_FEATURE_CPUID); } @@ -1276,6 +1273,10 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) fpu__init_system(c); + if (have_cpuid_p()) { + if (this_cpu->c_bsp_init) + this_cpu->c_bsp_init(c); + } #ifdef CONFIG_X86_32 /* * Regardless of whether PCID is enumerated, the SDM says -- 2.28.0