mirror of
https://github.com/opnsense/src.git
synced 2026-05-04 17:05:14 -04:00
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
|
||
|---|---|---|
| .. | ||
| _align.h | ||
| _bus.h | ||
| _inttypes.h | ||
| _limits.h | ||
| _stdint.h | ||
| _types.h | ||
| altivec.h | ||
| asm.h | ||
| atomic.h | ||
| bat.h | ||
| bus.h | ||
| bus_dma.h | ||
| clock.h | ||
| counter.h | ||
| cpu.h | ||
| cpufunc.h | ||
| db_machdep.h | ||
| dbdma.h | ||
| dump.h | ||
| efi.h | ||
| elf.h | ||
| endian.h | ||
| exec.h | ||
| float.h | ||
| floatingpoint.h | ||
| fpu.h | ||
| frame.h | ||
| gdb_machdep.h | ||
| hid.h | ||
| ieee.h | ||
| ieeefp.h | ||
| ifunc.h | ||
| in_cksum.h | ||
| intr_machdep.h | ||
| kdb.h | ||
| limits.h | ||
| machdep.h | ||
| md_var.h | ||
| memdev.h | ||
| metadata.h | ||
| minidump.h | ||
| mmuvar.h | ||
| ofw_machdep.h | ||
| openpicreg.h | ||
| openpicvar.h | ||
| param.h | ||
| pcb.h | ||
| pcpu.h | ||
| pcpu_aux.h | ||
| pio.h | ||
| platform.h | ||
| platformvar.h | ||
| pmap.h | ||
| pmc_mdep.h | ||
| proc.h | ||
| procctl.h | ||
| profile.h | ||
| psl.h | ||
| pte.h | ||
| ptrace.h | ||
| reg.h | ||
| reloc.h | ||
| resource.h | ||
| rtas.h | ||
| runq.h | ||
| sc_machdep.h | ||
| setjmp.h | ||
| sigframe.h | ||
| signal.h | ||
| slb.h | ||
| smp.h | ||
| spr.h | ||
| sr.h | ||
| stack.h | ||
| stdarg.h | ||
| sysarch.h | ||
| tlb.h | ||
| trap.h | ||
| ucontext.h | ||
| vdso.h | ||
| vm.h | ||
| vmparam.h | ||