linux/arch/arm64
Ard Biesheuvel aefbab8e77 arm64: fpsimd: Preserve/restore kernel mode NEON at context switch
Currently, the FPSIMD register file is not preserved and restored along
with the general registers on exception entry/exit or context switch.
For this reason, we disable preemption when enabling FPSIMD for kernel
mode use in task context, and suspend the processing of softirqs so that
there are no concurrent uses in the kernel. (Kernel mode FPSIMD may not
be used at all in other contexts).

Disabling preemption while doing CPU intensive work on inputs of
potentially unbounded size is bad for real-time performance, which is
why we try and ensure that SIMD crypto code does not operate on more
than ~4k at a time, which is an arbitrary limit and requires assembler
code to implement efficiently.

We can avoid the need for disabling preemption if we can ensure that any
in-kernel users of the NEON will not lose the FPSIMD register state
across a context switch. And given that disabling softirqs implicitly
disables preemption as well, we will also have to ensure that a softirq
that runs code using FPSIMD can safely interrupt an in-kernel user.

So introduce a thread_info flag TIF_KERNEL_FPSTATE, and modify the
context switch hook for FPSIMD to preserve and restore the kernel mode
FPSIMD to/from struct thread_struct when it is set. This avoids any
scheduling blackouts due to prolonged use of FPSIMD in kernel mode,
without the need for manual yielding.

In order to support softirq processing while FPSIMD is being used in
kernel task context, use the same flag to decide whether the kernel mode
FPSIMD state needs to be preserved and restored before allowing FPSIMD
to be used in softirq context.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20231208113218.3001940-8-ardb@google.com
Signed-off-by: Will Deacon <will@kernel.org>
2023-12-12 14:31:54 +00:00
..
boot remoteproc updates for v6.7 2023-11-07 16:53:28 -08:00
configs ARM defconfig updates for 6.7 2023-11-01 15:04:32 -10:00
crypto crypto: arm64/sha512 - clean up backwards function names 2023-10-20 13:39:26 +08:00
hyperv arm64/hyperv: Use CPUHP_AP_HYPERV_ONLINE state to fix CPU online sequencing 2023-06-17 23:09:47 +00:00
include arm64: fpsimd: Preserve/restore kernel mode NEON at context switch 2023-12-12 14:31:54 +00:00
kernel arm64: fpsimd: Preserve/restore kernel mode NEON at context switch 2023-12-12 14:31:54 +00:00
kvm ARM: 2023-11-02 15:45:15 -10:00
lib arm64: Avoid cpus_have_const_cap() for ARM64_HAS_WFXT 2023-10-16 14:17:05 +01:00
mm arm64: mm: Fix "rodata=on" when CONFIG_RODATA_FULL_DEFAULT_ENABLED=y 2023-11-22 18:46:05 +00:00
net bpf: Use bpf_is_subprog to check for subprogs 2023-09-16 09:34:20 -07:00
tools arm64 updates for 6.7: 2023-11-01 09:34:55 -10:00
xen
Kbuild
Kconfig As usual, lots of singleton and doubleton patches all over the tree and 2023-11-02 20:53:31 -10:00
Kconfig.debug
Kconfig.platforms arm64: Add config for AMD Pensando SoC platforms 2023-09-28 09:45:23 +02:00
Makefile arm64: add dependency between vmlinuz.efi and Image 2023-11-23 19:10:29 +00:00