xref: /openbmc/linux/arch/arm64/kernel/entry-fpsimd.S (revision 8dda2eac)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * FP/SIMD state saving and restoring
4 *
5 * Copyright (C) 2012 ARM Ltd.
6 * Author: Catalin Marinas <catalin.marinas@arm.com>
7 */
8
9#include <linux/linkage.h>
10
11#include <asm/assembler.h>
12#include <asm/fpsimdmacros.h>
13
14/*
15 * Save the FP registers.
16 *
17 * x0 - pointer to struct fpsimd_state
18 */
19SYM_FUNC_START(fpsimd_save_state)
20	fpsimd_save x0, 8
21	ret
22SYM_FUNC_END(fpsimd_save_state)
23
24/*
25 * Load the FP registers.
26 *
27 * x0 - pointer to struct fpsimd_state
28 */
29SYM_FUNC_START(fpsimd_load_state)
30	fpsimd_restore x0, 8
31	ret
32SYM_FUNC_END(fpsimd_load_state)
33
34#ifdef CONFIG_ARM64_SVE
35
36SYM_FUNC_START(sve_save_state)
37	sve_save 0, x1, 2
38	ret
39SYM_FUNC_END(sve_save_state)
40
41SYM_FUNC_START(sve_load_state)
42	sve_load 0, x1, x2, 3, x4
43	ret
44SYM_FUNC_END(sve_load_state)
45
46SYM_FUNC_START(sve_get_vl)
47	_sve_rdvl	0, 1
48	ret
49SYM_FUNC_END(sve_get_vl)
50
51SYM_FUNC_START(sve_set_vq)
52	sve_load_vq x0, x1, x2
53	ret
54SYM_FUNC_END(sve_set_vq)
55
56/*
57 * Load SVE state from FPSIMD state.
58 *
59 * x0 = pointer to struct fpsimd_state
60 * x1 = VQ - 1
61 *
62 * Each SVE vector will be loaded with the first 128-bits taken from FPSIMD
63 * and the rest zeroed. All the other SVE registers will be zeroed.
64 */
65SYM_FUNC_START(sve_load_from_fpsimd_state)
66	sve_load_vq	x1, x2, x3
67	fpsimd_restore	x0, 8
68	sve_flush_p_ffr
69	ret
70SYM_FUNC_END(sve_load_from_fpsimd_state)
71
72/*
73 * Zero all SVE registers but the first 128-bits of each vector
74 *
75 * VQ must already be configured by caller, any further updates of VQ
76 * will need to ensure that the register state remains valid.
77 *
78 * x0 = VQ - 1
79 */
80SYM_FUNC_START(sve_flush_live)
81	cbz		x0, 1f	// A VQ-1 of 0 is 128 bits so no extra Z state
82	sve_flush_z
831:	sve_flush_p_ffr
84	ret
85SYM_FUNC_END(sve_flush_live)
86
87#endif /* CONFIG_ARM64_SVE */
88