Skip to contentSkip to conversation

qemu: Enable XSAVE related CPUID

PATCH In review Sheng Yang 2 participants 3 messages May 27, 2010 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 qemu: Enable XSAVE related CPUID

We can support it in KVM now. The initial values are the minimal requirement of XSAVE capable processor.

---
 target-i386/cpuid.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
target-i386/cpuid.c +32 -0
index eebf038..cbf5595 100644
@@ -1067,6 +1067,38 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ecx = 0;
         *edx = 0;
         break;
+    case 0xD:
+        /* Processor Extended State */
+        if (!(env->cpuid_ext_features & CPUID_EXT_XSAVE)) {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+            break;
+        }
+        if (count == 0) {
+            *eax = 0x7; /* FP | SSE | YMM */
+            *ebx = 0x340; /* FP + SSE + YMM size */
+            *ecx = 0x340; /* FP + SSE + YMM size */
+            *edx = 0;
+        } else if (count == 1) {
+            /* eax = 1, so we can continue with others */
+            *eax = 1;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        } else if (count == 2) {
+            *eax = 0x100; /* YMM size */
+            *ebx = 0x240; /* YMM offset */
+            *ecx = 0;
+            *edx = 0;
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
+        break;
     case 0x80000000:
         *eax = env->cpuid_xlevel;
         *ebx = env->cpuid_vendor1;
Signature · 1 line
1.7.0.1
#1 lore raw
Quoted 20 lines · Sheng Yang

We can support it in KVM now. The initial values are the minimal requirement of XSAVE capable processor.

---
  target-i386/cpuid.c |   32 ++++++++++++++++++++++++++++++++
  1 files changed, 32 insertions(+), 0 deletions(-)
target-i386/cpuid.c +4 -0
index eebf038..cbf5595 100644
@@ -1067,6 +1067,38 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
          *ecx = 0;
          *edx = 0;
          break;
+    case 0xD:
+        /* Processor Extended State */
+        if (!(env->cpuid_ext_features&  CPUID_EXT_XSAVE)) {
+            *eax = 0;

target-i386/cpuid.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, · line 1083

Quoted 10 lines
target-i386/cpuid.c +9 -0
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+            break;
+        }
+        if (count == 0) {
+            *eax = 0x7; /* FP | SSE | YMM */
+            *ebx = 0x340; /* FP + SSE + YMM size */
+            *ecx = 0x340; /* FP + SSE + YMM size */
 

For -cpu host, we should pick these from KVM_GET_SUPPORTED_CPUID. For canned cpu types (e.g. qemu64), we need to return what we always did.

We can also add a new cpu type that has them built in (there's no cpu on the market with avx, right?)

target-i386/cpuid.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,

Quoted 13 lines
target-i386/cpuid.c +12 -0
+            *edx = 0;
+        } else if (count == 1) {
+            /* eax = 1, so we can continue with others */
+            *eax = 1;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        } else if (count == 2) {
+            *eax = 0x100; /* YMM size */
+            *ebx = 0x240; /* YMM offset */
+            *ecx = 0;
+            *edx = 0;
 

These, too.

Quoted 11 lines
target-i386/cpuid.c +7 -0
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
+        break;
      case 0x80000000:
          *eax = env->cpuid_xlevel;
          *ebx = env->cpuid_vendor1;
Signature · 1 line
error compiling committee.c: too many arguments to function
author
#2 lore raw
Quoted 21 lines · On Thursday 27 May 2010 20:56:17 Avi Kivity wrote:
Quoted 20 lines · Sheng Yang

We can support it in KVM now. The initial values are the minimal requirement of XSAVE capable processor.

---

  target-i386/cpuid.c |   32 ++++++++++++++++++++++++++++++++
  1 files changed, 32 insertions(+), 0 deletions(-)
target-i386/cpuid.c +0 -0
index eebf038..cbf5595 100644
@@ -1067,6 +1067,38 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t
 index, uint32_t count,
 
          *ecx = 0;
          *edx = 0;
          break;
 
Quoted 16 lines

target-i386/cpuid.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, · line 1082

Quoted 13 lines
target-i386/cpuid.c +13 -0
+    case 0xD:
+        /* Processor Extended State */
+        if (!(env->cpuid_ext_features&  CPUID_EXT_XSAVE)) {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+            break;
+        }
+        if (count == 0) {
+            *eax = 0x7; /* FP | SSE | YMM */
+            *ebx = 0x340; /* FP + SSE + YMM size */
+            *ecx = 0x340; /* FP + SSE + YMM size */

For -cpu host, we should pick these from KVM_GET_SUPPORTED_CPUID. For canned cpu types (e.g. qemu64), we need to return what we always did.

Yes, I also prefer this way. didn't do this because it's somehow out of current QEmu CPUID setting mechanism.

Quoted 3 lines

We can also add a new cpu type that has them built in (there's no cpu on the market with avx, right?)

Right... Let's use -cpu host now.

Quoted 14 lines

target-i386/cpuid.c void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, · line 1094

Quoted 13 lines
target-i386/cpuid.c +12 -0
+            *edx = 0;
+        } else if (count == 1) {
+            /* eax = 1, so we can continue with others */
+            *eax = 1;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        } else if (count == 2) {
+            *eax = 0x100; /* YMM size */
+            *ebx = 0x240; /* YMM offset */
+            *ecx = 0;
+            *edx = 0;
Quoted 1 line

These, too.

Sure.

--
regards
Yang, Sheng

Quoted 12 lines
Quoted 12 lines
target-i386/cpuid.c +7 -0
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
+        break;
      case 0x80000000:
          *eax = env->cpuid_xlevel;
          *ebx = env->cpuid_vendor1;