Skip to content

Commit 045aecd

Browse files
brooniectmarinas
authored andcommitted
arm64/ptrace: Don't enable SVE when setting streaming SVE
Systems which implement SME without also implementing SVE are architecturally valid but were not initially supported by the kernel, unfortunately we missed one issue in the ptrace code. The SVE register setting code is shared between SVE and streaming mode SVE. When we set full SVE register state we currently enable TIF_SVE unconditionally, in the case where streaming SVE is being configured on a system that supports vanilla SVE this is not an issue since we always initialise enough state for both vector lengths but on a system which only support SME it will result in us attempting to restore the SVE vector length after having set streaming SVE registers. Fix this by making the enabling of SVE conditional on setting SVE vector state. If we set streaming SVE state and SVE was not already enabled this will result in a SVE access trap on next use of normal SVE, this will cause us to flush our register state but this is fine since the only way to trigger a SVE access trap would be to exit streaming mode which will cause the in register state to be flushed anyway. Fixes: e12310a ("arm64/sme: Implement ptrace support for streaming mode SVE registers") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230803-arm64-fix-ptrace-ssve-no-sve-v1-1-49df214bfb3e@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 89a65c3 commit 045aecd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,11 +932,13 @@ static int sve_set_common(struct task_struct *target,
932932
/*
933933
* Ensure target->thread.sve_state is up to date with target's
934934
* FPSIMD regs, so that a short copyin leaves trailing
935-
* registers unmodified. Always enable SVE even if going into
936-
* streaming mode.
935+
* registers unmodified. Only enable SVE if we are
936+
* configuring normal SVE, a system with streaming SVE may not
937+
* have normal SVE.
937938
*/
938939
fpsimd_sync_to_sve(target);
939-
set_tsk_thread_flag(target, TIF_SVE);
940+
if (type == ARM64_VEC_SVE)
941+
set_tsk_thread_flag(target, TIF_SVE);
940942
target->thread.fp_type = FP_STATE_SVE;
941943

942944
BUILD_BUG_ON(SVE_PT_SVE_OFFSET != sizeof(header));

0 commit comments

Comments
 (0)