cpu-models-x86.rst.inc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. ABI compatibility levels for CPU models
  32. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  33. The x86_64 architecture has a number of `ABI compatibility levels`_
  34. defined. Traditionally most operating systems and toolchains would
  35. only target the original baseline ABI. It is expected that in
  36. future OS and toolchains are likely to target newer ABIs. The
  37. table that follows illustrates which ABI compatibility levels
  38. can be satisfied by the QEMU CPU models. Note that the table only
  39. lists the long term stable CPU model versions (eg Haswell-v4).
  40. In addition to what is listed, there are also many CPU model
  41. aliases which resolve to a different CPU model version,
  42. depending on the machine type is in use.
  43. .. _ABI compatibility levels: https://gitlab.com/x86-psABIs/x86-64-ABI/
  44. .. csv-table:: x86-64 ABI compatibility levels
  45. :file: cpu-models-x86-abi.csv
  46. :widths: 40,15,15,15,15
  47. :header-rows: 1
  48. Preferred CPU models for Intel x86 hosts
  49. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  50. The following CPU models are preferred for use on Intel hosts.
  51. Administrators / applications are recommended to use the CPU model that
  52. matches the generation of the host CPUs in use. In a deployment with a
  53. mixture of host CPU models between machines, if live migration
  54. compatibility is required, use the newest CPU model that is compatible
  55. across all desired hosts.
  56. ``ClearwaterForest``
  57. Intel Xeon Processor (ClearwaterForest, 2025)
  58. ``SierraForest``, ``SierraForest-v2``
  59. Intel Xeon Processor (SierraForest, 2024), SierraForest-v2 mitigates
  60. the GDS and RFDS vulnerabilities with stepping 3.
  61. ``GraniteRapids``, ``GraniteRapids-v2``
  62. Intel Xeon Processor (GraniteRapids, 2024)
  63. ``Cascadelake-Server``, ``Cascadelake-Server-noTSX``
  64. Intel Xeon Processor (Cascade Lake, 2019), with "stepping" levels 6
  65. or 7 only. (The Cascade Lake Xeon processor with *stepping 5 is
  66. vulnerable to MDS variants*.)
  67. ``Skylake-Server``, ``Skylake-Server-IBRS``, ``Skylake-Server-IBRS-noTSX``
  68. Intel Xeon Processor (Skylake, 2016)
  69. ``Skylake-Client``, ``Skylake-Client-IBRS``, ``Skylake-Client-noTSX-IBRS}``
  70. Intel Core Processor (Skylake, 2015)
  71. ``Broadwell``, ``Broadwell-IBRS``, ``Broadwell-noTSX``, ``Broadwell-noTSX-IBRS``
  72. Intel Core Processor (Broadwell, 2014)
  73. ``Haswell``, ``Haswell-IBRS``, ``Haswell-noTSX``, ``Haswell-noTSX-IBRS``
  74. Intel Core Processor (Haswell, 2013)
  75. ``IvyBridge``, ``IvyBridge-IBR``
  76. Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)
  77. ``SandyBridge``, ``SandyBridge-IBRS``
  78. Intel Xeon E312xx (Sandy Bridge, 2011)
  79. ``Westmere``, ``Westmere-IBRS``
  80. Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)
  81. ``Nehalem``, ``Nehalem-IBRS``
  82. Intel Core i7 9xx (Nehalem Class Core i7, 2008)
  83. ``Penryn``
  84. Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)
  85. ``Conroe``
  86. Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)
  87. Important CPU features for Intel x86 hosts
  88. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  89. The following are important CPU features that should be used on Intel
  90. x86 hosts, when available in the host CPU. Some of them require explicit
  91. configuration to enable, as they are not included by default in some, or
  92. all, of the named CPU models listed above. In general all of these
  93. features are included if using "Host passthrough" or "Host model".
  94. ``pcid``
  95. Recommended to mitigate the cost of the Meltdown (CVE-2017-5754) fix.
  96. Included by default in Haswell, Broadwell & Skylake Intel CPU models.
  97. Should be explicitly turned on for Westmere, SandyBridge, and
  98. IvyBridge Intel CPU models. Note that some desktop/mobile Westmere
  99. CPUs cannot support this feature.
  100. ``spec-ctrl``
  101. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  102. Included by default in Intel CPU models with -IBRS suffix.
  103. Must be explicitly turned on for Intel CPU models without -IBRS
  104. suffix.
  105. Requires the host CPU microcode to support this feature before it
  106. can be used for guest CPUs.
  107. ``stibp``
  108. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  109. operating systems.
  110. Must be explicitly turned on for all Intel CPU models.
  111. Requires the host CPU microcode to support this feature before it can
  112. be used for guest CPUs.
  113. ``ssbd``
  114. Required to enable the CVE-2018-3639 fix.
  115. Not included by default in any Intel CPU model.
  116. Must be explicitly turned on for all Intel CPU models.
  117. Requires the host CPU microcode to support this feature before it
  118. can be used for guest CPUs.
  119. ``pdpe1gb``
  120. Recommended to allow guest OS to use 1GB size pages.
  121. Not included by default in any Intel CPU model.
  122. Should be explicitly turned on for all Intel CPU models.
  123. Note that not all CPU hardware will support this feature.
  124. ``md-clear``
  125. Required to confirm the MDS (CVE-2018-12126, CVE-2018-12127,
  126. CVE-2018-12130, CVE-2019-11091) fixes.
  127. Not included by default in any Intel CPU model.
  128. Must be explicitly turned on for all Intel CPU models.
  129. Requires the host CPU microcode to support this feature before it
  130. can be used for guest CPUs.
  131. ``mds-no``
  132. Recommended to inform the guest OS that the host is *not* vulnerable
  133. to any of the MDS variants ([MFBDS] CVE-2018-12130, [MLPDS]
  134. CVE-2018-12127, [MSBDS] CVE-2018-12126).
  135. This is an MSR (Model-Specific Register) feature rather than a CPUID feature,
  136. therefore it will not appear in the Linux ``/proc/cpuinfo`` in the host or
  137. guest. Instead, the host kernel uses it to populate the MDS
  138. vulnerability file in ``sysfs``.
  139. So it should only be enabled for VMs if the host reports @code{Not
  140. affected} in the ``/sys/devices/system/cpu/vulnerabilities/mds`` file.
  141. ``taa-no``
  142. Recommended to inform the guest that the host is ``not``
  143. vulnerable to CVE-2019-11135, TSX Asynchronous Abort (TAA).
  144. This is also an MSR feature, therefore it does not show up in the Linux
  145. ``/proc/cpuinfo`` in the host or guest.
  146. It should only be enabled for VMs if the host reports ``Not affected``
  147. in the ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort``
  148. file.
  149. ``tsx-ctrl``
  150. Recommended to inform the guest that it can disable the Intel TSX
  151. (Transactional Synchronization Extensions) feature; or, if the
  152. processor is vulnerable, use the Intel VERW instruction (a
  153. processor-level instruction that performs checks on memory access) as
  154. a mitigation for the TAA vulnerability. (For details, refer to
  155. Intel's `deep dive into MDS
  156. <https://software.intel.com/security-software-guidance/insights/deep-dive-intel-analysis-microarchitectural-data-sampling>`_.)
  157. Expose this to the guest OS if and only if: (a) the host has TSX
  158. enabled; *and* (b) the guest has ``rtm`` CPU flag enabled.
  159. By disabling TSX, KVM-based guests can avoid paying the price of
  160. mitigating TSX-based attacks.
  161. Note that ``tsx-ctrl`` is also an MSR feature, therefore it does not show
  162. up in the Linux ``/proc/cpuinfo`` in the host or guest.
  163. To validate that Intel TSX is indeed disabled for the guest, there are
  164. two ways: (a) check for the *absence* of ``rtm`` in the guest's
  165. ``/proc/cpuinfo``; or (b) the
  166. ``/sys/devices/system/cpu/vulnerabilities/tsx_async_abort`` file in
  167. the guest should report ``Mitigation: TSX disabled``.
  168. ``bhi-no``
  169. Recommended to inform the guest that the host is ``not``
  170. vulnerable to CVE-2022-0001, Branch History Injection (BHI).
  171. This is also an MSR feature, therefore it does not show up in the Linux
  172. ``/proc/cpuinfo`` in the host or guest.
  173. It should only be enabled for VMs if the host reports
  174. ``BHI: Not affected`` in the
  175. ``/sys/devices/system/cpu/vulnerabilities/spectre_v2`` file.
  176. ``gds-no``
  177. Recommended to inform the guest that the host is ``not``
  178. vulnerable to CVE-2022-40982, Gather Data Sampling (GDS).
  179. This is also an MSR feature, therefore it does not show up in the Linux
  180. ``/proc/cpuinfo`` in the host or guest.
  181. It should only be enabled for VMs if the host reports ``Not affected``
  182. in the ``/sys/devices/system/cpu/vulnerabilities/gather_data_sampling``
  183. file.
  184. ``rfds-no``
  185. Recommended to inform the guest that the host is ``not``
  186. vulnerable to CVE-2023-28746, Register File Data Sampling (RFDS).
  187. This is also an MSR feature, therefore it does not show up in the Linux
  188. ``/proc/cpuinfo`` in the host or guest.
  189. It should only be enabled for VMs if the host reports ``Not affected``
  190. in the ``/sys/devices/system/cpu/vulnerabilities/reg_file_data_sampling``
  191. file.
  192. Preferred CPU models for AMD x86 hosts
  193. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  194. The following CPU models are preferred for use on AMD hosts.
  195. Administrators / applications are recommended to use the CPU model that
  196. matches the generation of the host CPUs in use. In a deployment with a
  197. mixture of host CPU models between machines, if live migration
  198. compatibility is required, use the newest CPU model that is compatible
  199. across all desired hosts.
  200. ``EPYC``, ``EPYC-IBPB``
  201. AMD EPYC Processor (2017)
  202. ``Opteron_G5``
  203. AMD Opteron 63xx class CPU (2012)
  204. ``Opteron_G4``
  205. AMD Opteron 62xx class CPU (2011)
  206. ``Opteron_G3``
  207. AMD Opteron 23xx (Gen 3 Class Opteron, 2009)
  208. ``Opteron_G2``
  209. AMD Opteron 22xx (Gen 2 Class Opteron, 2006)
  210. ``Opteron_G1``
  211. AMD Opteron 240 (Gen 1 Class Opteron, 2004)
  212. Important CPU features for AMD x86 hosts
  213. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  214. The following are important CPU features that should be used on AMD x86
  215. hosts, when available in the host CPU. Some of them require explicit
  216. configuration to enable, as they are not included by default in some, or
  217. all, of the named CPU models listed above. In general all of these
  218. features are included if using "Host passthrough" or "Host model".
  219. ``ibpb``
  220. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  221. Included by default in AMD CPU models with -IBPB suffix.
  222. Must be explicitly turned on for AMD CPU models without -IBPB suffix.
  223. Requires the host CPU microcode to support this feature before it
  224. can be used for guest CPUs.
  225. ``stibp``
  226. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  227. operating systems.
  228. Must be explicitly turned on for all AMD CPU models.
  229. Requires the host CPU microcode to support this feature before it
  230. can be used for guest CPUs.
  231. ``virt-ssbd``
  232. Required to enable the CVE-2018-3639 fix
  233. Not included by default in any AMD CPU model.
  234. Must be explicitly turned on for all AMD CPU models.
  235. This should be provided to guests, even if amd-ssbd is also provided,
  236. for maximum guest compatibility.
  237. Note for some QEMU / libvirt versions, this must be force enabled when
  238. when using "Host model", because this is a virtual feature that
  239. doesn't exist in the physical host CPUs.
  240. ``amd-ssbd``
  241. Required to enable the CVE-2018-3639 fix
  242. Not included by default in any AMD CPU model.
  243. Must be explicitly turned on for all AMD CPU models.
  244. This provides higher performance than ``virt-ssbd`` so should be
  245. exposed to guests whenever available in the host. ``virt-ssbd`` should
  246. none the less also be exposed for maximum guest compatibility as some
  247. kernels only know about ``virt-ssbd``.
  248. ``amd-no-ssb``
  249. Recommended to indicate the host is not vulnerable CVE-2018-3639
  250. Not included by default in any AMD CPU model.
  251. Future hardware generations of CPU will not be vulnerable to
  252. CVE-2018-3639, and thus the guest should be told not to enable
  253. its mitigations, by exposing amd-no-ssb. This is mutually
  254. exclusive with virt-ssbd and amd-ssbd.
  255. ``pdpe1gb``
  256. Recommended to allow guest OS to use 1GB size pages
  257. Not included by default in any AMD CPU model.
  258. Should be explicitly turned on for all AMD CPU models.
  259. Note that not all CPU hardware will support this feature.
  260. Default x86 CPU models
  261. ^^^^^^^^^^^^^^^^^^^^^^
  262. The default QEMU CPU models are designed such that they can run on all
  263. hosts. If an application does not wish to do perform any host
  264. compatibility checks before launching guests, the default is guaranteed
  265. to work.
  266. The default CPU models will, however, leave the guest OS vulnerable to
  267. various CPU hardware flaws, so their use is strongly discouraged.
  268. Applications should follow the earlier guidance to setup a better CPU
  269. configuration, with host passthrough recommended if live migration is
  270. not needed.
  271. ``qemu32``, ``qemu64``
  272. QEMU Virtual CPU version 2.5+ (32 & 64 bit variants)
  273. ``qemu64`` is used for x86_64 guests and ``qemu32`` is used for i686
  274. guests, when no ``-cpu`` argument is given to QEMU, or no ``<cpu>`` is
  275. provided in libvirt XML.
  276. Other non-recommended x86 CPUs
  277. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  278. The following CPUs models are compatible with most AMD and Intel x86
  279. hosts, but their usage is discouraged, as they expose a very limited
  280. featureset, which prevents guests having optimal performance.
  281. ``kvm32``, ``kvm64``
  282. Common KVM processor (32 & 64 bit variants).
  283. Legacy models just for historical compatibility with ancient QEMU
  284. versions.
  285. ``486``, ``athlon``, ``phenom``, ``coreduo``, ``core2duo``, ``n270``, ``pentium``, ``pentium2``, ``pentium3``
  286. Various very old x86 CPU models, mostly predating the introduction
  287. of hardware assisted virtualization, that should thus not be
  288. required for running virtual machines.
  289. Syntax for configuring CPU models
  290. =================================
  291. The examples below illustrate the approach to configuring the various
  292. CPU models / features in QEMU and libvirt.
  293. QEMU command line
  294. ^^^^^^^^^^^^^^^^^
  295. Host passthrough:
  296. .. parsed-literal::
  297. |qemu_system| -cpu host
  298. Host passthrough with feature customization:
  299. .. parsed-literal::
  300. |qemu_system| -cpu host,vmx=off,...
  301. Named CPU models:
  302. .. parsed-literal::
  303. |qemu_system| -cpu Westmere
  304. Named CPU models with feature customization:
  305. .. parsed-literal::
  306. |qemu_system| -cpu Westmere,pcid=on,...
  307. Libvirt guest XML
  308. ^^^^^^^^^^^^^^^^^
  309. Host passthrough::
  310. <cpu mode='host-passthrough'/>
  311. Host passthrough with feature customization::
  312. <cpu mode='host-passthrough'>
  313. <feature name="vmx" policy="disable"/>
  314. ...
  315. </cpu>
  316. Host model::
  317. <cpu mode='host-model'/>
  318. Host model with feature customization::
  319. <cpu mode='host-model'>
  320. <feature name="vmx" policy="disable"/>
  321. ...
  322. </cpu>
  323. Named model::
  324. <cpu mode='custom'>
  325. <model name="Westmere"/>
  326. </cpu>
  327. Named model with feature customization::
  328. <cpu mode='custom'>
  329. <model name="Westmere"/>
  330. <feature name="pcid" policy="require"/>
  331. ...
  332. </cpu>