From patchwork Wed Jun 17 17:56:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 30946 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 n5HHviG6015963 for ; Wed, 17 Jun 2009 17:57:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754936AbZFQR5F (ORCPT ); Wed, 17 Jun 2009 13:57:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752749AbZFQR5E (ORCPT ); Wed, 17 Jun 2009 13:57:04 -0400 Received: from wa4ehsobe003.messaging.microsoft.com ([216.32.181.13]:3648 "EHLO WA4EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754936AbZFQR5A (ORCPT ); Wed, 17 Jun 2009 13:57:00 -0400 Received: from mail169-wa4-R.bigfish.com (10.8.14.249) by WA4EHSOBE003.bigfish.com (10.8.40.23) with Microsoft SMTP Server id 8.1.340.0; Wed, 17 Jun 2009 17:57:02 +0000 Received: from mail169-wa4 (localhost.localdomain [127.0.0.1]) by mail169-wa4-R.bigfish.com (Postfix) with ESMTP id 0DAEBC2828D; Wed, 17 Jun 2009 17:57:03 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i17ch62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, Received: by mail169-wa4 (MessageSwitch) id 1245261421634108_18789; Wed, 17 Jun 2009 17:57:01 +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 mail169-wa4.bigfish.com (Postfix) with ESMTP id 755D53F804D; Wed, 17 Jun 2009 17:57:01 +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 n5HHuv5M020239; Wed, 17 Jun 2009 12:57:00 -0500 X-WSS-ID: 0KLE9UM-02-ZOL-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 21A4F16A03CB; Wed, 17 Jun 2009 12:56:46 -0500 (CDT) Received: from sausexmb2.amd.com ([163.181.3.157]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Jun 2009 12:56:56 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Jun 2009 12:56:56 -0500 Received: from seurexmb1.amd.com ([165.204.9.130]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Jun 2009 19:56:50 +0200 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Jun 2009 19:56:49 +0200 Received: by lemmy.amd.com (Postfix, from userid 41430) id 2180CC9DF8; Wed, 17 Jun 2009 19:56:49 +0200 (CEST) From: Joerg Roedel To: Avi Kivity CC: kvm@vger.kernel.org, Joerg Roedel Subject: [PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid Date: Wed, 17 Jun 2009 19:56:41 +0200 Message-ID: <1245261402-26440-3-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.3.1 In-Reply-To: <1245261402-26440-1-git-send-email-joerg.roedel@amd.com> References: <1245261402-26440-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 17 Jun 2009 17:56:49.0352 (UTC) FILETIME=[FCD03C80:01C9EF74] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The cpuid features exposed to the guest are currently not aligned with the bits returned by the supported_cpuid ioctl. This patch fixes it. Signed-off-by: Joerg Roedel --- qemu-kvm-x86.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 729d600..95774c1 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -578,6 +578,13 @@ int kvm_arch_qemu_init_env(CPUState *cenv) if (i == 0xd && copy.regs[R_EAX] == 0) break; } + } else if (i == 1) { + do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, ©); + kvm_trim_features(&cpuid_ent[cpuid_nent].edx, + kvm_arch_get_supported_cpuid(cenv, 1, R_EDX)); + kvm_trim_features(&cpuid_ent[cpuid_nent].ecx, + kvm_arch_get_supported_cpuid(cenv, 1, R_ECX)); + cpuid_nent++; } else do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, ©); } @@ -586,20 +593,19 @@ int kvm_arch_qemu_init_env(CPUState *cenv) qemu_kvm_cpuid_on_env(©); limit = copy.regs[R_EAX]; - for (i = 0x80000000; i <= limit; ++i) - do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, ©); + for (i = 0x80000000; i <= limit; ++i) { + do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, ©); + if (i == 0x80000001) { + kvm_trim_features(&cpuid_ent[cpuid_nent].edx, + kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX)); + kvm_trim_features(&cpuid_ent[cpuid_nent].ecx, + kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX)); + } + ++cpuid_nent; + } 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; }