All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: BrillyWu <brillywu@gmail.com>
Cc: avi@redhat.com, mtosatti@redhat.com, qemu-devel@nongnu.org,
	mst@redhat.com, karyjin@viatech.com.cn, kvm@vger.kernel.org,
	"BrillyWu@viatech.com.cn" <brillywu@viatech.com.cn>
Subject: Re: [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
Date: Sat, 28 May 2011 18:20:14 +0200	[thread overview]
Message-ID: <4DE120BE.1010602@web.de> (raw)
In-Reply-To: <BANLkTimzTSU7A-b9yc9H35b1szfL4z7H-A@mail.gmail.com>

[-- 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 --]

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@web.de>
To: BrillyWu <brillywu@gmail.com>
Cc: karyjin@viatech.com.cn, kvm@vger.kernel.org, mst@redhat.com,
	mtosatti@redhat.com,
	"BrillyWu@viatech.com.cn" <brillywu@viatech.com.cn>,
	qemu-devel@nongnu.org, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH uq/master V2] kvm: Add CPUID support for VIA CPU
Date: Sat, 28 May 2011 18:20:14 +0200	[thread overview]
Message-ID: <4DE120BE.1010602@web.de> (raw)
In-Reply-To: <BANLkTimzTSU7A-b9yc9H35b1szfL4z7H-A@mail.gmail.com>

[-- 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 --]

  parent reply	other threads:[~2011-05-28 16:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-05-28 16:20   ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DE120BE.1010602@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@redhat.com \
    --cc=brillywu@gmail.com \
    --cc=brillywu@viatech.com.cn \
    --cc=karyjin@viatech.com.cn \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.