__sve_load_p(state, vl, ffr);
}
-extern void sve_flush_live(bool flush_ffr, unsigned long vq_minus_1);
+/*
+ * Zero all SVE registers except for the first 128 bits of each vector.
+ *
+ * The caller must ensure that the VL has been configured and the CPU must be
+ * in non-streaming mode.
+ */
+static inline void sve_flush_live(void)
+{
+ unsigned long vl = sve_get_vl();
+
+ if (vl > sizeof(__uint128_t)) {
+ asm volatile(
+ __FPSIMD_PREAMBLE
+ FOR_EACH_Z_REG("n", "mov v\\n\\().16b, v\\n\\().16b")
+ );
+ }
+
+ asm volatile(
+ __SVE_PREAMBLE
+ FOR_EACH_P_REG("n", "pfalse p\\n\\().b")
+ " wrffr p0.b\n"
+ );
+}
+
extern void sme_save_state(struct arm64_sme_state *state, int zt);
extern void sme_load_state(const struct arm64_sme_state *state, int zt);
.endif
.endm
-/* Deprecated macros for SVE instructions */
-
-/* WRFFR P\np.B */
-.macro _sve_wrffr np
- .arch_extension sve
- wrffr p\np\().b
-.endm
-
-/* PFALSE P\np.B */
-.macro _sve_pfalse np
- .arch_extension sve
- pfalse p\np\().b
-.endm
-
/* Deprecated macros for SME instructions */
/* RDSVL X\nx, #\imm */
.purgem _for__body
.endm
-/* Preserve the first 128-bits of Znz and zero the rest. */
-.macro _sve_flush_z nz
- _sve_check_zreg \nz
- mov v\nz\().16b, v\nz\().16b
-.endm
-
-.macro sve_flush_z
- _for n, 0, 31, _sve_flush_z \n
-.endm
-.macro sve_flush_p
- _for n, 0, 15, _sve_pfalse \n
-.endm
-.macro sve_flush_ffr
- _sve_wrffr 0
-.endm
-
.macro sme_save_za nxbase, xvl, nw
mov w\nw, #0
if (!system_supports_sve())
return;
- if (test_thread_flag(TIF_SVE)) {
- unsigned int sve_vq_minus_one;
-
- sve_vq_minus_one = sve_vq_from_vl(task_get_sve_vl(current)) - 1;
- sve_flush_live(true, sve_vq_minus_one);
- }
+ if (test_thread_flag(TIF_SVE))
+ sve_flush_live();
/*
* Any live non-FPSIMD SVE state has been zeroed. Allow
#include <asm/assembler.h>
#include <asm/fpsimdmacros.h>
-#ifdef CONFIG_ARM64_SVE
-
-/*
- * Zero all SVE registers but the first 128-bits of each vector
- *
- * VQ must already be configured by caller, any further updates of VQ
- * will need to ensure that the register state remains valid.
- *
- * x0 = include FFR?
- * x1 = VQ - 1
- */
-SYM_FUNC_START(sve_flush_live)
- cbz x1, 1f // A VQ-1 of 0 is 128 bits so no extra Z state
- sve_flush_z
-1: sve_flush_p
- tbz x0, #0, 2f
- sve_flush_ffr
-2: ret
-SYM_FUNC_END(sve_flush_live)
-
-#endif /* CONFIG_ARM64_SVE */
-
#ifdef CONFIG_ARM64_SME
/*
if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) {
unsigned long vq = sve_vq_from_vl(task_get_sve_vl(current));
sysreg_clear_set_s(SYS_ZCR_EL1, ZCR_ELx_LEN, vq - 1);
- sve_flush_live(true, vq - 1);
+ sve_flush_live();
fpsimd_bind_task_to_cpu();
} else {
fpsimd_to_sve(current);