cpu-models-x86.rst.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. Recommendations for KVM CPU model configuration on x86 hosts
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. The information that follows provides recommendations for configuring
  4. CPU models on x86 hosts. The goals are to maximise performance, while
  5. protecting guest OS against various CPU hardware flaws, and optionally
  6. enabling live migration between hosts with heterogeneous CPU models.
  7. Two ways to configure CPU models with QEMU / KVM
  8. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  9. (1) **Host passthrough**
  10. This passes the host CPU model features, model, stepping, exactly to
  11. the guest. Note that KVM may filter out some host CPU model features
  12. if they cannot be supported with virtualization. Live migration is
  13. unsafe when this mode is used as libvirt / QEMU cannot guarantee a
  14. stable CPU is exposed to the guest across hosts. This is the
  15. recommended CPU to use, provided live migration is not required.
  16. (2) **Named model**
  17. QEMU comes with a number of predefined named CPU models, that
  18. typically refer to specific generations of hardware released by
  19. Intel and AMD. These allow the guest VMs to have a degree of
  20. isolation from the host CPU, allowing greater flexibility in live
  21. migrating between hosts with differing hardware. @end table
  22. In both cases, it is possible to optionally add or remove individual CPU
  23. features, to alter what is presented to the guest by default.
  24. Libvirt supports a third way to configure CPU models known as "Host
  25. model". This uses the QEMU "Named model" feature, automatically picking
  26. a CPU model that is similar the host CPU, and then adding extra features
  27. to approximate the host model as closely as possible. This does not
  28. guarantee the CPU family, stepping, etc will precisely match the host
  29. CPU, as they would with "Host passthrough", but gives much of the
  30. benefit of passthrough, while making live migration safe.
  31. Preferred CPU models for Intel x86 hosts
  32. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  33. The following CPU models are preferred for use on Intel hosts.
  34. Administrators / applications are recommended to use the CPU model that
  35. matches the generation of the host CPUs in use. In a deployment with a
  36. mixture of host CPU models between machines, if live migration
  37. compatibility is required, use the newest CPU model that is compatible
  38. across all desired hosts.
  39. ``Cascadelake-Server``, ``Cascadelake-Server-noTSX``
  40. Intel Xeon Processor (Cascade Lake, 2019), with "stepping" levels 6
  41. or 7 only. (The Cascade Lake Xeon processor with *stepping 5 is
  42. vulnerable to MDS variants*.)
  43. ``Skylake-Server``, ``Skylake-Server-IBRS``, ``Skylake-Server-IBRS-noTSX``
  44. Intel Xeon Processor (Skylake, 2016)
  45. ``Skylake-Client``, ``Skylake-Client-IBRS``, ``Skylake-Client-noTSX-IBRS}``
  46. Intel Core Processor (Skylake, 2015)
  47. ``Broadwell``, ``Broadwell-IBRS``, ``Broadwell-noTSX``, ``Broadwell-noTSX-IBRS``
  48. Intel Core Processor (Broadwell, 2014)
  49. ``Haswell``, ``Haswell-IBRS``, ``Haswell-noTSX``, ``Haswell-noTSX-IBRS``
  50. Intel Core Processor (Haswell, 2013)
  51. ``IvyBridge``, ``IvyBridge-IBR``
  52. Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)
  53. ``SandyBridge``, ``SandyBridge-IBRS``
  54. Intel Xeon E312xx (Sandy Bridge, 2011)
  55. ``Westmere``, ``Westmere-IBRS``
  56. Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)
  57. ``Nehalem``, ``Nehalem-IBRS``
  58. Intel Core i7 9xx (Nehalem Class Core i7, 2008)
  59. ``Penryn``
  60. Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)
  61. ``Conroe``
  62. Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)
  63. Important CPU features for Intel x86 hosts
  64. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  65. The following are important CPU features that should be used on Intel
  66. x86 hosts, when available in the host CPU. Some of them require explicit
  67. configuration to enable, as they are not included by default in some, or
  68. all, of the named CPU models listed above. In general all of these
  69. features are included if using "Host passthrough" or "Host model".
  70. ``pcid``
  71. Recommended to mitigate the cost of the Meltdown (CVE-2017-5754) fix.
  72. Included by default in Haswell, Broadwell & Skylake Intel CPU models.
  73. Should be explicitly turned on for Westmere, SandyBridge, and
  74. IvyBridge Intel CPU models. Note that some desktop/mobile Westmere
  75. CPUs cannot support this feature.
  76. ``spec-ctrl``
  77. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  78. Included by default in Intel CPU models with -IBRS suffix.
  79. Must be explicitly turned on for Intel CPU models without -IBRS
  80. suffix.
  81. Requires the host CPU microcode to support this feature before it
  82. can be used for guest CPUs.
  83. ``stibp``
  84. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  85. operating systems.
  86. Must be explicitly turned on for all Intel CPU models.
  87. Requires the host CPU microcode to support this feature before it can
  88. be used for guest CPUs.
  89. ``ssbd``
  90. Required to enable the CVE-2018-3639 fix.
  91. Not included by default in any Intel CPU model.
  92. Must be explicitly turned on for all Intel CPU models.
  93. Requires the host CPU microcode to support this feature before it
  94. can be used for guest CPUs.
  95. ``pdpe1gb``
  96. Recommended to allow guest OS to use 1GB size pages.
  97. Not included by default in any Intel CPU model.
  98. Should be explicitly turned on for all Intel CPU models.
  99. Note that not all CPU hardware will support this feature.
  100. ``md-clear``
  101. Required to confirm the MDS (CVE-2018-12126, CVE-2018-12127,
  102. CVE-2018-12130, CVE-2019-11091) fixes.
  103. Not included by default in any Intel CPU model.
  104. Must be explicitly turned on for all Intel CPU models.
  105. Requires the host CPU microcode to support this feature before it
  106. can be used for guest CPUs.
  107. ``mds-no``
  108. Recommended to inform the guest OS that the host is *not* vulnerable
  109. to any of the MDS variants ([MFBDS] CVE-2018-12130, [MLPDS]
  110. CVE-2018-12127, [MSBDS] CVE-2018-12126).
  111. This is an MSR (Model-Specific Register) feature rather than a CPUID feature,
  112. so it will not appear in the Linux ``/proc/cpuinfo`` in the host or
  113. guest. Instead, the host kernel uses it to populate the MDS
  114. vulnerability file in ``sysfs``.
  115. So it should only be enabled for VMs if the host reports @code{Not
  116. affected} in the ``/sys/devices/system/cpu/vulnerabilities/mds`` file.
  117. ``taa-no``
  118. Recommended to inform that the guest that the host is ``not``
  119. vulnerable to CVE-2019-11135, TSX Asynchronous Abort (TAA).
  120. This too is an MSR feature, so it does not show up in the Linux
  121. ``/proc/cpuinfo`` in the host or guest.
  122. It should only be enabled for VMs if the host reports ``Not affected``
  123. in the ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort``
  124. file.
  125. ``tsx-ctrl``
  126. Recommended to inform the guest that it can disable the Intel TSX
  127. (Transactional Synchronization Extensions) feature; or, if the
  128. processor is vulnerable, use the Intel VERW instruction (a
  129. processor-level instruction that performs checks on memory access) as
  130. a mitigation for the TAA vulnerability. (For details, refer to
  131. Intel's `deep dive into MDS
  132. <https://software.intel.com/security-software-guidance/insights/deep-dive-intel-analysis-microarchitectural-data-sampling>`_.)
  133. Expose this to the guest OS if and only if: (a) the host has TSX
  134. enabled; *and* (b) the guest has ``rtm`` CPU flag enabled.
  135. By disabling TSX, KVM-based guests can avoid paying the price of
  136. mitigating TSX-based attacks.
  137. Note that ``tsx-ctrl`` too is an MSR feature, so it does not show
  138. up in the Linux ``/proc/cpuinfo`` in the host or guest.
  139. To validate that Intel TSX is indeed disabled for the guest, there are
  140. two ways: (a) check for the *absence* of ``rtm`` in the guest's
  141. ``/proc/cpuinfo``; or (b) the
  142. ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort`` file in
  143. the guest should report ``Mitigation: TSX disabled``.
  144. Preferred CPU models for AMD x86 hosts
  145. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  146. The following CPU models are preferred for use on Intel hosts.
  147. Administrators / applications are recommended to use the CPU model that
  148. matches the generation of the host CPUs in use. In a deployment with a
  149. mixture of host CPU models between machines, if live migration
  150. compatibility is required, use the newest CPU model that is compatible
  151. across all desired hosts.
  152. ``EPYC``, ``EPYC-IBPB``
  153. AMD EPYC Processor (2017)
  154. ``Opteron_G5``
  155. AMD Opteron 63xx class CPU (2012)
  156. ``Opteron_G4``
  157. AMD Opteron 62xx class CPU (2011)
  158. ``Opteron_G3``
  159. AMD Opteron 23xx (Gen 3 Class Opteron, 2009)
  160. ``Opteron_G2``
  161. AMD Opteron 22xx (Gen 2 Class Opteron, 2006)
  162. ``Opteron_G1``
  163. AMD Opteron 240 (Gen 1 Class Opteron, 2004)
  164. Important CPU features for AMD x86 hosts
  165. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  166. The following are important CPU features that should be used on AMD x86
  167. hosts, when available in the host CPU. Some of them require explicit
  168. configuration to enable, as they are not included by default in some, or
  169. all, of the named CPU models listed above. In general all of these
  170. features are included if using "Host passthrough" or "Host model".
  171. ``ibpb``
  172. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  173. Included by default in AMD CPU models with -IBPB suffix.
  174. Must be explicitly turned on for AMD CPU models without -IBPB suffix.
  175. Requires the host CPU microcode to support this feature before it
  176. can be used for guest CPUs.
  177. ``stibp``
  178. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  179. operating systems.
  180. Must be explicitly turned on for all AMD CPU models.
  181. Requires the host CPU microcode to support this feature before it
  182. can be used for guest CPUs.
  183. ``virt-ssbd``
  184. Required to enable the CVE-2018-3639 fix
  185. Not included by default in any AMD CPU model.
  186. Must be explicitly turned on for all AMD CPU models.
  187. This should be provided to guests, even if amd-ssbd is also provided,
  188. for maximum guest compatibility.
  189. Note for some QEMU / libvirt versions, this must be force enabled when
  190. when using "Host model", because this is a virtual feature that
  191. doesn't exist in the physical host CPUs.
  192. ``amd-ssbd``
  193. Required to enable the CVE-2018-3639 fix
  194. Not included by default in any AMD CPU model.
  195. Must be explicitly turned on for all AMD CPU models.
  196. This provides higher performance than ``virt-ssbd`` so should be
  197. exposed to guests whenever available in the host. ``virt-ssbd`` should
  198. none the less also be exposed for maximum guest compatibility as some
  199. kernels only know about ``virt-ssbd``.
  200. ``amd-no-ssb``
  201. Recommended to indicate the host is not vulnerable CVE-2018-3639
  202. Not included by default in any AMD CPU model.
  203. Future hardware generations of CPU will not be vulnerable to
  204. CVE-2018-3639, and thus the guest should be told not to enable
  205. its mitigations, by exposing amd-no-ssb. This is mutually
  206. exclusive with virt-ssbd and amd-ssbd.
  207. ``pdpe1gb``
  208. Recommended to allow guest OS to use 1GB size pages
  209. Not included by default in any AMD CPU model.
  210. Should be explicitly turned on for all AMD CPU models.
  211. Note that not all CPU hardware will support this feature.
  212. Default x86 CPU models
  213. ^^^^^^^^^^^^^^^^^^^^^^
  214. The default QEMU CPU models are designed such that they can run on all
  215. hosts. If an application does not wish to do perform any host
  216. compatibility checks before launching guests, the default is guaranteed
  217. to work.
  218. The default CPU models will, however, leave the guest OS vulnerable to
  219. various CPU hardware flaws, so their use is strongly discouraged.
  220. Applications should follow the earlier guidance to setup a better CPU
  221. configuration, with host passthrough recommended if live migration is
  222. not needed.
  223. ``qemu32``, ``qemu64``
  224. QEMU Virtual CPU version 2.5+ (32 & 64 bit variants)
  225. ``qemu64`` is used for x86_64 guests and ``qemu32`` is used for i686
  226. guests, when no ``-cpu`` argument is given to QEMU, or no ``<cpu>`` is
  227. provided in libvirt XML.
  228. Other non-recommended x86 CPUs
  229. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  230. The following CPUs models are compatible with most AMD and Intel x86
  231. hosts, but their usage is discouraged, as they expose a very limited
  232. featureset, which prevents guests having optimal performance.
  233. ``kvm32``, ``kvm64``
  234. Common KVM processor (32 & 64 bit variants).
  235. Legacy models just for historical compatibility with ancient QEMU
  236. versions.
  237. ``486``, ``athlon``, ``phenom``, ``coreduo``, ``core2duo``, ``n270``, ``pentium``, ``pentium2``, ``pentium3``
  238. Various very old x86 CPU models, mostly predating the introduction
  239. of hardware assisted virtualization, that should thus not be
  240. required for running virtual machines.
  241. Syntax for configuring CPU models
  242. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  243. The examples below illustrate the approach to configuring the various
  244. CPU models / features in QEMU and libvirt.
  245. QEMU command line
  246. ^^^^^^^^^^^^^^^^^
  247. Host passthrough:
  248. .. parsed-literal::
  249. |qemu_system| -cpu host
  250. Host passthrough with feature customization:
  251. .. parsed-literal::
  252. |qemu_system| -cpu host,-vmx,...
  253. Named CPU models:
  254. .. parsed-literal::
  255. |qemu_system| -cpu Westmere
  256. Named CPU models with feature customization:
  257. .. parsed-literal::
  258. |qemu_system| -cpu Westmere,+pcid,...
  259. Libvirt guest XML
  260. ^^^^^^^^^^^^^^^^^
  261. Host passthrough::
  262. <cpu mode='host-passthrough'/>
  263. Host passthrough with feature customization::
  264. <cpu mode='host-passthrough'>
  265. <feature name="vmx" policy="disable"/>
  266. ...
  267. </cpu>
  268. Host model::
  269. <cpu mode='host-model'/>
  270. Host model with feature customization::
  271. <cpu mode='host-model'>
  272. <feature name="vmx" policy="disable"/>
  273. ...
  274. </cpu>
  275. Named model::
  276. <cpu mode='custom'>
  277. <model name="Westmere"/>
  278. </cpu>
  279. Named model with feature customization::
  280. <cpu mode='custom'>
  281. <model name="Westmere"/>
  282. <feature name="pcid" policy="require"/>
  283. ...
  284. </cpu>