Page MenuHomeFreeBSD

Improve FPU Tag Word reconstruction on i386 to indicate register states
ClosedPublic

Authored by mgorny_gentoo.org on Oct 19 2020, 11:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 11:28 PM
Unknown Object (File)
Mar 22 2024, 8:47 PM
Unknown Object (File)
Jan 23 2024, 4:19 AM
Unknown Object (File)
Dec 27 2023, 4:26 PM
Unknown Object (File)
Dec 22 2023, 11:47 PM
Unknown Object (File)
Dec 18 2023, 2:20 AM
Unknown Object (File)
Dec 13 2023, 5:02 AM
Unknown Object (File)
Dec 3 2023, 2:20 PM
Subscribers

Details

Summary

Improve the code reconstructing en_tw in struct fpreg32 from FXSAVE results so that all register states are indicated correctly. The previous code unconditionally mapped non-empty register state to 'normalized value' constant. The new code explicitly distinguishes the 'zero value' and 'special value' constants as well. This improves consistency between real FSAVE and translation from FXSAVE, and ensures that tests using PT_GETFPREGS can rely on a single correct value independently of the underlying implementation.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250454

Sponsored by: The FreeBSD Foundation
Obtained from: Moritz Systems
Submitted by: Michał Górny <mgorny@moritz.systems>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

That said:

  1. I'm wondering if there's a common place we could move this function too not to duplicate it.
  2. I suppose we could use a packed struct to look at the float80 instead of pointer hacks.

Merging i386/npx.c and amd64/fpu.c is a lot of work for many reasons, I evaluated that several years ago. For now keeping them separate is better IMO.

sys/amd64/ia32/ia32_reg.c
178 ↗(On Diff #78419)

Merge these two lines into multiline comment.

185 ↗(On Diff #78419)

if ((ab_tw & i) != 0)

187 ↗(On Diff #78419)

Style requires struct fpacc87 *fx_reg.

188 ↗(On Diff #78419)

(uint16_t *)&fx_reg

Also a comment like 'masking the sign bit' would be due there.

189 ↗(On Diff #78419)

Please move fx_reg, exp, and mantissa declarations to the declaration block at the start of the function.

sys/i386/i386/npx.c
1193 ↗(On Diff #78419)

All comments from the amd64 ia32 version are applicable there as well.

If you update the review with the style(9) items @kib identified he or I will commit.

mgorny_gentoo.org marked 6 inline comments as done.

Fixed per review comments.

This revision is now accepted and ready to land.Oct 20 2020, 11:28 PM