From patchwork Thu Jun 17 07:18:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 106621 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5H7IMKh019279 for ; Thu, 17 Jun 2010 07:18:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754471Ab0FQHSG (ORCPT ); Thu, 17 Jun 2010 03:18:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:38059 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477Ab0FQHSE (ORCPT ); Thu, 17 Jun 2010 03:18:04 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 17 Jun 2010 00:18:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.53,430,1272870000"; d="scan'208";a="808830562" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.189]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2010 00:18:02 -0700 Received: from yasker by syang10-desktop with local (Exim 4.71) (envelope-from ) id 1OP9Mg-0007Zv-4o; Thu, 17 Jun 2010 15:18:18 +0800 From: Sheng Yang To: Marcelo Tosatti , Avi Kivity Cc: Jan Kiszka , Anthony Liguori , kvm@vger.kernel.org, qemu-devel@nongnu.org, Sheng Yang Subject: [PATCH 1/4] qemu: kvm: Extend kvm_arch_get_supported_cpuid() to support index Date: Thu, 17 Jun 2010 15:18:13 +0800 Message-Id: <1276759096-29104-2-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1276759096-29104-1-git-send-email-sheng@linux.intel.com> References: <1276759096-29104-1-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 17 Jun 2010 07:18:23 +0000 (UTC) diff --git a/kvm.h b/kvm.h index a28e7aa..7975e87 100644 --- a/kvm.h +++ b/kvm.h @@ -145,7 +145,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 5a088a7..bb6a12f 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -72,7 +72,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; @@ -89,7 +90,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; @@ -111,7 +113,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; } @@ -127,7 +129,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; } @@ -179,16 +182,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;