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