kselftest/arm64: Exit streaming mode after collecting signal context
authorMark Brown <broonie@kernel.org>
Thu, 27 Jul 2023 23:26:12 +0000 (00:26 +0100)
committerWill Deacon <will@kernel.org>
Fri, 4 Aug 2023 16:36:52 +0000 (17:36 +0100)
commitd6da04b6fbabf4b464bfe29e34ff10c62024d1e4
tree01e35e70dbf61386a4d0d1c7a3a98855f16a93f2
parentd1890517ac751a427b962caddda91ecc2bbf21d0
kselftest/arm64: Exit streaming mode after collecting signal context

When we collect a signal context with one of the SME modes enabled we will
have enabled that mode behind the compiler and libc's back so they may
issue some instructions not valid in streaming mode, causing spurious
failures.

For the code prior to issuing the BRK to trigger signal handling we need to
stay in streaming mode if we were already there since that's a part of the
signal context the caller is trying to collect. Unfortunately this code
includes a memset() which is likely to be heavily optimised and is likely
to use FP instructions incompatible with streaming mode. We can avoid this
happening by open coding the memset(), inserting a volatile assembly
statement to avoid the compiler recognising what's being done and doing
something in optimisation. This code is not performance critical so the
inefficiency should not be an issue.

After collecting the context we can simply exit streaming mode, avoiding
these issues. Use a full SMSTOP for safety to prevent any issues appearing
with ZA.

Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230728-arm64-signal-memcpy-fix-v4-1-0c1290db5d46@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/signal/test_signals_utils.h