Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3817081ima; Tue, 23 Oct 2018 11:45:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV63uDxTGciuK+F+UoUpfN/PgV57ghV1ul5OtjJ/8mUkcJhkc0bZ/RWazu1v89YIg/32ClJgn X-Received: by 2002:a17:902:9f83:: with SMTP id g3-v6mr17129579plq.27.1540320346945; Tue, 23 Oct 2018 11:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540320346; cv=none; d=google.com; s=arc-20160816; b=mO4Am8YGY0VP53E3aY5Hx8AddMPA/wOFMwfLbmmRKOmB6I2wuxg1klxtWP6NHSrOU8 LoUf3RSbrWHuLsEh3LBH3YBT96gm0dH8x14yX1UM1784S9YnUFdtlfvJ0dT0JjzWT4Cj Ro7WyC1p0MFDXuHZYl3BF+1fypQqfzscfNyG8PoDiI7PMTLV3/QWz7Y50iIwasmwcbxI m3Z/qJDQlFlIqtDtoEARS3hZIbCn2zv++VtPHK1JhwLqlKUBWjm6D+igjJB3bepZHGel 27SjDk7jhG5bz26Se2foB1lVJwtg/l4uod0Lvl4bDBmlyOHcwd4C7AFD7QsHJDRAgOsA JFvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9wivwNVcv7Gm5iaQeay/3rI3jVZQUmj7GSx3kQNuDs8=; b=M8R1kUf6ZNL2YpcmgGJEsFVxvUeYGi8/1eer8hzAo6+MaTlTRNzbIaCBP/FjDVvWzy BttXurjrComvoa853H8chLgoCN9mdCbFMB2KBirxzf+5eZoE0DYIDdI8USETmH5deshS TnVKFHq3KmUeu7zfQvziocFFsJqoJN+flmdZNihNMNPMDvBWlEJj+GyVfwC3X7+ifrV7 qawzkiaLP/e0x/bPoJ4rYpCNE77EK5OLf7tP5njARikIG7jXLE2TeaobbwtnqLMxP79Q PUAEsjteA8dp5Dg/wWAim4+vv1NYJeWGC8l0d8TAiR9XmPjH1XT02FSzKaVsxT28QSrr A0KQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si1772299pln.175.2018.10.23.11.45.30; Tue, 23 Oct 2018 11:45:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728979AbeJXDIP (ORCPT + 99 others); Tue, 23 Oct 2018 23:08:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:55091 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728900AbeJXDIE (ORCPT ); Tue, 23 Oct 2018 23:08:04 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2018 11:43:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,417,1534834800"; d="scan'208";a="243726597" Received: from chang-linux-2.sc.intel.com ([10.3.52.139]) by orsmga004.jf.intel.com with ESMTP; 23 Oct 2018 11:43:29 -0700 From: "Chang S. Bae" To: Ingo Molnar , Thomas Gleixner , Andy Lutomirski , "H . Peter Anvin" Cc: Andi Kleen , Dave Hansen , Markus T Metzger , Ravi Shankar , "Chang S . Bae" , LKML Subject: [v3 10/12] x86/fsgsbase/64: Enable FSGSBASE by default and add a chicken bit Date: Tue, 23 Oct 2018 11:42:32 -0700 Message-Id: <20181023184234.14025-11-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023184234.14025-1-chang.seok.bae@intel.com> References: <20181023184234.14025-1-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Lutomirski Now that FSGSBASE is fully supported, remove unsafe_fsgsbase, enable FSGSBASE by default, and add nofsgsbase to disable it. Signed-off-by: Andy Lutomirski Signed-off-by: Chang S. Bae Reviewed-by: Andi Kleen Cc: H. Peter Anvin Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Dave Hansen --- .../admin-guide/kernel-parameters.txt | 3 +- arch/x86/kernel/cpu/common.c | 35 ++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index dfc2023b796b..72ed1a5ed832 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2729,8 +2729,7 @@ no5lvl [X86-64] Disable 5-level paging mode. Forces kernel to use 4-level paging instead. - unsafe_fsgsbase [X86] Allow FSGSBASE instructions. This will be - replaced with a nofsgsbase flag. + nofsgsbase [X86] Disables FSGSBASE instructions. no_console_suspend [HW] Never suspend the console diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 6c54e6d2fdfb..f20edc754532 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -365,24 +365,21 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c) cr4_clear_bits(X86_CR4_UMIP); } -/* - * Temporary hack: FSGSBASE is unsafe until a few kernel code paths are - * updated. This allows us to get the kernel ready incrementally. Setting - * unsafe_fsgsbase and TAINT_INSECURE flags will allow the series to be - * bisected if necessary. - * - * Once all the pieces are in place, these will go away and be replaced with - * a nofsgsbase chicken flag. - */ -static bool unsafe_fsgsbase; - -static __init int setup_unsafe_fsgsbase(char *arg) +static __init int x86_nofsgsbase_setup(char *arg) { - unsafe_fsgsbase = true; - add_taint(TAINT_INSECURE, LOCKDEP_STILL_OK); + /* Require an exact match without trailing characters. */ + if (strlen(arg)) + return 0; + + /* Do not emit a message if the feature is not present. */ + if (!boot_cpu_has(X86_FEATURE_FSGSBASE)) + return 1; + + setup_clear_cpu_cap(X86_FEATURE_FSGSBASE); + pr_info("nofsgsbase: FSGSBASE disabled\n"); return 1; } -__setup("unsafe_fsgsbase", setup_unsafe_fsgsbase); +__setup("nofsgsbase", x86_nofsgsbase_setup); /* * Protection Keys are not available in 32-bit mode. @@ -1372,12 +1369,8 @@ static void identify_cpu(struct cpuinfo_x86 *c) setup_umip(c); /* Enable FSGSBASE instructions if available. */ - if (cpu_has(c, X86_FEATURE_FSGSBASE)) { - if (unsafe_fsgsbase) - cr4_set_bits(X86_CR4_FSGSBASE); - else - clear_cpu_cap(c, X86_FEATURE_FSGSBASE); - } + if (cpu_has(c, X86_FEATURE_FSGSBASE)) + cr4_set_bits(X86_CR4_FSGSBASE); /* * The vendor-specific functions might have changed features. -- 2.19.1