Commit Graph

1819 Commits

Author SHA1 Message Date
riz
e4b52786d3 Work around the problem in PR port-amd64/49150 for all CPUs under Xen.
The problem (calling xrstor, which is privileged in Xen) has appeared
on some Intel CPUs as well, so implement the workaround (ensure that
x86_xsave_features is 0) for all CPUs, not just AMD CPUs.

XXX pullup to 7
2014-10-28 17:44:47 +00:00
christos
8933a7a2ee dtrace expects a globally accessible syscall symbol. 2014-10-26 15:38:28 +00:00
uebayasi
c0e750b9f1 Install agp_* drivers where pchb(4) is installed except INSTALL_FLOPPY.
XXX
Config around agp(4) is done in quite wrong direction.
	"pchb <- (agpbus) <- agp <- agp_*"
should be:
	"pchb <- (pcibus) <- agp_* <- (agpbus) <- agp"
2014-10-18 16:56:51 +00:00
uebayasi
32ac81d114 Fix another indirect circular dependency (agp_* -> (agpbus) -> pchb -> abp_*).
Fixes "no agp*" build.  Reported & build-tested by Kurt Schreiner.
2014-10-17 20:55:21 +00:00
bouyer
5266e8ff9b Add a missing || defined(XEN) which cause Xen non-DIAGNOSTIC kernels
to panic at boot.
2014-10-14 06:59:58 +00:00
jnemeth
debcdd0290 Force x86_xsave_features to 0 when running under XEN for AMD
processors.  This prevents the use of xsave and xrstor thus fixing
the problem in PR/49150.  The basic problem is that the way AMD
implements those instructions means that information can leak
between domains so XEN treats them as privileged.

XXX If anybody else comes up with a better / more "proper" fix, go
for it.  However, this solves the problem I was having.  And, given
that XEN being broken is pretty much a show-stopper for a release,
something needed to be done.
2014-10-14 03:16:56 +00:00
uebayasi
0895dc7210 Normalize: acpicpu depends on acpi. 2014-10-10 17:44:17 +00:00
uebayasi
46d7be3c23 Define "machdep" attribute and mark files (in amd64 and x86). 2014-10-10 09:13:21 +00:00
nat
812d660db3 Make remote access cards on HP ProLiant microservers N36L,
N40L and N54L work with ipmi(4).

Addresses PR 48233.

This commit was approved by christos@
2014-09-22 13:30:55 +00:00
christos
49527aa22e remove stray continue. 2014-09-21 16:52:26 +00:00
christos
7665fdf165 fix leak. 2014-09-21 16:40:53 +00:00
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
hikaru
3722b36159 Set ifflags callback so that the device can enter promiscuous mode. 2014-08-14 05:42:16 +00:00
jnemeth
3481529578 Add the infrastructure for MODULAR support for Xen kernels. At
the moment, this can only load very simple modules due to missing
symbols.  It is being add at this time to make pullups to the
netbsd-7 branch easier.  It is not enabled by default in any kernels.
2014-08-11 03:43:25 +00:00
tls
ea6af427bd Merge tls-earlyentropy branch into HEAD. 2014-08-10 16:44:32 +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
msaitoh
fc14d85d63 Modify p3_get_bus_clock():
- Intel SDM says 06_17H is the same as 06_0fH. Same as OpenBSD.
- Add some Silvermont models.
- For Slivermont architecture, 0x011 is not 166.67MHz but 116.67MHz.
- Print model name not in decimal but in hexadecimal
- Cleanup code.
2014-07-25 14:34:22 +00:00
ozaki-r
011b056d61 Use IFADDR_FOREACH for iterating if_addrlist of ifnet 2014-07-25 07:12:55 +00:00
riastradh
c5f3dfcf35 Add a FIRST1G page freelist to x86, for old graphics devices. 2014-07-24 13:42:28 +00:00
uebayasi
92e2b1bee8 KNF. 2014-07-20 15:48:54 +00:00
uebayasi
8d26686d50 ipifunc[]: Comment IPI constant names for grep'ability. Constify. 2014-07-20 15:46:34 +00:00
hikaru
a088d42522 Correct return value handling.
m_defrag(9) is different from OpenBSD one,
it returns new mbuf pointer on success, not zero.
2014-07-19 06:12:24 +00:00
msaitoh
49de7f7eab Add Vortex86EX. 2014-07-08 19:35:36 +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
dholland
c53acaa3d4 If we're going to use just the name of the dying function as a panic
string, it should at least be the name of the *right* function. ish.
2014-06-28 21:13:12 +00:00
hikaru
2943d72a5a Use 64-bit DMA, if it is available.
This fixes null packet handling on guest which have memory over than 3GB.
2014-06-19 13:20:28 +00:00
hikaru
f589d3a6c3 Make it be able to down I/F. This fixes panic when removing IFF_UP flag. 2014-06-19 13:16:29 +00:00
pgoyette
a86c6cba08 Check hypervisor version before trying to call xen_copypage() or
xen_pagezero().  Fixes recent issue encountered running a -current
kernel on a pre-3.4 hypervisor.

OK cherry@
2014-06-14 02:54:47 +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
christos
957638f2a5 centralize the double match warning. 2014-06-10 22:01:40 +00:00
hikaru
73c29dd7cc Add VMware VMXNET3 ethernet driver from OpenBSD, vmx(4). 2014-06-10 01:42:38 +00:00
plunky
c5016a8380 \%s is not an escape sequence, and we want %s 2014-05-29 19:08:30 +00:00
ozaki-r
492b37065c Pad 0 to align outputs 2014-05-20 03:24:19 +00:00
rmind
8011b285c0 Implement MI IPI interface with cross-call support. 2014-05-19 22:47:53 +00:00
rmind
f7741dab17 - Move IFNET_*() macros under #ifdef _KERNEL.
- Replace TAILQ_FOREACH on ifnet with IFNET_FOREACH().
2014-05-17 20:44:24 +00:00
joerg
cf336e5404 Match lapic conditionals from the primary CPU. 2014-05-12 11:56:02 +00:00
joerg
619e1e14cb buf is only used in the ioapic case. 2014-05-12 11:55:39 +00:00
joerg
6837797dba acpi_md_findoverride is only used when NIOAPIC > 0, so don't provide it
otherwise.
2014-05-12 11:51:34 +00:00
christos
40478976a2 tidy up. 2014-05-06 18:54:34 +00:00
sborrill
47b10421a6 Force pci_mode 1 when running as Xen HVM domU to allow cd* to be detected
correctly. Fixes kern/48770. Thanks to cube@
2014-05-06 09:01:26 +00:00
cherry
b3b58e3b56 Use the hypervisor to copy/zero pages. This saves us the extra overheads
of setting up temporary kernel mapping/unmapping.

riz@ reports savings of about 2s on a 120s kernel build.
2014-05-06 04:26:23 +00:00
christos
972d2857dd more conservative length check. 2014-04-18 15:00:37 +00:00
christos
41b25bacda CID/1203191: Out of bounds read 2014-04-17 16:01:24 +00:00
joerg
b98dd0fb03 x86_progress takes a format string. 2014-04-06 18:48:06 +00:00
christos
319a13bb90 make this compute the needed size instead of bailing. 2014-04-05 18:43:09 +00:00
christos
4aa1bc1f00 - prevent matchbiosdisks from being called twice. This could happen
via raid autoconf calling cpu_rootconf() once and then init main
  calling cpu_rootconf() a second time.
- separate booted_device setup into cpu_bootconf(), a new optional function.
  This function can be called before raid autoconfiguration to determine
  the booted device. This needs to be done before raid autoconfiguration,
  otherwise if we are using wedges, the raid will autoconfigure wedges,
  and we'll be unable to open the underlying devices later to determine
  the booted device.
- fix a debugging comment.
2014-04-03 15:21:52 +00:00
christos
563eea7895 - tidy up debugging 2014-04-02 02:14:08 +00:00
dsl
972ec8228f Revert most of the machdep sysctls to 32bit 2014-04-01 07:16:18 +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
christos
e93b33c96c correct/add protection against snprintf overflow. 2014-03-27 18:22:56 +00:00
christos
db89e006d6 kill sprintf 2014-03-26 08:04:19 +00:00
christos
b2543b9136 use cpu_{g,s}etmodel 2014-03-24 20:06:31 +00:00
christos
9e287239f7 need compat_netbsd.h 2014-03-20 20:44:42 +00:00
riastradh
6cb10275d0 Merge riastradh-drm2 to HEAD. 2014-03-18 18:20:35 +00:00
martin
bbeaaa76ed #ifdef a variable like its use 2014-03-12 12:54:33 +00:00
para
4d3aae87b7 mark a diagnostic only variable 2014-03-11 20:54:29 +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
pooka
4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
dsl
c8b478cd74 Fix a 'stupido' that stopped (amongst other things) the cpu brand string
being read.
The most obvious side effect the anita tests failed to detect they were
  running under qemu - so reported failures under qemu for things
  that qemu doesn't support.
2014-02-25 17:56:03 +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
8b623c15d9 Move the amd64 and i386 pcb to the bottom of the uarea, and move the
kernel stack to the top.
Change the pcb layouts so that fpu save area is at the end and is
  64byte aligned ready for xsave (saving the ymm registers).
Welcome to 6.99.32
2014-02-20 18:19:09 +00:00
dsl
3b3cbac768 This needs stdint.h in userspace (for uint64_t) 2014-02-20 18:14:11 +00:00
dsl
480bf53618 Add explicit #include <x86/fpu.h> instead of relying on pcb.h including it. 2014-02-19 21:23:01 +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
6cb5447c23 Change the argument to fpudna() to be the trapframe.
Move the checks for fpu traps in kernel into x86/fpu.c.
Remove the code from amd64/trap.c related to fpu traps (they've not gone
  there for ages - expect to panic in kernel mode).
In fpudna():
- Don't actually enable hardware interrupts unless we need to
  allow in IPIs.
- There is no point in enabling them when they are blocked in software
  (by splhigh()).
- Keep the splhigh() to avoid a load of the KASSERTS() firing.
2014-02-12 19:53:49 +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
52252605c4 Minor fpu initialisation cleanups:
Set default CR) so that the FPU is enabled (unset CR0_EM) and initialise
  i386_fpu_present to 1.
No need to call the npx trap indirectly, rename to fpunda() to match amd64.
Remove the i386_fpu_exception variable and sysctl (It used to indicate
  which irq was used for fpu exceptions, but we only support 'internal'
  now).  Hopefully no one cares.
fpuinit() now only needs to clear TS before the fninit(). Apart from the
  checks for 486SX and the 'fdiv bug' this matches the amd64 version.
Exclude fpuinit() from XEN kernels, they don't call it - which rather begs
  the question as to whether it is needed at all!
2014-02-02 22:41:20 +00:00
jakllsch
1e7506fdf0 Stopgap to prevent genfb from stealing console. Revisit later. 2014-01-27 23:11:50 +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
taca
b9e8d8ee67 Fix build problem when there is no com(4) but ucom(4). 2014-01-26 15:49:25 +00:00
msaitoh
e4bf50ce42 PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
   in pucdata.c's table.

 - Add a new option PUC_CNAUTO. If this option is set, consinit() in
   x86/x86/consinit.c checks puc com device to use it as console.
   Without this option, the behavior is the same as before.

 - Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
   If PUC_CNBUS is set, the specified number's bus will be scanned.

 - Rename comcnprobe() to puc_cnprobe() to make it clear.

 - Rename comcninit() to puc_cninit() to make it clear.

 - Add code for a device that a device's com register is MMIO (#if0 ed).
2014-01-26 10:54:24 +00:00
joerg
3d66511c09 Reduce amount of -no-integrated-as on x86 as .code16 is now supported by
LLVM.
2014-01-15 22:25:22 +00:00
christos
5a3fb681a6 Comment about missing stackframe member initialization (Richard Hansen)
I haven't studied the code, but I'm concerned that not initializing
sf->sf_edi could potentially leak a few bytes of information to a new
userspace process.
2014-01-11 17:14:00 +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
3c10ad5307 Add Z68 LPC. 2014-01-04 02:59:17 +00:00
msaitoh
4c6bef9716 Temporary disable C2000 PCU because the behavior of the wdog is little strange. 2014-01-04 02:09:12 +00:00
dsl
95739e63cd Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
  process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
  just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
  to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
2014-01-04 00:10:02 +00:00
msaitoh
f8748bc5e6 Add C2000 Platform Controller Unit(PCU). 2014-01-03 23:18:48 +00:00
dsl
be74e0a9c9 Change the type of the 'cookie' that holds the state of the core dump file
from 'void *' to the actual type 'struct coredump_iostate *'.
In most of the code the contents of the structure are still unknown.
This just stops the wrong type of pointer being passed to the 'void *'
parameter.
I hope I've found everything, amd64 GENERIC and i386 GENERIC & ALL compile.
2014-01-01 18:57:15 +00:00
jakllsch
42b1fe2393 Give cpu_comcnprobe a chance of working on Mode 2 PCI config space. 2013-12-25 17:24:39 +00:00
msaitoh
0f129fa49e move XCR0 definitions to next to CR0's. 2013-12-25 13:14:36 +00:00