kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* v2:  KVM: support for 'count' in CPUID functions 4, 0xb and 0xd.
@ 2009-01-13  7:09 Amit Shah
  2009-01-13  7:09 ` [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Amit Shah @ 2009-01-13  7:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm, aliguori

These two patches were sent separately earlier. There are a couple of
small changes in this version, including removal of a debug message that
was left behind.

Please apply.



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

* [PATCH] KVM: CPUID takes ecx as input value for some functions
  2009-01-13  7:09 v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Amit Shah
@ 2009-01-13  7:09 ` Amit Shah
  2009-01-13  7:09   ` [PATCH] KVM: Fetch sub-leaf cpuid values for functions 4, 0xb, 0xd Amit Shah
  2009-01-13  8:25 ` [Qemu-devel] v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Alexander Graf
  2009-01-13  9:56 ` [PATCH] Always return latest pmsts instead of the old one Zhang, Xiantao
  2 siblings, 1 reply; 13+ messages in thread
From: Amit Shah @ 2009-01-13  7:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm, aliguori, Amit Shah

The CPUID instruction takes the value of ECX as an input parameter
in addition to the value of EAX as the count for functions 4, 0xb
and 0xd. Make sure we pass the value to the instruction.

Also convert to the qemu-style whitespace for the surrounding code.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu/target-i386/cpu.h       |    2 +-
 qemu/target-i386/helper.c    |   34 +++++++++++++++++-----------------
 qemu/target-i386/kvm.c       |    8 ++++----
 qemu/target-i386/op_helper.c |    2 +-
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index 944e386..d9834db 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -743,7 +743,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo,
 int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
                              int is_write, int mmu_idx, int is_softmmu);
 void cpu_x86_set_a20(CPUX86State *env, int a20_state);
-void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
+void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx);
 
diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c
index cda0390..4c1e541 100644
--- a/qemu/target-i386/helper.c
+++ b/qemu/target-i386/helper.c
@@ -1377,7 +1377,8 @@ static void breakpoint_handler(CPUState *env)
 }
 #endif /* !CONFIG_USER_ONLY */
 
-static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
+static void host_cpuid(uint32_t function, uint32_t count,
+                       uint32_t *eax, uint32_t *ebx,
                        uint32_t *ecx, uint32_t *edx)
 {
 #if defined(CONFIG_KVM) || defined(USE_KVM)
@@ -1385,19 +1386,19 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 
 #ifdef __x86_64__
     asm volatile("cpuid"
-		 : "=a"(vec[0]), "=b"(vec[1]),
-		   "=c"(vec[2]), "=d"(vec[3])
-		 : "0"(function) : "cc");
+                 : "=a"(vec[0]), "=b"(vec[1]),
+                   "=c"(vec[2]), "=d"(vec[3])
+                 : "0"(function), "c"(count) : "cc");
 #else
     asm volatile("pusha \n\t"
-		 "cpuid \n\t"
-		 "mov %%eax, 0(%1) \n\t"
-		 "mov %%ebx, 4(%1) \n\t"
-		 "mov %%ecx, 8(%1) \n\t"
-		 "mov %%edx, 12(%1) \n\t"
-		 "popa"
-		 : : "a"(function), "S"(vec)
-		 : "memory", "cc");
+                 "cpuid \n\t"
+                 "mov %%eax, 0(%1) \n\t"
+                 "mov %%ebx, 4(%1) \n\t"
+                 "mov %%ecx, 8(%1) \n\t"
+                 "mov %%edx, 12(%1) \n\t"
+                 "popa"
+                 : : "a"(function), "c"(count), "S"(vec)
+                 : "memory", "cc");
 #endif
 
     if (eax)
@@ -1411,7 +1412,7 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 #endif
 }
 
-void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
+void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx)
 {
@@ -1436,7 +1437,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
          * actuall cpu, and say goodbye to migration between different vendors
          * is you use compatibility mode. */
         if (kvm_enabled())
-            host_cpuid(0, NULL, ebx, ecx, edx);
+            host_cpuid(0, 0, NULL, ebx, ecx, edx);
         break;
     case 1:
         *eax = env->cpuid_version;
@@ -1457,7 +1458,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
         break;
     case 4:
         /* cache info: needed for Core compatibility */
-        switch (*ecx) {
+        switch (count) {
             case 0: /* L1 dcache info */
                 *eax = 0x0000121;
                 *ebx = 0x1c0003f;
@@ -1483,7 +1484,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
                 *edx = 0;
                 break;
         }
-
         break;
     case 5:
         /* mwait info: needed for Core compatibility */
@@ -1528,7 +1528,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
         if (kvm_enabled()) {
             uint32_t h_eax, h_edx;
 
-            host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
+            host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx);
 
             /* disable CPU features that the host does not support */
 
diff --git a/qemu/target-i386/kvm.c b/qemu/target-i386/kvm.c
index f87bf36..bef3150 100644
--- a/qemu/target-i386/kvm.c
+++ b/qemu/target-i386/kvm.c
@@ -44,13 +44,13 @@ int kvm_arch_init_vcpu(CPUState *env)
 
     cpuid_i = 0;
 
-    cpu_x86_cpuid(env, 0, &eax, &ebx, &ecx, &edx);
+    cpu_x86_cpuid(env, 0, 0, &eax, &ebx, &ecx, &edx);
     limit = eax;
 
     for (i = 0; i <= limit; i++) {
         struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++];
 
-        cpu_x86_cpuid(env, i, &eax, &ebx, &ecx, &edx);
+        cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
         c->function = i;
         c->eax = eax;
         c->ebx = ebx;
@@ -58,13 +58,13 @@ int kvm_arch_init_vcpu(CPUState *env)
         c->edx = edx;
     }
 
-    cpu_x86_cpuid(env, 0x80000000, &eax, &ebx, &ecx, &edx);
+    cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx);
     limit = eax;
 
     for (i = 0x80000000; i <= limit; i++) {
         struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++];
 
-        cpu_x86_cpuid(env, i, &eax, &ebx, &ecx, &edx);
+        cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
         c->function = i;
         c->eax = eax;
         c->ebx = ebx;
diff --git a/qemu/target-i386/op_helper.c b/qemu/target-i386/op_helper.c
index 6e0e32e..74ba643 100644
--- a/qemu/target-i386/op_helper.c
+++ b/qemu/target-i386/op_helper.c
@@ -1898,7 +1898,7 @@ void helper_cpuid(void)
 
     helper_svm_check_intercept_param(SVM_EXIT_CPUID, 0);
 
-    cpu_x86_cpuid(env, (uint32_t)EAX, &eax, &ebx, &ecx, &edx);
+    cpu_x86_cpuid(env, (uint32_t)EAX, (uint32_t)ECX, &eax, &ebx, &ecx, &edx);
     EAX = eax;
     EBX = ebx;
     ECX = ecx;
-- 
1.6.0.6


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

* [PATCH] KVM: Fetch sub-leaf cpuid values for functions 4, 0xb, 0xd.
  2009-01-13  7:09 ` [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah
@ 2009-01-13  7:09   ` Amit Shah
  0 siblings, 0 replies; 13+ messages in thread
From: Amit Shah @ 2009-01-13  7:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm, aliguori, Amit Shah

CPUID functions 4, 0xb and 0xd have sub-leaf values which depend on the
input value of ECX. Store these values as well.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu/target-i386/kvm.c |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/qemu/target-i386/kvm.c b/qemu/target-i386/kvm.c
index bef3150..c17e58b 100644
--- a/qemu/target-i386/kvm.c
+++ b/qemu/target-i386/kvm.c
@@ -39,7 +39,7 @@ int kvm_arch_init_vcpu(CPUState *env)
         struct kvm_cpuid cpuid;
         struct kvm_cpuid_entry entries[100];
     } __attribute__((packed)) cpuid_data;
-    uint32_t limit, i, cpuid_i;
+    uint32_t limit, i, j, cpuid_i;
     uint32_t eax, ebx, ecx, edx;
 
     cpuid_i = 0;
@@ -50,14 +50,32 @@ int kvm_arch_init_vcpu(CPUState *env)
     for (i = 0; i <= limit; i++) {
         struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++];
 
-        cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
-        c->function = i;
-        c->eax = eax;
-        c->ebx = ebx;
-        c->ecx = ecx;
-        c->edx = edx;
+        if (i == 4 || i == 0xb || i == 0xd) {
+            for (j = 0; ; j++) {
+                cpu_x86_cpuid(env, i, j, &eax, &ebx, &ecx, &edx);
+                c->function = i;
+                c->eax = eax;
+                c->ebx = ebx;
+                c->ecx = ecx;
+                c->edx = edx;
+                c = &cpuid_data.entries[++cpuid_i];
+
+                if (i == 4 && eax == 0)
+                    break;
+                if (i == 0xb && !(ecx & 0xff00))
+                    break;
+                if (i == 0xd && eax == 0)
+                    break;
+            }
+        } else {
+            cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx);
+            c->function = i;
+            c->eax = eax;
+            c->ebx = ebx;
+            c->ecx = ecx;
+            c->edx = edx;
+        }
     }
-
     cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx);
     limit = eax;
 
-- 
1.6.0.6


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

* Re: [Qemu-devel] v2:  KVM: support for 'count' in CPUID functions 4, 0xb and 0xd.
  2009-01-13  7:09 v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Amit Shah
  2009-01-13  7:09 ` [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah
@ 2009-01-13  8:25 ` Alexander Graf
  2009-01-13  9:10   ` Amit Shah
  2009-01-13  9:56 ` [PATCH] Always return latest pmsts instead of the old one Zhang, Xiantao
  2 siblings, 1 reply; 13+ messages in thread
From: Alexander Graf @ 2009-01-13  8:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, avi, kvm


On 13.01.2009, at 08:09, Amit Shah wrote:

> These two patches were sent separately earlier. There are a couple of
> small changes in this version, including removal of a debug message  
> that
> was left behind.

Are you sure this actually implements the CPUID 4 leaf? I bet it  
simply submits multiple KVM_SET_CPUID ioctls, from which the kernel  
module picks the last one (0), not exposing _any_ cache information to  
the guest.

For exactly this purpose KVM_SET_CPUID2 was introduced quite a while  
ago, enabling support for all CPUID leaf flavors on the kernel side.  
Merely the userspace call is missing.

Nevertheless - thanks for taking onto this. Cpuid4 enabling is one of  
the (pretty low-prio) items on my TODO list for Mac OS X guest support.

Alex


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

* Re: [Qemu-devel] v2:  KVM: support for 'count' in CPUID functions 4, 0xb and 0xd.
  2009-01-13  8:25 ` [Qemu-devel] v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Alexander Graf
@ 2009-01-13  9:10   ` Amit Shah
  2009-01-13 11:06     ` Amit Shah
  0 siblings, 1 reply; 13+ messages in thread
From: Amit Shah @ 2009-01-13  9:10 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, aliguori, avi, kvm

On Tue, Jan 13, 2009 at 09:25:32AM +0100, Alexander Graf wrote:
>
> On 13.01.2009, at 08:09, Amit Shah wrote:
>
>> These two patches were sent separately earlier. There are a couple of
>> small changes in this version, including removal of a debug message  
>> that
>> was left behind.
>
> Are you sure this actually implements the CPUID 4 leaf? I bet it simply 
> submits multiple KVM_SET_CPUID ioctls, from which the kernel module picks 

I've also sent kernel patches to the kvm list.

Why do you think we submit multiple KVM_SET_CUPID calls, btw?

> the last one (0), not exposing _any_ cache information to the guest.

Please also see the kernel patches.

> For exactly this purpose KVM_SET_CPUID2 was introduced quite a while  
> ago, enabling support for all CPUID leaf flavors on the kernel side.  
> Merely the userspace call is missing.

We can do without using SET_CPUID2 (and hence not needing to do any
trickery for kernel-userspace version mismatches).

> Nevertheless - thanks for taking onto this. Cpuid4 enabling is one of  
> the (pretty low-prio) items on my TODO list for Mac OS X guest support.

Guess it'll work now. With these patches, not only does the "core2duo"
cpu type work with kvm, it also helps us get closer to use the "host"
cpu type. (Also, a simple userspace program in the guest that dumps
cpuid values indeed shows the correct values for all the sub-leaves for
function 4).

Amit

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

* [PATCH] Always return latest pmsts instead of the old one.
  2009-01-13  7:09 v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Amit Shah
  2009-01-13  7:09 ` [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah
  2009-01-13  8:25 ` [Qemu-devel] v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Alexander Graf
@ 2009-01-13  9:56 ` Zhang, Xiantao
  2009-01-15  6:27   ` Zhang, Xiantao
  2009-01-15 21:55   ` Anthony Liguori
  2 siblings, 2 replies; 13+ messages in thread
From: Zhang, Xiantao @ 2009-01-13  9:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: kvm, aliguori, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 915 bytes --]

For get_pmsts of acpi, it should always return latest value instead of the old one. 
Xiantao


From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Tue, 13 Jan 2009 17:42:16 +0800
Subject: [PATCH] Always return latest pmsts instead of the old one.

It may lead to the issue when booting windows guests with acpi=1
if return the old pmsts.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
 qemu/hw/acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index 0ff8851..8bde989 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
     d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
     if (d >= s->tmr_overflow_time)
         s->pmsts |= TMROF_EN;
-    return pmsts;
+    return s->pmsts;
 }
 
 static void pm_update_sci(PIIX4PMState *s)
-- 
1.6.0

[-- Attachment #2: 0001-Always-return-latest-pmsts-instead-of-the-old-one.patch --]
[-- Type: application/octet-stream, Size: 861 bytes --]

From 46d7994c0c263519b9603f8e5c7d2d2909a2fafe Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Tue, 13 Jan 2009 17:42:16 +0800
Subject: [PATCH] Always return latest pmsts instead of the old one.

It may lead to the issue when booting windows guests with acpi=1
if return the old pmsts.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
 qemu/hw/acpi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
index 0ff8851..8bde989 100644
--- a/qemu/hw/acpi.c
+++ b/qemu/hw/acpi.c
@@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
     d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
     if (d >= s->tmr_overflow_time)
         s->pmsts |= TMROF_EN;
-    return pmsts;
+    return s->pmsts;
 }
 
 static void pm_update_sci(PIIX4PMState *s)
-- 
1.6.0


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

* Re: [Qemu-devel] v2:  KVM: support for 'count' in CPUID functions 4, 0xb and 0xd.
  2009-01-13  9:10   ` Amit Shah
@ 2009-01-13 11:06     ` Amit Shah
  0 siblings, 0 replies; 13+ messages in thread
From: Amit Shah @ 2009-01-13 11:06 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, aliguori, avi, kvm

On Tue, Jan 13, 2009 at 02:40:53PM +0530, Amit Shah wrote:
> On Tue, Jan 13, 2009 at 09:25:32AM +0100, Alexander Graf wrote:

> > For exactly this purpose KVM_SET_CPUID2 was introduced quite a while  
> > ago, enabling support for all CPUID leaf flavors on the kernel side.  
> > Merely the userspace call is missing.
> 
> We can do without using SET_CPUID2 (and hence not needing to do any
> trickery for kernel-userspace version mismatches).

Avi points out that we can use SET_CPUID2 without version mismatches
because it was introduced in 2.6.25 and that is the min. kernel
requirement for userspace, so I'll send out a v3 that uses the
SET_CPUID2 interface and the kernel patches won't be necessary in that
case.

Amit

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

* RE: [PATCH] Always return latest pmsts instead of the old one.
  2009-01-13  9:56 ` [PATCH] Always return latest pmsts instead of the old one Zhang, Xiantao
@ 2009-01-15  6:27   ` Zhang, Xiantao
  2009-01-15 21:55   ` Anthony Liguori
  1 sibling, 0 replies; 13+ messages in thread
From: Zhang, Xiantao @ 2009-01-15  6:27 UTC (permalink / raw)
  To: Zhang, Xiantao, qemu-devel, blauwirbel; +Cc: kvm, aliguori, Avi Kivity

Any comments ?   

Zhang, Xiantao wrote:
> For get_pmsts of acpi, it should always return latest value instead
> of the old one. Xiantao
> 
> 
> From: Xiantao Zhang <xiantao.zhang@intel.com>
> Date: Tue, 13 Jan 2009 17:42:16 +0800
> Subject: [PATCH] Always return latest pmsts instead of the old one.
> 
> It may lead to the issue when booting windows guests with acpi=1
> if return the old pmsts.
> 
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> ---
>  qemu/hw/acpi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
> index 0ff8851..8bde989 100644
> --- a/qemu/hw/acpi.c
> +++ b/qemu/hw/acpi.c
> @@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>      if (d >= s->tmr_overflow_time)
>          s->pmsts |= TMROF_EN;
> -    return pmsts;
> +    return s->pmsts;
>  }
> 
>  static void pm_update_sci(PIIX4PMState *s)


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

* Re: [PATCH] Always return latest pmsts instead of the old one.
  2009-01-13  9:56 ` [PATCH] Always return latest pmsts instead of the old one Zhang, Xiantao
  2009-01-15  6:27   ` Zhang, Xiantao
@ 2009-01-15 21:55   ` Anthony Liguori
  2009-01-19 14:12     ` Zhang, Xiantao
  1 sibling, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2009-01-15 21:55 UTC (permalink / raw)
  To: Zhang, Xiantao; +Cc: qemu-devel, kvm, Avi Kivity

Zhang, Xiantao wrote:
> For get_pmsts of acpi, it should always return latest value instead of the old one. 
> Xiantao
>
>
> From: Xiantao Zhang <xiantao.zhang@intel.com>
> Date: Tue, 13 Jan 2009 17:42:16 +0800
> Subject: [PATCH] Always return latest pmsts instead of the old one.
>
> It may lead to the issue when booting windows guests with acpi=1
> if return the old pmsts.
>
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> ---
>  qemu/hw/acpi.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
>   

Please resubmit against QEMU, not kvm-userspace.

Regards,

Anthony Liguori

> index 0ff8851..8bde989 100644
> --- a/qemu/hw/acpi.c
> +++ b/qemu/hw/acpi.c
> @@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>      if (d >= s->tmr_overflow_time)
>          s->pmsts |= TMROF_EN;
> -    return pmsts;
> +    return s->pmsts;
>  }
>  
>  static void pm_update_sci(PIIX4PMState *s)
>   


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

* RE: [PATCH] Always return latest pmsts instead of the old one.
  2009-01-15 21:55   ` Anthony Liguori
@ 2009-01-19 14:12     ` Zhang, Xiantao
  2009-01-21  3:51       ` Zhang, Xiantao
  2009-01-21 16:35       ` Anthony Liguori
  0 siblings, 2 replies; 13+ messages in thread
From: Zhang, Xiantao @ 2009-01-19 14:12 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, kvm, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 1900 bytes --]

Attached the new patch, please check.
Xiantao


Subject: Always return latest pmsts instead of the old one.

It may lead to the issue when booting windows guests with acpi=1
if return the old pmsts.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>

Modified Paths:
--------------
    trunk/hw/acpi.c

Modified: trunk/hw/acpi.c
===================================================================

--- trunk/hw/acpi.c
+++ trunk/hw/acpi.c
@@ -92,7 +92,7 @@ static int get_pmsts(PIIX4PMState *s)
     d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
     if (d >= s->tmr_overflow_time)
         s->pmsts |= TMROF_EN;
-    return pmsts;
+    return s->pmsts;
 }
 
 static void pm_update_sci(PIIX4PMState *s)



Anthony Liguori wrote:
> Zhang, Xiantao wrote:
>> For get_pmsts of acpi, it should always return latest value instead
>> of the old one. Xiantao 
>> 
>> 
>> From: Xiantao Zhang <xiantao.zhang@intel.com>
>> Date: Tue, 13 Jan 2009 17:42:16 +0800
>> Subject: [PATCH] Always return latest pmsts instead of the old one.
>> 
>> It may lead to the issue when booting windows guests with acpi=1
>> if return the old pmsts.
>> 
>> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> ---
>>  qemu/hw/acpi.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
>> 
> 
> Please resubmit against QEMU, not kvm-userspace.
> 
> Regards,
> 
> Anthony Liguori
> 
>> index 0ff8851..8bde989 100644
>> --- a/qemu/hw/acpi.c
>> +++ b/qemu/hw/acpi.c
>> @@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
>>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>>      if (d >= s->tmr_overflow_time)
>>          s->pmsts |= TMROF_EN;
>> -    return pmsts;
>> +    return s->pmsts;
>>  }
>> 
>>  static void pm_update_sci(PIIX4PMState *s)


[-- Attachment #2: acpi_fix.patch --]
[-- Type: application/octet-stream, Size: 677 bytes --]

Subject: Always return latest pmsts instead of the old one.

It may lead to the issue when booting windows guests with acpi=1
if return the old pmsts.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>

Modified Paths:
--------------
    trunk/hw/acpi.c

Modified: trunk/hw/acpi.c
===================================================================

--- trunk/hw/acpi.c
+++ trunk/hw/acpi.c
@@ -92,7 +92,7 @@ static int get_pmsts(PIIX4PMState *s)
     d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
     if (d >= s->tmr_overflow_time)
         s->pmsts |= TMROF_EN;
-    return pmsts;
+    return s->pmsts;
 }
 
 static void pm_update_sci(PIIX4PMState *s)

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

* RE: [PATCH] Always return latest pmsts instead of the old one.
  2009-01-19 14:12     ` Zhang, Xiantao
@ 2009-01-21  3:51       ` Zhang, Xiantao
  2009-01-21 16:35       ` Anthony Liguori
  1 sibling, 0 replies; 13+ messages in thread
From: Zhang, Xiantao @ 2009-01-21  3:51 UTC (permalink / raw)
  To: Zhang, Xiantao, Anthony Liguori; +Cc: qemu-devel, kvm, Avi Kivity

 Any comments ?  If no, please help to check-in this patch. It blocks our work for a long time. Thanks!
Xiantao

-----Original Message-----
From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On Behalf Of Zhang, Xiantao
Sent: Monday, January 19, 2009 10:13 PM
To: Anthony Liguori
Cc: qemu-devel@nongnu.org; kvm@vger.kernel.org; Avi Kivity
Subject: RE: [PATCH] Always return latest pmsts instead of the old one.

Attached the new patch, please check.
Xiantao


Subject: Always return latest pmsts instead of the old one.

It may lead to the issue when booting windows guests with acpi=1
if return the old pmsts.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>

Modified Paths:
--------------
    trunk/hw/acpi.c

Modified: trunk/hw/acpi.c
===================================================================

--- trunk/hw/acpi.c
+++ trunk/hw/acpi.c
@@ -92,7 +92,7 @@ static int get_pmsts(PIIX4PMState *s)
     d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
     if (d >= s->tmr_overflow_time)
         s->pmsts |= TMROF_EN;
-    return pmsts;
+    return s->pmsts;
 }
 
 static void pm_update_sci(PIIX4PMState *s)



Anthony Liguori wrote:
> Zhang, Xiantao wrote:
>> For get_pmsts of acpi, it should always return latest value instead
>> of the old one. Xiantao 
>> 
>> 
>> From: Xiantao Zhang <xiantao.zhang@intel.com>
>> Date: Tue, 13 Jan 2009 17:42:16 +0800
>> Subject: [PATCH] Always return latest pmsts instead of the old one.
>> 
>> It may lead to the issue when booting windows guests with acpi=1
>> if return the old pmsts.
>> 
>> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> ---
>>  qemu/hw/acpi.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
>> 
> 
> Please resubmit against QEMU, not kvm-userspace.
> 
> Regards,
> 
> Anthony Liguori
> 
>> index 0ff8851..8bde989 100644
>> --- a/qemu/hw/acpi.c
>> +++ b/qemu/hw/acpi.c
>> @@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
>>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>>      if (d >= s->tmr_overflow_time)
>>          s->pmsts |= TMROF_EN;
>> -    return pmsts;
>> +    return s->pmsts;
>>  }
>> 
>>  static void pm_update_sci(PIIX4PMState *s)


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

* Re: [PATCH] Always return latest pmsts instead of the old one.
  2009-01-19 14:12     ` Zhang, Xiantao
  2009-01-21  3:51       ` Zhang, Xiantao
@ 2009-01-21 16:35       ` Anthony Liguori
  1 sibling, 0 replies; 13+ messages in thread
From: Anthony Liguori @ 2009-01-21 16:35 UTC (permalink / raw)
  To: Zhang, Xiantao; +Cc: qemu-devel, kvm, Avi Kivity

Zhang, Xiantao wrote:
> Attached the new patch, please check.
> Xiantao
>   

Applied.  Thanks.

Regards,

Anthony Liguori

> Subject: Always return latest pmsts instead of the old one.
>
> It may lead to the issue when booting windows guests with acpi=1
> if return the old pmsts.
>
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
>
> Modified Paths:
> --------------
>     trunk/hw/acpi.c
>
> Modified: trunk/hw/acpi.c
> ===================================================================
>
> --- trunk/hw/acpi.c
> +++ trunk/hw/acpi.c
> @@ -92,7 +92,7 @@ static int get_pmsts(PIIX4PMState *s)
>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>      if (d >= s->tmr_overflow_time)
>          s->pmsts |= TMROF_EN;
> -    return pmsts;
> +    return s->pmsts;
>  }
>  
>  static void pm_update_sci(PIIX4PMState *s)
>
>
>
> Anthony Liguori wrote:
>   
>> Zhang, Xiantao wrote:
>>     
>>> For get_pmsts of acpi, it should always return latest value instead
>>> of the old one. Xiantao 
>>>
>>>
>>> From: Xiantao Zhang <xiantao.zhang@intel.com>
>>> Date: Tue, 13 Jan 2009 17:42:16 +0800
>>> Subject: [PATCH] Always return latest pmsts instead of the old one.
>>>
>>> It may lead to the issue when booting windows guests with acpi=1
>>> if return the old pmsts.
>>>
>>> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com> ---
>>>  qemu/hw/acpi.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/qemu/hw/acpi.c b/qemu/hw/acpi.c
>>>
>>>       
>> Please resubmit against QEMU, not kvm-userspace.
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>     
>>> index 0ff8851..8bde989 100644
>>> --- a/qemu/hw/acpi.c
>>> +++ b/qemu/hw/acpi.c
>>> @@ -94,7 +94,7 @@ static int get_pmsts(PIIX4PMState *s)
>>>      d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
>>>      if (d >= s->tmr_overflow_time)
>>>          s->pmsts |= TMROF_EN;
>>> -    return pmsts;
>>> +    return s->pmsts;
>>>  }
>>>
>>>  static void pm_update_sci(PIIX4PMState *s)
>>>       
>
>   


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

* [PATCH] KVM: CPUID takes ecx as input value for some functions
@ 2009-01-12  8:10 Amit Shah
  0 siblings, 0 replies; 13+ messages in thread
From: Amit Shah @ 2009-01-12  8:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: avi, kvm, aliguori, Amit Shah

The CPUID instruction takes the value of ECX as an input parameter
in addition to the value of EAX as the count for functions 4 and 0xb.
Make sure we pass the value to the instruction.

Also convert to the qemu-style whitespace for the surrounding code.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu/target-i386/cpu.h       |    2 +-
 qemu/target-i386/helper.c    |   36 +++++++++++++++++++-----------------
 qemu/target-i386/op_helper.c |    2 +-
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index 944e386..d9834db 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -743,7 +743,7 @@ int cpu_x86_signal_handler(int host_signum, void *pinfo,
 int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
                              int is_write, int mmu_idx, int is_softmmu);
 void cpu_x86_set_a20(CPUX86State *env, int a20_state);
-void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
+void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx);
 
diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c
index cda0390..070c785 100644
--- a/qemu/target-i386/helper.c
+++ b/qemu/target-i386/helper.c
@@ -1377,7 +1377,8 @@ static void breakpoint_handler(CPUState *env)
 }
 #endif /* !CONFIG_USER_ONLY */
 
-static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
+static void host_cpuid(uint32_t function, uint32_t count,
+                       uint32_t *eax, uint32_t *ebx,
                        uint32_t *ecx, uint32_t *edx)
 {
 #if defined(CONFIG_KVM) || defined(USE_KVM)
@@ -1385,19 +1386,19 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 
 #ifdef __x86_64__
     asm volatile("cpuid"
-		 : "=a"(vec[0]), "=b"(vec[1]),
-		   "=c"(vec[2]), "=d"(vec[3])
-		 : "0"(function) : "cc");
+                 : "=a"(vec[0]), "=b"(vec[1]),
+                   "=c"(vec[2]), "=d"(vec[3])
+                 : "0"(function), "c"(count) : "cc");
 #else
     asm volatile("pusha \n\t"
-		 "cpuid \n\t"
-		 "mov %%eax, 0(%1) \n\t"
-		 "mov %%ebx, 4(%1) \n\t"
-		 "mov %%ecx, 8(%1) \n\t"
-		 "mov %%edx, 12(%1) \n\t"
-		 "popa"
-		 : : "a"(function), "S"(vec)
-		 : "memory", "cc");
+                 "cpuid \n\t"
+                 "mov %%eax, 0(%1) \n\t"
+                 "mov %%ebx, 4(%1) \n\t"
+                 "mov %%ecx, 8(%1) \n\t"
+                 "mov %%edx, 12(%1) \n\t"
+                 "popa"
+                 : : "a"(function), "c"(count), "S"(vec)
+                 : "memory", "cc");
 #endif
 
     if (eax)
@@ -1411,10 +1412,12 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx,
 #endif
 }
 
-void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
+void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx)
 {
+
+    fprintf(stderr, "cpuid requested, %x, ecx=%x\n", index, *ecx);
     /* test if maximum index reached */
     if (index & 0x80000000) {
         if (index > env->cpuid_xlevel)
@@ -1436,7 +1439,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
          * actuall cpu, and say goodbye to migration between different vendors
          * is you use compatibility mode. */
         if (kvm_enabled())
-            host_cpuid(0, NULL, ebx, ecx, edx);
+            host_cpuid(0, 0, NULL, ebx, ecx, edx);
         break;
     case 1:
         *eax = env->cpuid_version;
@@ -1457,7 +1460,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
         break;
     case 4:
         /* cache info: needed for Core compatibility */
-        switch (*ecx) {
+        switch (count) {
             case 0: /* L1 dcache info */
                 *eax = 0x0000121;
                 *ebx = 0x1c0003f;
@@ -1483,7 +1486,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
                 *edx = 0;
                 break;
         }
-
         break;
     case 5:
         /* mwait info: needed for Core compatibility */
@@ -1528,7 +1530,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
         if (kvm_enabled()) {
             uint32_t h_eax, h_edx;
 
-            host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);
+            host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx);
 
             /* disable CPU features that the host does not support */
 
diff --git a/qemu/target-i386/op_helper.c b/qemu/target-i386/op_helper.c
index 6e0e32e..74ba643 100644
--- a/qemu/target-i386/op_helper.c
+++ b/qemu/target-i386/op_helper.c
@@ -1898,7 +1898,7 @@ void helper_cpuid(void)
 
     helper_svm_check_intercept_param(SVM_EXIT_CPUID, 0);
 
-    cpu_x86_cpuid(env, (uint32_t)EAX, &eax, &ebx, &ecx, &edx);
+    cpu_x86_cpuid(env, (uint32_t)EAX, (uint32_t)ECX, &eax, &ebx, &ecx, &edx);
     EAX = eax;
     EBX = ebx;
     ECX = ecx;
-- 
1.6.0.6


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

end of thread, other threads:[~2009-01-21 16:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-13  7:09 v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Amit Shah
2009-01-13  7:09 ` [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah
2009-01-13  7:09   ` [PATCH] KVM: Fetch sub-leaf cpuid values for functions 4, 0xb, 0xd Amit Shah
2009-01-13  8:25 ` [Qemu-devel] v2: KVM: support for 'count' in CPUID functions 4, 0xb and 0xd Alexander Graf
2009-01-13  9:10   ` Amit Shah
2009-01-13 11:06     ` Amit Shah
2009-01-13  9:56 ` [PATCH] Always return latest pmsts instead of the old one Zhang, Xiantao
2009-01-15  6:27   ` Zhang, Xiantao
2009-01-15 21:55   ` Anthony Liguori
2009-01-19 14:12     ` Zhang, Xiantao
2009-01-21  3:51       ` Zhang, Xiantao
2009-01-21 16:35       ` Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2009-01-12  8:10 [PATCH] KVM: CPUID takes ecx as input value for some functions Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).