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 <pbonz...@redhat.com>
---
  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

Reply via email to