Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp743790ima; Fri, 15 Mar 2019 13:08:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJnCIoKFnoT0rOiX+Js60sYwbKjC0XPsnxIPPM9q6/cK+AC5nu8SsnsccYxxJ0MZmRXtGe X-Received: by 2002:a62:bd09:: with SMTP id a9mr5791582pff.61.1552680522711; Fri, 15 Mar 2019 13:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552680522; cv=none; d=google.com; s=arc-20160816; b=WqafcL6l5mYoxfBHy4OcH5xYKCUoe68UMlRCzKXaZqeFMwAix3ifgiD8layDeeNrda wZgCTVEqkDpA8ds3328QSItcXuItSy9TPEyNPogv9wsAsZY7CNPloZziZyhGwcntfd7D xS/9avgqBS3iXhW8S5BtkE82gBKfcqrb2yUr5hOuxgKQQgrD+J9vpDmRtTKuUupJCj8a 1EMlUQreXsqXaCesDkDjlNowpxuIH6mFYNV0CBEWk49XetIcSba6F+QAamoXpyK3yejC Y8nswQ+OirXxdswJl1mJYITrQP83e6DDdqtc8bflucfyqezrJ8/cl4eyN4Y8k+5vT2jv ScsQ== 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=jBdIreYWc2NRhceVUidvBhNzPiHfq6pC3uCjAuaoOUk=; b=0S+B8q7PJ+vCgKrdJF4NWg/8qZpSfx7fYkHrA6gZRJrLzWNAUBdC3v3pFlyFJ7KsS+ 7FtMR9JNPbmrvB7ou010v4o5q8blaOj0pQnBBOUO31rY4vTX8Ixr6a5l8qiQ/Var61wP F2ua+rl4Z2/jg7I0+Wq0VxQcbQ/weTfXc2q4Zxu1PB+LCt6YdtT4uRuQqBDZG3E9sNEG T935TgUSgVCYufbCAJ8WyYBI+zY0YrkuCx1bcssVCrhoCkl/MTM9EC+1AGiwqyWWKF0M JYlszJas3UnTiiNPANJP5qrjKnSbZcDNgFJPoeyzxB0yamjT8OD9Vv8rQmqyoitH9EWo w14A== 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 o10si2470316pgp.483.2019.03.15.13.08.27; Fri, 15 Mar 2019 13:08:42 -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 S1726915AbfCOUHc (ORCPT + 99 others); Fri, 15 Mar 2019 16:07:32 -0400 Received: from mga01.intel.com ([192.55.52.88]:22903 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbfCOUHF (ORCPT ); Fri, 15 Mar 2019 16:07:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2019 13:07:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,483,1544515200"; d="scan'208";a="307617731" Received: from chang-linux-3.sc.intel.com ([143.183.85.65]) by orsmga005.jf.intel.com with ESMTP; 15 Mar 2019 13:07:04 -0700 From: "Chang S. Bae" To: Thomas Gleixner , Ingo Molnar , Andy Lutomirski , "H . Peter Anvin" , Andi Kleen Cc: Ravi Shankar , "Chang S . Bae" , LKML Subject: [RESEND PATCH v6 10/12] x86/fsgsbase/64: Enable FSGSBASE by default and add a chicken bit Date: Fri, 15 Mar 2019 13:06:43 -0700 Message-Id: <1552680405-5265-11-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552680405-5265-1-git-send-email-chang.seok.bae@intel.com> References: <1552680405-5265-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 Cc: Thomas Gleixner Cc: Ingo Molnar --- .../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 b6ed956a78ab..29e6924ac957 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2765,8 +2765,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 40a2f60e7251..3d7d4ca1a29e 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -365,21 +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. - * - * 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("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. @@ -1369,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