License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / arch / s390 / include / asm / switch_to.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
a0616cde
DH
2/*
3 * Copyright IBM Corp. 1999, 2009
4 *
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 */
7
8#ifndef __ASM_SWITCH_TO_H
9#define __ASM_SWITCH_TO_H
10
11#include <linux/thread_info.h>
b0753902 12#include <asm/fpu/api.h>
bee5c286 13#include <asm/ptrace.h>
916cda1a 14#include <asm/guarded_storage.h>
a0616cde
DH
15
16extern struct task_struct *__switch_to(void *, void *);
64597f9d 17extern void update_cr_regs(struct task_struct *task);
a0616cde 18
a0616cde
DH
19static inline void save_access_regs(unsigned int *acrs)
20{
bee5c286
HC
21 typedef struct { int _[NUM_ACRS]; } acrstype;
22
23 asm volatile("stam 0,15,%0" : "=Q" (*(acrstype *)acrs));
a0616cde
DH
24}
25
26static inline void restore_access_regs(unsigned int *acrs)
27{
bee5c286
HC
28 typedef struct { int _[NUM_ACRS]; } acrstype;
29
30 asm volatile("lam 0,15,%0" : : "Q" (*(acrstype *)acrs));
a0616cde
DH
31}
32
33#define switch_to(prev,next,last) do { \
34 if (prev->mm) { \
d0164ee2 35 save_fpu_regs(); \
a0616cde 36 save_access_regs(&prev->thread.acrs[0]); \
e4b8b3f3 37 save_ri_cb(prev->thread.ri_cb); \
916cda1a 38 save_gs_cb(prev->thread.gs_cb); \
a0616cde
DH
39 } \
40 if (next->mm) { \
80703617 41 update_cr_regs(next); \
9977e886 42 set_cpu_flag(CIF_FPU); \
a0616cde 43 restore_access_regs(&next->thread.acrs[0]); \
e4b8b3f3 44 restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
916cda1a 45 restore_gs_cb(next->thread.gs_cb); \
a0616cde
DH
46 } \
47 prev = __switch_to(prev,next); \
48} while (0)
49
a0616cde 50#endif /* __ASM_SWITCH_TO_H */