]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - arch/x86/mm/pti.c
x86/pti: Add the pti= cmdline option and documentation
[mirror_ubuntu-artful-kernel.git] / arch / x86 / mm / pti.c
index 375f23a758bcbb222997152aa53bdb72c25c5412..a13f6b1098651a2777de81e403ae8e61350df66a 100644 (file)
@@ -54,21 +54,45 @@ static void __init pti_print_if_insecure(const char *reason)
                pr_info("%s\n", reason);
 }
 
+static void __init pti_print_if_secure(const char *reason)
+{
+       if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
+               pr_info("%s\n", reason);
+}
+
 void __init pti_check_boottime_disable(void)
 {
+       char arg[5];
+       int ret;
+
        if (hypervisor_is_type(X86_HYPER_XEN_PV)) {
                pti_print_if_insecure("disabled on XEN PV.");
                return;
        }
 
+       ret = cmdline_find_option(boot_command_line, "pti", arg, sizeof(arg));
+       if (ret > 0)  {
+               if (ret == 3 && !strncmp(arg, "off", 3)) {
+                       pti_print_if_insecure("disabled on command line.");
+                       return;
+               }
+               if (ret == 2 && !strncmp(arg, "on", 2)) {
+                       pti_print_if_secure("force enabled on command line.");
+                       goto enable;
+               }
+               if (ret == 4 && !strncmp(arg, "auto", 4))
+                       goto autosel;
+       }
+
        if (cmdline_find_option_bool(boot_command_line, "nopti")) {
                pti_print_if_insecure("disabled on command line.");
                return;
        }
 
+autosel:
        if (!boot_cpu_has_bug(X86_BUG_CPU_INSECURE))
                return;
-
+enable:
        setup_force_cpu_cap(X86_FEATURE_PTI);
 }