/* SPDX-License-Identifier: GPL-2.0-only */1/*2* FP/SIMD state saving and restoring3*4* Copyright (C) 2012 ARM Ltd.5* Author: Catalin Marinas <[email protected]>6*/78#include <linux/linkage.h>910#include <asm/assembler.h>11#include <asm/fpsimdmacros.h>1213/*14* Save the FP registers.15*16* x0 - pointer to struct fpsimd_state17*/18SYM_FUNC_START(fpsimd_save_state)19fpsimd_save x0, 820ret21SYM_FUNC_END(fpsimd_save_state)2223/*24* Load the FP registers.25*26* x0 - pointer to struct fpsimd_state27*/28SYM_FUNC_START(fpsimd_load_state)29fpsimd_restore x0, 830ret31SYM_FUNC_END(fpsimd_load_state)3233#ifdef CONFIG_ARM64_SVE3435/*36* Save the SVE state37*38* x0 - pointer to buffer for state39* x1 - pointer to storage for FPSR40* x2 - Save FFR if non-zero41*/42SYM_FUNC_START(sve_save_state)43sve_save 0, x1, x2, 344ret45SYM_FUNC_END(sve_save_state)4647/*48* Load the SVE state49*50* x0 - pointer to buffer for state51* x1 - pointer to storage for FPSR52* x2 - Restore FFR if non-zero53*/54SYM_FUNC_START(sve_load_state)55sve_load 0, x1, x2, 456ret57SYM_FUNC_END(sve_load_state)5859SYM_FUNC_START(sve_get_vl)60_sve_rdvl 0, 161ret62SYM_FUNC_END(sve_get_vl)6364SYM_FUNC_START(sve_set_vq)65sve_load_vq x0, x1, x266ret67SYM_FUNC_END(sve_set_vq)6869/*70* Zero all SVE registers but the first 128-bits of each vector71*72* VQ must already be configured by caller, any further updates of VQ73* will need to ensure that the register state remains valid.74*75* x0 = include FFR?76* x1 = VQ - 177*/78SYM_FUNC_START(sve_flush_live)79cbz x1, 1f // A VQ-1 of 0 is 128 bits so no extra Z state80sve_flush_z811: sve_flush_p82tbz x0, #0, 2f83sve_flush_ffr842: ret85SYM_FUNC_END(sve_flush_live)8687#endif /* CONFIG_ARM64_SVE */8889#ifdef CONFIG_ARM64_SME9091SYM_FUNC_START(sme_get_vl)92_sme_rdsvl 0, 193ret94SYM_FUNC_END(sme_get_vl)9596SYM_FUNC_START(sme_set_vq)97sme_load_vq x0, x1, x298ret99SYM_FUNC_END(sme_set_vq)100101/*102* Save the ZA and ZT state103*104* x0 - pointer to buffer for state105* x1 - number of ZT registers to save106*/107SYM_FUNC_START(sme_save_state)108_sme_rdsvl 2, 1 // x2 = VL/8109sme_save_za 0, x2, 12 // Leaves x0 pointing to the end of ZA110111cbz x1, 1f112_str_zt 01131:114ret115SYM_FUNC_END(sme_save_state)116117/*118* Load the ZA and ZT state119*120* x0 - pointer to buffer for state121* x1 - number of ZT registers to save122*/123SYM_FUNC_START(sme_load_state)124_sme_rdsvl 2, 1 // x2 = VL/8125sme_load_za 0, x2, 12 // Leaves x0 pointing to the end of ZA126127cbz x1, 1f128_ldr_zt 01291:130ret131SYM_FUNC_END(sme_load_state)132133#endif /* CONFIG_ARM64_SME */134135136