Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp910571ima; Fri, 1 Feb 2019 12:59:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IatF3cqNlGIpHoIXmA7OmNH0A0pKlewGv1zWiEZ4RD/xSG8TZdha5Uksmwq1X+CvyD3ZLS7 X-Received: by 2002:a17:902:4a0c:: with SMTP id w12mr711577pld.8.1549054782565; Fri, 01 Feb 2019 12:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549054782; cv=none; d=google.com; s=arc-20160816; b=VVlqhoJTqL82iEMk08N5dO7ivn423/Byv6us/M58zqqWtLExLjkiwX3sP0UW+gBJZd y8dE8ggJEWdYnLG/0V4F4tDGJu5SQIoP13vf172KV3FhaQic7d8ClDjOziUSqg44ri3h ecEUjBmxX5F7dprsafNrcZ98W4MxTaD03UUv5FgRbQ9VIs16whLalV6C/9D49ohV5VhE EjUcnMtfsNYhAbj6Gb5OWK9Q+TXiAhfWbA7BMwz+NqbrLaV99IQW+oRb1j38dBQVgMJu xlKq4EaCuOryGdZabbu7A6+/4xURcHaMduBpvfsvyJ/FRweMfdPVsaRt6ajqPIWfS7wI RiSQ== 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=GAsKanWl7bfCm+kQBLLhKlw67PAq9ReGlKaGnjC8JAg=; b=sRFgPbmqIylqPEO/7xBIJyQVKeGdzrD0ygTKOjIQC2cNIuLLAqc9YNG2Iomf8rQ2UE QeFmoGXMaBHisGREsrVDSgGANrpu10RRjP90jxUkc6y4Gyzqx4NLO2ugFUnSqT+Yf+8N Tt1hngZigmlK/yP43Nqg/oE/bL88TekIfn9ieIuhTb8WZdjTCEU6eo3rNzSW4kbaQZ/q Z+TWCQemR/pc5Tq2hLfyHjDsZkGQ8eMIfZjQVyRYGyZg5JBDFhdNq7OL0JRm0BXpC49s V/9PlqcVTzbDNp+IUbu7HjGnl5ErCZ745xvXvOf7hEtFLKLLa9PqsLr/+axr9KJuKia5 LotA== 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 a18si7372127pgj.77.2019.02.01.12.59.27; Fri, 01 Feb 2019 12:59:42 -0800 (PST) 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 S1730292AbfBAUzT (ORCPT + 99 others); Fri, 1 Feb 2019 15:55:19 -0500 Received: from mga07.intel.com ([134.134.136.100]:49754 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730577AbfBAUzE (ORCPT ); Fri, 1 Feb 2019 15:55:04 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2019 12:55:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,549,1539673200"; d="scan'208";a="140866396" Received: from chang-linux-2.sc.intel.com ([10.3.52.165]) by fmsmga004.fm.intel.com with ESMTP; 01 Feb 2019 12:55:04 -0800 From: "Chang S. Bae" To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andi Kleen Cc: Markus T Metzger , Ravi Shankar , "Chang S . Bae" , LKML Subject: [PATCH v5 11/13] x86/fsgsbase/64: Enable FSGSBASE by default and add a chicken bit Date: Fri, 1 Feb 2019 12:53:17 -0800 Message-Id: <20190201205319.15995-13-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190201205319.15995-1-chang.seok.bae@intel.com> References: <20190201205319.15995-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 --- .../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 871260e3e832..20ab1ba22a3e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2760,8 +2760,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 6e2cba21328f..3d7d4ca1a29e 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