Commit 760cb32c authored by Ingo Molnar's avatar Ingo Molnar Committed by Kleber Sacilotto de Souza

x86/speculation: Clean up various Spectre related details

BugLink: https://bugs.launchpad.net/bugs/1791080

commit 21e433bd upstream.

Harmonize all the Spectre messages so that a:

    dmesg | grep -i spectre

... gives us most Spectre related kernel boot messages.

Also fix a few other details:

 - clarify a comment about firmware speculation control

 - s/KPTI/PTI

 - remove various line-breaks that made the code uglier
Acked-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSrivatsa S. Bhat <srivatsa@csail.mit.edu>
Reviewed-by: default avatarMatt Helsley (VMware) <matt.helsley@gmail.com>
Reviewed-by: default avatarAlexey Makhalov <amakhalov@vmware.com>
Reviewed-by: default avatarBo Gan <ganb@vmware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 446e05b2
...@@ -283,8 +283,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) ...@@ -283,8 +283,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
if (cmdline_find_option_bool(boot_command_line, "nospectre_v2")) if (cmdline_find_option_bool(boot_command_line, "nospectre_v2"))
return SPECTRE_V2_CMD_NONE; return SPECTRE_V2_CMD_NONE;
else { else {
ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
sizeof(arg));
if (ret < 0) if (ret < 0)
return SPECTRE_V2_CMD_AUTO; return SPECTRE_V2_CMD_AUTO;
...@@ -305,8 +304,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) ...@@ -305,8 +304,7 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
cmd == SPECTRE_V2_CMD_RETPOLINE_AMD || cmd == SPECTRE_V2_CMD_RETPOLINE_AMD ||
cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) && cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) &&
!IS_ENABLED(CONFIG_RETPOLINE)) { !IS_ENABLED(CONFIG_RETPOLINE)) {
pr_err("%s selected but not compiled in. Switching to AUTO select\n", pr_err("%s selected but not compiled in. Switching to AUTO select\n", mitigation_options[i].option);
mitigation_options[i].option);
return SPECTRE_V2_CMD_AUTO; return SPECTRE_V2_CMD_AUTO;
} }
...@@ -359,14 +357,14 @@ static void __init spectre_v2_select_mitigation(void) ...@@ -359,14 +357,14 @@ static void __init spectre_v2_select_mitigation(void)
goto retpoline_auto; goto retpoline_auto;
break; break;
} }
pr_err("kernel not compiled with retpoline; no mitigation available!"); pr_err("Spectre mitigation: kernel not compiled with retpoline; no mitigation available!");
return; return;
retpoline_auto: retpoline_auto:
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
retpoline_amd: retpoline_amd:
if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) { if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) {
pr_err("LFENCE not serializing. Switching to generic retpoline\n"); pr_err("Spectre mitigation: LFENCE not serializing. Switching to generic retpoline\n");
goto retpoline_generic; goto retpoline_generic;
} }
mode = retp_compiler() ? SPECTRE_V2_RETPOLINE_AMD : mode = retp_compiler() ? SPECTRE_V2_RETPOLINE_AMD :
...@@ -386,7 +384,7 @@ static void __init spectre_v2_select_mitigation(void) ...@@ -386,7 +384,7 @@ static void __init spectre_v2_select_mitigation(void)
/* Initialize Indirect Branch Prediction Barrier if supported */ /* Initialize Indirect Branch Prediction Barrier if supported */
if (boot_cpu_has(X86_FEATURE_IBPB)) { if (boot_cpu_has(X86_FEATURE_IBPB)) {
setup_force_cpu_cap(X86_FEATURE_USE_IBPB); setup_force_cpu_cap(X86_FEATURE_USE_IBPB);
pr_info("Enabling Indirect Branch Prediction Barrier\n"); pr_info("Spectre v2 mitigation: Enabling Indirect Branch Prediction Barrier\n");
set_ibpb_supported(); set_ibpb_supported();
if (ibpb_inuse) if (ibpb_inuse)
...@@ -395,14 +393,14 @@ static void __init spectre_v2_select_mitigation(void) ...@@ -395,14 +393,14 @@ static void __init spectre_v2_select_mitigation(void)
/* Initialize Indirect Branch Restricted Speculation if supported */ /* Initialize Indirect Branch Restricted Speculation if supported */
if (boot_cpu_has(X86_FEATURE_IBRS)) { if (boot_cpu_has(X86_FEATURE_IBRS)) {
pr_info("Enabling Indirect Branch Restricted Speculation\n"); pr_info("Spectre v2 mitigation: Enabling Indirect Branch Restricted Speculation\n");
set_ibrs_supported(); set_ibrs_supported();
if (ibrs_inuse) if (ibrs_inuse)
sysctl_ibrs_enabled = 1; sysctl_ibrs_enabled = 1;
} }
pr_info("Speculation control IBPB %s IBRS %s", pr_info("Spectre v2 mitigation: Speculation control IBPB %s IBRS %s",
ibpb_supported ? "supported" : "not-supported", ibpb_supported ? "supported" : "not-supported",
ibrs_supported ? "supported" : "not-supported"); ibrs_supported ? "supported" : "not-supported");
...@@ -827,8 +825,7 @@ ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, c ...@@ -827,8 +825,7 @@ ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, c
return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V1); return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V1);
} }
ssize_t cpu_show_spectre_v2(struct device *dev, ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, char *buf)
struct device_attribute *attr, char *buf)
{ {
return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V2); return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V2);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment