From patchwork Mon Jun 28 16:14:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 57160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 907D9B6EEE for ; Tue, 29 Jun 2010 02:21:26 +1000 (EST) Received: from localhost ([127.0.0.1]:39446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTH35-0007eK-Bj for incoming@patchwork.ozlabs.org; Mon, 28 Jun 2010 12:19:07 -0400 Received: from [140.186.70.92] (port=46621 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTGzn-0006VW-9e for qemu-devel@nongnu.org; Mon, 28 Jun 2010 12:15:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTGzj-0001Ba-B4 for qemu-devel@nongnu.org; Mon, 28 Jun 2010 12:15:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29745) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTGzj-0001B3-4B for qemu-devel@nongnu.org; Mon, 28 Jun 2010 12:15:39 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5SGFbhw013033 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Jun 2010 12:15:38 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5SGFb9Z021805; Mon, 28 Jun 2010 12:15:37 -0400 Received: from amt.cnet (vpn2-11-80.ams2.redhat.com [10.36.11.80]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5SGFYXF017379; Mon, 28 Jun 2010 12:15:35 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 03BC068A893; Mon, 28 Jun 2010 13:14:36 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o5SGEWg0007580; Mon, 28 Jun 2010 13:14:32 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Mon, 28 Jun 2010 13:14:10 -0300 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Sheng Yang Subject: [Qemu-devel] [PATCH 3/7] kvm: Extend kvm_arch_get_supported_cpuid() to support index X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Sheng Yang Would use it later for XSAVE related CPUID. Signed-off-by: Sheng Yang Signed-off-by: Marcelo Tosatti --- kvm.h | 2 +- target-i386/kvm.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/kvm.h b/kvm.h index a30529c..500e7e4 100644 --- a/kvm.h +++ b/kvm.h @@ -144,7 +144,7 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env); int kvm_check_extension(KVMState *s, unsigned int extension); uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, - int reg); + uint32_t index, int reg); void kvm_cpu_synchronize_state(CPUState *env); void kvm_cpu_synchronize_post_reset(CPUState *env); void kvm_cpu_synchronize_post_init(CPUState *env); diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 5453239..2b14ff5 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -71,7 +71,8 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max) return cpuid; } -uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) +uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, + uint32_t index, int reg) { struct kvm_cpuid2 *cpuid; int i, max; @@ -88,7 +89,8 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) } for (i = 0; i < cpuid->nent; ++i) { - if (cpuid->entries[i].function == function) { + if (cpuid->entries[i].function == function && + cpuid->entries[i].index == index) { switch (reg) { case R_EAX: ret = cpuid->entries[i].eax; @@ -110,7 +112,7 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) /* On Intel, kvm returns cpuid according to the Intel spec, * so add missing bits according to the AMD spec: */ - cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, R_EDX); + cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX); ret |= cpuid_1_edx & 0x183f7ff; break; } @@ -126,7 +128,8 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) #else -uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg) +uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, + uint32_t index, int reg) { return -1U; } @@ -178,16 +181,16 @@ int kvm_arch_init_vcpu(CPUState *env) env->mp_state = KVM_MP_STATE_RUNNABLE; - env->cpuid_features &= kvm_arch_get_supported_cpuid(env, 1, R_EDX); + env->cpuid_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX); i = env->cpuid_ext_features & CPUID_EXT_HYPERVISOR; - env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(env, 1, R_ECX); + env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_ECX); env->cpuid_ext_features |= i; env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(env, 0x80000001, - R_EDX); + 0, R_EDX); env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(env, 0x80000001, - R_ECX); + 0, R_ECX); cpuid_i = 0;