freebsd-dev/sys/powerpc
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
..
aim Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
amigaone powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
booke Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
conf sys/*/conf/*, docs: fix links to handbook 2021-05-20 09:27:10 +01:00
cpufreq powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
fpu Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
include [PowerPC] Fix outdated FP regs on fork(2) and friends 2021-09-04 11:33:03 -05:00
mambo Add CFI start/end proc directives to arm64, i386, and ppc 2020-12-05 00:33:28 +00:00
mikrotik powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00
mpc85xx Rename ofwpci.c to ofw_pcib.c 2021-05-20 11:22:25 +02:00
ofw bus_child_pnpinfo: fix two stragglers 2021-06-22 22:10:31 -06:00
powermac newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf 2021-06-22 20:52:06 -06:00
powernv newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf 2021-06-22 20:52:06 -06:00
powerpc [PowerPC] Fix outdated FP regs on fork(2) and friends 2021-09-04 11:33:03 -05:00
ps3 cam: clear on-stack CCBs in last few drivers 2021-05-21 08:53:59 +01:00
pseries powerpc/pseries: Allow radix pmap in pseries for ISA 3.0 2021-08-11 19:07:04 -05:00
psim powerpc: clean up empty lines in .c and .h files 2020-09-01 21:20:08 +00:00