All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-10  8:02 ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-10  8:02 UTC (permalink / raw)
  To: avi, mtosatti, jan.kiszka, qemu-devel, mst
  Cc: karyjin, kvm, BrillyWu@viatech.com.cn

From: BrillyWu <brillywu@viatech.com.cn>

When KVM is running on VIA CPU with host cpu's model, the
feautures of VIA CPU will be passed into kvm guest by calling
the CPUID instruction for Centaur.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    3 +++
 target-i386/cpuid.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/kvm.c   |   15 +++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)

--- a/target-i386/cpu.h	2011-05-09 09:55:48.624885001 +0800
+++ b/target-i386/cpu.h	2011-05-09 09:48:53.704885019 +0800
@@ -721,6 +721,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     int cpuid_vendor_override;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t cpuid_xlevel2;
+    uint32_t cpuid_ext4_features;

     /* MTRRs */
     uint64_t mtrr_fixed[11];
--- a/target-i386/cpuid.c	2011-05-09 09:31:11.754884991 +0800
+++ b/target-i386/cpuid.c	2011-05-09 10:18:46.204885008 +0800
@@ -230,6 +230,9 @@ typedef struct x86_def_t {
     char model_id[48];
     int vendor_override;
     uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
 } x86_def_t;

 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
@@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
     cpu_x86_fill_model_id(x86_cpu_def->model_id);
     x86_cpu_def->vendor_override = 0;

+    /* Call Centaur's CPUID instruction. */
+    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
+    x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
+    x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
+        host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
+        if (eax >= 0xC0000001) {
+            /* Support VIA max extended level */
+            x86_cpu_def->xlevel2 = eax;
+            host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
+            x86_cpu_def->ext4_features = edx;
+        }
+    }

     /*
      * Every SVM feature requires emulation support in KVM - so we can't just
@@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
     env->cpuid_xlevel = def->xlevel;
     env->cpuid_kvm_features = def->kvm_features;
     env->cpuid_svm_features = def->svm_features;
+    env->cpuid_ext4_features = def->ext4_features;
+    env->cpuid_xlevel2 = def->xlevel2;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
@@ -1034,7 +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
                    uint32_t *ecx, uint32_t *edx)
 {
     /* test if maximum index reached */
-    if (index & 0x80000000) {
+    if ((index & 0xC000000f) == index) {
+        /* Handle the Centaur's CPUID instruction. */
+        if (index > env->cpuid_xlevel2) {
+            index = env->cpuid_xlevel2;
+        }
+    } else if (index & 0x80000000) {
         if (index > env->cpuid_xlevel)
             index = env->cpuid_level;
     } else {
@@ -1256,6 +1278,28 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 		*edx = 0;
 	}
         break;
+    case 0xC0000000:
+        *eax = env->cpuid_xlevel2;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
+    case 0xC0000001:
+        /* Support for VIA CPU's CPUID instruction */
+        *eax = env->cpuid_version;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = env->cpuid_ext4_features;
+        break;
+    case 0xC0000002:
+    case 0xC0000003:
+    case 0xC0000004:
+        /* Reserved for the future, and now filled with zero */
+        *eax = 0;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
     default:
         /* reserved values: zero */
         *eax = 0;
--- a/target-i386/kvm.c	2011-05-09 09:31:04.284884996 +0800
+++ b/target-i386/kvm.c	2011-05-09 09:55:42.984885014 +0800
@@ -492,6 +492,21 @@ int kvm_arch_init_vcpu(CPUState *env)
         cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
     }

+    /* Call Centaur's CPUID instructions they are supported. */
+    if (env->cpuid_xlevel2 > 0) {
+        env->cpuid_ext4_features &=
+            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+        cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
+
+        for (i = 0xC0000000; i <= limit; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+
+            c->function = i;
+            c->flags = 0;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+        }
+    }
+
     cpuid_data.cpuid.nent = cpuid_i;

 #ifdef KVM_CAP_MCE

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

* [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-10  8:02 ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-10  8:02 UTC (permalink / raw)
  To: avi, mtosatti, jan.kiszka, qemu-devel, mst
  Cc: karyjin, kvm, BrillyWu@viatech.com.cn

From: BrillyWu <brillywu@viatech.com.cn>

When KVM is running on VIA CPU with host cpu's model, the
feautures of VIA CPU will be passed into kvm guest by calling
the CPUID instruction for Centaur.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    3 +++
 target-i386/cpuid.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/kvm.c   |   15 +++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)

--- a/target-i386/cpu.h	2011-05-09 09:55:48.624885001 +0800
+++ b/target-i386/cpu.h	2011-05-09 09:48:53.704885019 +0800
@@ -721,6 +721,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     int cpuid_vendor_override;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t cpuid_xlevel2;
+    uint32_t cpuid_ext4_features;

     /* MTRRs */
     uint64_t mtrr_fixed[11];
--- a/target-i386/cpuid.c	2011-05-09 09:31:11.754884991 +0800
+++ b/target-i386/cpuid.c	2011-05-09 10:18:46.204885008 +0800
@@ -230,6 +230,9 @@ typedef struct x86_def_t {
     char model_id[48];
     int vendor_override;
     uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
 } x86_def_t;

 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
@@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
     cpu_x86_fill_model_id(x86_cpu_def->model_id);
     x86_cpu_def->vendor_override = 0;

+    /* Call Centaur's CPUID instruction. */
+    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
+    x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
+    x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
+        host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
+        if (eax >= 0xC0000001) {
+            /* Support VIA max extended level */
+            x86_cpu_def->xlevel2 = eax;
+            host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
+            x86_cpu_def->ext4_features = edx;
+        }
+    }

     /*
      * Every SVM feature requires emulation support in KVM - so we can't just
@@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
     env->cpuid_xlevel = def->xlevel;
     env->cpuid_kvm_features = def->kvm_features;
     env->cpuid_svm_features = def->svm_features;
+    env->cpuid_ext4_features = def->ext4_features;
+    env->cpuid_xlevel2 = def->xlevel2;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
@@ -1034,7 +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
                    uint32_t *ecx, uint32_t *edx)
 {
     /* test if maximum index reached */
-    if (index & 0x80000000) {
+    if ((index & 0xC000000f) == index) {
+        /* Handle the Centaur's CPUID instruction. */
+        if (index > env->cpuid_xlevel2) {
+            index = env->cpuid_xlevel2;
+        }
+    } else if (index & 0x80000000) {
         if (index > env->cpuid_xlevel)
             index = env->cpuid_level;
     } else {
@@ -1256,6 +1278,28 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 		*edx = 0;
 	}
         break;
+    case 0xC0000000:
+        *eax = env->cpuid_xlevel2;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
+    case 0xC0000001:
+        /* Support for VIA CPU's CPUID instruction */
+        *eax = env->cpuid_version;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = env->cpuid_ext4_features;
+        break;
+    case 0xC0000002:
+    case 0xC0000003:
+    case 0xC0000004:
+        /* Reserved for the future, and now filled with zero */
+        *eax = 0;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
     default:
         /* reserved values: zero */
         *eax = 0;
--- a/target-i386/kvm.c	2011-05-09 09:31:04.284884996 +0800
+++ b/target-i386/kvm.c	2011-05-09 09:55:42.984885014 +0800
@@ -492,6 +492,21 @@ int kvm_arch_init_vcpu(CPUState *env)
         cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
     }

+    /* Call Centaur's CPUID instructions they are supported. */
+    if (env->cpuid_xlevel2 > 0) {
+        env->cpuid_ext4_features &=
+            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+        cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
+
+        for (i = 0xC0000000; i <= limit; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+
+            c->function = i;
+            c->flags = 0;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+        }
+    }
+
     cpuid_data.cpuid.nent = cpuid_i;

 #ifdef KVM_CAP_MCE

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-10  8:02 ` [Qemu-devel] " BrillyWu
@ 2011-05-11 11:50   ` Avi Kivity
  -1 siblings, 0 replies; 28+ messages in thread
From: Avi Kivity @ 2011-05-11 11:50 UTC (permalink / raw)
  To: BrillyWu
  Cc: kvm, karyjin, mst, mtosatti, BrillyWu@viatech.com.cn, qemu-devel,
	jan.kiszka

On 05/10/2011 11:02 AM, BrillyWu wrote:
> From: BrillyWu<brillywu@viatech.com.cn>
>
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
>

Applied, thanks.

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

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-11 11:50   ` Avi Kivity
  0 siblings, 0 replies; 28+ messages in thread
From: Avi Kivity @ 2011-05-11 11:50 UTC (permalink / raw)
  To: BrillyWu
  Cc: kvm, karyjin, mst, mtosatti, BrillyWu@viatech.com.cn, qemu-devel,
	jan.kiszka

On 05/10/2011 11:02 AM, BrillyWu wrote:
> From: BrillyWu<brillywu@viatech.com.cn>
>
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
>

Applied, thanks.

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

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-10  8:02 ` [Qemu-devel] " BrillyWu
@ 2011-05-28 10:28   ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-28 10:28 UTC (permalink / raw)
  To: BrillyWu
  Cc: avi, mtosatti, qemu-devel, mst, karyjin, kvm, BrillyWu@viatech.com.cn

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

On 2011-05-10 10:02, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
> 
> Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
> Signed-off-by: KaryJin<karyjin@viatech.com.cn>
> ---
>  target-i386/cpu.h   |    3 +++
>  target-i386/cpuid.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
>  target-i386/kvm.c   |   15 +++++++++++++++
>  3 files changed, 63 insertions(+), 1 deletion(-)
> 
> --- a/target-i386/cpu.h	2011-05-09 09:55:48.624885001 +0800
> +++ b/target-i386/cpu.h	2011-05-09 09:48:53.704885019 +0800
> @@ -721,6 +721,9 @@ typedef struct CPUX86State {
>      uint32_t cpuid_ext3_features;
>      uint32_t cpuid_apic_id;
>      int cpuid_vendor_override;
> +    /* Store the results of Centaur's CPUID instructions */
> +    uint32_t cpuid_xlevel2;
> +    uint32_t cpuid_ext4_features;
> 
>      /* MTRRs */
>      uint64_t mtrr_fixed[11];
> --- a/target-i386/cpuid.c	2011-05-09 09:31:11.754884991 +0800
> +++ b/target-i386/cpuid.c	2011-05-09 10:18:46.204885008 +0800
> @@ -230,6 +230,9 @@ typedef struct x86_def_t {
>      char model_id[48];
>      int vendor_override;
>      uint32_t flags;
> +    /* Store the results of Centaur's CPUID instructions */
> +    uint32_t ext4_features;
> +    uint32_t xlevel2;
>  } x86_def_t;
> 
>  #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
> @@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
>      cpu_x86_fill_model_id(x86_cpu_def->model_id);
>      x86_cpu_def->vendor_override = 0;
> 
> +    /* Call Centaur's CPUID instruction. */
> +    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
> +    x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
> +    x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {

CPUID_VENDOR_VIA_* definitions in target-i386/cpu.h are missing so that
this patch breaks current uq/master build. Please fix.

Thanks,
Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-28 10:28   ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-28 10:28 UTC (permalink / raw)
  To: BrillyWu
  Cc: karyjin, kvm, mst, mtosatti, BrillyWu@viatech.com.cn, qemu-devel, avi

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

On 2011-05-10 10:02, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
> 
> Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
> Signed-off-by: KaryJin<karyjin@viatech.com.cn>
> ---
>  target-i386/cpu.h   |    3 +++
>  target-i386/cpuid.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
>  target-i386/kvm.c   |   15 +++++++++++++++
>  3 files changed, 63 insertions(+), 1 deletion(-)
> 
> --- a/target-i386/cpu.h	2011-05-09 09:55:48.624885001 +0800
> +++ b/target-i386/cpu.h	2011-05-09 09:48:53.704885019 +0800
> @@ -721,6 +721,9 @@ typedef struct CPUX86State {
>      uint32_t cpuid_ext3_features;
>      uint32_t cpuid_apic_id;
>      int cpuid_vendor_override;
> +    /* Store the results of Centaur's CPUID instructions */
> +    uint32_t cpuid_xlevel2;
> +    uint32_t cpuid_ext4_features;
> 
>      /* MTRRs */
>      uint64_t mtrr_fixed[11];
> --- a/target-i386/cpuid.c	2011-05-09 09:31:11.754884991 +0800
> +++ b/target-i386/cpuid.c	2011-05-09 10:18:46.204885008 +0800
> @@ -230,6 +230,9 @@ typedef struct x86_def_t {
>      char model_id[48];
>      int vendor_override;
>      uint32_t flags;
> +    /* Store the results of Centaur's CPUID instructions */
> +    uint32_t ext4_features;
> +    uint32_t xlevel2;
>  } x86_def_t;
> 
>  #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
> @@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
>      cpu_x86_fill_model_id(x86_cpu_def->model_id);
>      x86_cpu_def->vendor_override = 0;
> 
> +    /* Call Centaur's CPUID instruction. */
> +    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
> +    x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
> +    x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {

CPUID_VENDOR_VIA_* definitions in target-i386/cpu.h are missing so that
this patch breaks current uq/master build. Please fix.

Thanks,
Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-10  8:02 ` [Qemu-devel] " BrillyWu
@ 2011-05-28 16:20   ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-28 16:20 UTC (permalink / raw)
  To: BrillyWu
  Cc: avi, mtosatti, qemu-devel, mst, karyjin, kvm, BrillyWu@viatech.com.cn

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

On 2011-05-10 10:02, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
> 
> Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
> Signed-off-by: KaryJin<karyjin@viatech.com.cn>

...

> @@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
>      env->cpuid_xlevel = def->xlevel;
>      env->cpuid_kvm_features = def->kvm_features;
>      env->cpuid_svm_features = def->svm_features;
> +    env->cpuid_ext4_features = def->ext4_features;
> +    env->cpuid_xlevel2 = def->xlevel2;
>      if (!kvm_enabled()) {
>          env->cpuid_features &= TCG_FEATURES;
>          env->cpuid_ext_features &= TCG_EXT_FEATURES;
> @@ -1034,7 +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
>                     uint32_t *ecx, uint32_t *edx)
>  {
>      /* test if maximum index reached */
> -    if (index & 0x80000000) {
> +    if ((index & 0xC000000f) == index) {

This condition can't be correct. It triggers on every index <= 15 and
breaks qemu.

> +        /* Handle the Centaur's CPUID instruction. */
> +        if (index > env->cpuid_xlevel2) {
> +            index = env->cpuid_xlevel2;
> +        }
> +    } else if (index & 0x80000000) {

Your very first version looked like this:

-    if (index & 0x80000000) {
+    if ((index & 0xC0000000) == 0xC0000000) {
+	/* Handle the Centaur's CPUID instruction.*
+	* If cpuid_xlevel2 is "0", then put into the*
+	* default case. */
+	if (env->cpuid_xlevel2 == 0)
+	    index = 0xF0000000;
+	else if (index > env->cpuid_xlevel2)
+	    index = env->cpuid_xlevel2;
+    } else if (index & 0x80000000) {

Something went wrong here, please re-validate the patch carefully.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-28 16:20   ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-28 16:20 UTC (permalink / raw)
  To: BrillyWu
  Cc: karyjin, kvm, mst, mtosatti, BrillyWu@viatech.com.cn, qemu-devel, avi

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

On 2011-05-10 10:02, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> When KVM is running on VIA CPU with host cpu's model, the
> feautures of VIA CPU will be passed into kvm guest by calling
> the CPUID instruction for Centaur.
> 
> Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
> Signed-off-by: KaryJin<karyjin@viatech.com.cn>

...

> @@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
>      env->cpuid_xlevel = def->xlevel;
>      env->cpuid_kvm_features = def->kvm_features;
>      env->cpuid_svm_features = def->svm_features;
> +    env->cpuid_ext4_features = def->ext4_features;
> +    env->cpuid_xlevel2 = def->xlevel2;
>      if (!kvm_enabled()) {
>          env->cpuid_features &= TCG_FEATURES;
>          env->cpuid_ext_features &= TCG_EXT_FEATURES;
> @@ -1034,7 +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
>                     uint32_t *ecx, uint32_t *edx)
>  {
>      /* test if maximum index reached */
> -    if (index & 0x80000000) {
> +    if ((index & 0xC000000f) == index) {

This condition can't be correct. It triggers on every index <= 15 and
breaks qemu.

> +        /* Handle the Centaur's CPUID instruction. */
> +        if (index > env->cpuid_xlevel2) {
> +            index = env->cpuid_xlevel2;
> +        }
> +    } else if (index & 0x80000000) {

Your very first version looked like this:

-    if (index & 0x80000000) {
+    if ((index & 0xC0000000) == 0xC0000000) {
+	/* Handle the Centaur's CPUID instruction.*
+	* If cpuid_xlevel2 is "0", then put into the*
+	* default case. */
+	if (env->cpuid_xlevel2 == 0)
+	    index = 0xF0000000;
+	else if (index > env->cpuid_xlevel2)
+	    index = env->cpuid_xlevel2;
+    } else if (index & 0x80000000) {

Something went wrong here, please re-validate the patch carefully.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-28 16:20   ` [Qemu-devel] " Jan Kiszka
@ 2011-05-30  4:02     ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  4:02 UTC (permalink / raw)
  To: jan.kiszka, brillywu; +Cc: KaryJin, kvm, mst, mtosatti, qemu-devel, avi

Hi, Jan
> 
> > @@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
> >      env->cpuid_xlevel = def->xlevel;
> >      env->cpuid_kvm_features = def->kvm_features;
> >      env->cpuid_svm_features = def->svm_features;
> > +    env->cpuid_ext4_features = def->ext4_features;
> > +    env->cpuid_xlevel2 = def->xlevel2;
> >      if (!kvm_enabled()) {
> >          env->cpuid_features &= TCG_FEATURES;
> >          env->cpuid_ext_features &= TCG_EXT_FEATURES; @@ -1034,7
> > +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
> >                     uint32_t *ecx, uint32_t *edx)  {
> >      /* test if maximum index reached */
> > -    if (index & 0x80000000) {
> > +    if ((index & 0xC000000f) == index) {
> 
> This condition can't be correct. It triggers on every index <= 15 and 
> breaks qemu.

I'm so sorry to make such a stupid mistake. Thank you very for your revieview.

> 
> > +        /* Handle the Centaur's CPUID instruction. */
> > +        if (index > env->cpuid_xlevel2) {
> > +            index = env->cpuid_xlevel2;
> > +        }
> > +    } else if (index & 0x80000000) {
> 
> Your very first version looked like this:

The first version has some problem, so you could ignore it.

> 
> -    if (index & 0x80000000) {
> +    if ((index & 0xC0000000) == 0xC0000000) {
> +	/* Handle the Centaur's CPUID instruction.*
> +	* If cpuid_xlevel2 is "0", then put into the*
> +	* default case. */
> +	if (env->cpuid_xlevel2 == 0)
> +	    index = 0xF0000000;
> +	else if (index > env->cpuid_xlevel2)
> +	    index = env->cpuid_xlevel2;
> +    } else if (index & 0x80000000) {
> 
> Something went wrong here, please re-validate the patch carefully.

Ok, I will check it soon. 

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-30  4:02     ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  4:02 UTC (permalink / raw)
  To: jan.kiszka, brillywu; +Cc: KaryJin, kvm, mst, mtosatti, qemu-devel, avi

Hi, Jan
> 
> > @@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
> >      env->cpuid_xlevel = def->xlevel;
> >      env->cpuid_kvm_features = def->kvm_features;
> >      env->cpuid_svm_features = def->svm_features;
> > +    env->cpuid_ext4_features = def->ext4_features;
> > +    env->cpuid_xlevel2 = def->xlevel2;
> >      if (!kvm_enabled()) {
> >          env->cpuid_features &= TCG_FEATURES;
> >          env->cpuid_ext_features &= TCG_EXT_FEATURES; @@ -1034,7
> > +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
> >                     uint32_t *ecx, uint32_t *edx)  {
> >      /* test if maximum index reached */
> > -    if (index & 0x80000000) {
> > +    if ((index & 0xC000000f) == index) {
> 
> This condition can't be correct. It triggers on every index <= 15 and 
> breaks qemu.

I'm so sorry to make such a stupid mistake. Thank you very for your revieview.

> 
> > +        /* Handle the Centaur's CPUID instruction. */
> > +        if (index > env->cpuid_xlevel2) {
> > +            index = env->cpuid_xlevel2;
> > +        }
> > +    } else if (index & 0x80000000) {
> 
> Your very first version looked like this:

The first version has some problem, so you could ignore it.

> 
> -    if (index & 0x80000000) {
> +    if ((index & 0xC0000000) == 0xC0000000) {
> +	/* Handle the Centaur's CPUID instruction.*
> +	* If cpuid_xlevel2 is "0", then put into the*
> +	* default case. */
> +	if (env->cpuid_xlevel2 == 0)
> +	    index = 0xF0000000;
> +	else if (index > env->cpuid_xlevel2)
> +	    index = env->cpuid_xlevel2;
> +    } else if (index & 0x80000000) {
> 
> Something went wrong here, please re-validate the patch carefully.

Ok, I will check it soon. 

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-30  4:02     ` [Qemu-devel] " BrillyWu
@ 2011-05-30  7:40       ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  7:40 UTC (permalink / raw)
  To: jan.kiszka, BrillyWu; +Cc: avi, mtosatti, qemu-devel, mst, KaryJin, kvm

From: BrillyWu <brillywu@viatech.com.cn>

Hi, Jan
         I'm very sorry for these bugs in the patch. Now I have made a
new patch based on the
newest uq/master where the patch has been applied to fix these bugs,
is it feasible? If it is
not acceptable, should I re-generate a patch based on previous
uq/master, or what else?


Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    4 ++++
 target-i386/cpuid.c |   18 +++++++++++-------
 target-i386/2 files changed, 15 insertions(+), 7 deletions(-)

--- a/target-i386/cpu.h	2011-05-30 10:14:30.184533002 +0800
+++ b/target-i386/cpu.h	2011-05-30 10:41:45.704533001 +0800
@@ -441,6 +441,10 @@
 #define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */
 #define CPUID_VENDOR_AMD_3   0x444d4163 /* "cAMD" */

+#define CPUID_VENDOR_VIA_1   0x746e6543 /* "Cent" */
+#define CPUID_VENDOR_VIA_2   0x48727561 /* "aurH" */
+#define CPUID_VENDOR_VIA_3   0x736c7561 /* "auls" */
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */

--- a/target-i386/cpuid.c	2011-05-30 10:14:30.194533005 +0800
+++ b/target-i386/cpuid.c	2011-05-30 15:07:18.794532910 +0800
@@ -1051,14 +1051,18 @@ void cpu_x86_cpuid(CPUX86State *env, uin
                    uint32_t *ecx, uint32_t *edx)
 {
     /* test if maximum index reached */
-    if ((index & 0xC000000f) == index) {
-        /* Handle the Centaur's CPUID instruction. */
-        if (index > env->cpuid_xlevel2) {
-            index = env->cpuid_xlevel2;
+    if (index & 0x80000000) {
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
         }
-    } else if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-30  7:40       ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  7:40 UTC (permalink / raw)
  To: jan.kiszka, BrillyWu; +Cc: KaryJin, kvm, mst, mtosatti, qemu-devel, avi

From: BrillyWu <brillywu@viatech.com.cn>

Hi, Jan
         I'm very sorry for these bugs in the patch. Now I have made a
new patch based on the
newest uq/master where the patch has been applied to fix these bugs,
is it feasible? If it is
not acceptable, should I re-generate a patch based on previous
uq/master, or what else?


Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    4 ++++
 target-i386/cpuid.c |   18 +++++++++++-------
 target-i386/2 files changed, 15 insertions(+), 7 deletions(-)

--- a/target-i386/cpu.h	2011-05-30 10:14:30.184533002 +0800
+++ b/target-i386/cpu.h	2011-05-30 10:41:45.704533001 +0800
@@ -441,6 +441,10 @@
 #define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */
 #define CPUID_VENDOR_AMD_3   0x444d4163 /* "cAMD" */

+#define CPUID_VENDOR_VIA_1   0x746e6543 /* "Cent" */
+#define CPUID_VENDOR_VIA_2   0x48727561 /* "aurH" */
+#define CPUID_VENDOR_VIA_3   0x736c7561 /* "auls" */
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */

--- a/target-i386/cpuid.c	2011-05-30 10:14:30.194533005 +0800
+++ b/target-i386/cpuid.c	2011-05-30 15:07:18.794532910 +0800
@@ -1051,14 +1051,18 @@ void cpu_x86_cpuid(CPUX86State *env, uin
                    uint32_t *ecx, uint32_t *edx)
 {
     /* test if maximum index reached */
-    if ((index & 0xC000000f) == index) {
-        /* Handle the Centaur's CPUID instruction. */
-        if (index > env->cpuid_xlevel2) {
-            index = env->cpuid_xlevel2;
+    if (index & 0x80000000) {
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
         }
-    } else if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-30  7:40       ` [Qemu-devel] " BrillyWu
@ 2011-05-30  7:47         ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-30  7:47 UTC (permalink / raw)
  To: BrillyWu; +Cc: BrillyWu, avi, mtosatti, qemu-devel, mst, KaryJin, kvm

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

On 2011-05-30 09:40, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> Hi, Jan
>          I'm very sorry for these bugs in the patch. Now I have made a
> new patch based on the
> newest uq/master where the patch has been applied to fix these bugs,
> is it feasible? If it is
> not acceptable, should I re-generate a patch based on previous
> uq/master, or what else?

A clean patch (which passed checkpatch...) against uq/master without the
broken version is required. We can't push a non-bisectable series upstream.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-30  7:47         ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-30  7:47 UTC (permalink / raw)
  To: BrillyWu; +Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

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

On 2011-05-30 09:40, BrillyWu wrote:
> From: BrillyWu <brillywu@viatech.com.cn>
> 
> Hi, Jan
>          I'm very sorry for these bugs in the patch. Now I have made a
> new patch based on the
> newest uq/master where the patch has been applied to fix these bugs,
> is it feasible? If it is
> not acceptable, should I re-generate a patch based on previous
> uq/master, or what else?

A clean patch (which passed checkpatch...) against uq/master without the
broken version is required. We can't push a non-bisectable series upstream.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-30  7:40       ` [Qemu-devel] " BrillyWu
@ 2011-05-30  8:59         ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  8:59 UTC (permalink / raw)
  To: jan.kiszka, BrillyWu; +Cc: avi, mtosatti, qemu-devel, mst, KaryJin, kvm

>From BrillyWu@viatech.com.cn
Hi, Jan
        Thank you for you review and guide.
        I have fixed the bugs and re-generated a clean patch which has
been checked. It can be compiled
without any error and work normally.
        The patch v3 is here now.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    7 +++++++
 target-i386/cpuid.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 target-i386/kvm.c   |   15 +++++++++++++++
 3 files changed, 72 insertions(+), 2 deletions(-)

--- a/target-i386/cpu.h	2011-05-30 16:20:57.261342707 +0800
+++ b/target-i386/cpu.h	2011-05-30 10:41:45.704533001 +0800
@@ -441,6 +441,10 @@
 #define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */
 #define CPUID_VENDOR_AMD_3   0x444d4163 /* "cAMD" */

+#define CPUID_VENDOR_VIA_1   0x746e6543 /* "Cent" */
+#define CPUID_VENDOR_VIA_2   0x48727561 /* "aurH" */
+#define CPUID_VENDOR_VIA_3   0x736c7561 /* "auls" */
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */

@@ -730,6 +734,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     int cpuid_vendor_override;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t cpuid_xlevel2;
+    uint32_t cpuid_ext4_features;

     /* MTRRs */
     uint64_t mtrr_fixed[11];
--- a/target-i386/cpuid.c	2011-05-30 16:20:57.261342707 +0800
+++ b/target-i386/cpuid.c	2011-05-30 15:07:18.794532910 +0800
@@ -230,6 +230,9 @@ typedef struct x86_def_t {
     char model_id[48];
     int vendor_override;
     uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
 } x86_def_t;

 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
@@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
     cpu_x86_fill_model_id(x86_cpu_def->model_id);
     x86_cpu_def->vendor_override = 0;

+    /* Call Centaur's CPUID instruction. */
+    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
+        x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
+        x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
+        host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
+        if (eax >= 0xC0000001) {
+            /* Support VIA max extended level */
+            x86_cpu_def->xlevel2 = eax;
+            host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
+            x86_cpu_def->ext4_features = edx;
+        }
+    }

     /*
      * Every SVM feature requires emulation support in KVM - so we can't just
@@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
     env->cpuid_xlevel = def->xlevel;
     env->cpuid_kvm_features = def->kvm_features;
     env->cpuid_svm_features = def->svm_features;
+    env->cpuid_ext4_features = def->ext4_features;
+    env->cpuid_xlevel2 = def->xlevel2;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
@@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 {
     /* test if maximum index reached */
     if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
+        }
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;
@@ -1231,6 +1257,28 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 		*edx = 0;
 	}
         break;
+    case 0xC0000000:
+        *eax = env->cpuid_xlevel2;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
+    case 0xC0000001:
+        /* Support for VIA CPU's CPUID instruction */
+        *eax = env->cpuid_version;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = env->cpuid_ext4_features;
+        break;
+    case 0xC0000002:
+    case 0xC0000003:
+    case 0xC0000004:
+        /* Reserved for the future, and now filled with zero */
+        *eax = 0;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
     default:
         /* reserved values: zero */
         *eax = 0;
--- a/target-i386/kvm.c	2011-05-30 16:21:05.431342033 +0800
+++ b/target-i386/kvm.c	2011-05-30 10:16:03.284532914 +0800
@@ -482,6 +482,21 @@ int kvm_arch_init_vcpu(CPUState *env)
         cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
     }

+    /* Call Centaur's CPUID instructions they are supported. */
+    if (env->cpuid_xlevel2 > 0) {
+        env->cpuid_ext4_features &=
+            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+        cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
+
+        for (i = 0xC0000000; i <= limit; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+
+            c->function = i;
+            c->flags = 0;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+        }
+    }
+
     cpuid_data.cpuid.nent = cpuid_i;

 #ifdef KVM_CAP_MCE

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-30  8:59         ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-30  8:59 UTC (permalink / raw)
  To: jan.kiszka, BrillyWu; +Cc: KaryJin, kvm, mst, mtosatti, qemu-devel, avi

>From BrillyWu@viatech.com.cn
Hi, Jan
        Thank you for you review and guide.
        I have fixed the bugs and re-generated a clean patch which has
been checked. It can be compiled
without any error and work normally.
        The patch v3 is here now.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 target-i386/cpu.h   |    7 +++++++
 target-i386/cpuid.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 target-i386/kvm.c   |   15 +++++++++++++++
 3 files changed, 72 insertions(+), 2 deletions(-)

--- a/target-i386/cpu.h	2011-05-30 16:20:57.261342707 +0800
+++ b/target-i386/cpu.h	2011-05-30 10:41:45.704533001 +0800
@@ -441,6 +441,10 @@
 #define CPUID_VENDOR_AMD_2   0x69746e65 /* "enti" */
 #define CPUID_VENDOR_AMD_3   0x444d4163 /* "cAMD" */

+#define CPUID_VENDOR_VIA_1   0x746e6543 /* "Cent" */
+#define CPUID_VENDOR_VIA_2   0x48727561 /* "aurH" */
+#define CPUID_VENDOR_VIA_3   0x736c7561 /* "auls" */
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */

@@ -730,6 +734,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     int cpuid_vendor_override;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t cpuid_xlevel2;
+    uint32_t cpuid_ext4_features;

     /* MTRRs */
     uint64_t mtrr_fixed[11];
--- a/target-i386/cpuid.c	2011-05-30 16:20:57.261342707 +0800
+++ b/target-i386/cpuid.c	2011-05-30 15:07:18.794532910 +0800
@@ -230,6 +230,9 @@ typedef struct x86_def_t {
     char model_id[48];
     int vendor_override;
     uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
 } x86_def_t;

 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
@@ -522,6 +525,18 @@ static int cpu_x86_fill_host(x86_def_t *
     cpu_x86_fill_model_id(x86_cpu_def->model_id);
     x86_cpu_def->vendor_override = 0;

+    /* Call Centaur's CPUID instruction. */
+    if (x86_cpu_def->vendor1 == CPUID_VENDOR_VIA_1 &&
+        x86_cpu_def->vendor2 == CPUID_VENDOR_VIA_2 &&
+        x86_cpu_def->vendor3 == CPUID_VENDOR_VIA_3) {
+        host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
+        if (eax >= 0xC0000001) {
+            /* Support VIA max extended level */
+            x86_cpu_def->xlevel2 = eax;
+            host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
+            x86_cpu_def->ext4_features = edx;
+        }
+    }

     /*
      * Every SVM feature requires emulation support in KVM - so we can't just
@@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
     env->cpuid_xlevel = def->xlevel;
     env->cpuid_kvm_features = def->kvm_features;
     env->cpuid_svm_features = def->svm_features;
+    env->cpuid_ext4_features = def->ext4_features;
+    env->cpuid_xlevel2 = def->xlevel2;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
@@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 {
     /* test if maximum index reached */
     if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
+        }
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;
@@ -1231,6 +1257,28 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 		*edx = 0;
 	}
         break;
+    case 0xC0000000:
+        *eax = env->cpuid_xlevel2;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
+    case 0xC0000001:
+        /* Support for VIA CPU's CPUID instruction */
+        *eax = env->cpuid_version;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = env->cpuid_ext4_features;
+        break;
+    case 0xC0000002:
+    case 0xC0000003:
+    case 0xC0000004:
+        /* Reserved for the future, and now filled with zero */
+        *eax = 0;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
     default:
         /* reserved values: zero */
         *eax = 0;
--- a/target-i386/kvm.c	2011-05-30 16:21:05.431342033 +0800
+++ b/target-i386/kvm.c	2011-05-30 10:16:03.284532914 +0800
@@ -482,6 +482,21 @@ int kvm_arch_init_vcpu(CPUState *env)
         cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
     }

+    /* Call Centaur's CPUID instructions they are supported. */
+    if (env->cpuid_xlevel2 > 0) {
+        env->cpuid_ext4_features &=
+            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+        cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
+
+        for (i = 0xC0000000; i <= limit; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+
+            c->function = i;
+            c->flags = 0;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+        }
+    }
+
     cpuid_data.cpuid.nent = cpuid_i;

 #ifdef KVM_CAP_MCE

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-30  8:59         ` [Qemu-devel] " BrillyWu
@ 2011-05-30 10:45           ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-30 10:45 UTC (permalink / raw)
  To: BrillyWu; +Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

On 2011-05-30 10:59, BrillyWu wrote:
> From BrillyWu@viatech.com.cn
> Hi, Jan
>         Thank you for you review and guide.
>         I have fixed the bugs and re-generated a clean patch which has
> been checked. It can be compiled
> without any error and work normally.
>         The patch v3 is here now.

The above text can't be used as a commit log, so this needs to be fixed.
Moreover, your patch still contains at least on style issues
scripts/checkpatch.pl should have caught. Are you sure you ran it?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-30 10:45           ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-30 10:45 UTC (permalink / raw)
  To: BrillyWu; +Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

On 2011-05-30 10:59, BrillyWu wrote:
> From BrillyWu@viatech.com.cn
> Hi, Jan
>         Thank you for you review and guide.
>         I have fixed the bugs and re-generated a clean patch which has
> been checked. It can be compiled
> without any error and work normally.
>         The patch v3 is here now.

The above text can't be used as a commit log, so this needs to be fixed.
Moreover, your patch still contains at least on style issues
scripts/checkpatch.pl should have caught. Are you sure you ran it?

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-30 10:45           ` [Qemu-devel] " Jan Kiszka
@ 2011-05-31  1:25             ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  1:25 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: BrillyWu, avi, mtosatti, qemu-devel, mst, KaryJin, kvm

Hi, Jan

> patch which has
> > been checked. It can be compiled without any error and work
> normally.
> >         The patch v3 is here now.
>
> The above text can't be used as a commit log, so this needs to be
> fixed.
> Moreover, your patch still contains at least on style issues
> scripts/checkpatch.pl should have caught. Are you sure you ran it?
>

I am sure I have checked it with the scripts/checkpatch.pl, and it
shows no error or warning. Maybe I should check whether my windows
editor and  mail client can work well before sending it to you. I 'm
sorry.
OK, I will use the previous commit log, and send it to you in the new thread.

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-31  1:25             ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  1:25 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

Hi, Jan

> patch which has
> > been checked. It can be compiled without any error and work
> normally.
> >         The patch v3 is here now.
>
> The above text can't be used as a commit log, so this needs to be
> fixed.
> Moreover, your patch still contains at least on style issues
> scripts/checkpatch.pl should have caught. Are you sure you ran it?
>

I am sure I have checked it with the scripts/checkpatch.pl, and it
shows no error or warning. Maybe I should check whether my windows
editor and  mail client can work well before sending it to you. I 'm
sorry.
OK, I will use the previous commit log, and send it to you in the new thread.

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-31  1:25             ` [Qemu-devel] " BrillyWu
@ 2011-05-31  6:11               ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-31  6:11 UTC (permalink / raw)
  To: BrillyWu, Blue Swirl
  Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

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

On 2011-05-31 03:25, BrillyWu wrote:
> Hi, Jan
> 
>> patch which has
>>> been checked. It can be compiled without any error and work
>> normally.
>>>         The patch v3 is here now.
>>
>> The above text can't be used as a commit log, so this needs to be
>> fixed.
>> Moreover, your patch still contains at least on style issues
>> scripts/checkpatch.pl should have caught. Are you sure you ran it?
>>
> 
> I am sure I have checked it with the scripts/checkpatch.pl, and it
> shows no error or warning. Maybe I should check whether my windows
> editor and  mail client can work well before sending it to you. I 'm
> sorry.

Sorry, you are right. Your patch revealed a bug in the checkpatch script.

Blue, this does not trigger the missing braces warning:

@@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 {
     /* test if maximum index reached */
     if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
+        }
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;


> OK, I will use the previous commit log, and send it to you in the new thread.

Thanks. I think it would be fair to fix up the braces on commit now.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-31  6:11               ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-31  6:11 UTC (permalink / raw)
  To: BrillyWu, Blue Swirl
  Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, avi

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

On 2011-05-31 03:25, BrillyWu wrote:
> Hi, Jan
> 
>> patch which has
>>> been checked. It can be compiled without any error and work
>> normally.
>>>         The patch v3 is here now.
>>
>> The above text can't be used as a commit log, so this needs to be
>> fixed.
>> Moreover, your patch still contains at least on style issues
>> scripts/checkpatch.pl should have caught. Are you sure you ran it?
>>
> 
> I am sure I have checked it with the scripts/checkpatch.pl, and it
> shows no error or warning. Maybe I should check whether my windows
> editor and  mail client can work well before sending it to you. I 'm
> sorry.

Sorry, you are right. Your patch revealed a bug in the checkpatch script.

Blue, this does not trigger the missing braces warning:

@@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin
 {
     /* test if maximum index reached */
     if (index & 0x80000000) {
-        if (index > env->cpuid_xlevel)
-            index = env->cpuid_level;
+        if (index > env->cpuid_xlevel) {
+            if (env->cpuid_xlevel2 > 0) {
+                /* Handle the Centaur's CPUID instruction. */
+                if (index > env->cpuid_xlevel2) {
+                    index = env->cpuid_xlevel2;
+                } else if (index < 0xC0000000) {
+                    index = env->cpuid_xlevel;
+                }
+            } else
+                index =  env->cpuid_xlevel;
+        }
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;


> OK, I will use the previous commit log, and send it to you in the new thread.

Thanks. I think it would be fair to fix up the braces on commit now.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-31  6:11               ` [Qemu-devel] " Jan Kiszka
@ 2011-05-31  7:39                 ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  7:39 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Blue Swirl, BrillyWu, avi, mtosatti, qemu-devel, mst, KaryJin, kvm

Hi, Jan

> > I am sure I have checked it with the scripts/checkpatch.pl, and it
> > shows no error or warning. Maybe I should check whether my windows
> > editor and  mail client can work well before sending it to
> you. I 'm
> > sorry.
>
> Sorry, you are right. Your patch revealed a bug in the checkpatch
> script.
>
> Blue, this does not trigger the missing braces warning:

Do you mean the bug is that it can not trigger missing braces warining?
It seems that there is no missing braces in my patch, but some
unnecessary braces.

>
> @@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin  {
>      /* test if maximum index reached */
>      if (index & 0x80000000) {
> -        if (index > env->cpuid_xlevel)
> -            index = env->cpuid_level;
> +        if (index > env->cpuid_xlevel) {
> +            if (env->cpuid_xlevel2 > 0) {
> +                /* Handle the Centaur's CPUID instruction. */
> +                if (index > env->cpuid_xlevel2) {
> +                    index = env->cpuid_xlevel2;
> +                } else if (index < 0xC0000000) {
> +                    index = env->cpuid_xlevel;
> +                }
> +            } else
> +                index =  env->cpuid_xlevel;
> +        }
>      } else {
>          if (index > env->cpuid_level)
>              index = env->cpuid_level;
>
>
> > OK, I will use the previous commit log, and send it to you
> in the new thread.
>
> Thanks. I think it would be fair to fix up the braces on commit now.

It looks that there are some unnecessary braces, but if I remove them,
the script/checkpatch.pl will report warnings. Could I ignore it?
BTW, I have submited a patch v3 a few minutes before withou fixing up
the braces, and I have tested it with my mail client this time, so it
could be OK now.

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-31  7:39                 ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  7:39 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, Blue Swirl, avi

Hi, Jan

> > I am sure I have checked it with the scripts/checkpatch.pl, and it
> > shows no error or warning. Maybe I should check whether my windows
> > editor and  mail client can work well before sending it to
> you. I 'm
> > sorry.
>
> Sorry, you are right. Your patch revealed a bug in the checkpatch
> script.
>
> Blue, this does not trigger the missing braces warning:

Do you mean the bug is that it can not trigger missing braces warining?
It seems that there is no missing braces in my patch, but some
unnecessary braces.

>
> @@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin  {
>      /* test if maximum index reached */
>      if (index & 0x80000000) {
> -        if (index > env->cpuid_xlevel)
> -            index = env->cpuid_level;
> +        if (index > env->cpuid_xlevel) {
> +            if (env->cpuid_xlevel2 > 0) {
> +                /* Handle the Centaur's CPUID instruction. */
> +                if (index > env->cpuid_xlevel2) {
> +                    index = env->cpuid_xlevel2;
> +                } else if (index < 0xC0000000) {
> +                    index = env->cpuid_xlevel;
> +                }
> +            } else
> +                index =  env->cpuid_xlevel;
> +        }
>      } else {
>          if (index > env->cpuid_level)
>              index = env->cpuid_level;
>
>
> > OK, I will use the previous commit log, and send it to you
> in the new thread.
>
> Thanks. I think it would be fair to fix up the braces on commit now.

It looks that there are some unnecessary braces, but if I remove them,
the script/checkpatch.pl will report warnings. Could I ignore it?
BTW, I have submited a patch v3 a few minutes before withou fixing up
the braces, and I have tested it with my mail client this time, so it
could be OK now.

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-31  7:39                 ` [Qemu-devel] " BrillyWu
@ 2011-05-31  7:50                   ` Jan Kiszka
  -1 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-31  7:50 UTC (permalink / raw)
  To: BrillyWu
  Cc: Blue Swirl, BrillyWu, avi, mtosatti, qemu-devel, mst, KaryJin, kvm

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

On 2011-05-31 09:39, BrillyWu wrote:
> Hi, Jan
> 
>>> I am sure I have checked it with the scripts/checkpatch.pl, and it
>>> shows no error or warning. Maybe I should check whether my windows
>>> editor and  mail client can work well before sending it to
>> you. I 'm
>>> sorry.
>>
>> Sorry, you are right. Your patch revealed a bug in the checkpatch
>> script.
>>
>> Blue, this does not trigger the missing braces warning:
> 
> Do you mean the bug is that it can not trigger missing braces warining?

The script fails to detect missing braces as marked below.

> It seems that there is no missing braces in my patch, but some
> unnecessary braces.

There are no unnecessary braces according to QEMU coding style.

> 
>>
>> @@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin  {
>>      /* test if maximum index reached */
>>      if (index & 0x80000000) {
>> -        if (index > env->cpuid_xlevel)
>> -            index = env->cpuid_level;
>> +        if (index > env->cpuid_xlevel) {
>> +            if (env->cpuid_xlevel2 > 0) {
>> +                /* Handle the Centaur's CPUID instruction. */
>> +                if (index > env->cpuid_xlevel2) {
>> +                    index = env->cpuid_xlevel2;
>> +                } else if (index < 0xC0000000) {
>> +                    index = env->cpuid_xlevel;
>> +                }
>> +            } else
>> +                index =  env->cpuid_xlevel;

This should be:

    } else {
        index = ...
    }

>> +        }
>>      } else {
>>          if (index > env->cpuid_level)
>>              index = env->cpuid_level;
>>
>>
>>> OK, I will use the previous commit log, and send it to you
>> in the new thread.
>>
>> Thanks. I think it would be fair to fix up the braces on commit now.
> 
> It looks that there are some unnecessary braces, but if I remove them,
> the script/checkpatch.pl will report warnings. Could I ignore it?

Nope, see above.

> BTW, I have submited a patch v3 a few minutes before withou fixing up
> the braces, and I have tested it with my mail client this time, so it
> could be OK now.

Yes, your mail client works fine as far as I can see.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-31  7:50                   ` Jan Kiszka
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2011-05-31  7:50 UTC (permalink / raw)
  To: BrillyWu
  Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, Blue Swirl, avi

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

On 2011-05-31 09:39, BrillyWu wrote:
> Hi, Jan
> 
>>> I am sure I have checked it with the scripts/checkpatch.pl, and it
>>> shows no error or warning. Maybe I should check whether my windows
>>> editor and  mail client can work well before sending it to
>> you. I 'm
>>> sorry.
>>
>> Sorry, you are right. Your patch revealed a bug in the checkpatch
>> script.
>>
>> Blue, this does not trigger the missing braces warning:
> 
> Do you mean the bug is that it can not trigger missing braces warining?

The script fails to detect missing braces as marked below.

> It seems that there is no missing braces in my patch, but some
> unnecessary braces.

There are no unnecessary braces according to QEMU coding style.

> 
>>
>> @@ -1035,8 +1052,17 @@ void cpu_x86_cpuid(CPUX86State *env, uin  {
>>      /* test if maximum index reached */
>>      if (index & 0x80000000) {
>> -        if (index > env->cpuid_xlevel)
>> -            index = env->cpuid_level;
>> +        if (index > env->cpuid_xlevel) {
>> +            if (env->cpuid_xlevel2 > 0) {
>> +                /* Handle the Centaur's CPUID instruction. */
>> +                if (index > env->cpuid_xlevel2) {
>> +                    index = env->cpuid_xlevel2;
>> +                } else if (index < 0xC0000000) {
>> +                    index = env->cpuid_xlevel;
>> +                }
>> +            } else
>> +                index =  env->cpuid_xlevel;

This should be:

    } else {
        index = ...
    }

>> +        }
>>      } else {
>>          if (index > env->cpuid_level)
>>              index = env->cpuid_level;
>>
>>
>>> OK, I will use the previous commit log, and send it to you
>> in the new thread.
>>
>> Thanks. I think it would be fair to fix up the braces on commit now.
> 
> It looks that there are some unnecessary braces, but if I remove them,
> the script/checkpatch.pl will report warnings. Could I ignore it?

Nope, see above.

> BTW, I have submited a patch v3 a few minutes before withou fixing up
> the braces, and I have tested it with my mail client this time, so it
> could be OK now.

Yes, your mail client works fine as far as I can see.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

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

* Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
  2011-05-31  7:50                   ` [Qemu-devel] " Jan Kiszka
@ 2011-05-31  8:22                     ` BrillyWu
  -1 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  8:22 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Blue Swirl, BrillyWu, avi, mtosatti, qemu-devel, mst, KaryJin, kvm

> >> Blue, this does not trigger the missing braces warning:
> >
> > Do you mean the bug is that it can not trigger missing
> braces warining?
>
> The script fails to detect missing braces as marked below.
>
> > It seems that there is no missing braces in my patch, but some
> > unnecessary braces.
>
> There are no unnecessary braces according to QEMU coding style.

Oh, I see. Thank you!

> >> +                    index = env->cpuid_xlevel;
> >> +                }
> >> +            } else
> >> +                index =  env->cpuid_xlevel;
>
> This should be:
>
>     } else {
>         index = ...
>     }
>
> >> +        }
>
> Nope, see above.

It looks that I should add the missing braces.

>
> > BTW, I have submited a patch v3 a few minutes before withou
> fixing up
> > the braces, and I have tested it with my mail client this
> time, so it
> > could be OK now.
>
> Yes, your mail client works fine as far as I can see.

Yes, you are right. It seems to be the problem of my editor.

I'll check whether other places need any brace, and then send it to
the patch v3 thread.

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

* Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
@ 2011-05-31  8:22                     ` BrillyWu
  0 siblings, 0 replies; 28+ messages in thread
From: BrillyWu @ 2011-05-31  8:22 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: kvm, KaryJin, mst, mtosatti, BrillyWu, qemu-devel, Blue Swirl, avi

> >> Blue, this does not trigger the missing braces warning:
> >
> > Do you mean the bug is that it can not trigger missing
> braces warining?
>
> The script fails to detect missing braces as marked below.
>
> > It seems that there is no missing braces in my patch, but some
> > unnecessary braces.
>
> There are no unnecessary braces according to QEMU coding style.

Oh, I see. Thank you!

> >> +                    index = env->cpuid_xlevel;
> >> +                }
> >> +            } else
> >> +                index =  env->cpuid_xlevel;
>
> This should be:
>
>     } else {
>         index = ...
>     }
>
> >> +        }
>
> Nope, see above.

It looks that I should add the missing braces.

>
> > BTW, I have submited a patch v3 a few minutes before withou
> fixing up
> > the braces, and I have tested it with my mail client this
> time, so it
> > could be OK now.
>
> Yes, your mail client works fine as far as I can see.

Yes, you are right. It seems to be the problem of my editor.

I'll check whether other places need any brace, and then send it to
the patch v3 thread.

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

end of thread, other threads:[~2011-05-31  8:23 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-10  8:02 [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU BrillyWu
2011-05-10  8:02 ` [Qemu-devel] " BrillyWu
2011-05-11 11:50 ` Avi Kivity
2011-05-11 11:50   ` [Qemu-devel] " Avi Kivity
2011-05-28 10:28 ` Jan Kiszka
2011-05-28 10:28   ` [Qemu-devel] " Jan Kiszka
2011-05-28 16:20 ` Jan Kiszka
2011-05-28 16:20   ` [Qemu-devel] " Jan Kiszka
2011-05-30  4:02   ` BrillyWu
2011-05-30  4:02     ` [Qemu-devel] " BrillyWu
2011-05-30  7:40     ` BrillyWu
2011-05-30  7:40       ` [Qemu-devel] " BrillyWu
2011-05-30  7:47       ` Jan Kiszka
2011-05-30  7:47         ` [Qemu-devel] " Jan Kiszka
2011-05-30  8:59       ` BrillyWu
2011-05-30  8:59         ` [Qemu-devel] " BrillyWu
2011-05-30 10:45         ` Jan Kiszka
2011-05-30 10:45           ` [Qemu-devel] " Jan Kiszka
2011-05-31  1:25           ` BrillyWu
2011-05-31  1:25             ` [Qemu-devel] " BrillyWu
2011-05-31  6:11             ` Jan Kiszka
2011-05-31  6:11               ` [Qemu-devel] " Jan Kiszka
2011-05-31  7:39               ` BrillyWu
2011-05-31  7:39                 ` [Qemu-devel] " BrillyWu
2011-05-31  7:50                 ` Jan Kiszka
2011-05-31  7:50                   ` [Qemu-devel] " Jan Kiszka
2011-05-31  8:22                   ` BrillyWu
2011-05-31  8:22                     ` [Qemu-devel] " BrillyWu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.