From: Joerg Roedel Subject: [PATCH 1/2] qemu-x86: Add tsc_khz option to -cpu Date: Fri, 17 Jun 2011 16:00:13 +0200 Message-ID: <1308319214-8474-2-git-send-email-joerg.roedel@amd.com> References: <1308319214-8474-1-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , qemu-devel , Anthony Liguori , Joerg Roedel To: Avi Kivity , Marcelo Tosatti Return-path: Received: from ch1ehsobe003.messaging.microsoft.com ([216.32.181.183]:22072 "EHLO CH1EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753719Ab1FQN75 (ORCPT ); Fri, 17 Jun 2011 09:59:57 -0400 In-Reply-To: <1308319214-8474-1-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 | 10 ++++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 0b039d4..a381c34 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -753,6 +753,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 79e7580..2b59e66 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,14 @@ 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_khz")) { + char *err; + numvalue = strtoul(val, &err, 0); + if (!*val || *err) { + fprintf(stderr, "bad numerical value %s\n", val); + goto error; + } + x86_cpu_def->tsc_khz = numvalue; } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; @@ -872,6 +881,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