1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * FP/SIMD state saving and restoring
5 * Copyright (C) 2012 ARM Ltd.
6 * Author: Catalin Marinas <catalin.marinas@arm.com>
9 #include <linux/linkage.h>
11 #include <asm/assembler.h>
12 #include <asm/fpsimdmacros.h>
15 * Save the FP registers.
17 * x0 - pointer to struct fpsimd_state
19 SYM_FUNC_START(fpsimd_save_state)
22 SYM_FUNC_END(fpsimd_save_state)
25 * Load the FP registers.
27 * x0 - pointer to struct fpsimd_state
29 SYM_FUNC_START(fpsimd_load_state)
32 SYM_FUNC_END(fpsimd_load_state)
34 #ifdef CONFIG_ARM64_SVE
39 * x0 - pointer to buffer for state
40 * x1 - pointer to storage for FPSR
41 * x2 - Save FFR if non-zero
43 SYM_FUNC_START(sve_save_state)
46 SYM_FUNC_END(sve_save_state)
51 * x0 - pointer to buffer for state
52 * x1 - pointer to storage for FPSR
53 * x2 - Restore FFR if non-zero
55 SYM_FUNC_START(sve_load_state)
58 SYM_FUNC_END(sve_load_state)
60 SYM_FUNC_START(sve_get_vl)
63 SYM_FUNC_END(sve_get_vl)
65 SYM_FUNC_START(sve_set_vq)
66 sve_load_vq x0, x1, x2
68 SYM_FUNC_END(sve_set_vq)
71 * Zero all SVE registers but the first 128-bits of each vector
73 * VQ must already be configured by caller, any further updates of VQ
74 * will need to ensure that the register state remains valid.
79 SYM_FUNC_START(sve_flush_live)
80 cbz x1, 1f // A VQ-1 of 0 is 128 bits so no extra Z state
86 SYM_FUNC_END(sve_flush_live)
88 #endif /* CONFIG_ARM64_SVE */
90 #ifdef CONFIG_ARM64_SME
92 SYM_FUNC_START(sme_get_vl)
95 SYM_FUNC_END(sme_get_vl)
97 SYM_FUNC_START(sme_set_vq)
98 sme_load_vq x0, x1, x2
100 SYM_FUNC_END(sme_set_vq)
103 * Save the ZA and ZT state
105 * x0 - pointer to buffer for state
106 * x1 - number of ZT registers to save
108 SYM_FUNC_START(sme_save_state)
109 _sme_rdsvl 2, 1 // x2 = VL/8
110 sme_save_za 0, x2, 12 // Leaves x0 pointing to the end of ZA
116 SYM_FUNC_END(sme_save_state)
119 * Load the ZA and ZT state
121 * x0 - pointer to buffer for state
122 * x1 - number of ZT registers to save
124 SYM_FUNC_START(sme_load_state)
125 _sme_rdsvl 2, 1 // x2 = VL/8
126 sme_load_za 0, x2, 12 // Leaves x0 pointing to the end of ZA
132 SYM_FUNC_END(sme_load_state)
134 #endif /* CONFIG_ARM64_SME */