staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / arm64 / include / asm / fpsimd.h
blobb6a2c352f4c3fd64726115f478d1c6a4fd60b040
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 ARM Ltd.
4 */
5 #ifndef __ASM_FP_H
6 #define __ASM_FP_H
8 #include <asm/errno.h>
9 #include <asm/ptrace.h>
10 #include <asm/processor.h>
11 #include <asm/sigcontext.h>
12 #include <asm/sysreg.h>
14 #ifndef __ASSEMBLY__
16 #include <linux/bitmap.h>
17 #include <linux/build_bug.h>
18 #include <linux/bug.h>
19 #include <linux/cache.h>
20 #include <linux/init.h>
21 #include <linux/stddef.h>
22 #include <linux/types.h>
24 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
25 /* Masks for extracting the FPSR and FPCR from the FPSCR */
26 #define VFP_FPSCR_STAT_MASK 0xf800009f
27 #define VFP_FPSCR_CTRL_MASK 0x07f79f00
29 * The VFP state has 32x64-bit registers and a single 32-bit
30 * control/status register.
32 #define VFP_STATE_SIZE ((32 * 8) + 4)
33 #endif
35 struct task_struct;
37 extern void fpsimd_save_state(struct user_fpsimd_state *state);
38 extern void fpsimd_load_state(struct user_fpsimd_state *state);
40 extern void fpsimd_thread_switch(struct task_struct *next);
41 extern void fpsimd_flush_thread(void);
43 extern void fpsimd_signal_preserve_current_state(void);
44 extern void fpsimd_preserve_current_state(void);
45 extern void fpsimd_restore_current_state(void);
46 extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
48 extern void fpsimd_bind_task_to_cpu(void);
49 extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state,
50 void *sve_state, unsigned int sve_vl);
52 extern void fpsimd_flush_task_state(struct task_struct *target);
53 extern void fpsimd_save_and_flush_cpu_state(void);
55 /* Maximum VL that SVE VL-agnostic software can transparently support */
56 #define SVE_VL_ARCH_MAX 0x100
58 /* Offset of FFR in the SVE register dump */
59 static inline size_t sve_ffr_offset(int vl)
61 return SVE_SIG_FFR_OFFSET(sve_vq_from_vl(vl)) - SVE_SIG_REGS_OFFSET;
64 static inline void *sve_pffr(struct thread_struct *thread)
66 return (char *)thread->sve_state + sve_ffr_offset(thread->sve_vl);
69 extern void sve_save_state(void *state, u32 *pfpsr);
70 extern void sve_load_state(void const *state, u32 const *pfpsr,
71 unsigned long vq_minus_1);
72 extern unsigned int sve_get_vl(void);
74 struct arm64_cpu_capabilities;
75 extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
77 extern u64 read_zcr_features(void);
79 extern int __ro_after_init sve_max_vl;
80 extern int __ro_after_init sve_max_virtualisable_vl;
81 extern __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
84 * Helpers to translate bit indices in sve_vq_map to VQ values (and
85 * vice versa). This allows find_next_bit() to be used to find the
86 * _maximum_ VQ not exceeding a certain value.
88 static inline unsigned int __vq_to_bit(unsigned int vq)
90 return SVE_VQ_MAX - vq;
93 static inline unsigned int __bit_to_vq(unsigned int bit)
95 return SVE_VQ_MAX - bit;
98 /* Ensure vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX before calling this function */
99 static inline bool sve_vq_available(unsigned int vq)
101 return test_bit(__vq_to_bit(vq), sve_vq_map);
104 #ifdef CONFIG_ARM64_SVE
106 extern size_t sve_state_size(struct task_struct const *task);
108 extern void sve_alloc(struct task_struct *task);
109 extern void fpsimd_release_task(struct task_struct *task);
110 extern void fpsimd_sync_to_sve(struct task_struct *task);
111 extern void sve_sync_to_fpsimd(struct task_struct *task);
112 extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task);
114 extern int sve_set_vector_length(struct task_struct *task,
115 unsigned long vl, unsigned long flags);
117 extern int sve_set_current_vl(unsigned long arg);
118 extern int sve_get_current_vl(void);
120 static inline void sve_user_disable(void)
122 sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0);
125 static inline void sve_user_enable(void)
127 sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN);
131 * Probing and setup functions.
132 * Calls to these functions must be serialised with one another.
134 extern void __init sve_init_vq_map(void);
135 extern void sve_update_vq_map(void);
136 extern int sve_verify_vq_map(void);
137 extern void __init sve_setup(void);
139 #else /* ! CONFIG_ARM64_SVE */
141 static inline void sve_alloc(struct task_struct *task) { }
142 static inline void fpsimd_release_task(struct task_struct *task) { }
143 static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
144 static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
146 static inline int sve_set_current_vl(unsigned long arg)
148 return -EINVAL;
151 static inline int sve_get_current_vl(void)
153 return -EINVAL;
156 static inline void sve_user_disable(void) { BUILD_BUG(); }
157 static inline void sve_user_enable(void) { BUILD_BUG(); }
159 static inline void sve_init_vq_map(void) { }
160 static inline void sve_update_vq_map(void) { }
161 static inline int sve_verify_vq_map(void) { return 0; }
162 static inline void sve_setup(void) { }
164 #endif /* ! CONFIG_ARM64_SVE */
166 /* For use by EFI runtime services calls only */
167 extern void __efi_fpsimd_begin(void);
168 extern void __efi_fpsimd_end(void);
170 #endif
172 #endif