qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 0/3] x86-kvm: Fix Mac guest timekeeping by exposi


From: Phil Dennis-Jordan
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

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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]