From: Joerg Roedel <joerg.roedel@amd.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Joerg Roedel <joerg.roedel@amd.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
Date: Thu, 7 Jul 2011 16:13:12 +0200 [thread overview]
Message-ID: <1310047993-7649-3-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1310047993-7649-1-git-send-email-joerg.roedel@amd.com>
To let the user configure the desired tsc frequency for the
guest if running in KVM.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
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
next prev parent reply other threads:[~2011-07-07 14:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-07 14:13 [Qemu-devel] [PATCH 0/3][uq/master] Basic TSC-Scaling support v2 Joerg Roedel
2011-07-07 14:13 ` [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function Joerg Roedel
2011-07-08 8:00 ` Markus Armbruster
2011-07-07 14:13 ` Joerg Roedel [this message]
2011-07-19 11:46 ` [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu Marcelo Tosatti
2011-07-19 12:20 ` Avi Kivity
2011-07-19 12:56 ` Marcelo Tosatti
2011-07-19 13:30 ` Joerg Roedel
2011-07-19 13:54 ` Avi Kivity
2011-07-19 13:55 ` Avi Kivity
2011-07-19 14:14 ` Joerg Roedel
2011-07-19 15:55 ` Avi Kivity
2011-07-07 14:13 ` [Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported Joerg Roedel
2011-07-19 11:48 ` Marcelo Tosatti
2011-07-19 17:03 ` Jan Kiszka
2011-07-19 13:04 ` [Qemu-devel] [PATCH 0/3][uq/master] Basic TSC-Scaling support v2 Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1310047993-7649-3-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).