]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - arch/arm64/include/asm/fpsimd.h
arm64/sve: Core task context handling
[thirdparty/kernel/stable.git] / arch / arm64 / include / asm / fpsimd.h
1 /*
2 * Copyright (C) 2012 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #ifndef __ASM_FP_H
17 #define __ASM_FP_H
18
19 #include <asm/ptrace.h>
20
21 #ifndef __ASSEMBLY__
22
23 #include <linux/stddef.h>
24
25 /*
26 * FP/SIMD storage area has:
27 * - FPSR and FPCR
28 * - 32 128-bit data registers
29 *
30 * Note that user_fpsimd forms a prefix of this structure, which is
31 * relied upon in the ptrace FP/SIMD accessors.
32 */
33 struct fpsimd_state {
34 union {
35 struct user_fpsimd_state user_fpsimd;
36 struct {
37 __uint128_t vregs[32];
38 u32 fpsr;
39 u32 fpcr;
40 };
41 };
42 /* the id of the last cpu to have restored this state */
43 unsigned int cpu;
44 };
45
46
47 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
48 /* Masks for extracting the FPSR and FPCR from the FPSCR */
49 #define VFP_FPSCR_STAT_MASK 0xf800009f
50 #define VFP_FPSCR_CTRL_MASK 0x07f79f00
51 /*
52 * The VFP state has 32x64-bit registers and a single 32-bit
53 * control/status register.
54 */
55 #define VFP_STATE_SIZE ((32 * 8) + 4)
56 #endif
57
58 struct task_struct;
59
60 extern void fpsimd_save_state(struct fpsimd_state *state);
61 extern void fpsimd_load_state(struct fpsimd_state *state);
62
63 extern void fpsimd_thread_switch(struct task_struct *next);
64 extern void fpsimd_flush_thread(void);
65
66 extern void fpsimd_preserve_current_state(void);
67 extern void fpsimd_restore_current_state(void);
68 extern void fpsimd_update_current_state(struct fpsimd_state *state);
69
70 extern void fpsimd_flush_task_state(struct task_struct *target);
71
72 extern void sve_save_state(void *state, u32 *pfpsr);
73 extern void sve_load_state(void const *state, u32 const *pfpsr,
74 unsigned long vq_minus_1);
75 extern unsigned int sve_get_vl(void);
76
77 #ifdef CONFIG_ARM64_SVE
78
79 extern size_t sve_state_size(struct task_struct const *task);
80
81 extern void sve_alloc(struct task_struct *task);
82 extern void fpsimd_release_task(struct task_struct *task);
83
84 #else /* ! CONFIG_ARM64_SVE */
85
86 static inline void sve_alloc(struct task_struct *task) { }
87 static inline void fpsimd_release_task(struct task_struct *task) { }
88
89 #endif /* ! CONFIG_ARM64_SVE */
90
91 /* For use by EFI runtime services calls only */
92 extern void __efi_fpsimd_begin(void);
93 extern void __efi_fpsimd_end(void);
94
95 #endif
96
97 #endif