public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org, Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH] qemu-kvm: fix KVMs GET_SUPPORTED_CPUID feature usage
Date: Thu, 25 Jun 2009 15:12:03 +0200	[thread overview]
Message-ID: <1245935523-32604-1-git-send-email-andre.przywara@amd.com> (raw)

If we want to trim the user provided CPUID bits for KVM to be not greater
than that of the host, we should
a) not remove the bits _after_ we sent them to the kernel  and
b) not do the bitmangling on the original values while sending a copy
This fixes the masking of features that are not present on the host and
helps to use -cpu host.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 qemu-kvm-x86.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

Hi,
this is a port of patch 4/6 of my "-cpu host" series for QEMU.
The bug is similar, although the fix is a different one (different files).
Even without "-cpu host" features that the host does not support are
currently _not_ disabled as intended, so I consider this a bugfix.

Regards,
Andre.

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 66b2b19..f3e4b6b 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1190,7 +1190,6 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 
     qemu_kvm_load_lapic(cenv);
 
-    copy = *cenv;
 
 #ifdef KVM_CPUID_SIGNATURE
     /* Paravirtualization CPUIDs */
@@ -1209,6 +1208,17 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     pv_ent->eax = get_para_features(kvm_context);
 #endif
 
+    kvm_trim_features(&cenv->cpuid_features,
+                      kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
+    kvm_trim_features(&cenv->cpuid_ext_features,
+                      kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
+    kvm_trim_features(&cenv->cpuid_ext2_features,
+                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
+    kvm_trim_features(&cenv->cpuid_ext3_features,
+                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
+
+    copy = *cenv;
+
     copy.regs[R_EAX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
@@ -1243,15 +1253,6 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 
     kvm_setup_cpuid2(cenv->kvm_cpu_state.vcpu_ctx, cpuid_nent, cpuid_ent);
 
-    kvm_trim_features(&cenv->cpuid_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
-    kvm_trim_features(&cenv->cpuid_ext2_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext3_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
-
     return 0;
 }
 
-- 
1.6.1.3



             reply	other threads:[~2009-06-25 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-25 13:12 Andre Przywara [this message]
2009-07-01  9:49 ` [PATCH] qemu-kvm: fix KVMs GET_SUPPORTED_CPUID feature usage Avi Kivity

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=1245935523-32604-1-git-send-email-andre.przywara@amd.com \
    --to=andre.przywara@amd.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox