public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions
@ 2009-01-11 10:41 Amit Shah
  2009-01-11 10:46 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2009-01-11 10:41 UTC (permalink / raw)
  To: avi; +Cc: kvm, Amit Shah

The CPUID instruction takes the value of ECX as an input parameter
in addition to the value of EAX for function 4. Make sure we pass
the value to the instruction.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu/target-i386/helper.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c
index cda0390..e468366 100644
--- a/qemu/target-i386/helper.c
+++ b/qemu/target-i386/helper.c
@@ -1387,7 +1387,7 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
     asm volatile("cpuid"
 		 : "=a"(vec[0]), "=b"(vec[1]),
 		   "=c"(vec[2]), "=d"(vec[3])
-		 : "0"(function) : "cc");
+		 : "0"(function), "c"(*ecx) : "cc");
 #else
     asm volatile("pusha \n\t"
 		 "cpuid \n\t"
@@ -1396,7 +1396,7 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 		 "mov %%ecx, 8(%1) \n\t"
 		 "mov %%edx, 12(%1) \n\t"
 		 "popa"
-		 : : "a"(function), "S"(vec)
+		 : : "a"(function), "c"(*ecx), "S"(vec)
 		 : "memory", "cc");
 #endif
 
@@ -1483,7 +1483,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
                 *edx = 0;
                 break;
         }
-
         break;
     case 5:
         /* mwait info: needed for Core compatibility */
@@ -1526,9 +1525,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
         *edx = env->cpuid_ext2_features;
 
         if (kvm_enabled()) {
-            uint32_t h_eax, h_edx;
+            uint32_t h_eax, h_edx, h_ecx;
 
-            host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
+            host_cpuid(0x80000001, &h_eax, NULL, &h_ecx, &h_edx);
 
             /* disable CPU features that the host does not support */
 
-- 
1.6.0.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions
  2009-01-11 10:41 [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions Amit Shah
@ 2009-01-11 10:46 ` Avi Kivity
  2009-01-11 10:57   ` Amit Shah
  0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2009-01-11 10:46 UTC (permalink / raw)
  To: Amit Shah; +Cc: kvm

Amit Shah wrote:
> The CPUID instruction takes the value of ECX as an input parameter
> in addition to the value of EAX for function 4. Make sure we pass
> the value to the instruction.
>
>   

This needs to go to upstream qemu.  I'd suggest adding a new parameter 
rather than making ecx an in/out parameter.

I'd expect a loop when we use this...

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions
  2009-01-11 10:46 ` Avi Kivity
@ 2009-01-11 10:57   ` Amit Shah
  2009-01-11 11:23     ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Shah @ 2009-01-11 10:57 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Sun, Jan 11, 2009 at 12:46:49PM +0200, Avi Kivity wrote:
> Amit Shah wrote:
>> The CPUID instruction takes the value of ECX as an input parameter
>> in addition to the value of EAX for function 4. Make sure we pass
>> the value to the instruction.
>>
>>   
>
> This needs to go to upstream qemu.  I'd suggest adding a new parameter  
> rather than making ecx an in/out parameter.

You mean something like

host_cpuid(index, subindex, eax, ebx, ecx, edx);

?

>
> I'd expect a loop when we use this...

Why a loop? We'll only return the values true for a particular EAX:ECX
combination. The requestor (kernel) will loop.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions
  2009-01-11 10:57   ` Amit Shah
@ 2009-01-11 11:23     ` Avi Kivity
  0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2009-01-11 11:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: kvm

Amit Shah wrote:
> On Sun, Jan 11, 2009 at 12:46:49PM +0200, Avi Kivity wrote:
>   
>> Amit Shah wrote:
>>     
>>> The CPUID instruction takes the value of ECX as an input parameter
>>> in addition to the value of EAX for function 4. Make sure we pass
>>> the value to the instruction.
>>>
>>>   
>>>       
>> This needs to go to upstream qemu.  I'd suggest adding a new parameter  
>> rather than making ecx an in/out parameter.
>>     
>
> You mean something like
>
> host_cpuid(index, subindex, eax, ebx, ecx, edx);
>
> ?
>
>   

Yes.

>> I'd expect a loop when we use this...
>>     
>
> Why a loop? We'll only return the values true for a particular EAX:ECX
> combination. The requestor (kernel) will loop.
>   

The kernel doesn't call host_cpuid().  We preload all possible 
combinations of eax and ecx in advance.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-11 11:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-11 10:41 [PATCH] KVM: qemu: CPUID takes ecx as input value for some functions Amit Shah
2009-01-11 10:46 ` Avi Kivity
2009-01-11 10:57   ` Amit Shah
2009-01-11 11:23     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox