Received: from eggs.gnu.org ([2001:4830:134:3::10]:44826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEcKD-0000Ra-IC for qemu-devel@nongnu.org; Mon, 22 Oct 2018 11:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEcK8-0000Tu-GU for qemu-devel@nongnu.org; Mon, 22 Oct 2018 11:40:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEcK6-0000Q8-Re for qemu-devel@nongnu.org; Mon, 22 Oct 2018 11:40:55 -0400 From: Vitaly Kuznetsov In-Reply-To: <20181022143355.GA5839@rkaganb.sw.ru> References: <20181019111432.5040-1-vkuznets@redhat.com> <20181019111432.5040-3-vkuznets@redhat.com> <20181022143355.GA5839@rkaganb.sw.ru> Date: Mon, 22 Oct 2018 17:40:46 +0200 Message-ID: <87lg6q9egx.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/2] x86: hv_evmcs CPU flag support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Kagan Cc: "qemu-devel@nongnu.org" , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti Roman Kagan writes: > On Fri, Oct 19, 2018 at 01:14:32PM +0200, Vitaly Kuznetsov wrote: >> --- a/target/i386/kvm.c >> +++ b/target/i386/kvm.c >> @@ -798,6 +798,7 @@ int kvm_arch_init_vcpu(CPUState *cs) >> uint32_t unused; >> struct kvm_cpuid_entry2 *c; >> uint32_t signature[3]; >> + uint16_t evmcs_version; >> int kvm_base = KVM_CPUID_SIGNATURE; >> int r; >> Error *local_err = NULL; >> @@ -841,7 +842,7 @@ int kvm_arch_init_vcpu(CPUState *cs) >> memset(signature, 0, 12); >> memcpy(signature, cpu->hyperv_vendor_id, len); >> } >> - c->eax = HV_CPUID_MIN; >> + c->eax = cpu->hyperv_evmcs ? HV_CPUID_MIN_NESTED : HV_CPUID_MIN; > > > I think these two aren't meant to be used on the hypervisor side. My > understanding is that HV_CPUID_MIN is only there as a reminder that the > real Hyper-V exposes at least that many hypervisor-specific leaves so > the guest can rely on that. So I'd rather use directly > HV_CPUID_IMPLEMENT_LIMITS : HV_CPUID_NESTED_FEATURES, and not introduce > HV_CPUID_MIN_NESTED. Makes sense, will do v2. > Maybe better yet is to update this field with the > maximum value while populating HV_* leaves: > > if (hyperv_enabled(cpu)) { > uint32_t *cpuid_40000000_eax; > c = &cpuid_data.entries[cpuid_i++]; > c->function = HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; > cpuid_40000000_eax = &c->eax; > *cpuid_40000000_eax = c->function; > > .... > > c = &cpuid_data.entries[cpuid_i++]; > c->function = HV_CPUID_...; > *cpuid_40000000_eax = max(*cpuid_40000000_eax, c->function); > > but I think it can be done later and doesn't need to hold this patch. > > Another question related to this: are the guests OK with leaves > 0x40000006..0x40000009 missing? They seem to be, however, after you've asked I'm leaning towards zeroing them 'just in case'. -- Vitaly