Page MenuHomeFreeBSD

Arch64: Clear VFP state on execve()
ClosedPublic

Authored by arichardson on Mar 4 2021, 3:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 18 2024, 5:12 PM
Unknown Object (File)
Jan 18 2024, 5:12 PM
Unknown Object (File)
Jan 18 2024, 5:11 PM
Unknown Object (File)
Jan 12 2024, 1:35 PM
Unknown Object (File)
Jan 10 2024, 2:13 PM
Unknown Object (File)
Dec 27 2023, 4:44 AM
Unknown Object (File)
Dec 23 2023, 3:34 AM
Unknown Object (File)
Dec 12 2023, 5:41 AM
Subscribers

Details

Summary

I noticed that many of the math-related tests were failing on AArch64.
After a lot of debugging, I noticed that the floating point exception flags
were not being reset when starting a new process. This change resets the
VFP inside exec_setregs() to ensure no VFP register state is leaked from
parent processes to children.

This commit also moves the clearing of fpcr that was added in 65618fdda0f27
from fork() to execve() since that makes more sense: fork() can retain
current register values, but execve() should result in a well-defined
clean state.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

  • Also reset VFP for LInux and FreeBSD32 processes
  • Drop unrelated changes
sys/arm64/arm64/machdep.c
557

This should be in vfp.c and should probably call vfp_discard to ensure the hardware state is updated if it's enabled.

sys/arm64/arm64/machdep.c
557

I just tried moving it to vfp.c but that makes things really ugly if I want to handle !VFP cases. Can't I just add

#ifdef VFP
	vfp_discard(td);
#endif

to the end of this function?

sys/arm64/arm64/vfp.c
413

I don't think this is needed in the !VFP case. It resets values that should only ever be used when the VFP is present and the kernel is built to use it.

If this is the case it could be renamed to vfp_reset_state and moved to be near vfp_save_state.

423

If an interrupt that causes the thread to switch to a new CPU we could end up with an inconsistent state. The simplest fix is to move this critical_enter call to above the bzero. I think it would also work to call vfp_discard first, then clear the state as this will ensure the VFP unit is off.

One minor point, feel free to fix without updating the review.

sys/arm64/linux/linux_sysvec.c
60

I don't think this is needed.

This revision is now accepted and ready to land.Mar 5 2021, 8:49 PM
This revision was automatically updated to reflect the committed changes.