Received: by 10.213.65.68 with SMTP id h4csp1810926imn; Mon, 19 Mar 2018 13:58:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJ6zBm4RDBotl+RKV0n4bdkQyqJHjwGWEBcJruK0WZiMAf9aN/BMfEbWiGjN6HfJrOcv32 X-Received: by 10.99.124.25 with SMTP id x25mr10399362pgc.46.1521493094807; Mon, 19 Mar 2018 13:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521493094; cv=none; d=google.com; s=arc-20160816; b=LjyCeMs0gF6gvTdsNIGyAtDnX3nfEphTjNXj3LFR6xDALSap8SHlAfpdjcNHIEr0pH 5bb2CD7m7BSTN2t08iMTynS6B5eKQJ+aV9OePL317mWViPtTymZApLTqeroAguNCioKg 1g4+dMPDjnAL4aXGMDTGcRXaBWibGrKhdaGvKE944Qfx0HBKzExQAzutirMDHYTO4zfn CqZpOR3TiJWeUG7V5+ynf8Ch6f65lDoA9HkyRbOzYj07J7z1vX/9hTGMunq2I5IQjbum X7hVNT/I502ul7k5jdKeL8ErLOZXL2YJxGUWaXAO8aPC6lmS5kqZPunA3+mAv0E66HsS R57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=UC8xB9mV5lYMeDXh/c50wQbdHit7Vsjcw9vdLes66x8=; b=FB6WLUdVfoQIqJIREphUrLNm4nIVqf0lZY1CmixRTkXsqf8HmYHCr1UJxIUa/R2b0s rWu+EcEix14JeVW/VM0t5j1RV5ovu+SAg9S7DAPP5DFaT3IFCDmdfZEluvtD33oOWx/E 4BzzCl9hCUPKD7FA+kvctm337EcVXYNt/7q4NfXqFqYnvUMljW8ILDBtO5D1l2Tqgs8Y h93wgwS04+fmig9YdIiMQGdAkw+OrLmxXMEeeA90Po+BAss3TlZMKAedCla3l44jlbJP w7VhqwrvRRAQ7dt9h+y/pB2wpi2tYQKLznKxZ9m8osxLNmhdzFT86v/L44Y7zGuACnHq ugZg== 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 s78si29416pfa.374.2018.03.19.13.57.30; Mon, 19 Mar 2018 13:58:14 -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 S971630AbeCSUxe (ORCPT + 99 others); Mon, 19 Mar 2018 16:53:34 -0400 Received: from mga14.intel.com ([192.55.52.115]:62509 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968557AbeCSSI5 (ORCPT ); Mon, 19 Mar 2018 14:08:57 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2018 11:08:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,331,1517904000"; d="scan'208";a="39330611" Received: from chang-linux.sc.intel.com ([143.183.85.144]) by fmsmga001.fm.intel.com with ESMTP; 19 Mar 2018 11:08:55 -0700 From: "Chang S. Bae" To: x86@kernel.org Cc: luto@kernel.org, ak@linux.intel.com, hpa@zytor.com, markus.t.metzger@intel.com, tony.luck@intel.com, ravi.v.shankar@intel.com, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com Subject: [PATCH 15/15] x86/fsgsbase/64: Enable FSGSBASE by default and add a chicken bit Date: Mon, 19 Mar 2018 10:49:27 -0700 Message-Id: <1521481767-22113-16-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521481767-22113-1-git-send-email-chang.seok.bae@intel.com> References: <1521481767-22113-1-git-send-email-chang.seok.bae@intel.com> 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 --- Documentation/admin-guide/kernel-parameters.txt | 3 +-- arch/x86/kernel/cpu/common.c | 33 +++++++++++-------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 87c2260..433dd17 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2567,8 +2567,7 @@ emulation library even if a 387 maths coprocessor is present. - 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 019bdc3..f9b7eba 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -355,22 +355,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 will allow the series to be bisected if necessary. - * - * Once all the pieces are in place, this 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; + /* 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. @@ -1256,12 +1255,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.7.4