freebsd-src/sys/powerpc/include
Brandon Bergren 35a1aa5f9c [PowerPC] Fix outdated FP regs on fork(2) and friends
Summary:
Failure to update the FP / vector state was causing daemon(3) to violate C ABI by failing to preserve nonvolatile registers.

This was causing a weird issue where moused was not working on PowerBook G4s when daemonizing, but was working fine when running it foreground.

Force saving off the same state that cpu_switch() does in cases where we are about to copy a thread.

MFC after: 1 week
Sponsored by: Tag1 Consulting, Inc.

Test Plan:
```
/*
 * Test for ABI violation due to side effects of daemon(3).
 *
 * NOTE: Compile with -O2 to see the effect.
 */
/* Allow compiling for Linux too. */

static double test = 1234.56f;

/*
 * This contrivance coerces clang to not bounce the double
 * off of memory again in main.
 */
void __attribute__((noinline))
print_double(int j1, int j2, double d)
{
	printf("%f\n", d);
}

int
main(int argc, char *argv[])
{
	print_double(0, 0, test);

	if (daemon(0, 1)) {
	}
	/* Compiler assumes nonvolatile regs are intact... */
	print_double(0, 0, test);
	return(0);
}
```

Working output:
```
1234.560059
1234.560059
```

Output in broken case:
```
1234.560059
0.0
```

Reviewers: #powerpc

Subscribers: jhibbits, luporl, alfredo

Tags: #powerpc

Differential Revision: https://reviews.freebsd.org/D29851
2021-09-04 11:33:03 -05:00
..
_align.h
_bus.h Regularize my copyright notice 2019-12-04 16:56:11 +00:00
_inttypes.h
_limits.h
_stdint.h
_types.h Reduce code duplication in machine/_types.h 2021-06-14 16:30:16 +01:00
altivec.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
asm.h Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
atomic.h [PowerPC] Fix ISA_206 subword atomics 2021-03-30 20:23:04 -05:00
bat.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
bus.h Add missing assignment forgotten in r365899 2020-09-20 15:11:52 +00:00
bus_dma.h Rename struct device to struct _device 2021-04-12 09:32:30 -04:00
clock.h
counter.h
cpu.h powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x 2021-03-31 13:34:06 -05:00
cpufunc.h powerpc: change mfpvr return type to uint32_t 2021-07-28 14:08:19 -03:00
db_machdep.h [PowerPC] kernel ifunc support for powerpc*, fix ppc64 relocation oddities. 2020-05-07 19:32:49 +00:00
dbdma.h
dump.h
efi.h
elf.h [PowerPC64LE] Adjust ELF definitions for LE. 2020-09-13 17:36:43 +00:00
endian.h Consolidate machine/endian.h definitions 2021-03-26 19:00:22 -03:00
exec.h
float.h
floatingpoint.h
fpu.h [POWERPC] Floating-Point Exception trap support 2020-11-06 13:34:30 +00:00
frame.h
gdb_machdep.h gdb: report specific stop reason for watchpoints 2021-03-30 11:36:41 -03:00
hid.h
ieee.h
ieeefp.h
ifunc.h [PowerPC] Define powerpc IFUNC kernel/userspace ABI. 2019-12-24 20:13:29 +00:00
in_cksum.h
intr_machdep.h
kdb.h Introduce kdb-level watchpoint functions 2021-03-29 12:05:43 -03:00
limits.h
machdep.h powerpc: Axe PPC4xx support. 2020-03-18 01:09:43 +00:00
md_var.h Move vm_page_dump bitset array definition to MI code 2020-09-21 22:20:37 +00:00
memdev.h Add the MEM_EXTRACT_PADDR ioctl to /dev/mem. 2020-09-02 18:12:47 +00:00
metadata.h
minidump.h Sparsify the vm_page_dump bitmap 2020-09-21 22:21:59 +00:00
mmuvar.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
ofw_machdep.h powerpc: Fix the NUMA domain list on powernv 2020-01-18 01:26:54 +00:00
openpicreg.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
openpicvar.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
param.h [PowerPC64LE] Set up powerpc.powerpc64le architecture 2020-09-22 23:49:30 +00:00
pcb.h [PowerPC64LE] Fix LE VSX/fpr interop 2020-12-03 01:39:59 +00:00
pcpu.h Remove PCPU_INC 2021-03-20 19:23:59 -07:00
pcpu_aux.h
pio.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
platform.h powerpc: Fix the NUMA domain list on powernv 2020-01-18 01:26:54 +00:00
platformvar.h
pmap.h Add pmap_vm_page_alloc_check() 2021-07-31 16:53:42 +03:00
pmc_mdep.h powerpc64: add Power8 and Power9 PMCs 2021-07-26 10:27:23 -03:00
proc.h Pass the syscall number to capsicum permission-denied signals 2021-07-16 18:06:44 +01:00
procctl.h
profile.h powerpc: Axe PPC4xx support. 2020-03-18 01:09:43 +00:00
psl.h [POWERPC] Floating-Point Exception trap support 2020-11-06 13:34:30 +00:00
pte.h Implement superpages for PowerPC64 (HPT) 2020-11-06 14:12:45 +00:00
ptrace.h
reg.h [PowerPC] Fix outdated FP regs on fork(2) and friends 2021-09-04 11:33:03 -05:00
reloc.h
resource.h powerpc/booke: Simplify the MPC85XX PCIe root complex driver 2019-10-24 03:51:33 +00:00
rtas.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
runq.h
sc_machdep.h
setjmp.h
sigframe.h
signal.h
slb.h Implement superpages for PowerPC64 (HPT) 2020-11-06 14:12:45 +00:00
smp.h
spr.h Wrap the default SPE config in its own #define 2021-05-29 21:53:26 -05:00
sr.h powerpc64: Implement Radix MMU for POWER9 CPUs 2020-05-11 02:33:37 +00:00
stack.h
stdarg.h
sysarch.h
tlb.h powerpc: Axe PPC4xx support. 2020-03-18 01:09:43 +00:00
trap.h powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
ucontext.h
vdso.h [PowerPC] Implement VDSO timebase access on powerpc* 2020-09-08 03:00:31 +00:00
vm.h Create VM_MEMATTR_DEVICE on all architectures 2021-04-12 06:15:31 +00:00
vmparam.h Implement superpages for PowerPC64 (HPT) 2020-11-06 14:12:45 +00:00