switch_to.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1999 Cort Dougan <[email protected]>
  4. */
  5. #ifndef _ASM_POWERPC_SWITCH_TO_H
  6. #define _ASM_POWERPC_SWITCH_TO_H
  7. #include <linux/sched.h>
  8. #include <asm/reg.h>
  9. struct thread_struct;
  10. struct task_struct;
  11. struct pt_regs;
  12. extern struct task_struct *__switch_to(struct task_struct *,
  13. struct task_struct *);
  14. #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
  15. extern struct task_struct *_switch(struct thread_struct *prev,
  16. struct thread_struct *next);
  17. extern void switch_booke_debug_regs(struct debug_reg *new_debug);
  18. extern int emulate_altivec(struct pt_regs *);
  19. #ifdef CONFIG_PPC_BOOK3S_64
  20. void restore_math(struct pt_regs *regs);
  21. #else
  22. static inline void restore_math(struct pt_regs *regs)
  23. {
  24. }
  25. #endif
  26. void restore_tm_state(struct pt_regs *regs);
  27. extern void flush_all_to_thread(struct task_struct *);
  28. extern void giveup_all(struct task_struct *);
  29. #ifdef CONFIG_PPC_FPU
  30. extern void enable_kernel_fp(void);
  31. extern void flush_fp_to_thread(struct task_struct *);
  32. extern void giveup_fpu(struct task_struct *);
  33. extern void save_fpu(struct task_struct *);
  34. static inline void disable_kernel_fp(void)
  35. {
  36. msr_check_and_clear(MSR_FP);
  37. }
  38. #else
  39. static inline void save_fpu(struct task_struct *t) { }
  40. static inline void flush_fp_to_thread(struct task_struct *t) { }
  41. #endif
  42. #ifdef CONFIG_ALTIVEC
  43. extern void enable_kernel_altivec(void);
  44. extern void flush_altivec_to_thread(struct task_struct *);
  45. extern void giveup_altivec(struct task_struct *);
  46. extern void save_altivec(struct task_struct *);
  47. static inline void disable_kernel_altivec(void)
  48. {
  49. msr_check_and_clear(MSR_VEC);
  50. }
  51. #else
  52. static inline void save_altivec(struct task_struct *t) { }
  53. static inline void __giveup_altivec(struct task_struct *t) { }
  54. static inline void enable_kernel_altivec(void)
  55. {
  56. BUILD_BUG();
  57. }
  58. static inline void disable_kernel_altivec(void)
  59. {
  60. BUILD_BUG();
  61. }
  62. #endif
  63. #ifdef CONFIG_VSX
  64. extern void enable_kernel_vsx(void);
  65. extern void flush_vsx_to_thread(struct task_struct *);
  66. static inline void disable_kernel_vsx(void)
  67. {
  68. msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
  69. }
  70. #else
  71. static inline void enable_kernel_vsx(void)
  72. {
  73. BUILD_BUG();
  74. }
  75. static inline void disable_kernel_vsx(void)
  76. {
  77. BUILD_BUG();
  78. }
  79. #endif
  80. #ifdef CONFIG_SPE
  81. extern void enable_kernel_spe(void);
  82. extern void flush_spe_to_thread(struct task_struct *);
  83. extern void giveup_spe(struct task_struct *);
  84. extern void __giveup_spe(struct task_struct *);
  85. static inline void disable_kernel_spe(void)
  86. {
  87. msr_check_and_clear(MSR_SPE);
  88. }
  89. #else
  90. static inline void __giveup_spe(struct task_struct *t) { }
  91. #endif
  92. static inline void clear_task_ebb(struct task_struct *t)
  93. {
  94. #ifdef CONFIG_PPC_BOOK3S_64
  95. /* EBB perf events are not inherited, so clear all EBB state. */
  96. t->thread.ebbrr = 0;
  97. t->thread.ebbhr = 0;
  98. t->thread.bescr = 0;
  99. t->thread.mmcr2 = 0;
  100. t->thread.mmcr0 = 0;
  101. t->thread.siar = 0;
  102. t->thread.sdar = 0;
  103. t->thread.sier = 0;
  104. t->thread.used_ebb = 0;
  105. #endif
  106. }
  107. void kvmppc_save_user_regs(void);
  108. void kvmppc_save_current_sprs(void);
  109. extern int set_thread_tidr(struct task_struct *t);
  110. #endif /* _ASM_POWERPC_SWITCH_TO_H */