Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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#include <asm/errno.h>
21
22#ifndef __ASSEMBLY__
23
24#include <linux/cache.h>
25#include <linux/init.h>
26#include <linux/stddef.h>
27
28#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
29/* Masks for extracting the FPSR and FPCR from the FPSCR */
30#define VFP_FPSCR_STAT_MASK 0xf800009f
31#define VFP_FPSCR_CTRL_MASK 0x07f79f00
32/*
33 * The VFP state has 32x64-bit registers and a single 32-bit
34 * control/status register.
35 */
36#define VFP_STATE_SIZE ((32 * 8) + 4)
37#endif
38
39struct task_struct;
40
41extern void fpsimd_save_state(struct user_fpsimd_state *state);
42extern void fpsimd_load_state(struct user_fpsimd_state *state);
43
44extern void fpsimd_thread_switch(struct task_struct *next);
45extern void fpsimd_flush_thread(void);
46
47extern void fpsimd_signal_preserve_current_state(void);
48extern void fpsimd_preserve_current_state(void);
49extern void fpsimd_restore_current_state(void);
50extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
51
52extern void fpsimd_flush_task_state(struct task_struct *target);
53extern void sve_flush_cpu_state(void);
54
55/* Maximum VL that SVE VL-agnostic software can transparently support */
56#define SVE_VL_ARCH_MAX 0x100
57
58extern void sve_save_state(void *state, u32 *pfpsr);
59extern void sve_load_state(void const *state, u32 const *pfpsr,
60 unsigned long vq_minus_1);
61extern unsigned int sve_get_vl(void);
62
63struct arm64_cpu_capabilities;
64extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
65
66extern int __ro_after_init sve_max_vl;
67
68#ifdef CONFIG_ARM64_SVE
69
70extern size_t sve_state_size(struct task_struct const *task);
71
72extern void sve_alloc(struct task_struct *task);
73extern void fpsimd_release_task(struct task_struct *task);
74extern void fpsimd_sync_to_sve(struct task_struct *task);
75extern void sve_sync_to_fpsimd(struct task_struct *task);
76extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task);
77
78extern int sve_set_vector_length(struct task_struct *task,
79 unsigned long vl, unsigned long flags);
80
81extern int sve_set_current_vl(unsigned long arg);
82extern int sve_get_current_vl(void);
83
84/*
85 * Probing and setup functions.
86 * Calls to these functions must be serialised with one another.
87 */
88extern void __init sve_init_vq_map(void);
89extern void sve_update_vq_map(void);
90extern int sve_verify_vq_map(void);
91extern void __init sve_setup(void);
92
93#else /* ! CONFIG_ARM64_SVE */
94
95static inline void sve_alloc(struct task_struct *task) { }
96static inline void fpsimd_release_task(struct task_struct *task) { }
97static inline void sve_sync_to_fpsimd(struct task_struct *task) { }
98static inline void sve_sync_from_fpsimd_zeropad(struct task_struct *task) { }
99
100static inline int sve_set_current_vl(unsigned long arg)
101{
102 return -EINVAL;
103}
104
105static inline int sve_get_current_vl(void)
106{
107 return -EINVAL;
108}
109
110static inline void sve_init_vq_map(void) { }
111static inline void sve_update_vq_map(void) { }
112static inline int sve_verify_vq_map(void) { return 0; }
113static inline void sve_setup(void) { }
114
115#endif /* ! CONFIG_ARM64_SVE */
116
117/* For use by EFI runtime services calls only */
118extern void __efi_fpsimd_begin(void);
119extern void __efi_fpsimd_end(void);
120
121#endif
122
123#endif