[PATCH] target-i386: do not force-expose WAITPKG if -overcommit cpu-pm=on

Paolo Bonzini posted 1 patch 3 years, 10 months ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200521084229.13235-1-pbonzini@redhat.com
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>
target/i386/kvm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] target-i386: do not force-expose WAITPKG if -overcommit cpu-pm=on
Posted by Paolo Bonzini 3 years, 10 months ago
By force-enabling the WAITPKG bit whenever -overcommit cpu-pm=on is used,
commit 67192a298f ("x86/cpu: Add support for UMONITOR/UMWAIT/TPAUSE",
2019-10-23) broke that option is the host processor does not have
WAITPKG or the host kernel is too old.  This is because TPAUSE, UMWAIT
and UMONITOR are not NOPs on older processors (though perhaps they should
have been!).

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/kvm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 6513584948..6554fdef3c 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -408,9 +408,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
             ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
         }
     } else if (function == 7 && index == 0 && reg == R_ECX) {
-        if (enable_cpu_pm) {
-            ret |= CPUID_7_0_ECX_WAITPKG;
-        } else {
+        if (!enable_cpu_pm) {
             ret &= ~CPUID_7_0_ECX_WAITPKG;
         }
     } else if (function == 7 && index == 0 && reg == R_EDX) {
-- 
2.25.4