Re: [PATCH 1/5] KVM: cpuid: do_cpuid_ent works on a whole CPUID function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <pbonzini@xxxxxxxxxx>
---
  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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux