[PATCH 1/3] arm64: signal: Remove redundant SVE/SME cleanup logic
Mark Rutland
mark.rutland at arm.com
Tue Nov 3 04:13:44 PST 2026
Currently, restore_sve_fpsimd_context() and restore_za_context() clear
TIF_{SVE,SME} upon a memory allocation failure. This is benign, but
unnecessary:
* In restore_sve_fpsimd_context(), when sve_state cannot be allocated,
TIF_SVE is cleared. When sve_state is NULL, a task cannot legitimately
have TIF_SVE set, and hence the task should not have TIF_SVE set to
begin with.
* In restore_za_context(), when sme_state cannot be allocated, TIF_SME
is cleared and SVCR.ZA is cleared. When sme_state is NULL, a task
cannot legitimately have either TIF_SME set or SVCR.ZA set, and hence
the task should not have either set to begin with.
Historically, clearing TIF_{SVE,SME} served to (partially) hide bugs
where other code could leave the task in an invalid state. See:
https://lore.kernel.org/linux-arm-kernel/Z_Ueq4ezJyCPEJ6m@J2N7QTR9R3.cambridge.arm.com/
Those bugs have been fixed, and neither restore_sve_fpsimd_context() nor
restore_za_context() need to clear TIF_{SVE,SME}.
Delete the redundant logic.
Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Mark Brown <broonie at kernel.org>
Cc: Will Deacon <will at kernel.org>
---
arch/arm64/kernel/signal.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 6a06a4e352b1d..2e85ac6a24681 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -494,10 +494,8 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
}
sve_alloc(current, true);
- if (!current->thread.sve_state) {
- clear_thread_flag(TIF_SVE);
+ if (!current->thread.sve_state)
return -ENOMEM;
- }
if (sm) {
current->thread.svcr |= SVCR_SM_MASK;
@@ -629,11 +627,8 @@ static int restore_za_context(struct user_ctxs *user)
return -ENOMEM;
sme_alloc(current, true);
- if (!current->thread.sme_state) {
- current->thread.svcr &= ~SVCR_ZA_MASK;
- clear_thread_flag(TIF_SME);
+ if (!current->thread.sme_state)
return -ENOMEM;
- }
err = __copy_from_user(current->thread.sme_state,
(char __user const *)user->za +
--
2.30.2
More information about the linux-arm-kernel
mailing list