From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C2DDC5B578 for ; Mon, 8 Jul 2019 07:05:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B4DC20844 for ; Mon, 8 Jul 2019 07:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729277AbfGHHFQ (ORCPT ); Mon, 8 Jul 2019 03:05:16 -0400 Received: from mga17.intel.com ([192.55.52.151]:63267 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfGHHFP (ORCPT ); Mon, 8 Jul 2019 03:05:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jul 2019 00:05:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,465,1557212400"; d="scan'208";a="167591766" Received: from liujing-mobl.ccr.corp.intel.com (HELO [10.238.129.57]) ([10.238.129.57]) by orsmga003.jf.intel.com with ESMTP; 08 Jul 2019 00:05:14 -0700 Subject: Re: [PATCH 1/5] KVM: cpuid: do_cpuid_ent works on a whole CPUID function References: <20190704140715.31181-1-pbonzini@redhat.com> <20190704140715.31181-2-pbonzini@redhat.com> From: Jing Liu To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Message-ID: <50fccadc-ad5c-6548-529d-412f68cab1f5@linux.intel.com> Date: Mon, 8 Jul 2019 15:05:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190704140715.31181-2-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paolo, On 7/4/2019 10:07 PM, Paolo Bonzini wrote: > Rename it as well as __do_cpuid_ent and __do_cpuid_ent_emulated to have > "func" in its name, and drop the index parameter which is always 0. > > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/cpuid.c | 89 +++++++++++++++++++++----------------------- > 1 file changed, 42 insertions(+), 47 deletions(-) > > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index 004cbd84c351..ddffc56c39b4 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -294,14 +294,19 @@ static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function, > { > entry->function = function; > entry->index = index; > + entry->flags = 0; > + I'm wondering if we need set entry->flags = 0 here? entry->flags was initialized as zero when vzalloc. > cpuid_count(entry->function, entry->index, > &entry->eax, &entry->ebx, &entry->ecx, &entry->edx); > - entry->flags = 0; > } > > -static int __do_cpuid_ent_emulated(struct kvm_cpuid_entry2 *entry, > - u32 func, u32 index, int *nent, int maxnent) > +static int __do_cpuid_func_emulated(struct kvm_cpuid_entry2 *entry, > + u32 func, int *nent, int maxnent) > { > + entry->function = func; > + entry->index = 0; > + entry->flags = 0; > + The same question for flags and index, because entry is allocated by vzalloc. > switch (func) { > case 0: > entry->eax = 7; > @@ -313,21 +318,18 @@ static int __do_cpuid_ent_emulated(struct kvm_cpuid_entry2 *entry, > break; > case 7: > entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; > - if (index == 0) > - entry->ecx = F(RDPID); > + entry->eax = 0; > + entry->ecx = F(RDPID); > ++*nent; > default: > break; > } > > - entry->function = func; > - entry->index = index; > - > return 0; > } > Thanks, Jing