File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -147,9 +147,18 @@ struct thread_info {
147
147
_TIF_FSCHECK)
148
148
149
149
/* flags to check in __switch_to() */
150
- #define _TIF_WORK_CTXSW \
150
+ #define _TIF_WORK_CTXSW_BASE \
151
151
(_TIF_IO_BITMAP|_TIF_NOCPUID|_TIF_NOTSC|_TIF_BLOCKSTEP| \
152
- _TIF_SSBD|_TIF_SPEC_IB)
152
+ _TIF_SSBD)
153
+
154
+ /*
155
+ * Avoid calls to __switch_to_xtra() on UP as STIBP is not evaluated.
156
+ */
157
+ #ifdef CONFIG_SMP
158
+ # define _TIF_WORK_CTXSW (_TIF_WORK_CTXSW_BASE | _TIF_SPEC_IB)
159
+ #else
160
+ # define _TIF_WORK_CTXSW (_TIF_WORK_CTXSW_BASE)
161
+ #endif
153
162
154
163
#define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)
155
164
#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW)
Original file line number Diff line number Diff line change 2
2
//
3
3
// Code shared between 32 and 64 bit
4
4
5
+ #include <asm/spec-ctrl.h>
6
+
5
7
void __switch_to_xtra (struct task_struct * prev_p , struct task_struct * next_p );
6
8
7
9
/*
@@ -14,6 +16,19 @@ static inline void switch_to_extra(struct task_struct *prev,
14
16
unsigned long next_tif = task_thread_info (next )-> flags ;
15
17
unsigned long prev_tif = task_thread_info (prev )-> flags ;
16
18
19
+ if (IS_ENABLED (CONFIG_SMP )) {
20
+ /*
21
+ * Avoid __switch_to_xtra() invocation when conditional
22
+ * STIPB is disabled and the only different bit is
23
+ * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not
24
+ * in the TIF_WORK_CTXSW masks.
25
+ */
26
+ if (!static_branch_likely (& switch_to_cond_stibp )) {
27
+ prev_tif &= ~_TIF_SPEC_IB ;
28
+ next_tif &= ~_TIF_SPEC_IB ;
29
+ }
30
+ }
31
+
17
32
/*
18
33
* __switch_to_xtra() handles debug registers, i/o bitmaps,
19
34
* speculation mitigations etc.
You can’t perform that action at this time.
0 commit comments