Skip to contentSkip to conversation

kvm: userspace: Initialise ECX value with 'count' as host_cpuid now expects it

PATCH In review Amit Shah 2 participants 3 messages Feb 17, 2009 – Feb 18, 2009 KVM

lore
Share & tools
lore

Amit Shah

author
#0 lore raw

PATCH 1/1 kvm: userspace: Initialise ECX value with 'count' as host_cpuid now expects it

host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value of ecx before any call to the function.

---
 qemu/qemu-kvm-x86.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +2 -0
index 5264015..b1e2da2 100644
@@ -534,6 +534,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 #endif
 
     copy.regs[R_EAX] = 0;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
 
@@ -559,6 +560,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     }
 
     copy.regs[R_EAX] = 0x80000000;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
 
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 21 lines · Amit Shah

host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value of ecx before any call to the function.

---
 qemu/qemu-kvm-x86.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +1 -0
index 5264015..b1e2da2 100644
@@ -534,6 +534,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 #endif
 
     copy.regs[R_EAX] = 0;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
 

qemu/qemu-kvm-x86.c int kvm_arch_qemu_init_env(CPUState *cenv) · line 566

Quoted 7 lines
qemu/qemu-kvm-x86.c +1 -0
@@ -559,6 +560,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     }
 
     copy.regs[R_EAX] = 0x80000000;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX]; 
 

Does this make any difference? Neither function actually depends on ecx.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
author
#2 lore raw
Quoted 19 lines · Avi Kivity
Quoted 18 lines · Amit Shah

host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value of ecx before any call to the function.

---
 qemu/qemu-kvm-x86.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +1 -0
index 5264015..b1e2da2 100644
@@ -534,6 +534,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
 #endif
      copy.regs[R_EAX] = 0;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
Quoted 8 lines
Quoted 6 lines
qemu/qemu-kvm-x86.c +0 -0
 @@ -559,6 +560,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     }
      copy.regs[R_EAX] = 0x80000000;
+    copy.regs[R_ECX] = 0;
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];   

Does this make any difference? Neither function actually depends on ecx.

No; it doesn't. But it's good practice to init all the data that a function takes as arguments.