arm64/fpsimd: Remove the prototype for sve_flush_cpu_state()
[linux-block.git] / arch / arm64 / include / asm / fpsimd.h
CommitLineData
53631b54
CM
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
2d2123bc 19#include <asm/errno.h>
f9209e26 20#include <asm/ptrace.h>
9a6e5948
DM
21#include <asm/processor.h>
22#include <asm/sigcontext.h>
f9209e26 23#include <asm/sysreg.h>
53631b54
CM
24
25#ifndef __ASSEMBLY__
26
ead9e430 27#include <linux/bitmap.h>
f9209e26 28#include <linux/build_bug.h>
ead9e430 29#include <linux/bug.h>
7582e220 30#include <linux/cache.h>
b4f9b390 31#include <linux/init.h>
bc0ee476 32#include <linux/stddef.h>
ead9e430 33#include <linux/types.h>
bc0ee476 34
53631b54
CM
35#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
36/* Masks for extracting the FPSR and FPCR from the FPSCR */
37#define VFP_FPSCR_STAT_MASK 0xf800009f
38#define VFP_FPSCR_CTRL_MASK 0x07f79f00
39/*
40 * The VFP state has 32x64-bit registers and a single 32-bit
41 * control/status register.
42 */
43#define VFP_STATE_SIZE ((32 * 8) + 4)
44#endif
45
46struct task_struct;
47
20b85472
DM
48extern void fpsimd_save_state(struct user_fpsimd_state *state);
49extern void fpsimd_load_state(struct user_fpsimd_state *state);
53631b54 50
e6b673b7
DM
51extern void fpsimd_save(void);
52
53631b54
CM
53extern void fpsimd_thread_switch(struct task_struct *next);
54extern void fpsimd_flush_thread(void);
55
8cd969d2 56extern void fpsimd_signal_preserve_current_state(void);
c51f9269 57extern void fpsimd_preserve_current_state(void);
005f78cd 58extern void fpsimd_restore_current_state(void);
0abdeff5 59extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
c51f9269 60
e6b673b7 61extern void fpsimd_bind_task_to_cpu(void);
04950674
DM
62extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state,
63 void *sve_state, unsigned int sve_vl);
e6b673b7 64
005f78cd 65extern void fpsimd_flush_task_state(struct task_struct *target);
e6b673b7 66extern void fpsimd_flush_cpu_state(void);
005f78cd 67
7582e220
DM
68/* Maximum VL that SVE VL-agnostic software can transparently support */
69#define SVE_VL_ARCH_MAX 0x100
70
9a6e5948
DM
71/* Offset of FFR in the SVE register dump */
72static inline size_t sve_ffr_offset(int vl)
73{
74 return SVE_SIG_FFR_OFFSET(sve_vq_from_vl(vl)) - SVE_SIG_REGS_OFFSET;
75}
76
77static inline void *sve_pffr(struct thread_struct *thread)
78{
79 return (char *)thread->sve_state + sve_ffr_offset(thread->sve_vl);
80}
81
1fc5dce7
DM
82extern void sve_save_state(void *state, u32 *pfpsr);
83extern void sve_load_state(void const *state, u32 const *pfpsr,
84 unsigned long vq_minus_1);
85extern unsigned int sve_get_vl(void);
c0cda3b8
DM
86
87struct arm64_cpu_capabilities;
88extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
1fc5dce7 89
31dc52b3
DM
90extern u64 read_zcr_features(void);
91
7582e220 92extern int __ro_after_init sve_max_vl;
d06b76be 93extern int __ro_after_init sve_max_virtualisable_vl;
ead9e430
DM
94extern __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
95
96/*
97 * Helpers to translate bit indices in sve_vq_map to VQ values (and
98 * vice versa). This allows find_next_bit() to be used to find the
99 * _maximum_ VQ not exceeding a certain value.
100 */
101static inline unsigned int __vq_to_bit(unsigned int vq)
102{
103 return SVE_VQ_MAX - vq;
104}
105
106static inline unsigned int __bit_to_vq(unsigned int bit)
107{
ead9e430
DM
108 return SVE_VQ_MAX - bit;
109}
110
111/* Ensure vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX before calling this function */
112static inline bool sve_vq_available(unsigned int vq)
113{
114 return test_bit(__vq_to_bit(vq), sve_vq_map);
115}
7582e220 116
bc0ee476
DM
117#ifdef CONFIG_ARM64_SVE
118
119extern size_t sve_state_size(struct task_struct const *task);
120
121extern void sve_alloc(struct task_struct *task);
122extern void fpsimd_release_task(struct task_struct *task);
43d4da2c
DM
123extern void fpsimd_sync_to_sve(struct task_struct *task);
124extern void sve_sync_to_fpsimd(struct task_struct *task);
125extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task);
126
7582e220
DM
127extern int sve_set_vector_length(struct task_struct *task,
128 unsigned long vl, unsigned long flags);
bc0ee476 129
2d2123bc
DM
130extern int sve_set_current_vl(unsigned long arg);
131extern int sve_get_current_vl(void);
132
f9209e26
MR
133static inline void sve_user_disable(void)
134{
135 sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0);
136}
137
138static inline void sve_user_enable(void)
139{
140 sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN);
141}
142
2e0f2478
DM
143/*
144 * Probing and setup functions.
145 * Calls to these functions must be serialised with one another.
146 */
147extern void __init sve_init_vq_map(void);
148extern void sve_update_vq_map(void);
149extern int sve_verify_vq_map(void);
150extern void __init sve_setup(void);
151
bc0ee476
DM
152#else /* ! CONFIG_ARM64_SVE */
153
154static inline void sve_alloc(struct task_struct *task) { }
155static inline void fpsimd_release_task(struct task_struct *task) { }
43d4da2c
DM
156static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
157static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
158
2d2123bc
DM
159static inline int sve_set_current_vl(unsigned long arg)
160{
161 return -EINVAL;
162}
163
164static inline int sve_get_current_vl(void)
165{
166 return -EINVAL;
167}
168
f9209e26
MR
169static inline void sve_user_disable(void) { BUILD_BUG(); }
170static inline void sve_user_enable(void) { BUILD_BUG(); }
171
2e0f2478
DM
172static inline void sve_init_vq_map(void) { }
173static inline void sve_update_vq_map(void) { }
174static inline int sve_verify_vq_map(void) { return 0; }
175static inline void sve_setup(void) { }
bc0ee476
DM
176
177#endif /* ! CONFIG_ARM64_SVE */
178
4328825d
DM
179/* For use by EFI runtime services calls only */
180extern void __efi_fpsimd_begin(void);
181extern void __efi_fpsimd_end(void);
182
53631b54
CM
183#endif
184
185#endif