@@ -72,6 +72,7 @@ static bool has_msr_misc_enable;
static bool has_msr_bndcfgs;
static bool has_msr_kvm_steal_time;
static int lm_capable_kernel;
+static bool has_msr_hv_hypercall;
static bool has_msr_architectural_pmu;
static uint32_t num_architectural_pmu_counters;
@@ -437,8 +438,9 @@ static bool hyperv_hypercall_available(X86CPU *cpu)
static bool hyperv_enabled(X86CPU *cpu)
{
- return hyperv_hypercall_available(cpu) ||
- cpu->hyperv_relaxed_timing;
+ return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 &&
+ (hyperv_hypercall_available(cpu) ||
+ cpu->hyperv_relaxed_timing);
}
#define KVM_MAX_CPUID_ENTRIES 100
@@ -470,6 +472,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
} else {
memcpy(signature, "Microsoft Hv", 12);
c->eax = HYPERV_CPUID_MIN;
+ has_msr_hv_hypercall = true;
}
c->ebx = signature[0];
c->ecx = signature[1];
@@ -479,7 +482,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
c->function = KVM_CPUID_FEATURES;
c->eax = env->features[FEAT_KVM];
- if (hyperv_enabled(cpu)) {
+ if (has_msr_hv_hypercall) {
memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
c->eax = signature[0];