From f0c867593ede55a01346013ddfd941ad2035d0e7 Mon Sep 17 00:00:00 2001 From: Tim Chen Date: Thu, 21 Dec 2017 21:02:51 -0500 Subject: [PATCH] x86/mm: Set IBPB upon context switch Set IBPB on context switch with changing of page table. Orabug: 27344012 CVE: CVE-2017-5715 Signed-off-by: Tim Chen Signed-off-by: Konrad Rzeszutek Wilk [Backport needs an asm/microcode.h to include the native_wrmsrl] Reviewed-by: John Haxby Signed-off-by: Kirtikar Kashyap --- arch/x86/include/asm/mmu_context.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 73e38f14ddeb..517c3998d7e4 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -11,6 +11,7 @@ #include #include #include +#include #ifndef CONFIG_PARAVIRT static inline void paravirt_activate_mm(struct mm_struct *prev, struct mm_struct *next) @@ -97,6 +98,9 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, { unsigned cpu = smp_processor_id(); + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) + native_wrmsrl(MSR_IA32_PRED_CMD, FEATURE_SET_IBPB); + if (likely(prev != next)) { #ifdef CONFIG_SMP this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK); -- 2.50.1