From patchwork Thu Jul 2 13:27:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 33661 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 n62DSjqY024761 for ; Thu, 2 Jul 2009 13:28:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbZGBN2j (ORCPT ); Thu, 2 Jul 2009 09:28:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752043AbZGBN2j (ORCPT ); Thu, 2 Jul 2009 09:28:39 -0400 Received: from outbound-sin.frontbridge.com ([207.46.51.80]:22152 "EHLO SG2EHSOBE006.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbZGBN2i (ORCPT ); Thu, 2 Jul 2009 09:28:38 -0400 Received: from mail60-sin-R.bigfish.com (10.210.100.246) by SG2EHSOBE006.bigfish.com (10.210.112.26) with Microsoft SMTP Server id 8.1.340.0; Thu, 2 Jul 2009 13:28:40 +0000 Received: from mail60-sin (localhost.localdomain [127.0.0.1]) by mail60-sin-R.bigfish.com (Postfix) with ESMTP id 4EA2BBC0087; Thu, 2 Jul 2009 13:28:47 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(zzzz1202hzzz32i43j61h) X-Spam-TCS-SCL: 0:0 Received: by mail60-sin (MessageSwitch) id 1246541326192128_8574; Thu, 2 Jul 2009 13:28:46 +0000 (UCT) Received: from ausb3extmailp01.amd.com (unknown [163.181.251.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail60-sin.bigfish.com (Postfix) with ESMTP id 63DFA11F8056; Thu, 2 Jul 2009 13:28:45 +0000 (UTC) Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n62DSR0f003043; Thu, 2 Jul 2009 08:28:30 -0500 X-WSS-ID: 0KM5PFD-02-XWS-01 Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 25F5E16A03E9; Thu, 2 Jul 2009 08:28:25 -0500 (CDT) Received: from SAUSEXMB3.amd.com ([163.181.22.202]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 08:28:31 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by SAUSEXMB3.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 08:28:31 -0500 Received: from localhost.localdomain ([165.204.15.42]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 2 Jul 2009 15:27:29 +0200 From: Andre Przywara To: avi@redhat.com CC: kvm@vger.kernel.org, Andre Przywara Subject: [PATCH] qemu-kvm: preserve the hypervisor bit while KVM trims the CPUID bits Date: Thu, 2 Jul 2009 15:27:35 +0200 Message-ID: <1246541255-15103-1-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.6.1.3 X-OriginalArrivalTime: 02 Jul 2009 13:27:29.0871 (UTC) FILETIME=[D9355DF0:01C9FB18] 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(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index d6735c1..b02e604 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 = env->cpuid_ext_features & CPUID_EXT_HYPERVISOR; kvm_trim_features(&cenv->cpuid_ext_features, kvm_arch_get_supported_cpuid(cenv, 1, R_ECX)); + env->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,