qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposing TSC frequency in CPUID
@ 2017-01-20 14:11 Phil Dennis-Jordan
  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
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Phil Dennis-Jordan @ 2017-01-20 14:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Marcelo Tosatti, Michael S. Tsirkin, kvm, Phil Dennis-Jordan

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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-25 17:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 14:11 [Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposing TSC frequency in CPUID Phil Dennis-Jordan
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

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).