HomeFreeBSD

[PowerPC] Fix outdated FP regs on fork(2) and friends

Description

[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

Details

Provenance
bdragonAuthored on May 3 2021, 2:12 AM
jhibbitsCommitted on Sep 4 2021, 4:33 PM
Differential Revision
D29851: [PowerPC] Fix outdated FP regs on fork(2) and friends
Parents
rGb0025f9b7ff0: openssh: update default version addendum in man pages
Branches
Unknown
Tags
Unknown