summaryrefslogtreecommitdiff
path: root/target/i386/kvm.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2018-06-22 22:22:05 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2018-06-29 13:02:47 +0200
commit2266d44311321a833d569cd4deb46cca6021d0e7 (patch)
tree954cac47b13360c4ebafbc3f7cb2c4c2c31f9672 /target/i386/kvm.c
parent6f131f13e68d648a8e4f083c667ab1acd88ce4cd (diff)
downloadqemu-2266d44311321a833d569cd4deb46cca6021d0e7.zip
i386/cpu: make -cpu host support monitor/mwait
When guest CPU PM is enabled, and with -cpu host, expose the host CPU MWAIT leaf in the CPUID so guest can make good PM decisions. Note: the result is 100% CPU utilization reported by host as host no longer knows that the CPU is halted. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20180622192148.178309-3-mst@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/kvm.c')
-rw-r--r--target/i386/kvm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index dc991f6aca..c5f72d645b 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -366,6 +366,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
if (!kvm_irqchip_in_kernel()) {
ret &= ~CPUID_EXT_X2APIC;
}
+
+ if (enable_cpu_pm) {
+ int disable_exits = kvm_check_extension(s,
+ KVM_CAP_X86_DISABLE_EXITS);
+
+ if (disable_exits & KVM_X86_DISABLE_EXITS_MWAIT) {
+ ret |= CPUID_EXT_MONITOR;
+ }
+ }
} else if (function == 6 && reg == R_EAX) {
ret |= CPUID_6_EAX_ARAT; /* safe to allow because of emulated APIC */
} else if (function == 7 && index == 0 && reg == R_EBX) {