hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/arch/arm64/include/asm/fpsimdmacros.h
....@@ -1,21 +1,12 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * FP/SIMD state saving and restoring macros
34 *
45 * Copyright (C) 2012 ARM Ltd.
56 * Author: Catalin Marinas <catalin.marinas@arm.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
187 */
8
+
9
+#include <asm/assembler.h>
1910
2011 .macro fpsimd_save state, tmpnr
2112 stp q0, q1, [\state, #16 * 0]
....@@ -175,23 +166,57 @@
175166 | ((\np) << 5)
176167 .endm
177168
169
+/* PFALSE P\np.B */
170
+.macro _sve_pfalse np
171
+ _sve_check_preg \np
172
+ .inst 0x2518e400 \
173
+ | (\np)
174
+.endm
175
+
178176 .macro __for from:req, to:req
179177 .if (\from) == (\to)
180
- _for__body \from
178
+ _for__body %\from
181179 .else
182
- __for \from, (\from) + ((\to) - (\from)) / 2
183
- __for (\from) + ((\to) - (\from)) / 2 + 1, \to
180
+ __for %\from, %((\from) + ((\to) - (\from)) / 2)
181
+ __for %((\from) + ((\to) - (\from)) / 2 + 1), %\to
184182 .endif
185183 .endm
186184
187185 .macro _for var:req, from:req, to:req, insn:vararg
188186 .macro _for__body \var:req
187
+ .noaltmacro
189188 \insn
189
+ .altmacro
190190 .endm
191191
192
+ .altmacro
192193 __for \from, \to
194
+ .noaltmacro
193195
194196 .purgem _for__body
197
+.endm
198
+
199
+/* Update ZCR_EL1.LEN with the new VQ */
200
+.macro sve_load_vq xvqminus1, xtmp, xtmp2
201
+ mrs_s \xtmp, SYS_ZCR_EL1
202
+ bic \xtmp2, \xtmp, ZCR_ELx_LEN_MASK
203
+ orr \xtmp2, \xtmp2, \xvqminus1
204
+ cmp \xtmp2, \xtmp
205
+ b.eq 921f
206
+ msr_s SYS_ZCR_EL1, \xtmp2 //self-synchronising
207
+921:
208
+.endm
209
+
210
+/* Preserve the first 128-bits of Znz and zero the rest. */
211
+.macro _sve_flush_z nz
212
+ _sve_check_zreg \nz
213
+ mov v\nz\().16b, v\nz\().16b
214
+.endm
215
+
216
+.macro sve_flush
217
+ _for n, 0, 31, _sve_flush_z \n
218
+ _for n, 0, 15, _sve_pfalse \n
219
+ _sve_wrffr 0
195220 .endm
196221
197222 .macro sve_save nxbase, xpfpsr, nxtmp
....@@ -207,14 +232,7 @@
207232 str w\nxtmp, [\xpfpsr, #4]
208233 .endm
209234
210
-.macro sve_load nxbase, xpfpsr, xvqminus1, nxtmp, xtmp2
211
- mrs_s x\nxtmp, SYS_ZCR_EL1
212
- bic \xtmp2, x\nxtmp, ZCR_ELx_LEN_MASK
213
- orr \xtmp2, \xtmp2, \xvqminus1
214
- cmp \xtmp2, x\nxtmp
215
- b.eq 921f
216
- msr_s SYS_ZCR_EL1, \xtmp2 // self-synchronising
217
-921:
235
+.macro __sve_load nxbase, xpfpsr, nxtmp
218236 _for n, 0, 31, _sve_ldr_v \n, \nxbase, \n - 34
219237 _sve_ldr_p 0, \nxbase
220238 _sve_wrffr 0
....@@ -225,3 +243,8 @@
225243 ldr w\nxtmp, [\xpfpsr, #4]
226244 msr fpcr, x\nxtmp
227245 .endm
246
+
247
+.macro sve_load nxbase, xpfpsr, xvqminus1, nxtmp, xtmp2
248
+ sve_load_vq \xvqminus1, x\nxtmp, \xtmp2
249
+ __sve_load \nxbase, \xpfpsr, \nxtmp
250
+.endm