process.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. //
  3. // Code shared between 32 and 64 bit
  4. #include <asm/spec-ctrl.h>
  5. void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p);
  6. /*
  7. * This needs to be inline to optimize for the common case where no extra
  8. * work needs to be done.
  9. */
  10. static inline void switch_to_extra(struct task_struct *prev,
  11. struct task_struct *next)
  12. {
  13. unsigned long next_tif = task_thread_info(next)->flags;
  14. unsigned long prev_tif = task_thread_info(prev)->flags;
  15. if (IS_ENABLED(CONFIG_SMP)) {
  16. /*
  17. * Avoid __switch_to_xtra() invocation when conditional
  18. * STIBP is disabled and the only different bit is
  19. * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not
  20. * in the TIF_WORK_CTXSW masks.
  21. */
  22. if (!static_branch_likely(&switch_to_cond_stibp)) {
  23. prev_tif &= ~_TIF_SPEC_IB;
  24. next_tif &= ~_TIF_SPEC_IB;
  25. }
  26. }
  27. /*
  28. * __switch_to_xtra() handles debug registers, i/o bitmaps,
  29. * speculation mitigations etc.
  30. */
  31. if (unlikely(next_tif & _TIF_WORK_CTXSW_NEXT ||
  32. prev_tif & _TIF_WORK_CTXSW_PREV))
  33. __switch_to_xtra(prev, next);
  34. }