From: Thomas Gleixner Date: Thu, 10 May 2018 18:31:44 +0000 (+0200) Subject: x86/speculation: Rework speculative_store_bypass_update() X-Git-Tag: v4.1.12-124.31.3~740 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=77a6e80c51c715a66177867a672924ec0a10d582;p=users%2Fjedix%2Flinux-maple.git x86/speculation: Rework speculative_store_bypass_update() The upcoming support for the virtual SPEC_CTRL MSR on AMD needs to reuse speculative_store_bypass_update() to avoid code duplication. Add an argument for supplying a thread info (TIF) value and create a wrapper speculative_store_bypass_update_current() which is used at the existing call site. Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Darren Kenny Orabug: 28063992 CVE: CVE-2018-3639 (cherry picked from commit 0270be3e) Signed-off-by: Mihai Carabas Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Brian Maly Conflicts: arch/x86/kernel/cpu/bugs.c [Different filename (bugs_64.c)] Signed-off-by: Brian Maly --- diff --git a/arch/x86/include/asm/spec-ctrl.h b/arch/x86/include/asm/spec-ctrl.h index 43a2abaee318..3e28fbff68fd 100644 --- a/arch/x86/include/asm/spec-ctrl.h +++ b/arch/x86/include/asm/spec-ctrl.h @@ -42,6 +42,11 @@ extern void speculative_store_bypass_ht_init(void); static inline void speculative_store_bypass_ht_init(void) { } #endif -extern void speculative_store_bypass_update(void); +extern void speculative_store_bypass_update(unsigned long tif); + +static inline void speculative_store_bypass_update_current(void) +{ + speculative_store_bypass_update(current_thread_info()->flags); +} #endif diff --git a/arch/x86/kernel/cpu/bugs_64.c b/arch/x86/kernel/cpu/bugs_64.c index 3843b3585394..0738883ca111 100644 --- a/arch/x86/kernel/cpu/bugs_64.c +++ b/arch/x86/kernel/cpu/bugs_64.c @@ -868,7 +868,7 @@ static int ssb_prctl_set(struct task_struct *task, unsigned long ctrl) * mitigation until it is next scheduled. */ if (task == current && update) - speculative_store_bypass_update(); + speculative_store_bypass_update_current(); return 0; } diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 7920be85b3df..aca03f119511 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -365,10 +365,10 @@ static __always_inline void __speculative_store_bypass_update(unsigned long tifn intel_set_ssb_state(tifn); } -void speculative_store_bypass_update(void) +void speculative_store_bypass_update(unsigned long tif) { preempt_disable(); - __speculative_store_bypass_update(current_thread_info()->flags); + __speculative_store_bypass_update(tif); preempt_enable(); }