opnsense-src/sys/powerpc/include
Timothy Pearson 077e30e61d powerpc: Fix multiple issues with FP/VSX save/restore
Multiple issues existed within the powerpc FP/VSX save/restore functionality,
leading to register corruption and loss of register contents in specific
scenarios involving high signal load and use of both floating point and VSX
instructions.

Issue #1

On little endian systems the PCB used the wrong location for the shadowed
FP register within the larger VSX register.  This appears to have been an
attempt to correct issue #2 without understanding how the vector load/store
instructions actually operate.

Issue #2

On little endian systems, the VSX state save/restore routines swapped 32-bit
words within the 64-bit aliased double word for the associated floating point
register.  This was due to the use of a word-oriented load/store vs. doubleword
oriented load/store.

Issue #3

The FPU was turned off in the PCB but not in hardware, leading to a potential
race condition if the same thread was scheduled immediately after sigreturn.

The triggering codebase for this is Go, which makes heavy use of signals and
and generates an unusual mix of floating point and VSX assembler.  As a result,
when combined with th powerpc lazy FPU restore, a condition was repeatedly hit
whereby the thread was interrupted in FP+VSX mode, then restored in FP only
mode, thus reliably triggering the issues above.

Also clean up the associated asm() style issue flagged by GitHub Actions.

Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>

MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1756
2025-07-13 14:00:56 -04:00
..
_align.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
_bus.h _bus.h: Use standard licnese text 2023-11-13 12:25:30 -07:00
_inttypes.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
_limits.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
_stdint.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
_types.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
altivec.h powerpc: Implement fpu_kern_enter/fpu_kern_leave 2023-09-17 13:21:04 -04:00
asm.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
atomic.h atomics: Constify loads 2024-12-16 15:42:26 +01:00
bat.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
bus.h powerpc: Fix bus_space_unmap 2024-01-23 09:37:53 -08:00
bus_dma.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
clock.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
counter.h sys: Avoid relying on pollution from refcount.h 2024-11-05 18:22:20 +00:00
cpu.h powerpc: Add nominal support for POWER10 and POWER11 2024-10-11 17:17:43 -04:00
cpufunc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
db_machdep.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
dbdma.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dump.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
efi.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
elf.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
endian.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
exec.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
float.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
floatingpoint.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
fpu.h powerpc: Implement fpu_kern_enter/fpu_kern_leave 2023-09-17 13:21:04 -04:00
frame.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
gdb_machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
hid.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
ieee.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ieeefp.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
ifunc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
in_cksum.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
intr_machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
kdb.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
limits.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
md_var.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
memdev.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
metadata.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
minidump.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
mmuvar.h pmap_growkernel(): do not panic immediately, optionally return the error 2025-06-20 01:25:56 +03:00
ofw_machdep.h ofw: convert boolean_t to bool 2024-06-26 11:14:36 -03:00
openpicreg.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
openpicvar.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
param.h pci: cleanup __PCI_REROUTE_INTERRUPTS 2025-01-23 16:30:31 -04:00
pcb.h powerpc: Fix multiple issues with FP/VSX save/restore 2025-07-13 14:00:56 -04:00
pcpu.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pcpu_aux.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pio.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
platform.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
platformvar.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pmap.h pmap: Convert boolean_t to bool. 2024-01-31 14:48:26 -08:00
pmc_mdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
proc.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
procctl.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
profile.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
psl.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
pte.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
ptrace.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
reg.h sys: Add cpu_update_pcb hook 2025-01-31 15:40:29 -05:00
reloc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
resource.h Revert "powernv: Add RF_BIGENDIAN resource flag" 2025-05-14 09:50:12 -04:00
rtas.h sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
sc_machdep.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sdt_machdep.h sdt: Implement SDT probes using hot-patching 2024-06-19 16:57:41 -04:00
setjmp.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
sigframe.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
signal.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
slb.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
smp.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
spr.h powernv: Explicitly enable the facilities we support 2025-03-19 18:35:17 -04:00
sr.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
stack.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
stdarg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sysarch.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tlb.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tls.h Add <machine/tls.h> header to hold MD constants and helpers for TLS. 2021-12-09 13:17:13 -08:00
trap.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
ucontext.h powerpc: Fix multiple issues with FP/VSX save/restore 2025-07-13 14:00:56 -04:00
vdso.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vmparam.h vm: retire vm_page_lock() 2025-06-11 15:19:41 -05:00