Skip to content

Commit 1e530f1

Browse files
Julien Grallwilldeacon
authored andcommitted
arm64/sve: Implement a helper to flush SVE registers
Introduce a new helper that will zero all SVE registers but the first 128-bits of each vector. This will be used by subsequent patches to avoid costly store/maipulate/reload sequences in places like do_sve_acc(). Signed-off-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Dave Martin <Dave.Martin@arm.com> Link: https://lore.kernel.org/r/20200828181155.17745-6-broonie@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 6d40f05 commit 1e530f1

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

arch/arm64/include/asm/fpsimd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static inline void *sve_pffr(struct thread_struct *thread)
6969
extern void sve_save_state(void *state, u32 *pfpsr);
7070
extern void sve_load_state(void const *state, u32 const *pfpsr,
7171
unsigned long vq_minus_1);
72+
extern void sve_flush_live(void);
7273
extern unsigned int sve_get_vl(void);
7374

7475
struct arm64_cpu_capabilities;

arch/arm64/include/asm/fpsimdmacros.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@
164164
| ((\np) << 5)
165165
.endm
166166

167+
/* PFALSE P\np.B */
168+
.macro _sve_pfalse np
169+
_sve_check_preg \np
170+
.inst 0x2518e400 \
171+
| (\np)
172+
.endm
173+
167174
.macro __for from:req, to:req
168175
.if (\from) == (\to)
169176
_for__body %\from
@@ -198,6 +205,18 @@
198205
921:
199206
.endm
200207

208+
/* Preserve the first 128-bits of Znz and zero the rest. */
209+
.macro _sve_flush_z nz
210+
_sve_check_zreg \nz
211+
mov v\nz\().16b, v\nz\().16b
212+
.endm
213+
214+
.macro sve_flush
215+
_for n, 0, 31, _sve_flush_z \n
216+
_for n, 0, 15, _sve_pfalse \n
217+
_sve_wrffr 0
218+
.endm
219+
201220
.macro sve_save nxbase, xpfpsr, nxtmp
202221
_for n, 0, 31, _sve_str_v \n, \nxbase, \n - 34
203222
_for n, 0, 15, _sve_str_p \n, \nxbase, \n - 16

arch/arm64/kernel/entry-fpsimd.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SYM_FUNC_START(fpsimd_load_state)
3232
SYM_FUNC_END(fpsimd_load_state)
3333

3434
#ifdef CONFIG_ARM64_SVE
35+
3536
SYM_FUNC_START(sve_save_state)
3637
sve_save 0, x1, 2
3738
ret
@@ -46,4 +47,11 @@ SYM_FUNC_START(sve_get_vl)
4647
_sve_rdvl 0, 1
4748
ret
4849
SYM_FUNC_END(sve_get_vl)
50+
51+
/* Zero all SVE registers but the first 128-bits of each vector */
52+
SYM_FUNC_START(sve_flush_live)
53+
sve_flush
54+
ret
55+
SYM_FUNC_END(sve_flush_live)
56+
4957
#endif /* CONFIG_ARM64_SVE */

0 commit comments

Comments
 (0)