linux/arch
Mark Rutland be625d803c arm64/fpsimd: signal: Consistently read FPSIMD context
For historical reasons, restore_sve_fpsimd_context() has an open-coded
copy of the logic from read_fpsimd_context(), which is used to either
restore an FPSIMD-only context, or to merge FPSIMD state into an
SVE state when restoring an SVE+FPSIMD context. The logic is *almost*
identical.

Refactor the logic to avoid duplication and make this clearer.

This comes with two functional changes that I do not believe will be
problematic in practice:

* The user_fpsimd_state::size field will be checked in all restore paths
  that consume it user_fpsimd_state. The kernel always populates this
  field when delivering a signal, and so this should contain the
  expected value unless it has been corrupted.

* If a read of user_fpsimd_state fails, we will return early without
  modifying TIF_SVE, the saved SVCR, or the save fp_type. This will
  leave the task in a consistent state, without potentially resurrecting
  stale FPSIMD state. A read of user_fpsimd_state should never fail
  unless the structure has been corrupted or the stack has been
  unmapped.

Suggested-by: Will Deacon <will@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250508132644.1395904-5-mark.rutland@arm.com
[will: Ensure read_fpsimd_context() returns negative error code or zero]
Signed-off-by: Will Deacon <will@kernel.org>
2025-05-08 15:28:27 +01:00
..
alpha treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
arc irqdomain: Rename irq_set_default_host() to irq_set_default_domain() 2025-04-04 16:39:10 +02:00
arm A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
arm64 arm64/fpsimd: signal: Consistently read FPSIMD context 2025-05-08 15:28:27 +01:00
csky mm: pgtable: convert some architectures to use tlb_remove_ptdesc() 2025-04-01 15:17:13 -07:00
hexagon mm: pgtable: convert some architectures to use tlb_remove_ptdesc() 2025-04-01 15:17:13 -07:00
loongarch - The 2 patch series "mm: fixes for fallouts from mem_init() cleanup" 2025-04-03 11:10:00 -07:00
m68k treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
microblaze microblaze/mm: put mm_cmdline_setup() in .init.text section 2025-04-01 15:17:13 -07:00
mips A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
nios2 A set of updates for the interrupt subsystem: 2025-04-06 08:17:43 -07:00
openrisc mm: pgtable: convert some architectures to use tlb_remove_ptdesc() 2025-04-01 15:17:13 -07:00
parisc - The 6 patch series "Enable strict percpu address space checks" from 2025-04-01 09:29:18 -07:00
powerpc A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
riscv Kbuild updates for v6.15 2025-04-05 15:46:50 -07:00
s390 A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
sh A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
sparc treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
um treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
x86 A set of final cleanups for the timer subsystem: 2025-04-06 08:35:37 -07:00
xtensa treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
.gitignore
Kconfig Kbuild updates for v6.15 2025-04-05 15:46:50 -07:00