All of lore.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 v2] qemu-kvm: preserve the hypervisor bit while KVM trims the CPUID bits
Date: Thu, 2 Jul 2009 16:45:43 +0200	[thread overview]
Message-ID: <1246545943-17511-1-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <1246541255-15103-1-git-send-email-andre.przywara@amd.com>

The KVM kernel will disable all bits in CPUID which are not present in
the host. As this is mostly true for the hypervisor bit (1.ecx),
preserve its value before the trim and restore it afterwards.
This is similar to commit 6c0d7ee8, but since qemu-kvm uses another code
path it has to be inserted in qemu-kvm-x86.c, too.

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

The last patch had a typo (and I compile tested the wrong branch), so
here is the correct version.

Regards,
Andre.

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index d6735c1..7505380 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1211,8 +1211,13 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 
     kvm_trim_features(&cenv->cpuid_features,
                       kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
+
+    /* prevent the hypervisor bit from being cleared by the kernel */
+    i = cenv->cpuid_ext_features & CPUID_EXT_HYPERVISOR;
     kvm_trim_features(&cenv->cpuid_ext_features,
                       kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
+    cenv->cpuid_ext_features |= i;
+
     kvm_trim_features(&cenv->cpuid_ext2_features,
                       kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
     kvm_trim_features(&cenv->cpuid_ext3_features,
-- 
1.6.1.3



  reply	other threads:[~2009-07-02 14:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-02 13:27 [PATCH] qemu-kvm: preserve the hypervisor bit while KVM trims the CPUID bits Andre Przywara
2009-07-02 14:45 ` Andre Przywara [this message]
2009-07-07 11:38   ` [PATCH v2] " 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=1246545943-17511-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 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.