Commit Graph

297 Commits

Author SHA1 Message Date
jhb
4ee9c49971 MFC 274817,274878,276801,276840,278976:
Improve support for XSAVE with debuggers.
- Dump an NT_X86_XSTATE note if XSAVE is in use. This note is designed
  to match what Linux does in that 1) it dumps the entire XSAVE area
  including the fxsave state, and 2) it stashes a copy of the current
  xsave mask in the unused padding between the fxsave state and the
  xstate header at the same location used by Linux.
- Teach readelf() to recognize NT_X86_XSTATE notes.
- Change PT_GET/SETXSTATE to take the entire XSAVE state instead of
  only the extra portion. This avoids having to always make two
  ptrace() calls to get or set the full XSAVE state.
- Add a PT_GET_XSTATE_INFO which returns the length of the current
  XSTATE save area (so the size of the buffer needed for PT_GETXSTATE)
  and the current XSAVE mask (%xcr0).
2015-02-23 18:38:41 +00:00
kib
6aee714821 MFC r278606:
Registers definitions for the new capabilities.
2015-02-18 08:06:36 +00:00
kib
f387fc2f7e MFC r278605:
vm_page_lookup() accepts read-locked object.
2015-02-18 08:04:03 +00:00
jhb
9809511c44 MFC 273800:
Rework virtual machine hypervisor detection.
- Move the existing code to x86/x86/identcpu.c since it is x86-specific.
- If the CPUID2_HV flag is set, assume a hypervisor is present and query
  the 0x40000000 leaf to determine the hypervisor vendor ID.  Export the
  vendor ID and the highest supported hypervisor CPUID leaf via
  hv_vendor[] and hv_high variables, respectively.  The hv_vendor[]
  array is also exported via the hw.hv_vendor sysctl.
- Merge the VMWare detection code from tsc.c into the new probe in
  identcpu.c.  Add a VM_GUEST_VMWARE to identify vmware and use that in
  the TSC code to identify VMWare.
2015-02-10 16:34:42 +00:00
jhb
4d3ec3464b MFC 272666: Fix build for i386 kernels with out 'I686_CPU'.
Reported by:	Mike Tancsa <mike@sentex.net>
2015-01-21 17:59:32 +00:00
kib
da566e85be MFC r277047:
For x86, read MAXPHYADDR into variable cpu_maxphyaddr.
2015-01-19 10:52:55 +00:00
kib
5846d19730 MFC r277023:
Avoid excessive flushing and do missed neccessary flushing in the IOMMU
page table update code.
2015-01-18 09:49:32 +00:00
neel
649535f73c MFC r273748
Output a summary of optional SVM features in dmesg similar to CPU features.
If bootverbose is enabled, a detailed list is provided; otherwise, a
single-line summary is displayed.

Requested by:	jhb
2014-12-31 22:15:28 +00:00
neel
3b591af2d9 MFC 261321
Rename the AMD MSR_PERFCTR[0-3] so the Pentium Pro MSR_PERFCTR[0-1] aren't
redefined.

MFC r273214
Fix build to not bogusly always rebuild vmm.ko.

MFC r273338
Add support for AMD's nested page tables in pmap.c:
- Provide the correct bit mask for various bit fields in a PTE (e.g. valid bit)
  for a pmap of type PT_RVI.
- Add a function 'pmap_type_guest(pmap)' that returns TRUE if the pmap is of
  type PT_EPT or PT_RVI.

Add CPU_SET_ATOMIC_ACQ(num, cpuset):
This is used when activating a vcpu in the nested pmap. Using the 'acquire'
variant guarantees that the load of the 'pm_eptgen' will happen only after
the vcpu is activated in 'pm_active'.

Add defines for various AMD-specific MSRs.

Discussed with:	kib (r261321)
2014-12-30 00:00:42 +00:00
neel
88c1adb417 MFC r270326
Fix a recursive lock acquisition in vi_reset_dev().

MFC r270434
Return the spurious interrupt vector (IRQ7 or IRQ15) if the atpic cannot find
any unmasked pin with an interrupt asserted.

MFC r270436
Fix a bug in the emulation of CPUID leaf 0x4.

MFC r270437
Add "hw.vmm.topology.threads_per_core" and "hw.vmm.topology.cores_per_package"
tunables to modify the default cpu topology advertised by bhyve.

MFC r270855
Set the 'inst_length' to '0' early on before any error conditions are detected
in the emulation of the task switch. If any exceptions are triggered then the
guest %rip should point to instruction that caused the task switch as opposed
to the one after it.

MFC r270857
The "SUB" instruction used in getcc() actually does 'x -= y' so use the
proper constraint for 'x'. The "+r" constraint indicates that 'x' is an
input and output register operand.

While here generate code for different variants of getcc() using a macro
GETCC(sz) where 'sz' indicates the operand size.

Update the status bits in %rflags when emulating AND and OR opcodes.

MFC r271439
Initialize 'bc_rdonly' to the right value.

MFC r271451
Optimize the common case of injecting an interrupt into a vcpu after a HLT
by explicitly moving it out of the interrupt shadow.

MFC r271888
Restructure the MSR handling so it is entirely handled by processor-specific
code.

MFC r271890
MSR_KGSBASE is no longer saved and restored from the guest MSR save area. This
behavior was changed in r271888 so update the comment block to reflect this.

MFC r271891
Add some more KTR events to help debugging.

MFC r272197
mmap(2) requires either MAP_PRIVATE or MAP_SHARED for non-anonymous mappings.

MFC r272395
Get rid of code that dealt with the hardware not being able to save/restore
the PAT MSR on guest exit/entry. This workaround was done for a beta release
of VMware Fusion 5 but is no longer needed in later versions.

All Intel CPUs since Nehalem have supported saving and restoring MSR_PAT
in the VM exit and entry controls.

MFC r272670
Inject #UD into the guest when it executes either 'MONITOR' or 'MWAIT'.

MFC r272710
Implement the FLUSH operation in the virtio-block emulation.

MFC r272838
iasl(8) expects integer fields in data tables to be specified as hexadecimal
values. Therefore the bit width of the "PM Timer Block" was actually being
interpreted as 50-bits instead of the expected 32-bit.

This eliminates an error message emitted by a Linux 3.17 guest during boot:
"Invalid length for FADT/PmTimerBlock: 50, using default 32"

MFC r272839
Support Intel-specific MSRs that are accessed when booting up a linux in bhyve:
 - MSR_PLATFORM_INFO
 - MSR_TURBO_RATIO_LIMITx
 - MSR_RAPL_POWER_UNIT

MFC r273108
Emulate "POP r/m". This is needed to boot OpenBSD/i386 MP kernel in bhyve.

MFC r273212
Support stopping and restarting the AHCI command list via toggling PxCMD.ST
from '1' to '0' and back.  This allows the driver a chance to recover if
for instance a timeout occurred due to activity on the host.
2014-12-28 21:27:13 +00:00
kib
d2f5d57eaa MFC r271208:
Add a define for index of IA32_XSS MSR.
2014-12-23 12:04:23 +00:00
kib
10220d0061 MFC r271206:
Adjust the definition of struct xstate_hdr according to SDM rev. 50.
2014-12-23 12:00:41 +00:00
kib
5a03dd693d MFC r271197:
Add more bits for the XSAVE features from CPUID 0xd, sub-function 1
%eax report.  Print the XSAVE features 0xd/1 in the boot banner.
2014-12-23 11:55:53 +00:00
jhb
5ae50f92a8 MFC 273988,273989,273995,274057:
MFamd64: Add support for extended FPU states on i386.  This includes
support for AVX on i386.
2014-12-22 21:32:39 +00:00
jhb
71f9e38fa2 MFC 271405,271408,271409,272658:
MFamd64: Use initializecpu() to set various model-specific registers on
AP startup and AP resume (it was already used for BSP startup and BSP
resume).
2014-12-22 19:53:55 +00:00
jhb
2b345a08ed MFC 260557,271076,271077,271082,271083,271098:
- Remove spaces from boot messages when we print the CPU ID/Family/Stepping
- Move prototypes for various functions into out of C files and into
  <machine/md_var.h>.
- Reduce diffs between i386 and amd64 initcpu.c and identcpu.c files.
- Move blacklists of broken TSCs out of the printcpuinfo() function
  and into the TSC probe routine.
- Merge the amd64 and i386 identcpu.c into a single x86 implementation.
2014-12-22 18:40:59 +00:00
hselasky
1f41d295fb MFC r263710, r273377, r273378, r273423 and r273455:
- De-vnet hash sizes and hash masks.
- Fix multiple issues related to arguments passed to SYSCTL macros.

Sponsored by:	Mellanox Technologies
2014-10-27 14:38:00 +00:00
jhb
09bff45095 MFC 270850,271053,271192,271717:
Save and restore FPU state across suspend and resume on i386.
- Create a separate structure for per-CPU state saved across suspend and
  resume that is a superset of a pcb.
- Store the FPU state for suspend and resume in the new structure
  (for amd64, this moves it out of the PCB)
- On both i386 and amd64, all of the FPU suspend/resume handling is now
  done in C.

Approved by:	re (hrs)
2014-09-22 20:34:36 +00:00
akiyama
bf3d63ee28 MFC r263859:
Change default logic to CONFORM because this routine is shared
  with SCI polarity setting.

  Reviewed by: jhb

MFC r269184:
  Add missing newline to output dmesg properly.
2014-08-31 10:42:52 +00:00
grehan
5d455a50f5 MFC r267921, r267934, r267949, r267959, r267966, r268202, r268276,
r268427, r268428, r268521, r268638,	r268639, r268701, r268777,
    r268889, r268922, r269008, r269042,	r269043, r269080, r269094,
    r269108, r269109, r269281, r269317,	r269700, r269896, r269962,
    r269989.

Catch bhyve up to CURRENT.

Lightly tested with FreeBSD i386/amd64,	Linux i386/amd64, and
OpenBSD/amd64. Still resolving an	issue with OpenBSD/i386.

Many thanks to jhb@ for	all the	hard work on the prior MFCs !

r267921 - support the "mov r/m8, imm8" instruction
r267934 - document options
r267949 - set DMI vers/date to fixed values
r267959 - doc: sort cmd flags
r267966 - EPT misconf post-mortem info
r268202 - use correct flag for event index
r268276 - 64-bit virtio capability api
r268427 - invalidate guest TLB when cr3 is updated, needed for TSS
r268428 - identify vcpu's operating mode
r268521 - use correct offset in guest logical-to-linear translation
r268638 - chs value
r268639 - chs fake values
r268701 - instr emul operand/address size override prefix support
r268777 - emulation for legacy x86 task switching
r268889 - nested exception support
r268922 - fix INVARIANTS build
r269008 - emulate instructions found in the OpenBSD/i386 5.5 kernel
r269042 - fix fault injection
r269043 - Reduce VMEXIT_RESTARTs in task_switch.c
r269080 - fix issues in PUSH emulation
r269094 - simplify return values from the inout handlers
r269108 - don't return -1 from the push emulation handler
r269109 - avoid permanent sleep in vm_handle_hlt()
r269281 - list VT-x features in base kernel dmesg
r269317 - Mark AHCI fatal errors as not completed
r269700 - Support PCI extended config space in bhyve
r269896 - Minor cleanup
r269962 - use max guest memory when creating IOMMU domain
r269989 - fix interrupt mode names
2014-08-19 01:20:24 +00:00
marius
25248ca3c7 MFC: r260457
The changes in r233781 attempted to make logging during a machine check
exception more readable.  In practice they prevented all logging during
a machine check exception on at least some systems.  Specifically, when
an uncorrected ECC error is detected in a DIMM on a Nehalem/Westmere
class machine, all CPUs receive a machine check exception, but only
CPUs on the same package as the memory controller for the erroring DIMM
log an error.  The CPUs on the other package would complete the scan of
their machine check banks and panic before the first set of CPUs could
log an error.  The end result was a clearer display during the panic
(no interleaved messages), but a crashdump without any useful info about
the error that occurred.

To handle this case, make all CPUs spin in the machine check handler
once they have completed their scan of their machine check banks until
at least one machine check error is logged.  I tried using a DELAY()
instead so that the CPUs would not potentially hang forever, but that
was not reliable in testing.

While here, don't clear MCIP from MSR_MCG_STATUS before invoking panic.
Only clear it if the machine check handler does not panic and returns
to the interrupted thread.

MFC: r263113

Correct type for malloc().

Submitted by:	"Conrad Meyer" <conrad.meyer@isilon.com>

MFC: r269052, r269239, r269242

Intel desktop Haswell CPUs may report benign corrected parity errors (see
HSD131 erratum in [1]) at a considerable rate. So filter these (default),
unless logging is enabled. Unfortunately, there really is no better way to
reasonably implement suppressing these errors than to just skipping them
in mca_log(). Given that they are reported for bank 0, they'd need to be
masked in MSR_MC0_CTL. However, P6 family processors require that register
to be set to either all 0s or all 1s, disabling way more than the one error
in question when using all 0s there. Alternatively, it could be masked for
the corresponding CMCI, but that still wouldn't keep the periodic scanner
from detecting these spurious errors. Apart from that, register contents of
MSR_MC0_CTL{,2} don't seem to be publicly documented, neither in the Intel
Architectures Developer's Manual nor in the Haswell datasheets.

Note that while HSD131 actually is only about C0-stepping as of revision
014 of the Intel desktop 4th generation processor family specification
update, these corrected errors also have been observed with D0-stepping
aka "Haswell Refresh".

1: http://www.intel.de/content/dam/www/public/us/en/documents/specification-updates/4th-gen-core-family-desktop-specification-update.pdf

Reviewed by:	jhb
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-08-05 16:04:22 +00:00
scottl
d13d12a6a2 Merge r266746, 266775:
Now that there are separate back-end implementations of busdma, the bounce
 implementation shouldn't steal flags from the common front-end.
 Move those flags to the back-end.

 Eliminate the fake contig_dmamap and replace it with a new flag,
 BUS_DMA_KMEM_ALLOC.  They serve the same purpose, but using the flag
 means that the map can be NULL again, which in turn enables significant
 optimizations for the common case of no bouncing.

Obtained from:	Netflix, Inc.
2014-07-01 06:50:35 +00:00
rodrigc
8d5996c444 MFC r263795:
Strict value checking will cause problem.
Bay trail DN2820FYKH is supported on Linux but does not work on FreeBSD.
This behaviour is bug-compatible with Linux-3.13.5.

References:
http://d.hatena.ne.jp/syuu1228/20140326
http://lxr.linux.no/linux+v3.13.5/arch/x86/kernel/acpi/boot.c#L1094

Submitted by: syuu
PR: 187966
2014-06-23 22:37:49 +00:00
rodrigc
360ded2657 Undo bad merge. 2014-06-23 22:35:41 +00:00
rodrigc
95d8d7a8ec MFC r263795:
Strict value checking will cause problem.
Bay trail DN2820FYKH is supported on Linux but does not work on FreeBSD.
This behaviour is bug-compatible with Linux-3.13.5.

References:
http://d.hatena.ne.jp/syuu1228/20140326
http://lxr.linux.no/linux+v3.13.5/arch/x86/kernel/acpi/boot.c#L1094

Submitted by: syuu
PR: 187966
2014-06-23 22:31:28 +00:00
jhb
8119d8278f MFC 266263,266551,266552:
- Add definitions for more structured extended features as well as
  XSAVE Extended Features for AVX512 and MPX (Memory Protection Extensions).
- Don't permit users to request a subset of the AVX512 or MPX xsave masks.
2014-06-12 17:15:56 +00:00
jhb
d820529bb0 MFC 263772: Fix build without SMP.
PR:		187854
2014-06-04 17:50:47 +00:00
ian
057c745287 MFC r257738, r259202, r258410, r260288, r260292, r260294, r260320, r260323,
r260326, r260327, r260331, r260333, r260340, r260371, r260372, r260373,
    r260374, r260375

  Add common bus_space tag definition shared for most supported ARMv6/v7 SoCs.
  Correct license statements to reflect the fact that these files were all
  derived from sys/arm/mv/bus_space.c.

  In pmap_unmapdev(), remember the size, and use that as an argument to
  kva_free(), or we'd end up always passing it a size of 0

  In pmap_mapdev(), first check whether a static mapping exists,

  Convert TI static device mapping to use the new arm_devmap_add_entry(),

  Use the common armv6 fdt_bus_tag defintion for tegra instead of a local copy.

  Eliminate use of fdt_immr_addr(), it's not needed for tegra

  Convert lpc from using fdt_immr style to arm_devmap_add_entry() to make
  static device mappings.

  Retire machine/fdt.h as a header used by MI code, as its function is now
  obsolete. This involves the following pieces:
  - Remove it entirely on PowerPC, where it is not used by MD code either
  - Remove all references to machine/fdt.h in non-architecture-specific code
    (aside from uart_cpu_fdt.c, shared by ARM and MIPS, and so is somewhat
    non-arch-specific).
  - Fix code relying on header pollution from machine/fdt.h includes
  - Legacy fdtbus.c (still used on x86 FDT systems) now passes resource
    requests to its parent (nexus). This allows x86 FDT devices to allocate
    both memory and IO requests and removes the last notionally MI use of
    fdtbus_bs_tag.
  - On those architectures that retain a machine/fdt.h, unused bits like
    FDT_MAP_IRQ and FDT_INTR_MAX have been removed.

  Add #include <machine/fdt.h> to a few files that used to get it via pollution

  Enable the mv cesa security/crypto device by providing the required property
  in the dts source, and adding the right devices to the kernel config.

  Remove dev/fdt/fdt_pci.c, which was code specific to Marvell ARM SoCs,
  related to setting up static device mappings.  Since it was only used by
  arm/mv/mv_pci.c, it's now just static functions within that file, plus
  one public function that gets called only from arm/mv/mv_machdep.c.

  Switch RPi to using arm_devmap_add_entry() to set up static device mapping.

  Allow 'no static device mappings' to potentially work.

  Don't try to find a static mapping before calling pmap_mapdev(), that logic
  is now part of pmap_mapdev() and doesn't need to be duplicated here.

 Switch a10 to using arm_devmap_add_entry() to set up static device mapping.
2014-05-14 19:18:58 +00:00
tijl
e8ab551e5f MFC r263998:
Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4
-fms-extensions.
2014-04-15 09:41:52 +00:00
royger
382b727d12 MFC r263001
Move asm IPIs handlers to C code, so both Xen and native IPI handlers
share the same code.

Approved by: gibbs
Sponsored by: Citrix Systems R&D
2014-04-04 14:54:54 +00:00
kib
5a582ae617 MFC r263306:
Add some support for the PCI(e)-PCI bridges to the Intel VT-d driver.
2014-03-25 20:17:57 +00:00
kib
879dfba7f2 MFC r263305:
Provide a workaround by identity mapping the 32 pages after the bogus
entry start, which seems to be enough for the reported BIOS.
2014-03-25 20:16:28 +00:00
emaste
f9534c5185 MFC r263289: Update NetBSD Foundation copyrights to 2-clause BSD
The NetBSD Foundation states "Third parties are encouraged to change the
  license on any files which have a 4-clause license contributed to the
  NetBSD Foundation to a 2-clause license."

  This change removes clauses 3 and 4 from copyright / license blocks that
  list The NetBSD Foundation as the only copyright holder.

Sponsored by:	The FreeBSD Foundation
2014-03-24 13:48:04 +00:00
kib
a528b1ed30 MFC r263304:
Trim at EOL.
2014-03-21 13:31:56 +00:00
jkim
b04308525e MFC: r262746, r262748, r262750, r262752
Move fpusave() wrapper for suspend hander to sys/amd64/amd64/fpu.c.
2014-03-10 20:47:24 +00:00
jhb
5b0bab6d24 MFC 261517,261520:
Convert the license on files where I am the sole copyright holder to
2 clause BSD licenses.
2014-02-18 20:27:17 +00:00
jhb
8e8bf4982f MFC 259140:
Move constants for indices in the local APIC's local vector table from
apicvar.h to apicreg.h.
2014-02-18 01:15:32 +00:00
avg
b46715eb45 MFC r257417: Remove references to an unused fasttrap probe hook 2014-02-17 12:57:13 +00:00
eadler
ec294fd7f5 MFC r258779,r258780,r258787,r258822:
Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit.  Instead use (1U << 31) which gets the
expected result.

Similar to the (1 << 31) case it is not defined to do (2 << 30).

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.
2014-02-04 03:36:42 +00:00
jhb
37071258d8 MFC 259823:
Fix i386 build.
2014-01-31 17:26:15 +00:00
jhb
080d62f93d MFC 259782:
Add a resume hook for bhyve that runs a function on all CPUs during
resume.  For Intel CPUs, invoke vmxon for CPUs that were in VMX mode
at the time of suspend.
2014-01-29 21:23:37 +00:00
mav
211b1cf423 MFC r259197:
Do not DELAY() for P-state transition unless we want to see the result.

Intel manual says: "If a transition is already in progress, transition to
a new value will subsequently take effect. Reads of IA32_PERF_CTL determine
the last targeted operating point."  So seems it should be fine to just
trigger wanted transition and go.  Linux does the same.
2014-01-09 10:44:27 +00:00
jhb
bf62f8539b MFC 259013:
Fix the processor table entry structure to use a fixed-width type for
32-bit fields so it is the correct size on amd64.  Remove a workaround
for the broken structure from bhyve(8).
2013-12-24 19:10:56 +00:00
kib
2c4d831850 MFC DMAR busdma implementation.
MFC r257251:
Import the driver for VT-d DMAR hardware.  Implement the busdma(9) using DMARs.

MFC r257512:
Add support for queued invalidation.

MFC miscellaneous follow-ups to r257251.

MFC r257266:
Remove redundand assignment to error variable and check for its value.

MFC r257308:
Remove redundand declaration.

MFC r257511:
Return BUS_PROBE_NOWILDCARD from the DMAR probe method.

MFC r257860,r257896,r257900,r257902,r257903 (by dim):
Fixes for gcc compilation.
2013-12-17 13:49:35 +00:00
kib
3219a81518 MFC r257230:
Add a virtual table for the busdma methods on x86, to allow different
busdma implementations to coexist.
2013-12-17 13:39:50 +00:00
kib
5a15f697f5 MFC r257228:
Add bus_dmamap_load_ma() function to load map with the array of
vm_pages.
2013-12-17 13:38:21 +00:00
sbruno
07f179266d MFC r257769 to stable/10
Fix powerd/states on AMD cpus.  Resolves issues with system reporting:
hwpstate0: set freq failed, err 6

Tested on FX-8150 and others.

PR:		kern/167018
Submitted by:	avg@
Approved by:	re (gjb)
2013-12-05 17:57:51 +00:00
emaste
b0519089ed MFC r258135: x86: Allow users to change PSL_RF via ptrace(PT_SETREGS...)
Debuggers may need to change PSL_RF. Note that tf_eflags is already stored
  in the signal context during signal handling and PSL_RF previously could
  be modified via sigreturn, so this change should not provide any new
  ability to userspace.

  For background see the thread at:
  http://lists.freebsd.org/pipermail/freebsd-i386/2007-September/005910.html

  Reviewed by:	jhb, kib

Sponsored by:	DARPA, AFRL
Approved by:	re (gjb)
2013-11-25 15:58:48 +00:00
kib
5b26108b2e MFC r257856:
Add bits for the AMD features from CPUID function 0x80000001 ECX,
described in the rev. 3.0 of the Kabini BKDG, document 48751.pdf.

Approved by:	re (gjb)
2013-11-15 07:10:42 +00:00
kib
0c11a37a6f MFC r257069:
Add ddb 'show ioapic' and 'show all ioapics' commands.

Approved by:	re (glebius)
2013-11-01 06:29:38 +00:00