~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/include/asm/fpsimd.h

Version: ~ [ linux-5.12 ] ~ [ linux-5.11.16 ] ~ [ linux-5.10.32 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.114 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.188 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.231 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.267 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.267 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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
  7 
  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>
 13 
 14 #ifndef __ASSEMBLY__
 15 
 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>
 23 
 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
 28 /*
 29  * The VFP state has 32x64-bit registers and a single 32-bit
 30  * control/status register.
 31  */
 32 #define VFP_STATE_SIZE          ((32 * 8) + 4)
 33 #endif
 34 
 35 struct task_struct;
 36 
 37 extern void fpsimd_save_state(struct user_fpsimd_state *state);
 38 extern void fpsimd_load_state(struct user_fpsimd_state *state);
 39 
 40 extern void fpsimd_save(void);
 41 
 42 extern void fpsimd_thread_switch(struct task_struct *next);
 43 extern void fpsimd_flush_thread(void);
 44 
 45 extern void fpsimd_signal_preserve_current_state(void);
 46 extern void fpsimd_preserve_current_state(void);
 47 extern void fpsimd_restore_current_state(void);
 48 extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
 49 
 50 extern void fpsimd_bind_task_to_cpu(void);
 51 extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state,
 52                                      void *sve_state, unsigned int sve_vl);
 53 
 54 extern void fpsimd_flush_task_state(struct task_struct *target);
 55 extern void fpsimd_flush_cpu_state(void);
 56 extern void sve_flush_cpu_state(void);
 57 
 58 /* Maximum VL that SVE VL-agnostic software can transparently support */
 59 #define SVE_VL_ARCH_MAX 0x100
 60 
 61 /* Offset of FFR in the SVE register dump */
 62 static inline size_t sve_ffr_offset(int vl)
 63 {
 64         return SVE_SIG_FFR_OFFSET(sve_vq_from_vl(vl)) - SVE_SIG_REGS_OFFSET;
 65 }
 66 
 67 static inline void *sve_pffr(struct thread_struct *thread)
 68 {
 69         return (char *)thread->sve_state + sve_ffr_offset(thread->sve_vl);
 70 }
 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 struct arm64_cpu_capabilities;
 78 extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
 79 
 80 extern u64 read_zcr_features(void);
 81 
 82 extern int __ro_after_init sve_max_vl;
 83 extern int __ro_after_init sve_max_virtualisable_vl;
 84 extern __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
 85 
 86 /*
 87  * Helpers to translate bit indices in sve_vq_map to VQ values (and
 88  * vice versa).  This allows find_next_bit() to be used to find the
 89  * _maximum_ VQ not exceeding a certain value.
 90  */
 91 static inline unsigned int __vq_to_bit(unsigned int vq)
 92 {
 93         return SVE_VQ_MAX - vq;
 94 }
 95 
 96 static inline unsigned int __bit_to_vq(unsigned int bit)
 97 {
 98         return SVE_VQ_MAX - bit;
 99 }
100 
101 /* Ensure vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX before calling this function */
102 static inline bool sve_vq_available(unsigned int vq)
103 {
104         return test_bit(__vq_to_bit(vq), sve_vq_map);
105 }
106 
107 #ifdef CONFIG_ARM64_SVE
108 
109 extern size_t sve_state_size(struct task_struct const *task);
110 
111 extern void sve_alloc(struct task_struct *task);
112 extern void fpsimd_release_task(struct task_struct *task);
113 extern void fpsimd_sync_to_sve(struct task_struct *task);
114 extern void sve_sync_to_fpsimd(struct task_struct *task);
115 extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task);
116 
117 extern int sve_set_vector_length(struct task_struct *task,
118                                  unsigned long vl, unsigned long flags);
119 
120 extern int sve_set_current_vl(unsigned long arg);
121 extern int sve_get_current_vl(void);
122 
123 static inline void sve_user_disable(void)
124 {
125         sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0);
126 }
127 
128 static inline void sve_user_enable(void)
129 {
130         sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN);
131 }
132 
133 /*
134  * Probing and setup functions.
135  * Calls to these functions must be serialised with one another.
136  */
137 extern void __init sve_init_vq_map(void);
138 extern void sve_update_vq_map(void);
139 extern int sve_verify_vq_map(void);
140 extern void __init sve_setup(void);
141 
142 #else /* ! CONFIG_ARM64_SVE */
143 
144 static inline void sve_alloc(struct task_struct *task) { }
145 static inline void fpsimd_release_task(struct task_struct *task) { }
146 static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
147 static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
148 
149 static inline int sve_set_current_vl(unsigned long arg)
150 {
151         return -EINVAL;
152 }
153 
154 static inline int sve_get_current_vl(void)
155 {
156         return -EINVAL;
157 }
158 
159 static inline void sve_user_disable(void) { BUILD_BUG(); }
160 static inline void sve_user_enable(void) { BUILD_BUG(); }
161 
162 static inline void sve_init_vq_map(void) { }
163 static inline void sve_update_vq_map(void) { }
164 static inline int sve_verify_vq_map(void) { return 0; }
165 static inline void sve_setup(void) { }
166 
167 #endif /* ! CONFIG_ARM64_SVE */
168 
169 /* For use by EFI runtime services calls only */
170 extern void __efi_fpsimd_begin(void);
171 extern void __efi_fpsimd_end(void);
172 
173 #endif
174 
175 #endif
176 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp