[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/50] i386/kvm: advertise Hyper-V frequency MSRs
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 21/50] i386/kvm: advertise Hyper-V frequency MSRs |
Date: |
Tue, 19 Sep 2017 14:29:10 +0200 |
From: Ladi Prosek <address@hidden>
As of kernel commit eb82feea59d6 ("KVM: hyperv: support HV_X64_MSR_TSC_FREQUENCY
and HV_X64_MSR_APIC_FREQUENCY"), KVM supports two new MSRs which are required
for nested Hyper-V to read timestamps with RDTSC + TSC page.
This commit makes QEMU advertise the MSRs with CPUID.40000003H:EAX[11] and
CPUID.40000003H:EDX[8] as specified in the Hyper-V TLFS and experimentally
verified on a Hyper-V host. The feature is enabled with the existing hv-time CPU
flag, and only if the TSC frequency is stable across migrations and known.
Signed-off-by: Ladi Prosek <address@hidden>
Reviewed-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
target/i386/kvm.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 2dc01c9..739334a 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -89,6 +89,7 @@ static bool has_msr_hv_vpindex;
static bool has_msr_hv_runtime;
static bool has_msr_hv_synic;
static bool has_msr_hv_stimer;
+static bool has_msr_hv_frequencies;
static bool has_msr_xss;
static bool has_msr_architectural_pmu;
@@ -640,7 +641,13 @@ static int hyperv_handle_properties(CPUState *cs)
if (cpu->hyperv_time) {
env->features[FEAT_HYPERV_EAX] |= HV_X64_MSR_HYPERCALL_AVAILABLE;
env->features[FEAT_HYPERV_EAX] |= HV_X64_MSR_TIME_REF_COUNT_AVAILABLE;
- env->features[FEAT_HYPERV_EAX] |= 0x200;
+ env->features[FEAT_HYPERV_EAX] |= HV_X64_MSR_REFERENCE_TSC_AVAILABLE;
+
+ if (has_msr_hv_frequencies && tsc_is_stable_and_known(env)) {
+ env->features[FEAT_HYPERV_EAX] |= HV_X64_ACCESS_FREQUENCY_MSRS;
+ env->features[FEAT_HYPERV_EDX] |=
+ HV_FEATURE_FREQUENCY_MSRS_AVAILABLE;
+ }
}
if (cpu->hyperv_crash && has_msr_hv_crash) {
env->features[FEAT_HYPERV_EDX] |= HV_X64_GUEST_CRASH_MSR_AVAILABLE;
@@ -1134,6 +1141,9 @@ static int kvm_get_supported_msrs(KVMState *s)
case HV_X64_MSR_STIMER0_CONFIG:
has_msr_hv_stimer = true;
break;
+ case HV_X64_MSR_TSC_FREQUENCY:
+ has_msr_hv_frequencies = true;
+ break;
}
}
}
--
1.8.3.1
- [Qemu-devel] [PULL 12/50] scsi: rename scsi_build_sense to scsi_convert_sense, (continued)
- [Qemu-devel] [PULL 12/50] scsi: rename scsi_build_sense to scsi_convert_sense, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 15/50] scsi: introduce sg_io_sense_from_errno, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 16/50] scsi: move block/scsi.h to include/scsi/constants.h, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 20/50] i386/kvm: introduce tsc_is_stable_and_known(), Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 17/50] MAINTAINERS: update mail address for NVDIMM, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 18/50] i386/kvm: use a switch statement for MSR detection, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 19/50] i386/kvm: set tsc_khz before configuring Hyper-V CPUID, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 29/50] kvm: we never have overlapping slots in kvm_set_phys_mem(), Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 30/50] kvm: kvm_log_start/stop are only called with known sections, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 28/50] kvm: use start + size for memory ranges, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 21/50] i386/kvm: advertise Hyper-V frequency MSRs,
Paolo Bonzini <=
- [Qemu-devel] [PULL 22/50] MAINTAINERS: update email, add missing test entry for megasas, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 24/50] scsi/esp: Rename the ESP macro to ESP_STATE, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 27/50] kvm: factor out alignment of memory section, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 31/50] kvm: kvm_log_sync() is only called with known memory sections, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 25/50] multiboot: validate multiboot header address values, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 32/50] test-qga: add missing qemu-ga tool dependency, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 26/50] kvm: require JOIN_MEMORY_REGIONS_WORKS, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 23/50] memory: Rename queue to mrqueue (memory region queue), Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 13/50] scsi: move non-emulation specific code to scsi/, Paolo Bonzini, 2017/09/19
- [Qemu-devel] [PULL 33/50] hw/i386: Improve some of the warning messages, Paolo Bonzini, 2017/09/19