freebsd-skq/sys/x86/include
Konstantin Belousov 333d0c6060 Add support for the XSAVEOPT instruction use. Our XSAVE/XRSTOR usage
mostly meets the guidelines set by the Intel SDM:
1. We use XRSTOR and XSAVE from the same CPL using the same linear
   address for the store area
2. Contrary to the recommendations, we cannot zero the FPU save area
   for a new thread, since fork semantic requires the copy of the
   previous state. This advice seemingly contradicts to the advice
   from the item 6.
3. We do use XSAVEOPT in the context switch code only, and the area
   for XSAVEOPT already always contains the data saved by XSAVE.
4. We do not modify the save area between XRSTOR, when the area is
   loaded into FPU context, and XSAVE. We always spit the fpu context
   into save area and start emulation when directly writing into FPU
   context.
5. We do not use segmented addressing to access save area, or rather,
   always address it using %ds basing.
6. XSAVEOPT can be only executed in the area which was previously
   loaded with XRSTOR, since context switch code checks for FPU use by
   outgoing thread before saving, and thread which stopped emulation
   forcibly get context loaded with XRSTOR.
7. The PCB cannot be paged out while FPU emulation is turned off, since
   stack of the executing thread is never swapped out.

The context switch code is patched to issue XSAVEOPT instead of XSAVE
if supported. This approach eliminates one conditional in the context
switch code, which would be needed otherwise.

For user-visible machine context to have proper data, fpugetregs()
checks for unsaved extension blocks and manually copies pristine FPU
state into them, according to the description provided by CPUID leaf
0xd.

MFC after:  1 month
2012-07-14 15:48:30 +00:00
..
_align.h Merge amd64/i386 _align.h by aligning on the size of register_t (copied 2010-11-26 10:59:20 +00:00
_inttypes.h Copy powerpc/include/_inttypes.h to x86 and replace i386/amd64/pc98 2011-01-08 18:09:48 +00:00
_limits.h Consitently use "__LP64__". 2012-05-24 21:44:46 +00:00
_stdint.h Make the wchar_t type machine dependent. 2012-06-24 04:15:58 +00:00
_types.h Make the wchar_t type machine dependent. 2012-06-24 04:15:58 +00:00
apicreg.h
apm_bios.h Move identical copies of apm_bios.h to sys/x86/include, replace them with 2010-11-11 19:36:21 +00:00
bus.h Merge amd64 and i386 bus.h and move the resulting header to x86. Replace 2010-12-20 16:39:43 +00:00
endian.h Fix an issue introduced in sys/x86/include/endian.h with r232721. In 2012-03-29 23:31:48 +00:00
float.h Consitently use "__LP64__". 2012-05-24 21:44:46 +00:00
fpu.h Move userland bits of i386 npx.h and amd64 fpu.h to x86 fpu.h. 2012-03-16 20:24:30 +00:00
legacyvar.h Move the legacy(4) driver to x86. 2012-03-30 19:10:14 +00:00
mca.h Make machine check exception logging more readable. On newer Intel systems, 2012-04-02 15:07:22 +00:00
mptable.h Fix build when NEW_PCIB is not defined. 2011-07-16 14:05:34 +00:00
pci_cfgreg.h Move {amd64,i386}/pci/pci_bus.c and {amd64,i386}/include/pci_cfgreg.h to 2011-06-22 21:04:13 +00:00
psl.h Copy i386 psl.h to x86 and replace amd64/i386/pc98 psl.h with stubs. 2012-03-19 21:29:57 +00:00
ptrace.h Don't expose i386-only ptrace constants on amd64. This broke gdb with 2012-05-17 20:21:55 +00:00
reg.h Eliminate ia32_reg.h by moving its contents to x86 and ia64 reg.h. 2012-03-18 19:12:11 +00:00
segments.h Move the DTrace return IDT vector back up from 0x20 to 0x92. The 0x20 2012-03-28 16:32:17 +00:00
setjmp.h Copy amd64 setjmp.h to x86 and replace amd64/i386/pc98 setjmp.h with stubs. 2012-02-28 22:17:52 +00:00
specialreg.h Add support for the XSAVEOPT instruction use. Our XSAVE/XRSTOR usage 2012-07-14 15:48:30 +00:00
stdarg.h Copy amd64 stdarg.h to x86 and replace amd64/i386/pc98 stdarg.h with stubs. 2012-02-28 22:30:58 +00:00
sysarch.h Copy amd64 sysarch.h to x86 and merge with i386 sysarch.h. Replace 2012-03-19 21:57:31 +00:00
trap.h Copy amd64 trap.h to x86 and replace amd64/i386/pc98 trap.h with stubs. 2012-03-04 14:12:57 +00:00
vdso.h Implement mechanism to export some kernel timekeeping data to 2012-06-22 07:06:40 +00:00