Skip to content

Commit 9c4b4c7

Browse files
Julien Grallwilldeacon
authored andcommitted
arm64/sve: Implement a helper to load SVE registers from FPSIMD state
In a follow-up patch, we may save the FPSIMD rather than the full SVE state when the state has to be zeroed on return to userspace (e.g during a syscall). Introduce an helper to load SVE vectors from FPSIMD state and zero the rest of SVE registers. 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-7-broonie@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 1e530f1 commit 9c4b4c7

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

arch/arm64/include/asm/fpsimd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ 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);
7272
extern void sve_flush_live(void);
73+
extern void sve_load_from_fpsimd_state(struct user_fpsimd_state const *state,
74+
unsigned long vq_minus_1);
7375
extern unsigned int sve_get_vl(void);
7476

7577
struct arm64_cpu_capabilities;

arch/arm64/kernel/entry-fpsimd.S

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ SYM_FUNC_START(sve_get_vl)
4848
ret
4949
SYM_FUNC_END(sve_get_vl)
5050

51+
/*
52+
* Load SVE state from FPSIMD state.
53+
*
54+
* x0 = pointer to struct fpsimd_state
55+
* x1 = VQ - 1
56+
*
57+
* Each SVE vector will be loaded with the first 128-bits taken from FPSIMD
58+
* and the rest zeroed. All the other SVE registers will be zeroed.
59+
*/
60+
SYM_FUNC_START(sve_load_from_fpsimd_state)
61+
sve_load_vq x1, x2, x3
62+
fpsimd_restore x0, 8
63+
_for n, 0, 15, _sve_pfalse \n
64+
_sve_wrffr 0
65+
ret
66+
SYM_FUNC_END(sve_load_from_fpsimd_state)
67+
5168
/* Zero all SVE registers but the first 128-bits of each vector */
5269
SYM_FUNC_START(sve_flush_live)
5370
sve_flush

0 commit comments

Comments
 (0)