cpuid.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==============
  3. KVM CPUID bits
  4. ==============
  5. :Author: Glauber Costa <[email protected]>
  6. A guest running on a kvm host, can check some of its features using
  7. cpuid. This is not always guaranteed to work, since userspace can
  8. mask-out some, or even all KVM-related cpuid features before launching
  9. a guest.
  10. KVM cpuid functions are:
  11. function: KVM_CPUID_SIGNATURE (0x40000000)
  12. returns::
  13. eax = 0x40000001
  14. ebx = 0x4b4d564b
  15. ecx = 0x564b4d56
  16. edx = 0x4d
  17. Note that this value in ebx, ecx and edx corresponds to the string "KVMKVMKVM".
  18. The value in eax corresponds to the maximum cpuid function present in this leaf,
  19. and will be updated if more functions are added in the future.
  20. Note also that old hosts set eax value to 0x0. This should
  21. be interpreted as if the value was 0x40000001.
  22. This function queries the presence of KVM cpuid leafs.
  23. function: define KVM_CPUID_FEATURES (0x40000001)
  24. returns::
  25. ebx, ecx
  26. eax = an OR'ed group of (1 << flag)
  27. where ``flag`` is defined as below:
  28. ================================== =========== ================================
  29. flag value meaning
  30. ================================== =========== ================================
  31. KVM_FEATURE_CLOCKSOURCE 0 kvmclock available at msrs
  32. 0x11 and 0x12
  33. KVM_FEATURE_NOP_IO_DELAY 1 not necessary to perform delays
  34. on PIO operations
  35. KVM_FEATURE_MMU_OP 2 deprecated
  36. KVM_FEATURE_CLOCKSOURCE2 3 kvmclock available at msrs
  37. 0x4b564d00 and 0x4b564d01
  38. KVM_FEATURE_ASYNC_PF 4 async pf can be enabled by
  39. writing to msr 0x4b564d02
  40. KVM_FEATURE_STEAL_TIME 5 steal time can be enabled by
  41. writing to msr 0x4b564d03
  42. KVM_FEATURE_PV_EOI 6 paravirtualized end of interrupt
  43. handler can be enabled by
  44. writing to msr 0x4b564d04
  45. KVM_FEATURE_PV_UNHALT 7 guest checks this feature bit
  46. before enabling paravirtualized
  47. spinlock support
  48. KVM_FEATURE_PV_TLB_FLUSH 9 guest checks this feature bit
  49. before enabling paravirtualized
  50. tlb flush
  51. KVM_FEATURE_ASYNC_PF_VMEXIT 10 paravirtualized async PF VM EXIT
  52. can be enabled by setting bit 2
  53. when writing to msr 0x4b564d02
  54. KVM_FEATURE_PV_SEND_IPI 11 guest checks this feature bit
  55. before enabling paravirtualized
  56. send IPIs
  57. KVM_FEATURE_POLL_CONTROL 12 host-side polling on HLT can
  58. be disabled by writing
  59. to msr 0x4b564d05.
  60. KVM_FEATURE_PV_SCHED_YIELD 13 guest checks this feature bit
  61. before using paravirtualized
  62. sched yield.
  63. KVM_FEATURE_ASYNC_PF_INT 14 guest checks this feature bit
  64. before using the second async
  65. pf control msr 0x4b564d06 and
  66. async pf acknowledgment msr
  67. 0x4b564d07.
  68. KVM_FEATURE_MSI_EXT_DEST_ID 15 guest checks this feature bit
  69. before using extended destination
  70. ID bits in MSI address bits 11-5.
  71. KVM_FEATURE_HC_MAP_GPA_RANGE 16 guest checks this feature bit before
  72. using the map gpa range hypercall
  73. to notify the page state change
  74. KVM_FEATURE_MIGRATION_CONTROL 17 guest checks this feature bit before
  75. using MSR_KVM_MIGRATION_CONTROL
  76. KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24 host will warn if no guest-side
  77. per-cpu warps are expected in
  78. kvmclock
  79. ================================== =========== ================================
  80. ::
  81. edx = an OR'ed group of (1 << flag)
  82. Where ``flag`` here is defined as below:
  83. ================== ============ =================================
  84. flag value meaning
  85. ================== ============ =================================
  86. KVM_HINTS_REALTIME 0 guest checks this feature bit to
  87. determine that vCPUs are never
  88. preempted for an unlimited time
  89. allowing optimizations
  90. ================== ============ =================================