Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 //
0003 // Code shared between 32 and 64 bit
0004 
0005 #include <asm/spec-ctrl.h>
0006 
0007 void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p);
0008 
0009 /*
0010  * This needs to be inline to optimize for the common case where no extra
0011  * work needs to be done.
0012  */
0013 static inline void switch_to_extra(struct task_struct *prev,
0014                    struct task_struct *next)
0015 {
0016     unsigned long next_tif = read_task_thread_flags(next);
0017     unsigned long prev_tif = read_task_thread_flags(prev);
0018 
0019     if (IS_ENABLED(CONFIG_SMP)) {
0020         /*
0021          * Avoid __switch_to_xtra() invocation when conditional
0022          * STIBP is disabled and the only different bit is
0023          * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not
0024          * in the TIF_WORK_CTXSW masks.
0025          */
0026         if (!static_branch_likely(&switch_to_cond_stibp)) {
0027             prev_tif &= ~_TIF_SPEC_IB;
0028             next_tif &= ~_TIF_SPEC_IB;
0029         }
0030     }
0031 
0032     /*
0033      * __switch_to_xtra() handles debug registers, i/o bitmaps,
0034      * speculation mitigations etc.
0035      */
0036     if (unlikely(next_tif & _TIF_WORK_CTXSW_NEXT ||
0037              prev_tif & _TIF_WORK_CTXSW_PREV))
0038         __switch_to_xtra(prev, next);
0039 }