All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-stable@nongnu.org
Subject: [PATCH 23/77] KVM: x86: believe what KVM says about WAITPKG
Date: Thu,  3 Sep 2020 15:58:41 -0500	[thread overview]
Message-ID: <20200903205935.27832-24-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <20200903205935.27832-1-mdroth@linux.vnet.ibm.com>

From: Paolo Bonzini <pbonzini@redhat.com>

Currently, QEMU is overriding KVM_GET_SUPPORTED_CPUID's answer for
the WAITPKG bit depending on the "-overcommit cpu-pm" setting.  This is a
bad idea because it does not even check if the host supports it, but it
can be done in x86_cpu_realizefn just like we do for the MONITOR bit.

This patch moves it there, while making it conditional on host
support for the related UMWAIT MSR.

Cc: qemu-stable@nongnu.org
Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit e1e43813e7908b063938a3d01f172f88f6190c80)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 target/i386/cpu.c      |  3 +++
 target/i386/kvm.c      | 11 +++++------
 target/i386/kvm_i386.h |  1 +
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 90ffc5f3b1..471db0724f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6491,6 +6491,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
             host_cpuid(5, 0, &cpu->mwait.eax, &cpu->mwait.ebx,
                        &cpu->mwait.ecx, &cpu->mwait.edx);
             env->features[FEAT_1_ECX] |= CPUID_EXT_MONITOR;
+            if (kvm_enabled() && kvm_has_waitpkg()) {
+                env->features[FEAT_7_0_ECX] |= CPUID_7_0_ECX_WAITPKG;
+            }
         }
         if (kvm_enabled() && cpu->ucode_rev == 0) {
             cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state,
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 4901c6dd74..f9c873bcad 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -407,12 +407,6 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         if (host_tsx_blacklisted()) {
             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 {
-            ret &= ~CPUID_7_0_ECX_WAITPKG;
-        }
     } else if (function == 7 && index == 0 && reg == R_EDX) {
         /*
          * Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
@@ -4678,3 +4672,8 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
 {
     abort();
 }
+
+bool kvm_has_waitpkg(void)
+{
+    return has_msr_umwait;
+}
diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h
index 00bde7acaf..064b8798a2 100644
--- a/target/i386/kvm_i386.h
+++ b/target/i386/kvm_i386.h
@@ -44,6 +44,7 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_enable_x2apic(void);
 bool kvm_has_x2apic_api(void);
+bool kvm_has_waitpkg(void);
 
 bool kvm_hv_vpindex_settable(void);
 
-- 
2.17.1



  parent reply	other threads:[~2020-09-03 21:07 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 20:58 [PATCH 00/77] Patch Round-up for stable 5.0.1, freeze on 2020-09-10 Michael Roth
2020-09-03 20:58 ` [PATCH 01/77] hostmem: don't use mbind() if host-nodes is empty Michael Roth
2020-09-03 20:58 ` [PATCH 02/77] target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_* Michael Roth
2020-09-03 20:58 ` [PATCH 03/77] qemu-nbd: Close inherited stderr Michael Roth
2020-09-03 20:58 ` [PATCH 04/77] 9p: Lock directory streams with a CoMutex Michael Roth
2020-09-03 20:58 ` [PATCH 05/77] net: Do not include a newline in the id of -nic devices Michael Roth
2020-09-03 20:58 ` [PATCH 06/77] nbd/server: Avoid long error message assertions CVE-2020-10761 Michael Roth
2020-09-03 20:58 ` [PATCH 07/77] virtio-balloon: fix free page hinting without an iothread Michael Roth
2020-09-03 20:58 ` [PATCH 08/77] virtio-balloon: fix free page hinting check on unrealize Michael Roth
2020-09-03 20:58 ` [PATCH 09/77] virtio-balloon: unref the iothread when unrealizing Michael Roth
2020-09-03 20:58 ` [PATCH 10/77] block: Call attention to truncation of long NBD exports Michael Roth
2020-09-03 20:58 ` [PATCH 11/77] 9pfs: local: ignore O_NOATIME if we don't have permissions Michael Roth
2020-09-03 20:58 ` [PATCH 12/77] 9pfs: include linux/limits.h for XATTR_SIZE_MAX Michael Roth
2020-09-03 20:58 ` [PATCH 13/77] xen-9pfs: Fix log messages of reply errors Michael Roth
2020-09-03 20:58 ` [PATCH 14/77] Revert "9p: init_in_iov_from_pdu can truncate the size" Michael Roth
2020-09-03 20:58 ` [PATCH 15/77] xen/9pfs: yield when there isn't enough room on the ring Michael Roth
2020-09-04 10:59   ` Christian Schoenebeck
2020-09-03 20:58 ` [PATCH 16/77] ati-vga: check mm_index before recursive call (CVE-2020-13800) Michael Roth
2020-09-03 20:58 ` [PATCH 17/77] es1370: check total frame count against current frame Michael Roth
2020-09-03 20:58 ` [PATCH 18/77] Fix tulip breakage Michael Roth
2020-09-03 20:58 ` [PATCH 19/77] iotests/283: Use consistent size for source and target Michael Roth
2020-09-03 20:58 ` [PATCH 20/77] virtiofsd: add --rlimit-nofile=NUM option Michael Roth
2020-09-03 20:58 ` [PATCH 21/77] virtiofsd: stay below fs.file-max sysctl value (CVE-2020-10717) Michael Roth
2020-09-03 20:58 ` [PATCH 22/77] net: use peer when purging queue in qemu_flush_or_purge_queue_packets() Michael Roth
2020-09-03 20:58 ` Michael Roth [this message]
2020-09-03 20:58 ` [PATCH 24/77] aio-posix: don't duplicate fd handler deletion in fdmon_io_uring_destroy() Michael Roth
2020-09-03 20:58 ` [PATCH 25/77] aio-posix: disable fdmon-io_uring when GSource is used Michael Roth
2020-09-03 20:58 ` [PATCH 26/77] linux-user/strace.list: fix epoll_create{, 1} -strace output Michael Roth
2020-09-03 20:58 ` [PATCH 27/77] libqos: usb-hcd-ehci: use 32-bit write for config register Michael Roth
2020-09-03 20:58 ` [PATCH 28/77] libqos: pci-pc: use 32-bit write for EJ register Michael Roth
2020-09-03 20:58 ` [PATCH 29/77] memory: Revert "memory: accept mismatching sizes in memory_region_access_valid" Michael Roth
2020-09-03 20:58 ` [PATCH 30/77] hw/riscv: Allow 64 bit access to SiFive CLINT Michael Roth
2020-09-03 20:58 ` [PATCH 31/77] xhci: fix valid.max_access_size to access address registers Michael Roth
2020-09-03 20:58 ` [PATCH 32/77] acpi: accept byte and word access to core ACPI registers Michael Roth
2020-09-03 20:58 ` [PATCH 33/77] hw/display/artist: Unbreak size mismatch memory accesses Michael Roth
2020-09-03 20:58 ` [PATCH 34/77] hw/net/e1000e: Do not abort() on invalid PSRCTL register value Michael Roth
2020-09-03 20:58 ` [PATCH 35/77] virtiofsd: Whitelist fchmod Michael Roth
2020-09-03 20:58 ` [PATCH 36/77] hw/audio/gus: Fix registers 32-bit access Michael Roth
2020-09-03 20:58 ` [PATCH 37/77] net/virtio: Fix failover_replug_primary() return value regression Michael Roth
2020-09-03 20:58 ` [PATCH 38/77] error: Use error_reportf_err() where appropriate Michael Roth
2020-09-03 20:58 ` [PATCH 39/77] usb/dev-mtp: Fix Error double free after inotify failure Michael Roth
2020-09-03 20:58 ` [PATCH 40/77] nbd: Avoid off-by-one in long export name truncation Michael Roth
2020-09-03 20:58 ` [PATCH 41/77] chardev/tcp: Fix error message double free error Michael Roth
2020-09-03 20:59 ` [PATCH 42/77] qga: fix assert regression on guest-shutdown Michael Roth
2020-09-03 20:59 ` [PATCH 43/77] util: Introduce qemu_get_host_name() Michael Roth
2020-09-03 20:59 ` [PATCH 44/77] qga: Use qemu_get_host_name() instead of g_get_host_name() Michael Roth
2020-09-03 20:59 ` [PATCH 45/77] docs/orangepi: Add instructions for resizing SD image to power of two Michael Roth
2020-09-03 20:59 ` [PATCH 46/77] tests/acceptance/boot_linux: Tag tests using a SD card with 'device:sd' Michael Roth
2020-09-03 20:59 ` [PATCH 47/77] tests/acceptance: allow console interaction with specific VMs Michael Roth
2020-09-03 20:59 ` [PATCH 48/77] tests/acceptance: refactor boot_linux to allow code reuse Michael Roth
2020-09-03 20:59 ` [PATCH 49/77] tests/acceptance: refactor boot_linux_console test " Michael Roth
2020-09-03 20:59 ` [PATCH 50/77] tests/acceptance/boot_linux: Expand SD card image to power of 2 Michael Roth
2020-09-03 20:59 ` [PATCH 51/77] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Michael Roth
2020-09-03 20:59 ` [PATCH 52/77] hw/sd/sdcard: Simplify realize() a bit Michael Roth
2020-09-03 20:59 ` [PATCH 53/77] hw/sd/sdcard: Do not allow invalid SD card sizes Michael Roth
2020-09-03 20:59 ` [PATCH 54/77] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Michael Roth
2020-09-03 20:59 ` [PATCH 55/77] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Michael Roth
2020-09-03 20:59 ` [PATCH 56/77] target/hppa: Free some temps in do_sub Michael Roth
2020-09-03 20:59 ` [PATCH 57/77] tpm: tpm_spapr: Exit on TPM backend failures Michael Roth
2020-09-03 20:59 ` [PATCH 58/77] tests: tpm: Skip over pcrUpdateCounter byte in result comparison Michael Roth
2020-09-03 20:59 ` [PATCH 59/77] qdev: Fix device_add DRIVER,help to print to monitor Michael Roth
2020-09-03 20:59 ` [PATCH 60/77] virtio-balloon: Prevent guest from starting a report when we didn't request one Michael Roth
2020-09-03 20:59 ` [PATCH 61/77] virtio-balloon: Add locking to prevent possible race when starting hinting Michael Roth
2020-09-03 20:59 ` [PATCH 62/77] virtio-balloon: always indicate S_DONE when migration fails Michael Roth
2020-09-03 20:59 ` [PATCH 63/77] linux-headers: update against Linux 5.7-rc3 Michael Roth
2020-09-03 20:59 ` [PATCH 64/77] virtio-balloon: Replace free page hinting references to 'report' with 'hint' Michael Roth
2020-09-03 20:59 ` [PATCH 65/77] virtio: list legacy-capable devices Michael Roth
2020-09-03 20:59 ` [PATCH 66/77] virtio: verify that legacy support is not accidentally on Michael Roth
2020-09-07 12:18   ` Cornelia Huck
2020-09-03 20:59 ` [PATCH 67/77] intel_iommu: Use correct shift for 256 bits qi descriptor Michael Roth
2020-09-03 20:59 ` [PATCH 68/77] virtio-pci: Changed vdev to proxy for VirtIO PCI BAR callbacks Michael Roth
2020-09-03 20:59 ` [PATCH 69/77] libvhost-user: Report descriptor index on panic Michael Roth
2020-09-03 20:59 ` [PATCH 70/77] Update OpenBIOS images to 7f28286f built from submodule Michael Roth
2020-09-03 20:59 ` [PATCH 71/77] migration/block-dirty-bitmap: fix dirty_bitmap_mig_before_vm_start Michael Roth
2020-09-03 20:59 ` [PATCH 72/77] block: Fix bdrv_aligned_p*v() for qiov_offset != 0 Michael Roth
2020-09-03 20:59 ` [PATCH 73/77] iotests/028: Add test for cross-base-EOF reads Michael Roth
2020-09-03 20:59 ` [PATCH 74/77] nbd: Fix large trim/zero requests Michael Roth
2020-09-03 20:59 ` [PATCH 75/77] virtio-net: align RSC fields with updated virtio-net header Michael Roth
2020-09-03 20:59 ` [PATCH 76/77] hw/arm/sbsa-ref: fix typo breaking PCIe IRQs Michael Roth
2020-09-03 20:59 ` [PATCH 77/77] usb: fix setup_len init (CVE-2020-14364) Michael Roth
2020-09-04  9:20 ` [PATCH 00/77] Patch Round-up for stable 5.0.1, freeze on 2020-09-10 Philippe Mathieu-Daudé
2020-09-10 18:16   ` Michael Roth
2020-09-10 19:29     ` Philippe Mathieu-Daudé
2020-09-10 20:11     ` Philippe Mathieu-Daudé
2020-09-04 13:17 ` Thomas Huth
2020-09-10 18:14 ` Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200903205935.27832-24-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.