|
@@ -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);
|
|
|
}
|
|
|
|