Skip to content

Commit 2fe2b96

Browse files
mrutland-armctmarinas
authored andcommitted
arm64/fpsimd: signal: Simplify preserve_tpidr2_context()
During a context-switch, tls_thread_switch() reads and writes a task's thread_struct::tpidr2_el0 field. Other code shouldn't access this field for an active task, as such accesses would form a data-race with a concurrent context-switch. The usage in preserve_tpidr2_context() is suspicious, but benign as any race with a context switch will write the same value back to current->thread.tpidr2_el0. Make this clearer and match restore_tpidr2_context() by using a temporary variable instead, avoiding the (benign) data-race. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Mark Brown <broonie@kernel.org> Cc: Will Deacon <will@kernel.org> Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250409164010.3480271-14-mark.rutland@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 929fa99 commit 2fe2b96

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

arch/arm64/kernel/signal.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,12 @@ extern int preserve_sve_context(void __user *ctx);
478478

479479
static int preserve_tpidr2_context(struct tpidr2_context __user *ctx)
480480
{
481+
u64 tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0);
481482
int err = 0;
482483

483-
current->thread.tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0);
484-
485484
__put_user_error(TPIDR2_MAGIC, &ctx->head.magic, err);
486485
__put_user_error(sizeof(*ctx), &ctx->head.size, err);
487-
__put_user_error(current->thread.tpidr2_el0, &ctx->tpidr2, err);
486+
__put_user_error(tpidr2_el0, &ctx->tpidr2, err);
488487

489488
return err;
490489
}

0 commit comments

Comments
 (0)