From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QepKl-0007l3-FM for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QepKg-0001bk-K3 for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:39 -0400 Received: from ch1ehsobe004.messaging.microsoft.com ([216.32.181.184]:26566 helo=CH1EHSOBE002.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QepKf-0001bJ-Ua for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:34 -0400 From: Joerg Roedel Date: Thu, 7 Jul 2011 16:13:12 +0200 Message-ID: <1310047993-7649-3-git-send-email-joerg.roedel@amd.com> In-Reply-To: <1310047993-7649-1-git-send-email-joerg.roedel@amd.com> References: <1310047993-7649-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity , Marcelo Tosatti Cc: Joerg Roedel , qemu-devel@nongnu.org, kvm@vger.kernel.org To let the user configure the desired tsc frequency for the guest if running in KVM. Signed-off-by: Joerg Roedel --- target-i386/cpu.h | 1 + target-i386/cpuid.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index cdf68ff..399e124 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -743,6 +743,7 @@ typedef struct CPUX86State { uint32_t cpuid_kvm_features; uint32_t cpuid_svm_features; bool tsc_valid; + int tsc_khz; /* in order to simplify APIC support, we leave this pointer to the user */ diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index e1ae3af..89e9623 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -224,6 +224,7 @@ typedef struct x86_def_t { int family; int model; int stepping; + int tsc_khz; uint32_t features, ext_features, ext2_features, ext3_features; uint32_t kvm_features, svm_features; uint32_t xlevel; @@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) } else if (!strcmp(featurestr, "model_id")) { pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id), val); + } else if (!strcmp(featurestr, "tsc_freq")) { + int64_t tsc_freq; + char *err; + + tsc_freq = strtosz_suffix_unit(val, &err, + STRTOSZ_DEFSUFFIX_B, 1000); + if (!*val || *err) { + fprintf(stderr, "bad numerical value %s\n", val); + goto error; + } + x86_cpu_def->tsc_khz = tsc_freq / 1000; } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; @@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_svm_features = def->svm_features; env->cpuid_ext4_features = def->ext4_features; env->cpuid_xlevel2 = def->xlevel2; + env->tsc_khz = def->tsc_khz; if (!kvm_enabled()) { env->cpuid_features &= TCG_FEATURES; env->cpuid_ext_features &= TCG_EXT_FEATURES; -- 1.7.4.1