Skip to content

Commit 8a25334

Browse files
suryasaimadhugregkh
authored andcommitted
x86/pti: Add the pti= cmdline option and documentation
commit 41f4c20 upstream. 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 <torvalds@linux-foundation.org> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirsky <luto@kernel.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Laight <David.Laight@aculab.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Eduardo Valentin <eduval@amazon.com> Cc: Greg KH <gregkh@linuxfoundation.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Will Deacon <will.deacon@arm.com> Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Link: https://lkml.kernel.org/r/20171212133952.10177-1-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a4b07fb commit 8a25334

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎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)