Skip to contentSkip to conversation

i386/cpu: Don't emulate L3 cache on 8000_001D if l3-cache is disabled

PATCH In review Yanan Wang via 2 participants 3 messages May 31, 2023 – Jun 9, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386/cpu: Don't emulate L3 cache on 8000_001D if l3-cache is disabled

Currently, we only avoid emulating L3 cache properties for AMD CPU when l3-cache is off, but failed to consider this case on CPUID 8000_001D. This result in a fact that we will still have L3 caches in the VM although we pass "host-cache-info=off,l3-cache=off" CLI to qemu.

Fixes 8f4202fb108 ("i386: Populate AMD Processor Cache Information for cpuid 0x8000001D")
---
 target/i386/cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target/i386/cpu.c +4 -2
index 1242bd541a..17c367c5ba 100644
@@ -6337,8 +6337,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                                        &topo_info, eax, ebx, ecx, edx);
             break;
         case 3: /* L3 cache info */
-            encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
-                                       &topo_info, eax, ebx, ecx, edx);
+            if (cpu->enable_l3_cache) {
+                encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
+                                           &topo_info, eax, ebx, ecx, edx);
+            }
             break;
         default: /* end of info */
             *eax = *ebx = *ecx = *edx = 0;
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Yanan Wang

Currently, we only avoid emulating L3 cache properties for AMD CPU when l3-cache is off, but failed to consider this case on CPUID 8000_001D. This result in a fact that we will still have L3 caches in the VM although we pass "host-cache-info=off,l3-cache=off" CLI to qemu.

Out of curiosity, do you have a valid real use case to run VM with "l3-cache = off"?

Quoted 23 lines
Fixes 8f4202fb108 ("i386: Populate AMD Processor Cache Information for cpuid 0x8000001D")
---
  target/i386/cpu.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
target/i386/cpu.c +4 -2
index 1242bd541a..17c367c5ba 100644
@@ -6337,8 +6337,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                                         &topo_info, eax, ebx, ecx, edx);
              break;
          case 3: /* L3 cache info */
-            encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
-                                       &topo_info, eax, ebx, ecx, edx);
+            if (cpu->enable_l3_cache) {
+                encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
+                                           &topo_info, eax, ebx, ecx, edx);
+            }
              break;
          default: /* end of info */
              *eax = *ebx = *ecx = *edx = 0;
#2 lore raw
Quoted 7 lines · Xiaoyao Li
Quoted 4 lines · Yanan Wang

Currently, we only avoid emulating L3 cache properties for AMD CPU when l3-cache is off, but failed to consider this case on CPUID 8000_001D. This result in a fact that we will still have L3 caches in the VM although we pass "host-cache-info=off,l3-cache=off" CLI to qemu.

Thanks.

Quoted 2 lines

Out of curiosity, do you have a valid real use case to run VM with "l3-cache = off"?

No, actually. This problem is found just in testing.

Yanan.

Quoted 28 lines
Quoted 26 lines
Fixes 8f4202fb108 ("i386: Populate AMD Processor Cache Information for cpuid 0x8000001D")

---
  target/i386/cpu.c | 6 ++++--

  1 file changed, 4 insertions(+), 2 deletions(-)
target/i386/cpu.c +0 -0
index 1242bd541a..17c367c5ba 100644
@@ -6337,8 +6337,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t 
 index, uint32_t count,
                                          &topo_info, eax, ebx, ecx, edx);
               break;

          case 3: /* L3 cache info */
- encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
-                                       &topo_info, eax, ebx, ecx, edx); +            if (cpu->enable_l3_cache) {
+ encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache,
+                                           &topo_info, eax, ebx, ecx, edx);
+            }
              break;
          default: /* end of info */
              *eax = *ebx = *ecx = *edx = 0;