blob: bf820f53e27edda9c27b9963d0ae12140c925371 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
David Howellsae3a1972012-03-28 18:30:02 +01002/*
3 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4 */
5#ifndef _ASM_POWERPC_SWITCH_TO_H
6#define _ASM_POWERPC_SWITCH_TO_H
7
Anton Blanchard3eb5d582015-10-29 11:44:06 +11008#include <asm/reg.h>
9
David Howellsae3a1972012-03-28 18:30:02 +010010struct thread_struct;
11struct task_struct;
12struct pt_regs;
13
14extern struct task_struct *__switch_to(struct task_struct *,
15 struct task_struct *);
16#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
17
David Howellsae3a1972012-03-28 18:30:02 +010018extern struct task_struct *_switch(struct thread_struct *prev,
19 struct thread_struct *next);
20
Scott Woodf5f97212013-11-22 15:52:29 -060021extern void switch_booke_debug_regs(struct debug_reg *new_debug);
David Howellsae3a1972012-03-28 18:30:02 +010022
Anton Blanchardd1e1cf22015-10-29 11:44:11 +110023extern int emulate_altivec(struct pt_regs *);
24
25extern void flush_all_to_thread(struct task_struct *);
26extern void giveup_all(struct task_struct *);
27
Kevin Hao037f0ee2013-07-14 17:02:05 +080028#ifdef CONFIG_PPC_FPU
Anton Blanchardd1e1cf22015-10-29 11:44:11 +110029extern void enable_kernel_fp(void);
Kevin Hao037f0ee2013-07-14 17:02:05 +080030extern void flush_fp_to_thread(struct task_struct *);
Kevin Hao5f20be42013-07-14 17:02:06 +080031extern void giveup_fpu(struct task_struct *);
Cyril Bur87924682016-02-29 17:53:49 +110032extern void save_fpu(struct task_struct *);
Anton Blanchard3eb5d582015-10-29 11:44:06 +110033static inline void disable_kernel_fp(void)
34{
35 msr_check_and_clear(MSR_FP);
36}
Kevin Hao037f0ee2013-07-14 17:02:05 +080037#else
Cyril Burde2a20a2016-02-29 17:53:48 +110038static inline void __giveup_fpu(struct task_struct *t) { }
Cyril Bur87924682016-02-29 17:53:49 +110039static inline void save_fpu(struct task_struct *t) { }
Kevin Hao037f0ee2013-07-14 17:02:05 +080040static inline void flush_fp_to_thread(struct task_struct *t) { }
41#endif
42
David Howellsae3a1972012-03-28 18:30:02 +010043#ifdef CONFIG_ALTIVEC
Anton Blanchardd1e1cf22015-10-29 11:44:11 +110044extern void enable_kernel_altivec(void);
David Howellsae3a1972012-03-28 18:30:02 +010045extern void flush_altivec_to_thread(struct task_struct *);
Anton Blanchard8cd3c232012-04-15 20:54:59 +000046extern void giveup_altivec(struct task_struct *);
Cyril Bur6f515d82016-02-29 17:53:50 +110047extern void save_altivec(struct task_struct *);
Anton Blanchard3eb5d582015-10-29 11:44:06 +110048static inline void disable_kernel_altivec(void)
49{
50 msr_check_and_clear(MSR_VEC);
51}
Cyril Burde2a20a2016-02-29 17:53:48 +110052#else
Cyril Bur6f515d82016-02-29 17:53:50 +110053static inline void save_altivec(struct task_struct *t) { }
Cyril Burde2a20a2016-02-29 17:53:48 +110054static inline void __giveup_altivec(struct task_struct *t) { }
David Howellsae3a1972012-03-28 18:30:02 +010055#endif
56
57#ifdef CONFIG_VSX
Anton Blanchardd1e1cf22015-10-29 11:44:11 +110058extern void enable_kernel_vsx(void);
David Howellsae3a1972012-03-28 18:30:02 +010059extern void flush_vsx_to_thread(struct task_struct *);
Anton Blanchard3eb5d582015-10-29 11:44:06 +110060static inline void disable_kernel_vsx(void)
61{
62 msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
63}
David Howellsae3a1972012-03-28 18:30:02 +010064#endif
65
66#ifdef CONFIG_SPE
Anton Blanchardd1e1cf22015-10-29 11:44:11 +110067extern void enable_kernel_spe(void);
David Howellsae3a1972012-03-28 18:30:02 +010068extern void flush_spe_to_thread(struct task_struct *);
Anton Blanchard98da5812015-10-29 11:44:01 +110069extern void giveup_spe(struct task_struct *);
70extern void __giveup_spe(struct task_struct *);
Anton Blanchard3eb5d582015-10-29 11:44:06 +110071static inline void disable_kernel_spe(void)
72{
73 msr_check_and_clear(MSR_SPE);
74}
Cyril Burde2a20a2016-02-29 17:53:48 +110075#else
76static inline void __giveup_spe(struct task_struct *t) { }
David Howellsae3a1972012-03-28 18:30:02 +010077#endif
78
Michael Ellerman330a1eb2013-06-28 18:15:16 +100079static inline void clear_task_ebb(struct task_struct *t)
80{
81#ifdef CONFIG_PPC_BOOK3S_64
82 /* EBB perf events are not inherited, so clear all EBB state. */
Michael Ellerman3df48c92014-06-10 16:46:21 +100083 t->thread.ebbrr = 0;
84 t->thread.ebbhr = 0;
Michael Ellerman330a1eb2013-06-28 18:15:16 +100085 t->thread.bescr = 0;
86 t->thread.mmcr2 = 0;
87 t->thread.mmcr0 = 0;
88 t->thread.siar = 0;
89 t->thread.sdar = 0;
90 t->thread.sier = 0;
91 t->thread.used_ebb = 0;
92#endif
93}
94
David Howellsae3a1972012-03-28 18:30:02 +010095#endif /* _ASM_POWERPC_SWITCH_TO_H */