From patchwork Thu Jul 2 14:45:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 33685 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n62EjvL3008149 for ; Thu, 2 Jul 2009 14:45:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753576AbZGBOpv (ORCPT ); Thu, 2 Jul 2009 10:45:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753275AbZGBOpv (ORCPT ); Thu, 2 Jul 2009 10:45:51 -0400 Received: from outbound-dub.frontbridge.com ([213.199.154.16]:19107 "EHLO IE1EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbZGBOpu (ORCPT ); Thu, 2 Jul 2009 10:45:50 -0400 Received: from mail69-dub-R.bigfish.com (10.5.252.3) by IE1EHSOBE001.bigfish.com (10.5.252.21) with Microsoft SMTP Server id 8.1.340.0; Thu, 2 Jul 2009 14:45:53 +0000 Received: from mail69-dub (localhost.localdomain [127.0.0.1]) by mail69-dub-R.bigfish.com (Postfix) with ESMTP id DA8901AF8148; Thu, 2 Jul 2009 14:45:52 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i61h) X-Spam-TCS-SCL: 0:0 Received: by mail69-dub (MessageSwitch) id 1246545951996651_29591; Thu, 2 Jul 2009 14:45:51 +0000 (UCT) Received: from ausb3extmailp02.amd.com (ausb3extmailp02.amd.com [163.181.251.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail69-dub.bigfish.com (Postfix) with ESMTP id 4B3071B8005A; Thu, 2 Jul 2009 14:45:51 +0000 (UTC) Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n62Ejkv5012462; Thu, 2 Jul 2009 09:45:49 -0500 X-WSS-ID: 0KM5T01-02-1V0-01 Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 27AFB16A03E2; Thu, 2 Jul 2009 09:45:37 -0500 (CDT) Received: from sausexmb2.amd.com ([163.181.3.157]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 09:45:44 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 09:45:44 -0500 Received: from localhost.localdomain ([165.204.15.42]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 16:45:37 +0200 From: Andre Przywara To: avi@redhat.com CC: kvm@vger.kernel.org, Andre Przywara Subject: [PATCH v2] qemu-kvm: preserve the hypervisor bit while KVM trims the CPUID bits Date: Thu, 2 Jul 2009 16:45:43 +0200 Message-ID: <1246545943-17511-1-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.6.1.3 In-Reply-To: <1246541255-15103-1-git-send-email-andre.przywara@amd.com> References: <1246541255-15103-1-git-send-email-andre.przywara@amd.com> X-OriginalArrivalTime: 02 Jul 2009 14:45:37.0563 (UTC) FILETIME=[C34A66B0:01C9FB23] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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,