]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64/fpsimd: Reset FPMR upon exec()
authorMark Rutland <mark.rutland@arm.com>
Wed, 9 Apr 2025 16:40:05 +0000 (17:40 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 9 Apr 2025 17:06:31 +0000 (18:06 +0100)
An exec() is expected to reset all FPSIMD/SVE/SME state, and barring
special handling of the vector lengths, the state is expected to reset
to zero. This reset is handled in fpsimd_flush_thread(), which the core
exec() code calls via flush_thread().

When support was added for FPMR, no logic was added to
fpsimd_flush_thread() to reset the FPMR value, and thus it is
erroneously inherited across an exec().

Add the missing reset of FPMR.

Fixes: 203f2b95a882 ("arm64/fpsimd: Support FEAT_FPMR")
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-9-mark.rutland@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/fpsimd.c

index 4a0b0bb3a3fadf54a2ba0ab80a037cf0190c6190..0b6fda5b7bad5a9c02e7ae6e6f8baee2255b134f 100644 (file)
@@ -1638,6 +1638,9 @@ void fpsimd_flush_thread(void)
                current->thread.svcr = 0;
        }
 
+       if (system_supports_fpmr())
+               current->thread.uw.fpmr = 0;
+
        current->thread.fp_type = FP_STATE_FPSIMD;
 
        put_cpu_fpsimd_context();