]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/s390/include/asm/switch_to.h
Merge tag 'jfs-4.13' of git://github.com/kleikamp/linux-shaggy
[mirror_ubuntu-focal-kernel.git] / arch / s390 / include / asm / switch_to.h
1 /*
2 * Copyright IBM Corp. 1999, 2009
3 *
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 */
6
7 #ifndef __ASM_SWITCH_TO_H
8 #define __ASM_SWITCH_TO_H
9
10 #include <linux/thread_info.h>
11 #include <asm/fpu/api.h>
12 #include <asm/ptrace.h>
13 #include <asm/guarded_storage.h>
14
15 extern struct task_struct *__switch_to(void *, void *);
16 extern void update_cr_regs(struct task_struct *task);
17
18 static inline void save_access_regs(unsigned int *acrs)
19 {
20 typedef struct { int _[NUM_ACRS]; } acrstype;
21
22 asm volatile("stam 0,15,%0" : "=Q" (*(acrstype *)acrs));
23 }
24
25 static inline void restore_access_regs(unsigned int *acrs)
26 {
27 typedef struct { int _[NUM_ACRS]; } acrstype;
28
29 asm volatile("lam 0,15,%0" : : "Q" (*(acrstype *)acrs));
30 }
31
32 #define switch_to(prev,next,last) do { \
33 if (prev->mm) { \
34 save_fpu_regs(); \
35 save_access_regs(&prev->thread.acrs[0]); \
36 save_ri_cb(prev->thread.ri_cb); \
37 save_gs_cb(prev->thread.gs_cb); \
38 } \
39 if (next->mm) { \
40 update_cr_regs(next); \
41 set_cpu_flag(CIF_FPU); \
42 restore_access_regs(&next->thread.acrs[0]); \
43 restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
44 restore_gs_cb(next->thread.gs_cb); \
45 } \
46 prev = __switch_to(prev,next); \
47 } while (0)
48
49 #endif /* __ASM_SWITCH_TO_H */