]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/s390/include/asm/switch_to.h
Merge back PM core material for v4.16.
[mirror_ubuntu-jammy-kernel.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
fbbd7f1a
HC
33#define switch_to(prev, next, last) do { \
34 /* save_fpu_regs() sets the CIF_FPU flag, which enforces \
35 * a restore of the floating point / vector registers as \
36 * soon as the next task returns to user space \
37 */ \
38 save_fpu_regs(); \
39 save_access_regs(&prev->thread.acrs[0]); \
40 save_ri_cb(prev->thread.ri_cb); \
41 save_gs_cb(prev->thread.gs_cb); \
a1c5befc 42 update_cr_regs(next); \
fbbd7f1a
HC
43 restore_access_regs(&next->thread.acrs[0]); \
44 restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
45 restore_gs_cb(next->thread.gs_cb); \
46 prev = __switch_to(prev, next); \
a0616cde
DH
47} while (0)
48
a0616cde 49#endif /* __ASM_SWITCH_TO_H */