History log of /freebsd-current/sys/x86/x86/identcpu.c
Revision Date Author Comments
# c6113ac5 13-May-2024 Konstantin Belousov <kib@FreeBSD.org>

AMD CPUs: update bits and data from CPUID 0x8000_0008

from AMD APM vol3 doc no 24594 Rev. 3.36 March 2024

Reviewed and tested by: emaste
Sponsored by: Advanced Micro Devices (AMD)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D45188


# ecaab0fb 01-May-2024 Stephen J. Kiernan <stevek@FreeBSD.org>

guestrpc module to handle VMware backdoor port GuestRPC functionality

Convert existing FreeBSD vmware_hvcall function to take a channel
and parameter arguments.

Added vmware_guestrpc_cmd() to send GuestRPC commands to the VMware
hypervisor. The sbuf argument is used for both the command to send
and to store the data to return to the caller.

The following KPIs can be used to get and set FreeBSD-specific guest
information in key/value pairs:
* vmware_guestrpc_set_guestinfo
- set a value into the guestinfo.fbsd.<keyword> key
* vmware_guestrpc_get_guestinfo
- get the value stored in the guestinfo.fbsd.<keyword> key

Add VMware devices to x86 NOTES

Reviewed by: jhb
Obtained from: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D44528


# 8f5406c7 02-Feb-2024 Roger Pau Monné <royger@FreeBSD.org>

x86/xen: implement early init hook

Unify the HVM and PVH early setup, byt making both rely on the hypervisor
initialization hook part of identify_hypervisor().

The current initialization takes care of the hypercall page, the sahred info
page and does any fixup necessary to metadata video console information if
FreeBSD is booted as the initial domain (so the video console is handed from
Xen into FreeBSD).

Note this has the nice side effect of also allowing to use the Xen console on
HVM guests, which allows to get rid of the QEMU emulated uart and still get
a nice text console.

Sponsored by: Cloud Software Group
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D43764


# 4401b068 02-Feb-2024 Roger Pau Monné <royger@FreeBSD.org>

x86/cpu: introduce an optional hook for early hypervisor initialization

Hypervisor detection is done very early on x86, and so can be used to also do
some very early hypervisor related initialization. Such initialization is
required when running as a Xen PVH guest, as for example the PIT needs to be
replaced with an hypervisor based timecounter.

Introduce an optional hook that gets called as part of the early hypervisor
detection.

No functional change intended.

Sponsored by: Cloud Software Group
Reviewed by: markj kib
Differential revision: https://reviews.freebsd.org/D43763


# 6744fd8e 19-Jan-2024 Roger Pau Monné <royger@FreeBSD.org>

x86/cpu: improve hypervisor detection

Some hypervisors can expose multiple signatures, for example Xen will expose
both the Xen and the HyperV signatures if Viridian extensions are enabled for
the guest. Presence of multiple signatures is currently not handled by
FreeBSD, that will exit once a known signature is found in cpuid output.

Exposing the HyperV signature on hypervisors different than HyperV is not
uncommon, this is done so that such hypervisor can expose a (subset) of the
Viridian extensions to Windows guests for performance reasons. Likely for
compatibility purposes the HyperV signature is always exposed on the first
leaf, and the Xen signature is exposed in the secondary leaf.

Fix the specific case of HyperV by not exiting from the scan if the HyperV
signature is found, and prefer a second signature if one is found.

Note that long term we might wish to convert vm_guest into a bitmap, so that it
can signal detection of multiple hypervisor interfaces.

Fixes: b0165dc4539f ('x86/xen: fix HVM guest hypercall page setup')
PR: 276421
Sponsored by: Cloud Software Group
Reviewed by: markj kib
Differential revision: https://reviews.freebsd.org/D43508


# 969fc091 04-Jan-2024 Mark Johnston <markj@FreeBSD.org>

sysctl: Don't pass CTLFLAG_MPSAFE to SYSCTL_STRING

It is redundant. No functional change intended.

MFC after: 1 week


# 0aba5dd2 04-Jan-2024 Mark Johnston <markj@FreeBSD.org>

identcpu: Let the hw.model be readable in capability mode

On some platforms this static information can be derived directly from
the CPU, and there doesn't seem much use in restricting it.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281


# d63ea036 04-Jan-2024 Mark Johnston <markj@FreeBSD.org>

x86: Make cpu_model[] public

No functional change intended.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 9d6ae1e3 04-Jun-2023 Colin Percival <cperciva@FreeBSD.org>

Revert "Revert "tslog: Annotate some early boot functions""

Now that <sys/tslog.h> is wrapped in #ifdef _KERNEL, it's safe to have
tslog annotations in files which might be built from userland (i.e. in
subr_boot.c, which is built as part of the boot loader).

This reverts commit 59588a546f55523d6fd37ab42eb08b719311d7d6.


# 59588a54 04-Jun-2023 Colin Percival <cperciva@FreeBSD.org>

Revert "tslog: Annotate some early boot functions"

The change to subr_boot.c broke the libsa build because the TSLOG
macros have their own definitions for the boot loader -- I didn't
realize that the loader code used subr_boot.c.

I'm currently testing a fix and I'll revert this revert once I'm
satisfied that everything works, but I don't want to leave the
tree broken for too long.

This reverts commit 469cfa3c30ee7a5ddeb597d0a8c3e7cac909b27a.


# 469cfa3c 22-May-2023 Colin Percival <cperciva@FreeBSD.org>

tslog: Annotate some early boot functions

Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM,
hammer_time takes roughly 2740 us:
* 55 us in xen_pvh_parse_preload_data
* 20 us in boot_parse_cmdline_delim
* 20 us in boot_env_to_howto
* 15 us in identify_hypervisor
* 1320 us in link_elf_reloc
* 1310 us in relocate_file1 handling ef->rela
* 25 us in init_param1
* 30 us in dpcpu_init
* 355 us in initializecpu
* 255 us in initializecpu calling load_cr4
* 425 us in getmemsize
* 280 us in pmap_bootstrap
* 205 us in create_pagetables
* 10 us in init_param2
* 25 us in pci_early_quirks
* 60 us in cninit
* 90 us in kdb_init
* 105 us in msgbufinit
* 20 us in fpuinit
* 205 us elsewhere in hammer_time

Some of these are unavoidable (e.g. identify_hypervisor uses CPUID and
load_cr4 loads the CR4 register, both of which trap to the hypervisor)
but others may deserve attention.

Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D40325


# 2fee8756 23-Feb-2023 John-Mark Gurney <jmg@FreeBSD.org>

abstract out the vm detection via smbios..

This makes the detection of VMs common between platforms that
have SMBios.

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D38800


# 4a1c4de2 05-Feb-2023 Val Packett <val@packett.cool>

Allow sysctl hw.machine/hw.machine_arch in capability mode

There's no harm in reading strings like 'amd64'.

Reviewed by: emaste, manu
Sponsored by: https://www.patreon.com/valpackett
Differential Revision: https://reviews.freebsd.org/D28703


# 5c321467 01-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

amd64: Eliminate write only cpu_fxsr.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38289
MFC after: 1 week


# 050f5a84 29-Jun-2022 Dmitry Chagin <dchagin@FreeBSD.org>

amd64: Reload CPU ext features after resume or cr4 changes

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D35555
MFC after: 2 weeks


# 56f5947a 12-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove checks for __GNUCLIKE_ASM assuming it is always true.

All supported compilers (modern versions of GCC and clang) support
this.

Many places didn't have an #else so would just silently do the wrong
thing. Ancient versions of icc (the original motivation for this) are
no longer a compiler FreeBSD supports.

PR: 263102 (exp-run)
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D34797


# 396a8479 16-Mar-2022 Roger Pau Monné <royger@FreeBSD.org>

x86/xen: fix CPUID signature

MFC: 3 days
Reviewed by: cem
Sponsored by: Citrix Systems R&D
Differential revision: https://reviews.freebsd.org/D34580


# aa9450e4 06-Jan-2021 Konstantin Belousov <kib@FreeBSD.org>

x86 identcpu.c: fix formatting of the comment.

Reviewed by: gallatin, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27986


# ab6c81a2 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

x86: clean up empty lines in .c and .h files


# 958d257e 12-Jun-2020 Konstantin Belousov <kib@FreeBSD.org>

x86: add bits definitions for SRBDS mitigation control.

See https://software.intel.com/security-software-guidance/insights/deep-dive-special-register-buffer-data-sampling

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25221


# 9d3b7f62 26-May-2020 Conrad Meyer <cem@FreeBSD.org>

x86: Detect new feature bits

Fix an off-by-one in AVX512VPOPCNTDQ identification. That was actually the
TME bit.

Reported by: debdrup


# 43cd55db 21-Feb-2020 Konstantin Belousov <kib@FreeBSD.org>

x86/identcpu.c whitespace cleanup.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 3f490f6e 21-Feb-2020 Konstantin Belousov <kib@FreeBSD.org>

print_svm_info: decode a CPUID 0x8000000a.edx bit 20.

This is SVM features word, the bit is defined in "PPR for AMD Family
17h Model 31h B0", document 55803 Rev 0.54.

N.B. GuesSpecCtl (no 't') is the spelling from the document.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 3 days


# 5e3574c8 01-Feb-2020 Conrad Meyer <cem@FreeBSD.org>

x86: Add/amend some power-management comments/macros

No functional change.


# d9591f0c 27-Jan-2020 Conrad Meyer <cem@FreeBSD.org>

x86: identcpu: Decode new Intel Structured Extended feature bits


# 4799e199 27-Jan-2020 Conrad Meyer <cem@FreeBSD.org>

x86: identcpu: Decode new Zen2 AMD Feature2 bit


# 2ee49fac 21-Jan-2020 Konstantin Belousov <kib@FreeBSD.org>

Add support for Hygon Dhyana Family 18h processor.

As a new x86 CPU vendor, Chengdu Haiguang IC Design Co., Ltd (Hygon)
is a joint venture between AMD and Haiguang Information Technology Co.,
Ltd., aims at providing x86 processors for China server market.

The first generation Hygon processor(Dhyana) shares most architecture
with AMD's family 17h, but with different CPU vendor ID("HygonGenuine")
and PCI vendor ID(0x1d94) and family series number 18h(Hygon negotiated
with AMD to confirm that only Hygon use family 18h).

To enable Hygon Dhyana support in FreeBSD, add new definitions
HYGON_VENDOR_ID("HygonGenuine") and X86_VENDOR_HYGON(0x1d94) to identify
Hygon Dhyana CPU.

Initialize the CPU features(topology, local APIC ext, MSI, TSC, hwpstate,
MCA, DEBUG_CTL, etc) for amd64 and i386 mode by sharing the code path of
AMD family 17h.

The changes have been applied on FreeBSD 13.0-CURRENT and tested
successfully on Hygon Dhyana processor.

References:
[1] Linux kernel patches for Hygon Dhyana, merged in 4.20:

https://git.kernel.org/tip/c9661c1e80b609cd038db7c908e061f0535804ef

[2] MSR and CPUID definition:

https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf

Submitted by: Pu Wen <puwen@hygon.cn>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23163


# 837d7332 12-Nov-2019 Scott Long <scottl@FreeBSD.org>

Add new bit definitions for TSX, related to the TAA issue. The actual
mitigation will follow in a future commit.

Sponsored by: Intel


# c47c10a1 11-Nov-2019 Scott Long <scottl@FreeBSD.org>

Add the text attribute for MDS_NO in the IA32_ARCH_CAP MSR.


# 706bc29b 29-Oct-2019 Conrad Meyer <cem@FreeBSD.org>

amd64: Define and decode new AMD64 feature bits

These are documented in revisions 3.32 of the public AMD64 Vol. 2 and
revision 3.28 of Vol. 3, published October and September 2019, respectively.


# bb044eaf 17-Oct-2019 Conrad Meyer <cem@FreeBSD.org>

x86: Fetch and save standard CPUID leaf 6 in identcpu

Rather than a few scattered places in the tree. Organize flag names in a
contiguous region of specialreg.h.

While here, delete deprecated PCOMMIT from leaf 7.

No functional change.


# d23e252d 14-Oct-2019 Conrad Meyer <cem@FreeBSD.org>

x86: Use canonical spelling of MOVDIR64B feature/instruction

The former spelling probably confused MOVDIR64B with MOVDIRI64.

MOVDIR_64B is the 64-*byte* direct store instruction; MOVDIR_I64 is the
64-*bit* direct store instruction (underscores added here for clarity; they are
not part of the canonical instruction name).

No functional change.

Sponsored by: Dell EMC Isilon


# c63f1e21 22-May-2019 Conrad Meyer <cem@FreeBSD.org>

Decode and name additional x86 feature bits

These are all enumerated in Intel's ISA extension reference, 37th ed.

Sponsored by: Dell EMC Isilon


# 1177d38c 21-May-2019 Stephen J. Kiernan <stevek@FreeBSD.org>

The older detection methods (smbios.bios.vendor and smbios.system.product)
are able to determine some virtual machines, but the vm_guest variable was
still only being set to VM_GUEST_VM.

Since we do know what some of them specifically are, we can set vm_guest
appropriately.

Also, if we see the CPUID has the HV flag, but we were unable to find a
definitive vendor in the Hypervisor CPUID Information Leaf, fall back to
the older detection methods, as they may be able to determine a specific
HV type.

Add VM_GUEST_PARALLELS value to VM_GUEST for Parallels.

Approved by: cem
Differential Revision: https://reviews.freebsd.org/D20305


# c5c89162 19-May-2019 Stephen J. Kiernan <stevek@FreeBSD.org>

Add missing setting of hv_base to the leaf that we used.
Correct setting hv_high to use regs[0], not leaf.


# 949f834a 17-May-2019 Stephen J. Kiernan <stevek@FreeBSD.org>

Instead of individual conditional statements to look for each hypervisor
type, use a table to make it easier to add more in the future, if needed.

Add VirtualBox detection to the table ("VBoxVBoxVBox" is the hypervisor
vendor string to look for.) Also add VM_GUEST_VBOX to the VM_GUEST
enumeration to indicate VirtualBox.

Save the CPUID base for the hypervisor entry that we detected. Driver code
may need to know about it in order to obtain additional CPUID features.

Approved by: bryanv, jhb
Differential Revision: https://reviews.freebsd.org/D16305


# e7e3d522 15-May-2019 Conrad Meyer <cem@FreeBSD.org>

x86: Correctly identify bhyve hypervisor

Spotted after a similar report by Olivier Cochard-Labbé.

Sponsored by: Dell EMC Isilon


# b55d4ebe 15-May-2019 Konstantin Belousov <kib@FreeBSD.org>

Properly announce MD_CLEAR.

Submitted by: Petr Lampa <lampa@fit.vutbr.cz>
MFC after: 3 days


# 3dcf329e 12-Mar-2019 Konstantin Belousov <kib@FreeBSD.org>

Add register number, CPUID bits, and print identification for TSX
force abort errata.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# ccc2d07e 04-Feb-2019 Konstantin Belousov <kib@FreeBSD.org>

Update CPUID bits definitions and CPU identification based on changes
in SDM rev. 069.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 9a527560 29-Jan-2019 Konstantin Belousov <kib@FreeBSD.org>

i386: Merge PAE and non-PAE pmaps into same kernel.

Effectively all i386 kernels now have two pmaps compiled in: one
managing PAE pagetables, and another non-PAE. The implementation is
selected at cold time depending on the CPU features. The vm_paddr_t is
always 64bit now. As result, nx bit can be used on all capable CPUs.

Option PAE only affects the bus_addr_t: it is still 32bit for non-PAE
configs, for drivers compatibility. Kernel layout, esp. max kernel
address, low memory PDEs and max user address (same as trampoline
start) are now same for PAE and for non-PAE regardless of the type of
page tables used.

Non-PAE kernel (when using PAE pagetables) can handle physical memory
up to 24G now, larger memory requires re-tuning the KVA consumers and
instead the code caps the maximum at 24G. Unfortunately, a lot of
drivers do not use busdma(9) properly so by default even 4G barrier is
not easy. There are two tunables added: hw.above4g_allow and
hw.above24g_allow, the first one is kept enabled for now to evaluate
the status on HEAD, second is only for dev use.

i386 now creates three freelists if there is any memory above 4G, to
allow proper bounce pages allocation. Also, VM_KMEM_SIZE_SCALE changed
from 3 to 1.

The PAE_TABLES kernel config option is retired.

In collaboarion with: pho
Discussed with: emaste
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D18894


# 16068ae4 17-Jan-2019 Conrad Meyer <cem@FreeBSD.org>

Add definitions for AMD Spectre/Meltdown CPUID information

No functional change, aside from printing recognized bits in CPU
identification.

The bits are documented in 111006-B "Indirect Branch Control Extension"[1] and
124441 "Speculative Store Bypass Disable."[2]

Notably missing (left as future work):
* Integration with hw.spec_store_bypass_disable and hw_ssb_active flag,
which are currently Intel-specific
* Integration with hw_ibrs_active global flag, which are currently
Intel-specific
* SSB_NO integration in hw_ssb_recalculate()
* Bhyve integration (PR 235010)

[1]:
https://developer.amd.com/wp-content/resources/111006-B_AMD64TechnologyIndirectBranchControlExtenstion_WP_7-18Update_FNL.pdf

[2]:
https://developer.amd.com/wp-content/resources/124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf

PR: 235010 (related, but does not fix)
MFC after: a week


# 23437573 16-Nov-2018 Konstantin Belousov <kib@FreeBSD.org>

Align IA32_ARCH_CAP MSR definitions and use with SDM rev. 068.

SDM rev. 068 was released yesterday and it contains the description of
the MSR 0x10a IA32_ARCH_CAP. This change adds symbolic definitions for
all bits present in the document, and decode them in the CPU
identification lines printed on boot.

But also, the document defines SSB_NO as bit 4, while FreeBSD used but
2 to detect the need to work-around Speculative Store Bypass
issue. Change code to use the bit from SDM.

Similarly, the document describes bit 3 as an indicator that L1TF
issue is not present, in particular, no L1D flush is needed on
VMENTRY. We used RDCL_NO to avoid flushing, and again I changed the
code to follow new spec from SDM.

In fact my Apollo Lake machine with latest ucode shows this:
IA32_ARCH_CAPS=0x19<RDCL_NO,SKIP_L1DFL_VME,SSB_NO>

Reviewed by: bwidawsk
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D18006


# 83813c66 12-Nov-2018 Konstantin Belousov <kib@FreeBSD.org>

Apply fix to un-cripple max cpu id on BSP earlier.

We need to know actual value for the standard extended features before
ifuncs are resolved.

Reported and tested by: madpilot
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 9e2d4791 17-Aug-2018 Konstantin Belousov <kib@FreeBSD.org>

Print L1D FLUSH feature.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 9be4bbbb 21-May-2018 Konstantin Belousov <kib@FreeBSD.org>

Add definition for Intel Speculative Store Bypass Disable MSR bits

Security: CVE-2018-3639
Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 70916086 23-Mar-2018 John Baldwin <jhb@FreeBSD.org>

Add a workaround to the hypervisor detection for older versions of KVM.

Originally KVM set %eax to 0 in the cpuid leaf 0x4000000 rather than
to the highest supported leaf in the hypervisor "branch". Detect this
case and fixup the %eax value so that the hypervisor is still
detected.

Reported by: jpaetzel
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14810


# 7471a3fa 12-Mar-2018 Andriy Gapon <avg@FreeBSD.org>

fix r297857, do not modify CPU extension bits under virtual machines

r297857 was meant for real hardware only.

PR: 213155
Submitted by: mainland@apeiron.net
MFC after: 1 week


# 3b531932 31-Jan-2018 Konstantin Belousov <kib@FreeBSD.org>

Do not enable PTI when IA32_ARCH_CAP_RDCL_NO bit is set.

Intel document 336996-001 claims that this will be the way to inform
about Meltdown correction.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# b3327f62 19-Jan-2018 Ed Maste <emaste@FreeBSD.org>

Enable KPTI by default on amd64 for non-AMD CPUs

Kernel Page Table Isolation (KPTI) was introduced in r328083 as a
mitigation for the 'Meltdown' vulnerability. AMD CPUs are not affected,
per https://www.amd.com/en/corporate/speculative-execution:

We believe AMD processors are not susceptible due to our use of
privilege level protections within paging architecture and no
mitigation is required.

Thus default KPTI to off for AMD CPUs, and to on for others. This may
be refined later as we obtain more specific information on the sets of
CPUs that are and are not affected.

Submitted by: Mitchell Horne
Reviewed by: cem
Relnotes: Yes
Security: CVE-2017-5754
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13971


# e8c770a6 13-Jan-2018 Konstantin Belousov <kib@FreeBSD.org>

Enumerate and print Intel CPU features for Speculative Execution Side
Channel Mitigations.

The definitions are taken from the document 336996-001.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 0530a936 05-Jan-2018 Konstantin Belousov <kib@FreeBSD.org>

Make it possible to re-evaluate cpu_features.

Add cpuctl(4) ioctl CPUCTL_EVAL_CPU_FEATURES which forces re-read of
cpu_features, cpu_features2, cpu_stdext_features, and
std_stdext_features2.

The intent is to allow the kernel to see the changes in the CPU
features after micocode update. Of course, the update is not atomic
across variables and not synchronized with readers. See the man page
warning as well.

Reviewed by: imp (previous version), jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13770


# 6332b148 23-Dec-2017 Konstantin Belousov <kib@FreeBSD.org>

Add missed AVX512VL (128 and 256 bit vector length) extension
identification bit.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 194446f9 20-Sep-2017 Conrad Meyer <cem@FreeBSD.org>

x86: Decode AMD "Extended Feature Extensions ID EBX" bits

In particular, this determines CPU support for the CLZERO instruction.

(No, I am not making this name up.)

Sponsored by: Dell EMC Isilon


# e8be4e41 11-Sep-2017 Conrad Meyer <cem@FreeBSD.org>

Decode new AMD SVM feature bits on family 17h

Sponsored by: Dell EMC Isilon


# cd8c2581 07-Sep-2017 Conrad Meyer <cem@FreeBSD.org>

Store AMD RAS Capabilities cpuid value and name flags

Reviewed by: truckman
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12237


# 2624320f 24-Aug-2017 Konstantin Belousov <kib@FreeBSD.org>

Stop masking FSGSBASE and SMEP features under monitors.

Not enabling FSGSBASE in %cr4 does not prevent reporting of the
feature by the CPUID instruction (blame Int*l). As result, kernels
which were run under monitors pretended that usermode cannot modify
TLS base without the syscall, while libc noted right combination of
capable CPU and the new kernel version, trying to use the WRFSBASE
instruction.

Really old hypervisors that cannot handle enablement of these features
in %cr4 would require the manual configuration, by setting the loader
tunable hw.cpu_stdext_disable=0x81

Reported by: lwhsu, mjoras
Sponsored by: The FreeBSD Foundation
MFC after: 18 days


# b5669d0a 09-Aug-2017 Jung-uk Kim <jkim@FreeBSD.org>

Split identify_cpu() into two functions for amd64 as we do for i386. This
reduces diff between amd64 and i386. Also, it fixes a regression introduced
in r322076, i.e., identify_hypervisor() failed to identify some hypervisors.
This function assumes cpu_feature2 is already initialized.

Reported by: dexuan
Tested by: dexuan


# 01050344 05-Aug-2017 Jung-uk Kim <jkim@FreeBSD.org>

Detect hypervisors early. We used to set lower hz on hypervisors by default
but it was broken since r273800 (and r278522, its MFC to stable/10) because
identify_cpu() is called too late, i.e., after init_param1().

MFC after: 3 days


# e0a6a23c 07-Jun-2017 Marcelo Araujo <araujo@FreeBSD.org>

Allow sysctl kern.vm_guest to return bhyve when running under bhyve.

Submitted by: Sean Fagan <sef@ixsystems.com>
Reviewed by: grehan
MFH: 4 weeks.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D11090


# cae91bbe 30-May-2017 Andriy Gapon <avg@FreeBSD.org>

fix indentation

MFC after: 4 days


# 264fae07 15-Mar-2017 Peter Grehan <grehan@FreeBSD.org>

Add the AMD MONITORX/MWAITX feature definition introduced in
Bulldozer/Ryzen CPUs.

Reviewed by: kib
MFC after: 1 week


# 57f6622f 02-Feb-2017 Konstantin Belousov <kib@FreeBSD.org>

For i386, remove config options CPU_DISABLE_CMPXCHG, CPU_DISABLE_SSE
and device npx.

This means that FPU is always initialized and handled when available,
and SSE+ register file and exception are handled when available. This
makes the kernel FPU code much easier to maintain by the cost of
slight bloat for CPUs older than 25 years.

CPU_DISABLE_CMPXCHG outlived its usefulness, see the removed comment
explaining the original purpose.

Suggested by and discussed with: bde
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks


# 53dc58f2 19-Oct-2016 Mateusz Guzik <mjg@FreeBSD.org>

Mark a bunch of mpsafe sysctls as such.

This gives me a sysctl Giant-free buildworld.


# 38605d73 15-Sep-2016 John Baldwin <jhb@FreeBSD.org>

Remove 'cpu' and 'cpu_class' on amd64.

The 'cpu' and 'cpu_class' variables were always set to the same value
on amd64 and are legacy holdovers from i386. Remove them entirely on
amd64.

Reviewed by: imp, kib (older version)
Differential Revision: https://reviews.freebsd.org/D7888


# 1a9ded46 12-Sep-2016 Konstantin Belousov <kib@FreeBSD.org>

Fix typo in comment.

MFC after: 3 days


# fdb6320d 13-Jul-2016 Eric Badger <badger@FreeBSD.org>

Add explicit detection of KVM hypervisor

Set vm_guest to a new enum value (VM_GUEST_KVM) when kvm is detected and use
vm_guest in conditionals testing for KVM.

Also, fix a conditional checking if we're running in a VM which caught only
the generic VM case, but not more specific VMs (KVM, VMWare, etc.). (Spotted
by: vangyzen).

Differential revision: https://reviews.freebsd.org/D7172
Sponsored by: Dell Inc.
Approved by: kib (mentor), vangyzen (mentor)
Reviewed by: alc
MFC after: 4 weeks


# ea24b056 19-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

X86: use our nitems() macro when it is avaliable through param.h.

No functional change, only trivial cases are done in this sweep,

Discussed in: freebsd-current


# c5c20928 16-Apr-2016 Konstantin Belousov <kib@FreeBSD.org>

Add x86 CPU features definitions published in the Intel SDM rev. 58.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 0d63fc3e 12-Apr-2016 Andriy Gapon <avg@FreeBSD.org>

re-enable AMD Topology extension on certain models if disabled by BIOS

Some BIOSes disable AMD Topology extension on AMD Family 15h notebook
processors. We re-enable the extension, so that we can properly discover
core and cache topology. Linux seems to do the same.

Reported by: Johannes Dieterich <dieterich.joh@gmail.com>
Reviewed by: jhb, kib
Tested by: Johannes Dieterich <dieterich.joh@gmail.com>
(earlier version)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D5883


# 69a53a7a 13-Jan-2016 Sepherosa Ziehau <sephe@FreeBSD.org>

hyperv: use x86 generic code to do the hypervisor detection

This is first step to move the generic part of HV code into kernel instead
of module, so that it is possible to use hypercall to implement some other
paravirtualization code in the kernel.

Submitted by: Howard Su <howard0su@gmail.com>
Reviewed by: royger, delphij, adrian
Approved by: adrian (mentor)
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D3072


# 6b247f85 29-Dec-2015 Konstantin Belousov <kib@FreeBSD.org>

Add standard extended feature bit 6 from the Intel SDM rev. 57, which
indicates that data-pointer in the saved x87 FPU state is only updated
on FPU exceptions.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 9e8d8b4b 23-Dec-2015 John Baldwin <jhb@FreeBSD.org>

Move shared variables from {amd64,i386}/initcpu.c to x86/identcpu.c.
While here, move the common bits of <machine/cputypes.h> to
<x86/cputypes.h> as well.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D4670


# ce43b54a 19-Dec-2015 Conrad Meyer <cem@FreeBSD.org>

x86: Detect feature flags "AVX512DQ", "AVX512IFMA", "AVX512BW", "AVX512VBMI"

Documented in Intel Architecture Set Extensions Programming Reference
(319433-023).

Sponsored by: EMC / Isilon Storage Division


# f750a7ed 19-Dec-2015 Conrad Meyer <cem@FreeBSD.org>

x86: Detect feature flags "CLWB" and "PCOMMIT"

"The availability of CLWB instruction is indicated by the presence of
the CPUID feature flag CLWB (bit 24 of the EBX register)."

CLWB is similar to CLFLUSHOPT, except that it is not required to discard
cacheline contents.

"On processors that supports PCOMMIT, PCOMMIT is enumerated through
CPUID (CPUID.7.0.EBX[22]) only when the feature is enabled by BIOS."

PCOMMIT is used to cause store-to-memory operations to become persistent
(protected from power failure).

Sponsored by: EMC / Isilon Storage Division


# 2a8a46b1 24-Nov-2015 Konstantin Belousov <kib@FreeBSD.org>

Correct the number of DTLB entries reported for the CPUID Leaf 2
descriptor 0x6c.

Confirmed by: Intel
MFC after: 3 days


# c0db387d 23-Oct-2015 Konstantin Belousov <kib@FreeBSD.org>

Decode new values for CPUID leaf 2 cache and TLB descriptors, from the
Intel SDM revision 56.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# f94cc234 02-Aug-2015 Konstantin Belousov <kib@FreeBSD.org>

Clear the IA32_MISC_ENABLE MSR bit, which limits the max CPUID
reported, on APs. We already did this on BSP.

Otherwise, the userspace software which depends on the features
reported by the high CPUID levels is misbehaving. In particular, AVX
detection is non-functional, depending on which CPU thread happens to
execute when doing CPUID. Another victim is the libthr signal
handlers interposer, which needs to save full FPU extended state.

Reported and tested by: Andre Meiser <ortadur@web.de>
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks


# 32a1e9e4 06-Jun-2015 Konstantin Belousov <kib@FreeBSD.org>

Update print_INTEL_TLB() by the tag values from the Intel SDM
rev. 55. The modern CPUs cache and TLB descriptions looked quite
questionable without the update, e.g. Haswell i7 4770S reported:
Data TLB: 4 KB pages, 4-way set associative, 64 entries
L2 cache: 256 kbytes, 8-way associative, 64 bytes/line
After the update, the report is:
Data TLB: 1 GByte pages, 4-way set associative, 4 entries
Data TLB: 4 KB pages, 4-way set associative, 64 entries
Instruction TLB: 2M/4M pages, fully associative, 8 entries
Instruction TLB: 4KByte pages, 8-way set associative, 64 entries
64-Byte prefetching
Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries
L2 cache: 256 kbytes, 8-way associative, 64 bytes/line
Some tags were apparently removed from the table 3-21, Vol. 2A. Keep
them around, but add a comment stating the removal.

Update the format line for cpu_stdext_feature according to the bits
from the SDM rev.55. It appears that Haswells do not store %cs and
%ds values in the FPU save area.

Store content of the %ecx register from the CPUID leaf 0x7
subleaf 0 as cpu_stdext_feature2 and print defined bits from it,
again acording to SDM rev. 55.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# ed95805e 30-Apr-2015 John Baldwin <jhb@FreeBSD.org>

Remove support for Xen PV domU kernels. Support for HVM domU kernels
remains. Xen is planning to phase out support for PV upstream since it
is harder to maintain and has more overhead. Modern x86 CPUs include
virtualization extensions that support HVM guests instead of PV guests.
In addition, the PV code was i386 only and not as well maintained recently
as the HVM code.
- Remove the i386-only NATIVE option that was used to disable certain
components for PV kernels. These components are now standard as they
are on amd64.
- Remove !XENHVM bits from PV drivers.
- Remove various shims required for XEN (e.g. PT_UPDATES_FLUSH, LOAD_CR3,
etc.)
- Remove duplicate copy of <xen/features.h>.
- Remove unused, i386-only xenstored.h.

Differential Revision: https://reviews.freebsd.org/D2362
Reviewed by: royger
Tested by: royger (i386/amd64 HVM domU and amd64 PVH dom0)
Relnotes: yes


# b1752aa0 12-Jan-2015 Konstantin Belousov <kib@FreeBSD.org>

For x86, read MAXPHYADDR, defined in SDM vol 3 4.1.4 Enumeration of Paging
Features by CPUID as CPUID.80000008H:EAX[7:0], into variable cpu_maxphyaddr.

Reviewed by: alc
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# e31b1dc8 08-Jan-2015 Sean Bruno <sbruno@FreeBSD.org>

Update Features2 to display SDBG capability of processor. This is
showing up on Haswell-class CPUs

From the Intel SDM, "Table 3-20. Feature Information Returned in the
ECX Register"

11 | SDBG | A value of 1 indicates the processor supports
IA32_DEBUG_INTERFACE MSR for silicon debug.

Submitted by: jiashiun@gmail.com
Reviewed by: jhb neel
MFC after: 2 weeks


# 01e1933d 28-Oct-2014 John Baldwin <jhb@FreeBSD.org>

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.

Differential Revision: https://reviews.freebsd.org/D1010
Reviewed by: delphij, jkim, neel


# 0792e3be 27-Oct-2014 Peter Grehan <grehan@FreeBSD.org>

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.

Differential Revision: https://reviews.freebsd.org/D1008
Reviewed by: jhb, neel
MFC after: 1 week


# eec906cf 10-Sep-2014 John Baldwin <jhb@FreeBSD.org>

Move code to set various MSRs on AMD cpus out of printcpuinfo() and
into initalizecpu() instead.


# dc7c2b07 06-Sep-2014 Konstantin Belousov <kib@FreeBSD.org>

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. The printcpuinfo()
is executed late enough so that XSAVE is already enabled.

There is no known to me off the shelf hardware that implements any
feature bits except XSAVEOPT, the list is taken from SDM rev. 50. The
banner printing will allow us to note the hardware arrival.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 33a50f1b 04-Sep-2014 John Baldwin <jhb@FreeBSD.org>

Merge the amd64 and i386 identcpu.c into a single x86 implementation.
This brings the structured extended features mask and VT-x reporting to
i386 and Intel cache and TLB info (under bootverbose) to amd64.