Commit Graph

552 Commits

Author SHA1 Message Date
msaitoh
43ebf58e10 - Add two more bit definitions
- XINUSE -> XGETBV
2014-09-11 18:11:59 +00:00
msaitoh
bd7e665bf4 Add new cache descriptor (0xc3) from the latest Intel SDM. 2014-09-09 15:11:33 +00:00
msaitoh
fb2cf9b066 Update CPUID(EAX=0x0d, ECX=1) from Intel SDM:
- XSAVEC(bit1)
- XGETBV(bit2)
- XSAVES(bit3)
2014-09-09 15:09:16 +00:00
joerg
eb6cc7528a Consistently define WARN in a way that passes format string checks, i.e.
always uses the same number of arguments as given in the format string.
2014-08-06 21:57:48 +00:00
uebayasi
8d26686d50 ipifunc[]: Comment IPI constant names for grep'ability. Constify. 2014-07-20 15:46:34 +00:00
msaitoh
fdfbcc0346 Fix some entries:
- Desc 0x55 and 0xb1 are Instruction TLB but not fixed to 4K.
 - Desc 0x5a and 0xc0 are Data TLB but not fixed to 4K.
 - Desc 0x57 and 0x59 are 4K fixed DTLB.
 - Fix string of desc 0xc2 and it's not fixed to 4K.
 - Desc 0xca is 4K fixed L2 shared TLB.
 - Add desc 0xa0.

BUG: A lot of CPUs have multiple CAI_DTLB and/or CAI_DTLB2 entries. Currently
TLB info is indexed in ci_cinfo[CAI_COUNT], so some info is overwritten.

Nowadays CPUs have very complexed TLBs. It's hard to manage with CAI_* index.
We should think to separate TLB info structure from ci_cinfo[CAI_COUNT]
in struct cpu_info.
2014-07-03 17:24:33 +00:00
riastradh
cd2156f4c2 Tweak x86 page freelists and add x86_select_freelist.
- Add 4G freelist to i386 -- there may be higher addresses if PAE.
- Add 64G and 1T freelists to amd64.
- Simplify freelist setup code and condense it into a table.
- Add x86_select_freelist to get a freelist guaranteed to yield
addresses no greater than a prescribed maximum address.

x86_select_freelist takes a uint64_t, not a paddr_t or bus_addr_t, so
that you can pass in, e.g., a 36-bit maximum address without needing
to write conditionals for i386/PAE.

No objections on port-x86:

https://mail-index.netbsd.org/port-i386/2014/05/21/msg003277.html
https://mail-index.netbsd.org/port-amd64/2014/05/21/msg002062.html
2014-06-12 19:02:35 +00:00
rmind
8011b285c0 Implement MI IPI interface with cross-call support. 2014-05-19 22:47:53 +00:00
joerg
b98dd0fb03 x86_progress takes a format string. 2014-04-06 18:48:06 +00:00
christos
e58a356cba make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
2014-03-29 19:28:24 +00:00
dsl
3a107b0ac4 Add support for saving the AVX-256 ymm registers during FPU context switches.
Add support for the forthcoming AVX-512 registers.
Code compiled with -mavx seems to work, but I've not tested context
  switches with live ymm registers.
There is a small cost on fork/exec (a larger area is copied/zerod),
  but I don't think the ymm registers are read/written unless they
  have been used.
The code use XSAVE on all cpus, I'm not brave enough to enable XSAVEOPT.
2014-02-25 22:16:52 +00:00
dsl
1bda540607 Add the XCR bits for snazzy upcoming features.
Define a mask for the fpu releated ones - only these wll be enabled.
The memory bound ones will need saving on every context switch.
2014-02-25 22:11:11 +00:00
dsl
a1bc28e807 Rename (the recently added) 'x86_xsave_size' to 'x86_fpu_save_size'
and default to 512 (the size of the fxsave structure).
2014-02-23 22:38:40 +00:00
dsl
21ead8e9af Add fpu_set_default_cw() and use it in the emulations to set the default
x87 control word.
This means that nothing outside fpu.c cares about the internals of the
  fpu save area.
New kernel modules won't load with the old kernel - but that won't matter.
2014-02-23 22:35:27 +00:00
dsl
f9cd6e68d1 Determine whether the cpu supports xsave (and hence AVX).
The result is only written to sysctl nodes at the moment.
I see:
machdep.fpu_save = 3 (implies xsaveopt)
machdep.xsave_size = 832
machdep.xsave_features = 7
Completely common up the i386 and amd64 machdep sysctl creation.
2014-02-23 12:56:40 +00:00
dsl
fc194a52bb Re-use the unused ci_cpu_serial[3] to save the highest cpuid values
for the normal and extended leafs.
(The 'normal' one might be luring in the global cpulevel.)
Read the 'extended feature' from cpuid.80000001.%ecx/edx into
    ci_feat_val[3/2] just after saving cpuid.1.%ecx/dx in ci_feat_val[1/0]
    instead of doing it separately for amd k678 and via c3 processors
    in their probe functions and repeating it for all cpus a few instructions
    later when x86_cpu_topology() is called.
x86_cpu_topology() is only called from cpu_probe() and really doesn't
  deserve its own source file. Chasing the setup code is bad enough anyway.
2014-02-22 17:48:08 +00:00
dsl
3b3cbac768 This needs stdint.h in userspace (for uint64_t) 2014-02-20 18:14:11 +00:00
dsl
ae3b84a62b It seems that firefox includes machine/fpu.h on amd64.
Add the file back so that the firwfox source doesn't have to depend
on the version of netbsd it is being compiled for.
(The i386 version doesn't play the same games in its SIGFPE handler.)
2014-02-18 18:39:10 +00:00
dsl
b5e700c786 Load and save the fpu registers (for copies to/from userspace) using
helper functions in arch/x86/x86/fpu.c
They (hopefully) ensure that we write to the entire buffer and don't load
  values that might cause faults in kernel.
Also zero out the 'pad' field of the i386 mcontext fp area that I think
  once contained the registers of any Weitek fpu.
  Dunno why it wasn't pasrt of the union.
Some of these copies could be removed if the code directly copied the save
  area to/from userspace addresses.
2014-02-15 22:20:41 +00:00
dsl
b9df3e93ac Remove all references to MDL_USEDFPU and deferred fpu initialisation.
The cost of zeroing the save area on exec is minimal.
This stops the FP registers of a random process being used the first
  time an lwp uses the fpu.
sendsig_siginfo() and get_mcontext() now unconditionally copy the FP
registers.
I'll remove the double-copy for signal handlers soon.
get_mcontext() might have been leaking kernel memory to userspace - and
  may still do so if i386_use_fxsave is false (short copies).
2014-02-15 10:11:14 +00:00
dsl
1a42f747d5 Check the argument types for the fpu asm functions. 2014-02-13 19:37:08 +00:00
dsl
e405c62563 Change i386 to use x86/fpu.c instead of i386/isa/npx.c
This changes the trap10 and trap13 code to call directly into fpu.c,
  removing all the code for T_ARITHTRAP, T_XMM and T_FPUNDA from i386/trap.c
Not all of the code thate appeared to handle fpu traps was ever called!
Most of the changes just replace the include of machine/npx.h with x86/fpu.h
  (or remove it entirely).
2014-02-12 23:24:09 +00:00
dsl
742d777c6d Move sys/arch/amd64/amd64/fpu.c and sys/arch/amd64/include/fpu.h
into sys/arch/x86 in preparation for using the same code for i386.
2014-02-11 20:17:16 +00:00
dsl
2736f96cdb Add x86_stmxcsr for amd64. 2014-02-09 17:07:41 +00:00
dsl
43beae7c02 Add compatibility for some userspace code (eg firefox) that seems to look
inside the ucontext structure passed to signal handlers to modify the
  xmm registers.
This should make the code compile - I'm not at all sure it works as expected,
  the interactions between FP and signal handlers aren't at all clear.
AFAICT the FP state is saved on the user stack when the handler is called,
  however the FP trap code can already done odd things to the FPU....
2014-02-09 14:44:42 +00:00
dsl
36d637262e Add bit defs for more of the x87 status register. 2014-02-08 22:36:50 +00:00
dsl
519a61193d Convert the amd64 build to use x86/cpu_extended_state.h so that the fpu
definitions match those of i386.
Mostly just structure and field renames, in addition:
1) process_xmm_to_s87() and process_s87_to_xmm() moved into
   x86/convert_xmm_s87.c so they can be used by amd64's netbsd32 code.
2) The linux signal code simplified to use a structure copy for ths fxsave
   data - it matches the hardware definition and won't change.
2014-02-07 22:40:22 +00:00
dsl
a3bf2d1fce Userspace (especially libkvm) build better is cpu_extended_state.h
is exported.
2014-02-07 21:52:46 +00:00
dsl
27a8f3e1e9 Move all the hardware register layout for the x86 cpus into a header
that can also be used by amd64.
Add in skeleton definitions for XSAVE and AVX.
Update some comments to match reality.
2014-02-07 19:36:15 +00:00
dsl
b2f9af25a4 There is no need to check for recursive calls into fpudna().
Rename the associated ci_fpsaving field to 'unused'.
I'm not sure they could ever happen, you could get unwanted calls into
  the fpu trap code while saving state when using INT13 - but these are
  different.
The return value from the i386 fpudna() was always 1 - possibly a historic
  relic of the kernel fp emulation. Remove and don't check in trap.S.
The amd64 and i386 fpudna() code is now almost identical.
2014-02-04 21:09:23 +00:00
dsl
51a0d6b173 Remove support for 'external' floating point units and the MS-DOS
compatible method of handling floating point exceptions.
Make kernel support for teh fpu non-optional (486SX should still work).
Only 386 cpus support external fpu, and i386 support was removed years ago.
This means that the npx code no longer uses port 0xf0 or interupt 13.
All the "npx at isa" lines go from the configs, arch/i386/isa/npx.c
  is now mandatory for all i386 kernels.
I've renamed npxinit() to fpuinit() and npxinit_cpu() to fpuinit_cpu()
  to match the very similar amd64 functions.
The fpu of the boot cpu is now initialised by a direct call from
  cpu_configure(), this enables FP emulation for a 486SX.
  (for amd64 the cr0 values are set in locore.S and similar).
This fixes a long-standing bug in linux_setregs() - which did not
  save the fpu regsiters if they were active.
I've test booted a single cpu i386 kernel (using anita).
amd64 builds - none of teh changes should affect it.
The i386 XEN kernels build, but I'm not sure where they set cr0, and
  it might have got lost!
2014-01-26 19:16:16 +00:00
christos
be5445b6bd Add softint case (Richard Hansen) 2014-01-11 17:10:40 +00:00
msaitoh
5f07a8b14e Add Energy Performance Bias bit. 2014-01-04 21:09:39 +00:00
msaitoh
3468c7c6bf Remove duplicated entry. Modify comments a bit. 2014-01-04 19:08:43 +00:00
msaitoh
0f129fa49e move XCR0 definitions to next to CR0's. 2013-12-25 13:14:36 +00:00
dsl
7d3a3fd1aa Remove the now-unused CPU_MAXMODEL and CPU_DEFMODEL 2013-12-08 18:08:34 +00:00
dsl
c4cd1a519d Add some definitions for cpu 'extended state'.
These are needed for support of the AVX SIMD instructions.
Nothing yet uses them.
2013-12-08 18:00:51 +00:00
christos
f0ceb57840 revert fpu/pcu changes until we figure out what's wrong; they cause random
freezes
2013-12-01 01:05:16 +00:00
msaitoh
66501cca1f - Add some AMD Fn80000001 extended features %ecx bits definitions from
the document (AMD64 Architecture ProgrammerVolume 3: General-Purpose and
  System Instructions. Document revision 3.20)

-  "s/MXX/MMXX/" because this bit is "MMX eXtention".
2013-11-20 17:50:39 +00:00
msaitoh
b1a32cacda Modify some macros and add some new macros for CPU family and model
to reduce code duplication and to avoid bug.

CPUID_TO_STEPPING(cpuid)	(not changed)

CPUID_TO_FAMILY(cpuid)		(new)
CPUID_TO_MODEL(cpuid)		(new)

	Return the display family and the display model.
	The macro names are the same as FreeBSD.

CPUID_TO_BASEFAMILY(cpuid)	(The old name was CPUID2FAMILY)
CPUID_TO_BASEMODEL(cpuid)	(The old name was CPUID2MODEL)

	Only for the base field.

CPUID_TO_EXTFAMILY(cpuid)	(The old name was CPUID2EXTFAMILY)
CPUID_TO_EXTMODEL(cpuid)	(The old name was CPUID2EXTMODEL)

	Only for the extended field.

See http://mail-index.netbsd.org/port-amd64/2013/11/12/msg001978.html
2013-11-15 08:47:55 +00:00
christos
abc81f7c5e use __unused instead of __USE and void cast to mark iterator variable unused
where needed (from phone)
2013-11-10 00:50:13 +00:00
christos
6bdd8d8ebf initialize cii before using it. 2013-11-05 16:04:13 +00:00
msaitoh
c622541618 Support prefetch size. 2013-10-28 05:41:49 +00:00
drochner
23780ff8df Use the MI "pcu" framework for bookkeeping of npx/fpu states on x86.
This reduces the amount of MD code enormously, and makes it easier
to implement support for newer CPU features which require more fpu
state, or for fpu usage by the kernel.
For access to FPU state across CPUs, an xcall kthread is used now
rather than a dedicated IPI.
No user visible changes intended.
2013-10-23 20:18:50 +00:00
msaitoh
a5b582da9e - Add Intel Deterministic Cache Parameter Leaf (CPUID leaf 4).
This definitions are required to know cache information of
  newer Intel CPU.
- Fix comment.
2013-10-21 06:11:49 +00:00
christos
148f2a4a9b __USE() unused variables 2013-10-17 20:59:16 +00:00
msaitoh
07c34455c2 Sort definitions. No functional change.
- CPUID_FEAT_BLACKLIST is for Fn00000001 %edx, so move it.
- Sort CPUID definitions with initial EAX value.
2013-10-04 17:53:19 +00:00
msaitoh
b688898b59 Add comment about CPUID Processor extended state Enumeration Fn0000000d %eax. 2013-10-04 17:21:43 +00:00
msaitoh
14076ae099 Add Shared L2 TLB and some cache and tlb entries from the latest document. 2013-09-14 17:21:19 +00:00
msaitoh
66afe11791 Add some definitions of Intel's cpuid feature from the latest document. 2013-09-14 17:18:18 +00:00