Bug 206370 - amd64 fpu not fully initialized
Summary: amd64 fpu not fully initialized
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.2-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-01-18 16:13 UTC by joss.upton
Modified: 2017-08-24 14:21 UTC (History)
3 users (show)

See Also:


Attachments
fpu zero-ing diff (1.11 KB, patch)
2016-01-18 16:13 UTC, joss.upton
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description joss.upton 2016-01-18 16:13:23 UTC
Created attachment 165763 [details]
fpu zero-ing diff

The register file for the x86 MMU is not fully zero'd when creating the thread0 context.  This leaves garbage in several of the registers.  For the X87 FPU registers, they are properly tagged as empty, but the register file still contains garbage.  For the XMM registers, only register 0 is actually zero'd (not the whole file).  The diff attached, fully zero's the X87 registers and ALL 16 of the XMM registers.

The contents of the fxsave area look something like the stuff below w/out the diff.  With the diff, all of the registers are zero'd.  Diff is against 10.2-R.

xmm st0 = 0100000000000000ffff
xmm st1 = 00f0000000000000ffff
xmm st2 = 27e9000000000000ffff
xmm st3 = a1e8000000000000ffff
xmm st4 = 2800000000000000ffff
xmm st5 = 0000000000000000ffff
xmm st6 = 0a00000000000000ffff
xmm st7 = 00000000000000000000
xmm xmm0 = 00000000000000000000000000000000
xmm xmm1 = 0000c842000000000000000000000000
xmm xmm2 = 075b0000000000000000000000000000
xmm xmm3 = 00000080000000000000000000000000
xmm xmm4 = 40020000000000000000000000000000
xmm xmm5 = 020000e0000000000000000000000000
xmm xmm6 = 00400000000000000000000000000000
xmm xmm7 = 3f7f0000000000000000000000000000
xmm xmm8 = 00000000000000000000000000000000
xmm xmm9 = 00000000000000000000000000000000
xmm xmma = 00000000000000000000000000000000
xmm xmmb = 00000000000000000000000000000000
xmm xmmc = 00000000000000000000000000000000
xmm xmmd = 00000000000000000000000000000000
xmm xmme = 00000000000000000000000000000000
xmm xmmf = 00000000000000000000000000000000
Comment 1 commit-hook freebsd_committer freebsd_triage 2016-01-19 08:04:54 UTC
A commit references this bug:

Author: kib
Date: Tue Jan 19 08:04:02 UTC 2016
New revision: 294311
URL: https://svnweb.freebsd.org/changeset/base/294311

Log:
  Clear whole XMM register file instead of only XMM0.  Also clear x87
  registers.  This brings amd64 on par with i386, providing consistent
  initial FPU state.

  Note that we do not clear any extended state, at least because kernel
  does not understand extended state structure and consequences of zero
  overwrite after fninit()/fpusave().

  Submitted by:	joss.upton@yahoo.com
  PR:	206370
  MFC after:	2 weeks

Changes:
  head/sys/amd64/amd64/fpu.c
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2016-01-21 05:47:10 UTC
Assign to committer.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-02-02 14:16:25 UTC
A commit references this bug:

Author: kib
Date: Tue Feb  2 14:16:08 UTC 2016
New revision: 295148
URL: https://svnweb.freebsd.org/changeset/base/295148

Log:
  MFC r294311:
  Clear whole XMM register file instead of only XMM0.  Also clear x87
  registers.  This brings amd64 on par with i386, providing consistent
  initial FPU state.

  PR:	206370

  MFC r294312:
  Use ANSI definitions.  Wrap long line.

  MFC r294313:
  Adjust i386 comment to match amd64 one after r294311.

  Approved by:	re (gjb)

Changes:
_U  stable/10/
  stable/10/sys/amd64/amd64/fpu.c
  stable/10/sys/i386/isa/npx.c
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2017-08-24 14:01:10 UTC
Committed back in 2016.