Skip to contentSkip to conversation

x86: Fix Opteron xlevels

PATCH In review Alexander Graf 2 participants 6 messages Apr 21, 2015 – Apr 22, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Fix Opteron xlevels

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target-i386/cpu.c +3 -3
index 03b33cf..d1b1b8c 100644
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
             CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
             CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,
         .model_id = "AMD Opteron 240 (Gen 1 Class Opteron)",
     },
     {
@@ -1262,7 +1262,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_DE | CPUID_EXT2_FPU,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,
         .model_id = "AMD Opteron 22xx (Gen 2 Class Opteron)",
     },
     {
@@ -1292,7 +1292,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A |
             CPUID_EXT3_ABM | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x8000001A,
         .model_id = "AMD Opteron 23xx (Gen 3 Class Opteron)",
     },
     {
Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 10 lines · Alexander Graf

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

It needs compatibility properties in HW_COMPAT_2_1. See commit 6b11322e0f724eb0649fdc324a44288b783023ad for reference.

Quoted 9 lines
---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target-i386/cpu.c +0 -0
index 03b33cf..d1b1b8c 100644

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1237

Quoted 5 lines
target-i386/cpu.c +1 -1
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
             CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
             CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,

Why did you choose 0x80000018? The highest 0x80000000 leaf we implement today is 0x8000000A. SVM info is at 0x8000000A.

Quoted 25 lines
target-i386/cpu.c +2 -2
         .model_id = "AMD Opteron 240 (Gen 1 Class Opteron)",
     },
     {
@@ -1262,7 +1262,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_DE | CPUID_EXT2_FPU,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,
         .model_id = "AMD Opteron 22xx (Gen 2 Class Opteron)",
     },
     {
@@ -1292,7 +1292,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A |
             CPUID_EXT3_ABM | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x8000001A,
         .model_id = "AMD Opteron 23xx (Gen 3 Class Opteron)",
     },
     {
Signature · 1 line
1.7.12.4
Signature · 1 line
Eduardo
#2 lore raw
Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Alexander Graf

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

Quoted 8 lines
Quoted 6 lines

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

It needs compatibility properties in HW_COMPAT_2_1. See commit 6b11322e0f724eb0649fdc324a44288b783023ad for reference.

Ah, sure, will do.

Quoted 5 lines
Quoted 5 lines
---
  target-i386/cpu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 12 lines

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1237

Quoted 10 lines
target-i386/cpu.c +1 -1
index 03b33cf..d1b1b8c 100644
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
              CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
              CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
              CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,

Why did you choose 0x80000018? The highest 0x80000000 leaf we implement today is 0x8000000A. SVM info is at 0x8000000A.

Because it's what real hardware exposes ;).

Alex

Quoted 27 lines
Quoted 27 lines
target-i386/cpu.c +2 -2
          .model_id = "AMD Opteron 240 (Gen 1 Class Opteron)",
      },
      {
@@ -1262,7 +1262,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
              CPUID_EXT2_DE | CPUID_EXT2_FPU,
          .features[FEAT_8000_0001_ECX] =
              CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,
          .model_id = "AMD Opteron 22xx (Gen 2 Class Opteron)",
      },
      {
@@ -1292,7 +1292,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
          .features[FEAT_8000_0001_ECX] =
              CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A |
              CPUID_EXT3_ABM | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
-        .xlevel = 0x80000008,
+        .xlevel = 0x8000001A,
          .model_id = "AMD Opteron 23xx (Gen 3 Class Opteron)",
      },
      {
Signature · 1 line
1.7.12.4
#3 lore raw
Quoted 35 lines · Alexander Graf
Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Alexander Graf

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

Quoted 8 lines
Quoted 6 lines

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

It needs compatibility properties in HW_COMPAT_2_1. See commit 6b11322e0f724eb0649fdc324a44288b783023ad for reference.

Ah, sure, will do.

Quoted 5 lines
Quoted 5 lines
---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 12 lines

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1237

Quoted 10 lines
target-i386/cpu.c +1 -1
index 03b33cf..d1b1b8c 100644
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
             CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
             CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,

Why did you choose 0x80000018? The highest 0x80000000 leaf we implement today is 0x8000000A. SVM info is at 0x8000000A.

Quoted 1 line

Because it's what real hardware exposes ;).

Real hardware exposes 0x80000018 because it does return useful information in some of the 0x8000000B-0x80000018 leaves.

We don't return anything useful in CPUID leaves above 0x8000000a[1], so what exactly are you trying to do by reporting leaves 0x8000000B-0x80000018 as available?

[1] I don't even know what's present in those leaves. I will check the Intel and AMD docs right now.

Signature · 1 line
Eduardo
#4 lore raw
Quoted 33 lines · Eduardo Habkost
Quoted 32 lines · Alexander Graf
Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Alexander Graf

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

Quoted 8 lines
Quoted 6 lines

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

It needs compatibility properties in HW_COMPAT_2_1. See commit 6b11322e0f724eb0649fdc324a44288b783023ad for reference.

Ah, sure, will do.

Quoted 16 lines
Quoted 9 lines
---
  target-i386/cpu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
target-i386/cpu.c +0 -0
index 03b33cf..d1b1b8c 100644

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1237

Quoted 5 lines
target-i386/cpu.c +1 -1
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
              CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
              CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
              CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,

Why did you choose 0x80000018? The highest 0x80000000 leaf we implement today is 0x8000000A. SVM info is at 0x8000000A.

Quoted 7 lines
Quoted 1 line

Because it's what real hardware exposes ;).

Real hardware exposes 0x80000018 because it does return useful information in some of the 0x8000000B-0x80000018 leaves.

We don't return anything useful in CPUID leaves above 0x8000000a[1], so what exactly are you trying to do by reporting leaves 0x8000000B-0x80000018 as available?

Considering that the G4 Opteron exposes 0x1a I'd say we have that problem already. So if we want to fix the unpopulated leafs, we need to do that regardless.

Alex

Quoted 4 lines

[1] I don't even know what's present in those leaves. I will check the Intel and AMD docs right now.

#5 lore raw
Quoted 38 lines · Alexander Graf
Quoted 37 lines · Eduardo Habkost
Quoted 32 lines · Alexander Graf
Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Alexander Graf

The AMD Opteron family has different xlevel levels depending on the generation. I looked up Gen1, Gen2 and Gen3 hardware and adapted the levels according to real silicon.

Quoted 8 lines
Quoted 6 lines

The reason this came up is that there is a sanity check in KVM making sure that SVM is only used when xlevel is high enough. Using real hardware levels, they now are.

It needs compatibility properties in HW_COMPAT_2_1. See commit 6b11322e0f724eb0649fdc324a44288b783023ad for reference.

Ah, sure, will do.

Quoted 4 lines
Quoted 4 lines
---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 12 lines

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1237

Quoted 10 lines
target-i386/cpu.c +1 -1
index 03b33cf..d1b1b8c 100644
@@ -1234,7 +1234,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT2_MTRR | CPUID_EXT2_SYSCALL | CPUID_EXT2_APIC |
             CPUID_EXT2_CX8 | CPUID_EXT2_MCE | CPUID_EXT2_PAE | CPUID_EXT2_MSR |
             CPUID_EXT2_TSC | CPUID_EXT2_PSE | CPUID_EXT2_DE | CPUID_EXT2_FPU,
-        .xlevel = 0x80000008,
+        .xlevel = 0x80000018,

Why did you choose 0x80000018? The highest 0x80000000 leaf we implement today is 0x8000000A. SVM info is at 0x8000000A.

Quoted 1 line

Because it's what real hardware exposes ;).

Real hardware exposes 0x80000018 because it does return useful information in some of the 0x8000000B-0x80000018 leaves.

Quoted 7 lines
Quoted 3 lines

We don't return anything useful in CPUID leaves above 0x8000000a[1], so what exactly are you trying to do by reporting leaves 0x8000000B-0x80000018 as available?

Considering that the G4 Opteron exposes 0x1a I'd say we have that problem already. So if we want to fix the unpopulated leafs, we need to do that regardless.

True, and the issue isn't serious (see my reply to v2, most bits are reserved). But I would argue that making xlevel=0x1a on Opteron_G4 without an analysis of each of the new CPUID leaves was a mistake. All we get by increasing xlevel too much is is the false impression that we are getting closer to real hardware, when we are actually exposing more information that doesn't match real hardware to the guest.

Signature · 1 line
Eduardo