Skip to content

Commit b7b8440

Browse files
KAGA-KOKOgregkh
authored andcommitted
x86/speculation: Rework speculative_store_bypass_update()
commit 0270be3 upstream 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 <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7c0b2dc commit b7b8440

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

arch/x86/include/asm/spec-ctrl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ extern void speculative_store_bypass_ht_init(void);
4242
static inline void speculative_store_bypass_ht_init(void) { }
4343
#endif
4444

45-
extern void speculative_store_bypass_update(void);
45+
extern void speculative_store_bypass_update(unsigned long tif);
46+
47+
static inline void speculative_store_bypass_update_current(void)
48+
{
49+
speculative_store_bypass_update(current_thread_info()->flags);
50+
}
4651

4752
#endif

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static int ssb_prctl_set(struct task_struct *task, unsigned long ctrl)
597597
* mitigation until it is next scheduled.
598598
*/
599599
if (task == current && update)
600-
speculative_store_bypass_update();
600+
speculative_store_bypass_update_current();
601601

602602
return 0;
603603
}

arch/x86/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ static __always_inline void __speculative_store_bypass_update(unsigned long tifn
338338
intel_set_ssb_state(tifn);
339339
}
340340

341-
void speculative_store_bypass_update(void)
341+
void speculative_store_bypass_update(unsigned long tif)
342342
{
343343
preempt_disable();
344-
__speculative_store_bypass_update(current_thread_info()->flags);
344+
__speculative_store_bypass_update(tif);
345345
preempt_enable();
346346
}
347347

0 commit comments

Comments
 (0)