KVM CPUID bits¶
| Author: | Glauber Costa <glommer@gmail.com> |
|---|
A guest running on a kvm host, can check some of its features usingcpuid. This is not always guaranteed to work, since userspace canmask-out some, or even all KVM-related cpuid features before launchinga guest.
KVM cpuid functions are:
function: KVM_CPUID_SIGNATURE (0x40000000)
returns:
eax = 0x40000001ebx = 0x4b4d564becx = 0x564b4d56edx = 0x4d
Note that this value in ebx, ecx and edx corresponds to the string “KVMKVMKVM”.The value in eax corresponds to the maximum cpuid function present in this leaf,and will be updated if more functions are added in the future.Note also that old hosts set eax value to 0x0. This shouldbe interpreted as if the value was 0x40000001.This function queries the presence of KVM cpuid leafs.
function: define KVM_CPUID_FEATURES (0x40000001)
returns:
ebx, ecxeax = an OR'ed group of (1 << flag)
whereflag is defined as below:
| flag | value | meaning |
|---|---|---|
| KVM_FEATURE_CLOCKSOURCE | 0 | kvmclock available at msrs0x11 and 0x12 |
| KVM_FEATURE_NOP_IO_DELAY | 1 | not necessary to perform delayson PIO operations |
| KVM_FEATURE_MMU_OP | 2 | deprecated |
| KVM_FEATURE_CLOCKSOURCE2 | 3 | kvmclock available at msrs0x4b564d00 and 0x4b564d01 |
| KVM_FEATURE_ASYNC_PF | 4 | async pf can be enabled bywriting to msr 0x4b564d02 |
| KVM_FEATURE_STEAL_TIME | 5 | steal time can be enabled bywriting to msr 0x4b564d03 |
| KVM_FEATURE_PV_EOI | 6 | paravirtualized end of interrupthandler can be enabled bywriting to msr 0x4b564d04 |
| KVM_FEATURE_PV_UNHAULT | 7 | guest checks this feature bitbefore enabling paravirtualizedspinlock support |
| KVM_FEATURE_PV_TLB_FLUSH | 9 | guest checks this feature bitbefore enabling paravirtualizedtlb flush |
| KVM_FEATURE_ASYNC_PF_VMEXIT | 10 | paravirtualized async PF VM EXITcan be enabled by setting bit 2when writing to msr 0x4b564d02 |
| KVM_FEATURE_PV_SEND_IPI | 11 | guest checks this feature bitbefore enabling paravirtualizedsebd IPIs |
| KVM_FEATURE_PV_POLL_CONTROL | 12 | host-side polling on HLT canbe disabled by writingto msr 0x4b564d05. |
| KVM_FEATURE_PV_SCHED_YIELD | 13 | guest checks this feature bitbefore using paravirtualizedsched yield. |
| KVM_FEATURE_ASYNC_PF_INT | 14 | guest checks this feature bitbefore using the second asyncpf control msr 0x4b564d06 andasync pf acknowledgment msr0x4b564d07. |
| KVM_FEATURE_CLOCSOURCE_STABLE_BIT | 24 | host will warn if no guest-sideper-cpu warps are expeced inkvmclock |
edx = an OR'ed group of (1 << flag)
Whereflag here is defined as below:
| flag | value | meaning |
|---|---|---|
| KVM_HINTS_REALTIME | 0 | guest checks this feature bit todetermine that vCPUs are neverpreempted for an unlimited timeallowing optimizations |