Skip to content

Commit 41f4c20

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
x86/pti: Add the pti= cmdline option and documentation
Keep the "nopti" optional for traditional reasons. [ tglx: Don't allow force on when running on XEN PV and made 'on' printout conditional ] Requested-by: Linus Torvalds <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Andy Lutomirsky <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Laight <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Greg KH <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent aa8c624 commit 41f4c20

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,6 +3255,12 @@
32553255
pt. [PARIDE]
32563256
See Documentation/blockdev/paride.txt.
32573257

3258+
pti= [X86_64]
3259+
Control user/kernel address space isolation:
3260+
on - enable
3261+
off - disable
3262+
auto - default setting
3263+
32583264
pty.legacy_count=
32593265
[KNL] Number of legacy pty's. Overwrites compiled-in
32603266
default number.

arch/x86/mm/pti.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,45 @@ static void __init pti_print_if_insecure(const char *reason)
5454
pr_info("%s\n", reason);
5555
}
5656

57+
static void __init pti_print_if_secure(const char *reason)
58+
{
59+
if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
60+
pr_info("%s\n", reason);
61+
}
62+
5763
void __init pti_check_boottime_disable(void)
5864
{
65+
char arg[5];
66+
int ret;
67+
5968
if (hypervisor_is_type(X86_HYPER_XEN_PV)) {
6069
pti_print_if_insecure("disabled on XEN PV.");
6170
return;
6271
}
6372

73+
ret = cmdline_find_option(boot_command_line, "pti", arg, sizeof(arg));
74+
if (ret > 0) {
75+
if (ret == 3 && !strncmp(arg, "off", 3)) {
76+
pti_print_if_insecure("disabled on command line.");
77+
return;
78+
}
79+
if (ret == 2 && !strncmp(arg, "on", 2)) {
80+
pti_print_if_secure("force enabled on command line.");
81+
goto enable;
82+
}
83+
if (ret == 4 && !strncmp(arg, "auto", 4))
84+
goto autosel;
85+
}
86+
6487
if (cmdline_find_option_bool(boot_command_line, "nopti")) {
6588
pti_print_if_insecure("disabled on command line.");
6689
return;
6790
}
6891

92+
autosel:
6993
if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
7094
return;
71-
95+
enable:
7296
setup_force_cpu_cap(X86_FEATURE_PTI);
7397
}
7498

0 commit comments

Comments
 (0)