From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
kvm@vger.kernel.org, Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposing TSC frequency in CPUID
Date: Fri, 20 Jan 2017 15:11:33 +0100 [thread overview]
Message-ID: <1484921496-11257-1-git-send-email-phil@philjordan.eu> (raw)
Darwin/OS X/macOS for x86-64 uses the TSC for timekeeping; it normally calibrates this by querying various clock frequency scaling MSRs. Details depend on the exact CPU model detected. The local APIC timer frequency is extracted from (EFI) firmware. Virtualisation environments including Qemu/KVM don't expose those MSRs to guests, and in any case the host and guest CPUs' MSRs may not match up. To solve this, the xnu kernel queries CPUID leaf 0x40000010 for the TSC and APIC timers if leaf 0x40000000 suggests that this leaf exists, which is the case when running inside VMWare (Fusion). This patch series replicates the behaviour of these CPUID leaves for Qemu/KVM via a new x86 CPU option, "vmware-cpuid-freq."
The option is activated by default on 2.9 and newer pc (PIIX and Q35) machine variants, if the TSC is stable and known (invtsc or user-specified).
Changelog
========
v1 -> v2
* The v1 thread was "[PATCH] x86-KVM: Supply TSC and APIC clock rates to guest like VMWare"
* The option has been renamed as suggested in the v1 discussion.
* It now checks that either invtsc or a user-specified TSC clock rate are active before activating leaf 0x40000010.
* CPUID leaf 0x40000000 exposed by KVM will only reference 0x40000010 if all preconditions are met and the functionality is actually active.
* No more error message if preconditions are not met.
* cpuid_data.cpuid.nent update/cpuid_find_entry bug fixed.
* 2 extra patches included, one for setting up PC machine version 2.8/2.9 compatibility configurations, the second for enabling the new option in version 2.9+ PIIX/q35 configurations by default, while leaving it disabled for 2.8 or older machines.
Phil Dennis-Jordan (3):
x86-KVM: Supply TSC and APIC clock rates to guest like VMWare
pc: Add 2.9 machine type
pc: Enable vmware-cpuid-freq CPU option for 2.9+ machine types
hw/i386/pc_piix.c | 13 ++++++++++++-
hw/i386/pc_q35.c | 12 +++++++++++-
include/hw/i386/pc.h | 6 ++++++
target/i386/cpu.c | 1 +
target/i386/cpu.h | 4 ++++
target/i386/kvm.c | 36 ++++++++++++++++++++++++++++++------
6 files changed, 64 insertions(+), 8 deletions(-)
--
2.3.2 (Apple Git-55)
next reply other threads:[~2017-01-20 14:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 14:11 Phil Dennis-Jordan [this message]
2017-01-20 14:11 ` [Qemu-devel] [PATCH v2 1/3] x86-KVM: Supply TSC and APIC clock rates to guest like VMWare Phil Dennis-Jordan
2017-01-20 14:11 ` [Qemu-devel] [PATCH v2 2/3] pc: Add 2.9 machine type Phil Dennis-Jordan
2017-01-20 14:11 ` [Qemu-devel] [PATCH v2 3/3] pc: Enable vmware-cpuid-freq CPU option for 2.9+ machine types Phil Dennis-Jordan
2017-01-24 11:58 ` [Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposing TSC frequency in CPUID Paolo Bonzini
2017-01-25 17:26 ` Phil Dennis-Jordan
2017-01-25 17:30 ` 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=1484921496-11257-1-git-send-email-phil@philjordan.eu \
--to=phil@philjordan.eu \
--cc=ehabkost@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).