Skip to content

Commit b745cfb

Browse files
amlutoKAGA-KOKO
authored andcommitted
x86/cpu: Enable FSGSBASE on 64bit by default and add a chicken bit
Now that FSGSBASE is fully supported, remove unsafe_fsgsbase, enable FSGSBASE by default, and add nofsgsbase to disable it. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Chang S. Bae <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent c82965f commit b745cfb

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,8 +3079,7 @@
30793079
no5lvl [X86-64] Disable 5-level paging mode. Forces
30803080
kernel to use 4-level paging instead.
30813081

3082-
unsafe_fsgsbase [X86] Allow FSGSBASE instructions. This will be
3083-
replaced with a nofsgsbase flag.
3082+
nofsgsbase [X86] Disables FSGSBASE instructions.
30843083

30853084
no_console_suspend
30863085
[HW] Never suspend the console

arch/x86/kernel/cpu/common.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,21 +441,21 @@ static void __init setup_cr_pinning(void)
441441
static_key_enable(&cr_pinning.key);
442442
}
443443

444-
/*
445-
* Temporary hack: FSGSBASE is unsafe until a few kernel code paths are
446-
* updated. This allows us to get the kernel ready incrementally.
447-
*
448-
* Once all the pieces are in place, these will go away and be replaced with
449-
* a nofsgsbase chicken flag.
450-
*/
451-
static bool unsafe_fsgsbase;
452-
453-
static __init int setup_unsafe_fsgsbase(char *arg)
444+
static __init int x86_nofsgsbase_setup(char *arg)
454445
{
455-
unsafe_fsgsbase = true;
446+
/* Require an exact match without trailing characters. */
447+
if (strlen(arg))
448+
return 0;
449+
450+
/* Do not emit a message if the feature is not present. */
451+
if (!boot_cpu_has(X86_FEATURE_FSGSBASE))
452+
return 1;
453+
454+
setup_clear_cpu_cap(X86_FEATURE_FSGSBASE);
455+
pr_info("FSGSBASE disabled via kernel command line\n");
456456
return 1;
457457
}
458-
__setup("unsafe_fsgsbase", setup_unsafe_fsgsbase);
458+
__setup("nofsgsbase", x86_nofsgsbase_setup);
459459

460460
/*
461461
* Protection Keys are not available in 32-bit mode.
@@ -1512,12 +1512,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
15121512
setup_umip(c);
15131513

15141514
/* Enable FSGSBASE instructions if available. */
1515-
if (cpu_has(c, X86_FEATURE_FSGSBASE)) {
1516-
if (unsafe_fsgsbase)
1517-
cr4_set_bits(X86_CR4_FSGSBASE);
1518-
else
1519-
clear_cpu_cap(c, X86_FEATURE_FSGSBASE);
1520-
}
1515+
if (cpu_has(c, X86_FEATURE_FSGSBASE))
1516+
cr4_set_bits(X86_CR4_FSGSBASE);
15211517

15221518
/*
15231519
* The vendor-specific functions might have changed features.

0 commit comments

Comments
 (0)