diff mbox series

[SRU,Xenial,3/3] UBUNTU: SAUCE: x86/speculation: Move RSB_CTXSW hunk

Message ID 20181121135831.25405-4-juergh@canonical.com
State New
Headers show
Series [SRU,Xenial,1/3] UBUNTU: SAUCE: x86/speculation: Cleanup IBPB runtime control handling | expand

Commit Message

Juerg Haefliger Nov. 21, 2018, 1:58 p.m. UTC
Move the RSB_CTXSW hunk further up in spectre_v2_select_mitigation() to
match upstream. No functional changes.

CVE-2017-5715

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 arch/x86/kernel/cpu/bugs.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Tyler Hicks Nov. 30, 2018, 8:05 p.m. UTC | #1
On 2018-11-21 14:58:31, Juerg Haefliger wrote:
> Move the RSB_CTXSW hunk further up in spectre_v2_select_mitigation() to
> match upstream. No functional changes.
> 
> CVE-2017-5715
> 
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>

Acked-by: Tyler Hicks <tyhicks@canonical.com>

Tyler
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a4565038ab35..60907abf12f5 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -410,6 +410,17 @@  specv2_set_mode:
 	spectre_v2_enabled = mode;
 	pr_info("%s\n", spectre_v2_strings[mode]);
 
+	/*
+	 * If spectre v2 protection has been enabled, unconditionally fill
+	 * RSB during a context switch; this protects against two independent
+	 * issues:
+	 *
+	 *	- RSB underflow (and switch to BTB) on Skylake+
+	 *	- SpectreRSB variant of spectre v2 on X86_BUG_SPECTRE_V2 CPUs
+	 */
+	setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW);
+	pr_info("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n");
+
 	/*
 	 * Initialize Indirect Branch Prediction Barrier if supported and not
 	 * disabled on the commandline
@@ -424,17 +435,6 @@  specv2_set_mode:
 		}
 	}
 
-	/*
-	 * If spectre v2 protection has been enabled, unconditionally fill
-	 * RSB during a context switch; this protects against two independent
-	 * issues:
-	 *
-	 *	- RSB underflow (and switch to BTB) on Skylake+
-	 *	- SpectreRSB variant of spectre v2 on X86_BUG_SPECTRE_V2 CPUs
-	 */
-	setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW);
-	pr_info("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n");
-
 	/*
 	 * Retpoline means the kernel is safe because it has no indirect
 	 * branches. Enhanced IBRS protects firmware too, so, enable restricted