From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5YLn-0004YQ-Ai for qemu-devel@nongnu.org; Tue, 21 Jan 2014 05:14:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5YLh-0002qg-CL for qemu-devel@nongnu.org; Tue, 21 Jan 2014 05:14:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5YLh-0002qN-20 for qemu-devel@nongnu.org; Tue, 21 Jan 2014 05:14:25 -0500 Message-ID: <52DE487A.9090609@redhat.com> Date: Tue, 21 Jan 2014 11:14:18 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1390291367-21958-1-git-send-email-vrozenfe@redhat.com> <1390291367-21958-2-git-send-email-vrozenfe@redhat.com> In-Reply-To: <1390291367-21958-2-git-send-email-vrozenfe@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] cleanup hyper-v interface initialization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vadim Rozenfeld Cc: mtosatti@redhat.com, pl@dlhnet.de, qemu-devel@nongnu.org, aliguori@amazon.com Il 21/01/2014 09:02, Vadim Rozenfeld ha scritto: > Signed-off-by: Vadim Rozenfeld > --- > target-i386/kvm.c | 46 +++++++++++++++++----------------------------- > 1 file changed, 17 insertions(+), 29 deletions(-) Please split this part into multiple parts and document each in the commit message. Also please cite relevant parts of the MS document in the commit messages. Paolo > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 7522e98..768ca1d 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -71,6 +71,8 @@ static bool has_msr_pv_eoi_en; > static bool has_msr_misc_enable; > static bool has_msr_kvm_steal_time; > static int lm_capable_kernel; > +static bool has_msr_hv_hypercall; > +static bool has_msr_hv_vapic; > > static bool has_msr_architectural_pmu; > static uint32_t num_architectural_pmu_counters; > @@ -463,13 +465,7 @@ int kvm_arch_init_vcpu(CPUState *cs) > /* Paravirtualization CPUIDs */ > c = &cpuid_data.entries[cpuid_i++]; > c->function = KVM_CPUID_SIGNATURE; > - if (!hyperv_enabled(cpu)) { > - memcpy(signature, "KVMKVMKVM\0\0\0", 12); > - c->eax = 0; > - } else { > - memcpy(signature, "Microsoft Hv", 12); > - c->eax = HYPERV_CPUID_MIN; > - } > + memcpy(signature, "KVMKVMKVM\0\0\0", 12); > c->ebx = signature[0]; > c->ecx = signature[1]; > c->edx = signature[2]; > @@ -478,23 +474,23 @@ int kvm_arch_init_vcpu(CPUState *cs) > c->function = KVM_CPUID_FEATURES; > c->eax = env->features[FEAT_KVM]; > > - if (hyperv_enabled(cpu)) { > + if (hyperv_enabled(cpu) && > + kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0) { > + has_msr_hv_hypercall = true; > + > memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12); > c->eax = signature[0]; > > c = &cpuid_data.entries[cpuid_i++]; > - c->function = HYPERV_CPUID_VERSION; > - c->eax = 0x00001bbc; > - c->ebx = 0x00060001; > - > - c = &cpuid_data.entries[cpuid_i++]; > c->function = HYPERV_CPUID_FEATURES; > if (cpu->hyperv_relaxed_timing) { > c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE; > } > - if (cpu->hyperv_vapic) { > + if (cpu->hyperv_vapic && > + kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_VAPIC) > 0) { > c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE; > c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE; > + has_msr_hv_vapic = true; > } > > c = &cpuid_data.entries[cpuid_i++]; > @@ -502,23 +498,15 @@ int kvm_arch_init_vcpu(CPUState *cs) > if (cpu->hyperv_relaxed_timing) { > c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; > } > - if (cpu->hyperv_vapic) { > + if (has_msr_hv_vapic) { > c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; > } > - c->ebx = cpu->hyperv_spinlock_attempts; > - > - c = &cpuid_data.entries[cpuid_i++]; > - c->function = HYPERV_CPUID_IMPLEMENT_LIMITS; > - c->eax = 0x40; > - c->ebx = 0x40; > - > - c = &cpuid_data.entries[cpuid_i++]; > - c->function = KVM_CPUID_SIGNATURE_NEXT; > - memcpy(signature, "KVMKVMKVM\0\0\0", 12); > - c->eax = 0; > - c->ebx = signature[0]; > - c->ecx = signature[1]; > - c->edx = signature[2]; > + if (cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY && > + kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_SPIN) > 0) { > + c->ebx = cpu->hyperv_spinlock_attempts; > + } else { > + c->ebx = HYPERV_SPINLOCK_NEVER_RETRY; > + } > } > > has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF); >