arm64/fpsimd: Ensure SME storage is allocated after SVE VL changes
authorMark Brown <broonie@kernel.org>
Thu, 20 Jul 2023 18:38:58 +0000 (19:38 +0100)
committerWill Deacon <will@kernel.org>
Fri, 21 Jul 2023 10:11:09 +0000 (11:11 +0100)
commitd4d5be94a87872421ea2569044092535aff0b886
tree477368305c395b806d7e616abd78da0c85e53cc3
parent71e06e1acecbb50e712a3be9a7d56778509f3538
arm64/fpsimd: Ensure SME storage is allocated after SVE VL changes

When we reconfigure the SVE vector length we discard the backing storage
for the SVE vectors and then reallocate on next SVE use, leaving the SME
specific state alone. This means that we do not enable SME traps if they
were already disabled. That means that userspace code can enter streaming
mode without trapping, putting the task in a state where if we try to save
the state of the task we will fault.

Since the ABI does not specify that changing the SVE vector length disturbs
SME state, and since SVE code may not be aware of SME code in the process,
we shouldn't simply discard any ZA state. Instead immediately reallocate
the storage for SVE, and disable SME if we change the SVE vector length
while there is no SME state active.

Disabling SME traps on SVE vector length changes would make the overall
code more complex since we would have a state where we have valid SME state
stored but might get a SME trap.

Fixes: 9e4ab6c89109 ("arm64/sme: Implement vector length configuration prctl()s")
Reported-by: David Spickett <David.Spickett@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230720-arm64-fix-sve-sme-vl-change-v2-1-8eea06b82d57@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/fpsimd.c