]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/speculation: parse l1tf boot parameter early
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Mon, 13 Aug 2018 00:45:49 +0000 (20:45 -0400)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Mon, 13 Aug 2018 01:24:34 +0000 (21:24 -0400)
early_param() is too late for us to use for parsing "l1tf" boot parameter,
we should do it similarly to how spectre_v2_select_mitigation() and
ssbd_ibrs_selected() do it.

Orabug: 28491688

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/kernel/cpu/bugs_64.c

index 831365e63e6d191eef1cf57332f269ed64b339bf..cb6f314bb60eb900c374c6ed0b29fcf835e5c17e 100644 (file)
@@ -972,6 +972,32 @@ enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO;
 EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation);
 #endif
 
+static void __init parse_l1tf_cmdline(void)
+{
+       char arg[12];
+       int ret;
+
+       ret = cmdline_find_option(boot_command_line, "l1tf", arg,
+                                 sizeof(arg));
+       if (ret <= 0)
+               return;
+
+       if (match_option(arg, ret, "off"))
+               l1tf_mitigation = L1TF_MITIGATION_OFF;
+       else if (match_option(arg, ret, "flush,nowarn"))
+               l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOWARN;
+       else if (match_option(arg, ret, "flush"))
+               l1tf_mitigation = L1TF_MITIGATION_FLUSH;
+       else if (match_option(arg, ret, "flush,nosmt"))
+               l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
+       else if (match_option(arg, ret, "full"))
+               l1tf_mitigation = L1TF_MITIGATION_FULL;
+       else if (match_option(arg, ret, "full,force"))
+               l1tf_mitigation = L1TF_MITIGATION_FULL_FORCE;
+       else
+               pr_warn("l1tf: unknown option %s\n", arg);
+}
+
 static void __init l1tf_select_mitigation(void)
 {
        u64 half_pa;
@@ -979,6 +1005,8 @@ static void __init l1tf_select_mitigation(void)
        if (!boot_cpu_has_bug(X86_BUG_L1TF))
                return;
 
+       parse_l1tf_cmdline();
+
        switch (l1tf_mitigation) {
        case L1TF_MITIGATION_OFF:
        case L1TF_MITIGATION_FLUSH_NOWARN:
@@ -1012,31 +1040,6 @@ static void __init l1tf_select_mitigation(void)
        setup_force_cpu_cap(X86_FEATURE_L1TF_PTEINV);
 }
 
-static int __init l1tf_cmdline(char *str)
-{
-       if (!boot_cpu_has_bug(X86_BUG_L1TF))
-               return 0;
-
-       if (!str)
-               return -EINVAL;
-
-       if (!strcmp(str, "off"))
-               l1tf_mitigation = L1TF_MITIGATION_OFF;
-       else if (!strcmp(str, "flush,nowarn"))
-               l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOWARN;
-       else if (!strcmp(str, "flush"))
-               l1tf_mitigation = L1TF_MITIGATION_FLUSH;
-       else if (!strcmp(str, "flush,nosmt"))
-               l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
-       else if (!strcmp(str, "full"))
-               l1tf_mitigation = L1TF_MITIGATION_FULL;
-       else if (!strcmp(str, "full,force"))
-               l1tf_mitigation = L1TF_MITIGATION_FULL_FORCE;
-
-       return 0;
-}
-early_param("l1tf", l1tf_cmdline);
-
 #undef pr_fmt
 
 #ifdef CONFIG_SYSFS