diff mbox

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

Message ID 1234885535-8332-1-git-send-email-amit.shah@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amit Shah Feb. 17, 2009, 3:45 p.m. UTC
host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value
of ecx before any call to the function.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu/qemu-kvm-x86.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Avi Kivity Feb. 17, 2009, 6:11 p.m. UTC | #1
Amit Shah wrote:
> host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value
> of ecx before any call to the function.
>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  qemu/qemu-kvm-x86.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
> index 5264015..b1e2da2 100644
> --- a/qemu/qemu-kvm-x86.c
> +++ b/qemu/qemu-kvm-x86.c
> @@ -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]; 
>   

Does this make any difference?  Neither function actually depends on ecx.
Amit Shah Feb. 18, 2009, 4:58 a.m. UTC | #2
On (Tue) Feb 17 2009 [18:11:55], Avi Kivity wrote:
> Amit Shah wrote:
>> host_cpuid now accepts a 'count' parameter for cpuid. Initialise the value
>> of ecx before any call to the function.
>>
>> Signed-off-by: Amit Shah <amit.shah@redhat.com>
>> ---
>>  qemu/qemu-kvm-x86.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
>> index 5264015..b1e2da2 100644
>> --- a/qemu/qemu-kvm-x86.c
>> +++ b/qemu/qemu-kvm-x86.c
>> @@ -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];   
>
> 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.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
index 5264015..b1e2da2 100644
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -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];