From: Ladi Prosek <lprosek@redhat.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, david@redhat.com,
rkrcmar@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/4] i386/kvm: introduce tsc_is_stable_and_known()
Date: Mon, 7 Aug 2017 10:57:02 +0200 [thread overview]
Message-ID: <20170807085703.32267-4-lprosek@redhat.com> (raw)
In-Reply-To: <20170807085703.32267-1-lprosek@redhat.com>
Move the "is TSC stable and known" condition to a reusable helper.
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
target/i386/kvm.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 15d56ae..2dc01c9 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -611,6 +611,15 @@ static int kvm_arch_set_tsc_khz(CPUState *cs)
return 0;
}
+static bool tsc_is_stable_and_known(CPUX86State *env)
+{
+ if (!env->tsc_khz) {
+ return false;
+ }
+ return (env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC)
+ || env->user_tsc_khz;
+}
+
static int hyperv_handle_properties(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
@@ -986,9 +995,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
&& cpu->expose_kvm
&& kvm_base == KVM_CPUID_SIGNATURE
/* TSC clock must be stable and known for this feature. */
- && ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC)
- || env->user_tsc_khz != 0)
- && env->tsc_khz != 0) {
+ && tsc_is_stable_and_known(env)) {
c = &cpuid_data.entries[cpuid_i++];
c->function = KVM_CPUID_SIGNATURE | 0x10;
--
2.9.3
next prev parent reply other threads:[~2017-08-07 8:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 8:56 [Qemu-devel] [PATCH v2 0/4] i386/kvm: advertise Hyper-V frequency MSRs Ladi Prosek
2017-08-07 8:57 ` [Qemu-devel] [PATCH v2 1/4] i386/kvm: use a switch statement for MSR detection Ladi Prosek
2017-08-07 14:19 ` David Hildenbrand
2017-08-07 14:24 ` Ladi Prosek
2017-08-07 8:57 ` [Qemu-devel] [PATCH v2 2/4] i386/kvm: set tsc_khz before configuring Hyper-V CPUID Ladi Prosek
2017-08-07 8:57 ` Ladi Prosek [this message]
2017-08-07 14:22 ` [Qemu-devel] [PATCH v2 3/4] i386/kvm: introduce tsc_is_stable_and_known() David Hildenbrand
2017-08-07 8:57 ` [Qemu-devel] [PATCH v2 4/4] i386/kvm: advertise Hyper-V frequency MSRs Ladi Prosek
2017-08-07 14:25 ` David Hildenbrand
2017-08-09 0:50 ` [Qemu-devel] [PATCH v2 0/4] " Marcelo Tosatti
2017-08-16 1:49 ` Konrad Rzeszutek Wilk
2017-09-11 9:52 ` Paolo Bonzini
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=20170807085703.32267-4-lprosek@redhat.com \
--to=lprosek@redhat.com \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.com \
/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).