Merge tag 'v9.0.0-rc3'
[qemu/ar7.git] / docs / system / cpu-models-x86.rst.inc
blobba27b5683fbfb97917f37a969f544ce93e176d39
1 Recommendations for KVM CPU model configuration on x86 hosts
2 ============================================================
4 The information that follows provides recommendations for configuring
5 CPU models on x86 hosts. The goals are to maximise performance, while
6 protecting guest OS against various CPU hardware flaws, and optionally
7 enabling live migration between hosts with heterogeneous CPU models.
10 Two ways to configure CPU models with QEMU / KVM
11 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 (1) **Host passthrough**
15     This passes the host CPU model features, model, stepping, exactly to
16     the guest. Note that KVM may filter out some host CPU model features
17     if they cannot be supported with virtualization. Live migration is
18     unsafe when this mode is used as libvirt / QEMU cannot guarantee a
19     stable CPU is exposed to the guest across hosts. This is the
20     recommended CPU to use, provided live migration is not required.
22 (2) **Named model**
24     QEMU comes with a number of predefined named CPU models, that
25     typically refer to specific generations of hardware released by
26     Intel and AMD.  These allow the guest VMs to have a degree of
27     isolation from the host CPU, allowing greater flexibility in live
28     migrating between hosts with differing hardware.  @end table
30 In both cases, it is possible to optionally add or remove individual CPU
31 features, to alter what is presented to the guest by default.
33 Libvirt supports a third way to configure CPU models known as "Host
34 model".  This uses the QEMU "Named model" feature, automatically picking
35 a CPU model that is similar the host CPU, and then adding extra features
36 to approximate the host model as closely as possible. This does not
37 guarantee the CPU family, stepping, etc will precisely match the host
38 CPU, as they would with "Host passthrough", but gives much of the
39 benefit of passthrough, while making live migration safe.
42 ABI compatibility levels for CPU models
43 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 The x86_64 architecture has a number of `ABI compatibility levels`_
46 defined. Traditionally most operating systems and toolchains would
47 only target the original baseline ABI. It is expected that in
48 future OS and toolchains are likely to target newer ABIs. The
49 table that follows illustrates which ABI compatibility levels
50 can be satisfied by the QEMU CPU models. Note that the table only
51 lists the long term stable CPU model versions (eg Haswell-v4).
52 In addition to what is listed, there are also many CPU model
53 aliases which resolve to a different CPU model version,
54 depending on the machine type is in use.
56 .. _ABI compatibility levels: https://gitlab.com/x86-psABIs/x86-64-ABI/
58 .. csv-table:: x86-64 ABI compatibility levels
59    :file: cpu-models-x86-abi.csv
60    :widths: 40,15,15,15,15
61    :header-rows: 1
64 Preferred CPU models for Intel x86 hosts
65 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67 The following CPU models are preferred for use on Intel hosts.
68 Administrators / applications are recommended to use the CPU model that
69 matches the generation of the host CPUs in use. In a deployment with a
70 mixture of host CPU models between machines, if live migration
71 compatibility is required, use the newest CPU model that is compatible
72 across all desired hosts.
74 ``Cascadelake-Server``, ``Cascadelake-Server-noTSX``
75     Intel Xeon Processor (Cascade Lake, 2019), with "stepping" levels 6
76     or 7 only.  (The Cascade Lake Xeon processor with *stepping 5 is
77     vulnerable to MDS variants*.)
79 ``Skylake-Server``, ``Skylake-Server-IBRS``, ``Skylake-Server-IBRS-noTSX``
80     Intel Xeon Processor (Skylake, 2016)
82 ``Skylake-Client``, ``Skylake-Client-IBRS``, ``Skylake-Client-noTSX-IBRS}``
83     Intel Core Processor (Skylake, 2015)
85 ``Broadwell``, ``Broadwell-IBRS``, ``Broadwell-noTSX``, ``Broadwell-noTSX-IBRS``
86     Intel Core Processor (Broadwell, 2014)
88 ``Haswell``, ``Haswell-IBRS``, ``Haswell-noTSX``, ``Haswell-noTSX-IBRS``
89     Intel Core Processor (Haswell, 2013)
91 ``IvyBridge``, ``IvyBridge-IBR``
92     Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)
94 ``SandyBridge``, ``SandyBridge-IBRS``
95     Intel Xeon E312xx (Sandy Bridge, 2011)
97 ``Westmere``, ``Westmere-IBRS``
98     Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)
100 ``Nehalem``, ``Nehalem-IBRS``
101     Intel Core i7 9xx (Nehalem Class Core i7, 2008)
103 ``Penryn``
104     Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)
106 ``Conroe``
107     Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)
110 Important CPU features for Intel x86 hosts
111 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
113 The following are important CPU features that should be used on Intel
114 x86 hosts, when available in the host CPU. Some of them require explicit
115 configuration to enable, as they are not included by default in some, or
116 all, of the named CPU models listed above. In general all of these
117 features are included if using "Host passthrough" or "Host model".
119 ``pcid``
120   Recommended to mitigate the cost of the Meltdown (CVE-2017-5754) fix.
122   Included by default in Haswell, Broadwell & Skylake Intel CPU models.
124   Should be explicitly turned on for Westmere, SandyBridge, and
125   IvyBridge Intel CPU models. Note that some desktop/mobile Westmere
126   CPUs cannot support this feature.
128 ``spec-ctrl``
129   Required to enable the Spectre v2 (CVE-2017-5715) fix.
131   Included by default in Intel CPU models with -IBRS suffix.
133   Must be explicitly turned on for Intel CPU models without -IBRS
134   suffix.
136   Requires the host CPU microcode to support this feature before it
137   can be used for guest CPUs.
139 ``stibp``
140   Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
141   operating systems.
143   Must be explicitly turned on for all Intel CPU models.
145   Requires the host CPU microcode to support this feature before it can
146   be used for guest CPUs.
148 ``ssbd``
149   Required to enable the CVE-2018-3639 fix.
151   Not included by default in any Intel CPU model.
153   Must be explicitly turned on for all Intel CPU models.
155   Requires the host CPU microcode to support this feature before it
156   can be used for guest CPUs.
158 ``pdpe1gb``
159   Recommended to allow guest OS to use 1GB size pages.
161   Not included by default in any Intel CPU model.
163   Should be explicitly turned on for all Intel CPU models.
165   Note that not all CPU hardware will support this feature.
167 ``md-clear``
168   Required to confirm the MDS (CVE-2018-12126, CVE-2018-12127,
169   CVE-2018-12130, CVE-2019-11091) fixes.
171   Not included by default in any Intel CPU model.
173   Must be explicitly turned on for all Intel CPU models.
175   Requires the host CPU microcode to support this feature before it
176   can be used for guest CPUs.
178 ``mds-no``
179   Recommended to inform the guest OS that the host is *not* vulnerable
180   to any of the MDS variants ([MFBDS] CVE-2018-12130, [MLPDS]
181   CVE-2018-12127, [MSBDS] CVE-2018-12126).
183   This is an MSR (Model-Specific Register) feature rather than a CPUID feature,
184   so it will not appear in the Linux ``/proc/cpuinfo`` in the host or
185   guest.  Instead, the host kernel uses it to populate the MDS
186   vulnerability file in ``sysfs``.
188   So it should only be enabled for VMs if the host reports @code{Not
189   affected} in the ``/sys/devices/system/cpu/vulnerabilities/mds`` file.
191 ``taa-no``
192   Recommended to inform that the guest that the host is ``not``
193   vulnerable to CVE-2019-11135, TSX Asynchronous Abort (TAA).
195   This too is an MSR feature, so it does not show up in the Linux
196   ``/proc/cpuinfo`` in the host or guest.
198   It should only be enabled for VMs if the host reports ``Not affected``
199   in the ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort``
200   file.
202 ``tsx-ctrl``
203   Recommended to inform the guest that it can disable the Intel TSX
204   (Transactional Synchronization Extensions) feature; or, if the
205   processor is vulnerable, use the Intel VERW instruction (a
206   processor-level instruction that performs checks on memory access) as
207   a mitigation for the TAA vulnerability.  (For details, refer to
208   Intel's `deep dive into MDS
209   <https://software.intel.com/security-software-guidance/insights/deep-dive-intel-analysis-microarchitectural-data-sampling>`_.)
211   Expose this to the guest OS if and only if: (a) the host has TSX
212   enabled; *and* (b) the guest has ``rtm`` CPU flag enabled.
214   By disabling TSX, KVM-based guests can avoid paying the price of
215   mitigating TSX-based attacks.
217   Note that ``tsx-ctrl`` too is an MSR feature, so it does not show
218   up in the Linux ``/proc/cpuinfo`` in the host or guest.
220   To validate that Intel TSX is indeed disabled for the guest, there are
221   two ways: (a) check for the *absence* of ``rtm`` in the guest's
222   ``/proc/cpuinfo``; or (b) the
223   ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort`` file in
224   the guest should report ``Mitigation: TSX disabled``.
227 Preferred CPU models for AMD x86 hosts
228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230 The following CPU models are preferred for use on AMD hosts.
231 Administrators / applications are recommended to use the CPU model that
232 matches the generation of the host CPUs in use. In a deployment with a
233 mixture of host CPU models between machines, if live migration
234 compatibility is required, use the newest CPU model that is compatible
235 across all desired hosts.
237 ``EPYC``, ``EPYC-IBPB``
238     AMD EPYC Processor (2017)
240 ``Opteron_G5``
241     AMD Opteron 63xx class CPU (2012)
243 ``Opteron_G4``
244     AMD Opteron 62xx class CPU (2011)
246 ``Opteron_G3``
247     AMD Opteron 23xx (Gen 3 Class Opteron, 2009)
249 ``Opteron_G2``
250     AMD Opteron 22xx (Gen 2 Class Opteron, 2006)
252 ``Opteron_G1``
253     AMD Opteron 240 (Gen 1 Class Opteron, 2004)
256 Important CPU features for AMD x86 hosts
257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259 The following are important CPU features that should be used on AMD x86
260 hosts, when available in the host CPU. Some of them require explicit
261 configuration to enable, as they are not included by default in some, or
262 all, of the named CPU models listed above. In general all of these
263 features are included if using "Host passthrough" or "Host model".
265 ``ibpb``
266   Required to enable the Spectre v2 (CVE-2017-5715) fix.
268   Included by default in AMD CPU models with -IBPB suffix.
270   Must be explicitly turned on for AMD CPU models without -IBPB suffix.
272   Requires the host CPU microcode to support this feature before it
273   can be used for guest CPUs.
275 ``stibp``
276   Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
277   operating systems.
279   Must be explicitly turned on for all AMD CPU models.
281   Requires the host CPU microcode to support this feature before it
282   can be used for guest CPUs.
284 ``virt-ssbd``
285   Required to enable the CVE-2018-3639 fix
287   Not included by default in any AMD CPU model.
289   Must be explicitly turned on for all AMD CPU models.
291   This should be provided to guests, even if amd-ssbd is also provided,
292   for maximum guest compatibility.
294   Note for some QEMU / libvirt versions, this must be force enabled when
295   when using "Host model", because this is a virtual feature that
296   doesn't exist in the physical host CPUs.
298 ``amd-ssbd``
299   Required to enable the CVE-2018-3639 fix
301   Not included by default in any AMD CPU model.
303   Must be explicitly turned on for all AMD CPU models.
305   This provides higher performance than ``virt-ssbd`` so should be
306   exposed to guests whenever available in the host. ``virt-ssbd`` should
307   none the less also be exposed for maximum guest compatibility as some
308   kernels only know about ``virt-ssbd``.
310 ``amd-no-ssb``
311   Recommended to indicate the host is not vulnerable CVE-2018-3639
313   Not included by default in any AMD CPU model.
315   Future hardware generations of CPU will not be vulnerable to
316   CVE-2018-3639, and thus the guest should be told not to enable
317   its mitigations, by exposing amd-no-ssb. This is mutually
318   exclusive with virt-ssbd and amd-ssbd.
320 ``pdpe1gb``
321   Recommended to allow guest OS to use 1GB size pages
323   Not included by default in any AMD CPU model.
325   Should be explicitly turned on for all AMD CPU models.
327   Note that not all CPU hardware will support this feature.
330 Default x86 CPU models
331 ^^^^^^^^^^^^^^^^^^^^^^
333 The default QEMU CPU models are designed such that they can run on all
334 hosts.  If an application does not wish to do perform any host
335 compatibility checks before launching guests, the default is guaranteed
336 to work.
338 The default CPU models will, however, leave the guest OS vulnerable to
339 various CPU hardware flaws, so their use is strongly discouraged.
340 Applications should follow the earlier guidance to setup a better CPU
341 configuration, with host passthrough recommended if live migration is
342 not needed.
344 ``qemu32``, ``qemu64``
345     QEMU Virtual CPU version 2.5+ (32 & 64 bit variants)
347 ``qemu64`` is used for x86_64 guests and ``qemu32`` is used for i686
348 guests, when no ``-cpu`` argument is given to QEMU, or no ``<cpu>`` is
349 provided in libvirt XML.
351 Other non-recommended x86 CPUs
352 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
354 The following CPUs models are compatible with most AMD and Intel x86
355 hosts, but their usage is discouraged, as they expose a very limited
356 featureset, which prevents guests having optimal performance.
358 ``kvm32``, ``kvm64``
359     Common KVM processor (32 & 64 bit variants).
361     Legacy models just for historical compatibility with ancient QEMU
362     versions.
364 ``486``, ``athlon``, ``phenom``, ``coreduo``, ``core2duo``, ``n270``, ``pentium``, ``pentium2``, ``pentium3``
365     Various very old x86 CPU models, mostly predating the introduction
366     of hardware assisted virtualization, that should thus not be
367     required for running virtual machines.
370 Syntax for configuring CPU models
371 =================================
373 The examples below illustrate the approach to configuring the various
374 CPU models / features in QEMU and libvirt.
376 QEMU command line
377 ^^^^^^^^^^^^^^^^^
379 Host passthrough:
381 .. parsed-literal::
383   |qemu_system| -cpu host
385 Host passthrough with feature customization:
387 .. parsed-literal::
389   |qemu_system| -cpu host,vmx=off,...
391 Named CPU models:
393 .. parsed-literal::
395   |qemu_system| -cpu Westmere
397 Named CPU models with feature customization:
399 .. parsed-literal::
401   |qemu_system| -cpu Westmere,pcid=on,...
403 Libvirt guest XML
404 ^^^^^^^^^^^^^^^^^
406 Host passthrough::
408     <cpu mode='host-passthrough'/>
410 Host passthrough with feature customization::
412     <cpu mode='host-passthrough'>
413         <feature name="vmx" policy="disable"/>
414         ...
415     </cpu>
417 Host model::
419     <cpu mode='host-model'/>
421 Host model with feature customization::
423     <cpu mode='host-model'>
424         <feature name="vmx" policy="disable"/>
425         ...
426     </cpu>
428 Named model::
430     <cpu mode='custom'>
431         <model name="Westmere"/>
432     </cpu>
434 Named model with feature customization::
436     <cpu mode='custom'>
437         <model name="Westmere"/>
438         <feature name="pcid" policy="require"/>
439         ...
440     </cpu>