Skip to content

Commit 2f43f54

Browse files
brooniectmarinas
authored andcommitted
arm64/ptrace: Ensure that the task sees ZT writes on first use
When the value of ZT is set via ptrace we don't disable traps for SME. This means that when a the task has never used SME before then the value set via ptrace will never be seen by the target task since it will trigger a SME access trap which will flush the register state. Disable SME traps when setting ZT, this means we also need to allocate storage for SVE if it is not already allocated, for the benefit of streaming SVE. Fixes: f90b529 ("arm64/sme: Implement ZT0 ptrace support") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: <stable@vger.kernel.org> # 6.3.x Link: https://lore.kernel.org/r/20230816-arm64-zt-ptrace-first-use-v2-1-00aa82847e28@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 5d0a8d2 commit 2f43f54

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,11 @@ static int zt_set(struct task_struct *target,
11771177
if (!system_supports_sme2())
11781178
return -EINVAL;
11791179

1180+
/* Ensure SVE storage in case this is first use of SME */
1181+
sve_alloc(target, false);
1182+
if (!target->thread.sve_state)
1183+
return -ENOMEM;
1184+
11801185
if (!thread_za_enabled(&target->thread)) {
11811186
sme_alloc(target, true);
11821187
if (!target->thread.sme_state)
@@ -1186,8 +1191,10 @@ static int zt_set(struct task_struct *target,
11861191
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
11871192
thread_zt_state(&target->thread),
11881193
0, ZT_SIG_REG_BYTES);
1189-
if (ret == 0)
1194+
if (ret == 0) {
11901195
target->thread.svcr |= SVCR_ZA_MASK;
1196+
set_tsk_thread_flag(target, TIF_SME);
1197+
}
11911198

11921199
fpsimd_flush_task_state(target);
11931200

0 commit comments

Comments
 (0)