freebsd-dev/sys/i386/i386
Konstantin Belousov 8c6f8f3d5b Add support for the extended FPU states on amd64, both for native
64bit and 32bit ABIs.  As a side-effect, it enables AVX on capable
CPUs.

In particular:

- Query the CPU support for XSAVE, list of the supported extensions
  and the required size of FPU save area. The hw.use_xsave tunable is
  provided for disabling XSAVE, and hw.xsave_mask may be used to
  select the enabled extensions.

- Remove the FPU save area from PCB and dynamically allocate the
  (run-time sized) user save area on the top of the kernel stack,
  right above the PCB. Reorganize the thread0 PCB initialization to
  postpone it after BSP is queried for save area size.

- The dumppcb, stoppcbs and susppcbs now do not carry the FPU state as
  well. FPU state is only useful for suspend, where it is saved in
  dynamically allocated suspfpusave area.

- Use XSAVE and XRSTOR to save/restore FPU state, if supported and
  enabled.

- Define new mcontext_t flag _MC_HASFPXSTATE, indicating that
  mcontext_t has a valid pointer to out-of-struct extended FPU
  state. Signal handlers are supplied with stack-allocated fpu
  state. The sigreturn(2) and setcontext(2) syscall honour the flag,
  allowing the signal handlers to inspect and manipilate extended
  state in the interrupted context.

- The getcontext(2) never returns extended state, since there is no
  place in the fixed-sized mcontext_t to place variable-sized save
  area. And, since mcontext_t is embedded into ucontext_t, makes it
  impossible to fix in a reasonable way.  Instead of extending
  getcontext(2) syscall, provide a sysarch(2) facility to query
  extended FPU state.

- Add ptrace(2) support for getting and setting extended state; while
  there, implement missed PT_I386_{GET,SET}XMMREGS for 32bit binaries.

- Change fpu_kern KPI to not expose struct fpu_kern_ctx layout to
  consumers, making it opaque. Internally, struct fpu_kern_ctx now
  contains a space for the extended state. Convert in-kernel consumers
  of fpu_kern KPI both on i386 and amd64.

First version of the support for AVX was submitted by Tim Bird
<tim.bird am sony com> on behalf of Sony. This version was written
from scratch.

Tested by:	pho (previous version), Yamagi Burmeister <lists yamagi org>
MFC after:	1 month
2012-01-21 17:45:27 +00:00
..
apic_vector.s Reintroduce the lazypmap infrastructure and convert it to using 2011-05-20 14:53:16 +00:00
atomic.c
atpic_vector.s Clear DF bit in eflags/rflags on the kernel entry. The i386 and amd64 2010-06-23 20:44:07 +00:00
autoconf.c
bios.c MFp4: 2008-11-02 18:48:54 +00:00
bioscall.s
bpf_jit_machdep.c If a conditional jump instruction has the same jt and jf, do not perform 2010-04-22 23:47:19 +00:00
bpf_jit_machdep.h If a conditional jump instruction has the same jt and jf, do not perform 2010-04-22 23:47:19 +00:00
db_disasm.c Decode some more "exotic" instructions including: fxsave, fxrstor, ldmxcsr, 2008-08-11 20:19:42 +00:00
db_interface.c
db_trace.c Reintroduce the lazypmap infrastructure and convert it to using 2011-05-20 14:53:16 +00:00
elan-mmcr.c Use intr_disable() and intr_restore() instead of frobbing the flags register 2010-10-25 15:28:03 +00:00
elf_machdep.c Extend struct sysvec with new method sv_schedtail, which is used for an 2011-03-08 19:01:45 +00:00
exception.s Register an interrupt vector for DTrace return probes. There is some 2010-08-28 08:03:29 +00:00
gdb_machdep.c
genassym.c - Remove the eintrcnt/eintrnames usage and introduce the concept of 2011-07-18 15:19:40 +00:00
geode.c Apply a patch that has been lingering in my inbox for far too long: 2010-05-15 10:31:11 +00:00
i686_mem.c Avoid preemption while manipulating CRs and MTRRs. 2011-01-17 17:30:35 +00:00
identcpu.c Update CPUID bits to reflect AMD Bulldozer and Intel Sandy Bridge features. 2011-05-17 22:36:16 +00:00
in_cksum.c Trim comments about the MP-safety of various bits of the amd64/i386 2009-03-09 13:11:16 +00:00
initcpu.c Improve CPU identifications of various IDT/Centaur/VIA, Rise and Transmeta 2011-03-26 02:02:07 +00:00
intr_machdep.c - Remove the eintrcnt/eintrnames usage and introduce the concept of 2011-07-18 15:19:40 +00:00
io.c - Extract the IODEV_PIO interface from ia64 and make it MI. 2010-04-28 15:38:01 +00:00
k6_mem.c Initial suspend/resume support for amd64. 2009-03-17 00:48:11 +00:00
legacy.c - There's no need to overwrite the default device method with the default 2011-11-22 21:28:20 +00:00
locore.s Simplify the implementation of the identity mapping in start_all_aps(). 2011-12-15 17:54:23 +00:00
longrun.c Use intr_disable() and intr_restore() instead of frobbing the flags register 2010-10-25 15:28:03 +00:00
machdep.c Add support for the extended FPU states on amd64, both for native 2012-01-21 17:45:27 +00:00
mem.c Add reader/writer lock around mem_range_attr_get() and mem_range_attr_set(). 2011-01-17 22:58:28 +00:00
minidump_machdep.c Add the watchdogs patting during the (shutdown time) disk syncing and 2011-04-28 16:02:05 +00:00
mp_clock.c
mp_machdep.c Simplify the implementation of the identity mapping in start_all_aps(). 2011-12-15 17:54:23 +00:00
mp_watchdog.c Move <machine/apicreg.h> to <x86/apicreg.h>. 2010-11-01 18:18:46 +00:00
mpboot.s Move <machine/apicreg.h> to <x86/apicreg.h>. 2010-11-01 18:18:46 +00:00
perfmon.c Use atomic load & store for TSC frequency. It may be overkill for amd64 but 2011-04-07 23:28:28 +00:00
pmap.c Fix a bug in the Xen pmap's implementation of pmap_extract_and_hold(): 2011-12-28 19:59:54 +00:00
ptrace_machdep.c Introduce the x86 kernel interfaces to allow kernel code to use 2010-06-05 15:59:59 +00:00
stack_machdep.c
support.s - Remove the eintrcnt/eintrnames usage and introduce the concept of 2011-07-18 15:19:40 +00:00
swtch.s Reintroduce the lazypmap infrastructure and convert it to using 2011-05-20 14:53:16 +00:00
symbols.raw
sys_machdep.c Use curthread rather than PCPU_GET(curthread). 'curthread' uses 2011-12-29 16:40:54 +00:00
trap.c Attempt to improve formatting and content of several comments for 2011-11-09 18:25:50 +00:00
uio_machdep.c Put the general logic for being a CPU hog into a new function 2011-02-02 16:35:10 +00:00
vm86.c Change the functions to ANSI in those cases where it breaks promotion 2009-02-24 18:09:31 +00:00
vm86bios.s Fix yet another fallout from r208833. VM86 BIOS call may cause page fault 2011-01-19 17:09:07 +00:00
vm_machdep.c Remove pc_other_cpus usage from i386 and XEN. 2011-06-22 20:04:39 +00:00