cpu-models-x86.rst.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. ``Skylake-Server``, ``Skylake-Server-IBRS``
  40. Intel Xeon Processor (Skylake, 2016)
  41. ``Skylake-Client``, ``Skylake-Client-IBRS``
  42. Intel Core Processor (Skylake, 2015)
  43. ``Broadwell``, ``Broadwell-IBRS``, ``Broadwell-noTSX``, ``Broadwell-noTSX-IBRS``
  44. Intel Core Processor (Broadwell, 2014)
  45. ``Haswell``, ``Haswell-IBRS``, ``Haswell-noTSX``, ``Haswell-noTSX-IBRS``
  46. Intel Core Processor (Haswell, 2013)
  47. ``IvyBridge``, ``IvyBridge-IBR``
  48. Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)
  49. ``SandyBridge``, ``SandyBridge-IBRS``
  50. Intel Xeon E312xx (Sandy Bridge, 2011)
  51. ``Westmere``, ``Westmere-IBRS``
  52. Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)
  53. ``Nehalem``, ``Nehalem-IBRS``
  54. Intel Core i7 9xx (Nehalem Class Core i7, 2008)
  55. ``Penryn``
  56. Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)
  57. ``Conroe``
  58. Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)
  59. Important CPU features for Intel x86 hosts
  60. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  61. The following are important CPU features that should be used on Intel
  62. x86 hosts, when available in the host CPU. Some of them require explicit
  63. configuration to enable, as they are not included by default in some, or
  64. all, of the named CPU models listed above. In general all of these
  65. features are included if using "Host passthrough" or "Host model".
  66. ``pcid``
  67. Recommended to mitigate the cost of the Meltdown (CVE-2017-5754) fix.
  68. Included by default in Haswell, Broadwell & Skylake Intel CPU models.
  69. Should be explicitly turned on for Westmere, SandyBridge, and
  70. IvyBridge Intel CPU models. Note that some desktop/mobile Westmere
  71. CPUs cannot support this feature.
  72. ``spec-ctrl``
  73. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  74. Included by default in Intel CPU models with -IBRS suffix.
  75. Must be explicitly turned on for Intel CPU models without -IBRS
  76. suffix.
  77. Requires the host CPU microcode to support this feature before it
  78. can be used for guest CPUs.
  79. ``stibp``
  80. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  81. operating systems.
  82. Must be explicitly turned on for all Intel CPU models.
  83. Requires the host CPU microcode to support this feature before it can
  84. be used for guest CPUs.
  85. ``ssbd``
  86. Required to enable the CVE-2018-3639 fix.
  87. Not included by default in any Intel CPU model.
  88. Must be explicitly turned on for all Intel CPU models.
  89. Requires the host CPU microcode to support this feature before it
  90. can be used for guest CPUs.
  91. ``pdpe1gb``
  92. Recommended to allow guest OS to use 1GB size pages.
  93. Not included by default in any Intel CPU model.
  94. Should be explicitly turned on for all Intel CPU models.
  95. Note that not all CPU hardware will support this feature.
  96. ``md-clear``
  97. Required to confirm the MDS (CVE-2018-12126, CVE-2018-12127,
  98. CVE-2018-12130, CVE-2019-11091) fixes.
  99. Not included by default in any Intel CPU model.
  100. Must be explicitly turned on for all Intel CPU models.
  101. Requires the host CPU microcode to support this feature before it
  102. can be used for guest CPUs.
  103. Preferred CPU models for AMD x86 hosts
  104. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  105. The following CPU models are preferred for use on Intel hosts.
  106. Administrators / applications are recommended to use the CPU model that
  107. matches the generation of the host CPUs in use. In a deployment with a
  108. mixture of host CPU models between machines, if live migration
  109. compatibility is required, use the newest CPU model that is compatible
  110. across all desired hosts.
  111. ``EPYC``, ``EPYC-IBPB``
  112. AMD EPYC Processor (2017)
  113. ``Opteron_G5``
  114. AMD Opteron 63xx class CPU (2012)
  115. ``Opteron_G4``
  116. AMD Opteron 62xx class CPU (2011)
  117. ``Opteron_G3``
  118. AMD Opteron 23xx (Gen 3 Class Opteron, 2009)
  119. ``Opteron_G2``
  120. AMD Opteron 22xx (Gen 2 Class Opteron, 2006)
  121. ``Opteron_G1``
  122. AMD Opteron 240 (Gen 1 Class Opteron, 2004)
  123. Important CPU features for AMD x86 hosts
  124. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  125. The following are important CPU features that should be used on AMD x86
  126. hosts, when available in the host CPU. Some of them require explicit
  127. configuration to enable, as they are not included by default in some, or
  128. all, of the named CPU models listed above. In general all of these
  129. features are included if using "Host passthrough" or "Host model".
  130. ``ibpb``
  131. Required to enable the Spectre v2 (CVE-2017-5715) fix.
  132. Included by default in AMD CPU models with -IBPB suffix.
  133. Must be explicitly turned on for AMD CPU models without -IBPB suffix.
  134. Requires the host CPU microcode to support this feature before it
  135. can be used for guest CPUs.
  136. ``stibp``
  137. Required to enable stronger Spectre v2 (CVE-2017-5715) fixes in some
  138. operating systems.
  139. Must be explicitly turned on for all AMD CPU models.
  140. Requires the host CPU microcode to support this feature before it
  141. can be used for guest CPUs.
  142. ``virt-ssbd``
  143. Required to enable the CVE-2018-3639 fix
  144. Not included by default in any AMD CPU model.
  145. Must be explicitly turned on for all AMD CPU models.
  146. This should be provided to guests, even if amd-ssbd is also provided,
  147. for maximum guest compatibility.
  148. Note for some QEMU / libvirt versions, this must be force enabled when
  149. when using "Host model", because this is a virtual feature that
  150. doesn't exist in the physical host CPUs.
  151. ``amd-ssbd``
  152. Required to enable the CVE-2018-3639 fix
  153. Not included by default in any AMD CPU model.
  154. Must be explicitly turned on for all AMD CPU models.
  155. This provides higher performance than ``virt-ssbd`` so should be
  156. exposed to guests whenever available in the host. ``virt-ssbd`` should
  157. none the less also be exposed for maximum guest compatibility as some
  158. kernels only know about ``virt-ssbd``.
  159. ``amd-no-ssb``
  160. Recommended to indicate the host is not vulnerable CVE-2018-3639
  161. Not included by default in any AMD CPU model.
  162. Future hardware generations of CPU will not be vulnerable to
  163. CVE-2018-3639, and thus the guest should be told not to enable
  164. its mitigations, by exposing amd-no-ssb. This is mutually
  165. exclusive with virt-ssbd and amd-ssbd.
  166. ``pdpe1gb``
  167. Recommended to allow guest OS to use 1GB size pages
  168. Not included by default in any AMD CPU model.
  169. Should be explicitly turned on for all AMD CPU models.
  170. Note that not all CPU hardware will support this feature.
  171. Default x86 CPU models
  172. ^^^^^^^^^^^^^^^^^^^^^^
  173. The default QEMU CPU models are designed such that they can run on all
  174. hosts. If an application does not wish to do perform any host
  175. compatibility checks before launching guests, the default is guaranteed
  176. to work.
  177. The default CPU models will, however, leave the guest OS vulnerable to
  178. various CPU hardware flaws, so their use is strongly discouraged.
  179. Applications should follow the earlier guidance to setup a better CPU
  180. configuration, with host passthrough recommended if live migration is
  181. not needed.
  182. ``qemu32``, ``qemu64``
  183. QEMU Virtual CPU version 2.5+ (32 & 64 bit variants)
  184. ``qemu64`` is used for x86_64 guests and ``qemu32`` is used for i686
  185. guests, when no ``-cpu`` argument is given to QEMU, or no ``<cpu>`` is
  186. provided in libvirt XML.
  187. Other non-recommended x86 CPUs
  188. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  189. The following CPUs models are compatible with most AMD and Intel x86
  190. hosts, but their usage is discouraged, as they expose a very limited
  191. featureset, which prevents guests having optimal performance.
  192. ``kvm32``, ``kvm64``
  193. Common KVM processor (32 & 64 bit variants).
  194. Legacy models just for historical compatibility with ancient QEMU
  195. versions.
  196. ``486``, ``athlon``, ``phenom``, ``coreduo``, ``core2duo``, ``n270``, ``pentium``, ``pentium2``, ``pentium3``
  197. Various very old x86 CPU models, mostly predating the introduction
  198. of hardware assisted virtualization, that should thus not be
  199. required for running virtual machines.
  200. Syntax for configuring CPU models
  201. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202. The examples below illustrate the approach to configuring the various
  203. CPU models / features in QEMU and libvirt.
  204. QEMU command line
  205. ^^^^^^^^^^^^^^^^^
  206. Host passthrough:
  207. .. parsed-literal::
  208. |qemu_system| -cpu host
  209. Host passthrough with feature customization:
  210. .. parsed-literal::
  211. |qemu_system| -cpu host,-vmx,...
  212. Named CPU models:
  213. .. parsed-literal::
  214. |qemu_system| -cpu Westmere
  215. Named CPU models with feature customization:
  216. .. parsed-literal::
  217. |qemu_system| -cpu Westmere,+pcid,...
  218. Libvirt guest XML
  219. ^^^^^^^^^^^^^^^^^
  220. Host passthrough::
  221. <cpu mode='host-passthrough'/>
  222. Host passthrough with feature customization::
  223. <cpu mode='host-passthrough'>
  224. <feature name="vmx" policy="disable"/>
  225. ...
  226. </cpu>
  227. Host model::
  228. <cpu mode='host-model'/>
  229. Host model with feature customization::
  230. <cpu mode='host-model'>
  231. <feature name="vmx" policy="disable"/>
  232. ...
  233. </cpu>
  234. Named model::
  235. <cpu mode='custom'>
  236. <model name="Westmere"/>
  237. </cpu>
  238. Named model with feature customization::
  239. <cpu mode='custom'>
  240. <model name="Westmere"/>
  241. <feature name="pcid" policy="require"/>
  242. ...
  243. </cpu>