Skip to content

Commit e6fda52

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: "More SVE/SME fixes for ptrace() and for the (potentially future) case where SME is implemented in hardware without SVE support" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64/fpsimd: Sync and zero pad FPSIMD state for streaming SVE arm64/fpsimd: Sync FPSIMD state with SVE for SME only systems arm64/ptrace: Don't enable SVE when setting streaming SVE arm64/ptrace: Flush FP state when setting ZT0 arm64/fpsimd: Clear SME state in the target task when setting the VL
2 parents c8273a2 + 69af56a commit e6fda52

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static void fpsimd_to_sve(struct task_struct *task)
679679
void *sst = task->thread.sve_state;
680680
struct user_fpsimd_state const *fst = &task->thread.uw.fpsimd_state;
681681

682-
if (!system_supports_sve())
682+
if (!system_supports_sve() && !system_supports_sme())
683683
return;
684684

685685
vq = sve_vq_from_vl(thread_get_cur_vl(&task->thread));
@@ -705,7 +705,7 @@ static void sve_to_fpsimd(struct task_struct *task)
705705
unsigned int i;
706706
__uint128_t const *p;
707707

708-
if (!system_supports_sve())
708+
if (!system_supports_sve() && !system_supports_sme())
709709
return;
710710

711711
vl = thread_get_cur_vl(&task->thread);
@@ -835,7 +835,8 @@ void sve_sync_from_fpsimd_zeropad(struct task_struct *task)
835835
void *sst = task->thread.sve_state;
836836
struct user_fpsimd_state const *fst = &task->thread.uw.fpsimd_state;
837837

838-
if (!test_tsk_thread_flag(task, TIF_SVE))
838+
if (!test_tsk_thread_flag(task, TIF_SVE) &&
839+
!thread_sm_enabled(&task->thread))
839840
return;
840841

841842
vq = sve_vq_from_vl(thread_get_cur_vl(&task->thread));
@@ -909,7 +910,7 @@ int vec_set_vector_length(struct task_struct *task, enum vec_type type,
909910
*/
910911
task->thread.svcr &= ~(SVCR_SM_MASK |
911912
SVCR_ZA_MASK);
912-
clear_thread_flag(TIF_SME);
913+
clear_tsk_thread_flag(task, TIF_SME);
913914
free_sme = true;
914915
}
915916
}

arch/arm64/kernel/ptrace.c

Lines changed: 7 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));
@@ -1180,6 +1182,8 @@ static int zt_set(struct task_struct *target,
11801182
if (ret == 0)
11811183
target->thread.svcr |= SVCR_ZA_MASK;
11821184

1185+
fpsimd_flush_task_state(target);
1186+
11831187
return ret;
11841188
}
11851189

0 commit comments

Comments
 (0)