Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1228165ybp; Fri, 4 Oct 2019 11:21:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzC3A6OrnjBQbyu0aP2mGHvA3ErFk72/uY5KDzn7Jbnt5UJqsJY4ubmIGbzNBlIl9KH0Xiy X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr13307183ejr.294.1570213299192; Fri, 04 Oct 2019 11:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570213299; cv=none; d=google.com; s=arc-20160816; b=mza8d412uW1xEyTRCeaJWhyTrZ0HvGsBrIAkdKNU4ldB4nss4DyQA4QJoix+AN2EuW Z7bVnHb6FzIfy2+bRInhydftTaFtO0Yn1IsjItdJUledRI4foTmzdZWiUO+cw1NL6J5R DM4cGkNLYlZk8LZUGxasCY9fnEjZl6z+vHRJ82eUf7EPlLKvR79QZX6GRiKt5WKgCI/v NwV5agupe1EMfAayLl1LLIMU2H0EwrJXJ8u62cMJ9I0z7eIhyuIupNAATNUdV7KsmuaP d3lhj40/TojNWXrZ1AOw1DzgSJSu2PcrGj3ZATGIw2vkMjSS8SS3NmOAUIrPCapaPBZu Dmrg== 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; bh=fVOWMQ7re98UzVsj5wS1N7b1BKL/af8NHTW7+kTUZlA=; b=Itfv7dzK55XFGOJvH/qRRpScfPgwOJxInF/J8HGL29Fcu1EO7XcarFjy2Q40lClYSQ No63cUuBdmO3/FVbxittZMXsaO5Awy3UmvpXN/uhGSpbWTp/jLkp1oOuu4qsJoOF26+e JFJf746R5L0qr5xO7CvrhxJGRKzx2WZmRQpjsWSrLclpngaKwtBzQVt8IB7vGToPS8YZ 0bTGfogsW4Ts3lfslM9gxFooHut4xjvF0Aj9yukRD3GP3mkn1VHfFO7o1GlssLCnj/0+ OLnfpS9gkuFmIqGICo97+jQGiOE6cte/7z+WBgPckfAvqgvnkKpSsd3CauETsC6QnKWA Lzbw== 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 b50si4289000ede.28.2019.10.04.11.21.15; Fri, 04 Oct 2019 11:21:39 -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 S2389002AbfJDSRS (ORCPT + 99 others); Fri, 4 Oct 2019 14:17:18 -0400 Received: from mga07.intel.com ([134.134.136.100]:15535 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388616AbfJDSRH (ORCPT ); Fri, 4 Oct 2019 14:17:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 11:17:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="204394820" Received: from chang-linux-3.sc.intel.com ([172.25.66.185]) by orsmga002.jf.intel.com with ESMTP; 04 Oct 2019 11:17:06 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, luto@kernel.org Cc: hpa@zytor.com, dave.hansen@intel.com, tony.luck@intel.com, ak@linux.intel.com, ravi.v.shankar@intel.com, chang.seok.bae@intel.com Subject: [PATCH v9 15/17] x86/fsgsbase/64: Enable FSGSBASE on 64bit by default and add a chicken bit Date: Fri, 4 Oct 2019 11:16:07 -0700 Message-Id: <1570212969-21888-16-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1570212969-21888-1-git-send-email-chang.seok.bae@intel.com> References: <1570212969-21888-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: Tony Luck Cc: Thomas Gleixner Cc: Borislav Petkov Cc: Andy Lutomirski Cc: H. Peter Anvin Cc: Dave Hansen Cc: Tony Luck Cc: Andi Kleen --- Changes from v8: * Massaged the print message for FSGSBASE enablement by Thomas. This change was missed in v7. Changes from v7: * No code change * Massaged title by Thomas --- Documentation/admin-guide/kernel-parameters.txt | 3 +-- arch/x86/kernel/cpu/common.c | 32 +++++++++++-------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index eb9a491..a14289a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2899,8 +2899,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 9f57fb0..9b59377bb 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -437,21 +437,21 @@ static void __init setup_cr_pinning(void) static_key_enable(&cr_pinning.key); } -/* - * Temporary hack: FSGSBASE is unsafe until a few kernel code paths are - * updated. This allows us to get the kernel ready incrementally. - * - * 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; + /* 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("FSGSBASE disabled via kernel command line\n"); return 1; } -__setup("unsafe_fsgsbase", setup_unsafe_fsgsbase); +__setup("nofsgsbase", x86_nofsgsbase_setup); /* * Protection Keys are not available in 32-bit mode. @@ -1472,12 +1472,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