Skip to contentSkip to conversation

target/i386: Remove core_id assert check in CPUID 0x8000001E

PATCH Applied Babu Moger 2 participants 2 messages Sep 21, 2020 – Sep 22, 2020

lore
Share & tools
lore

Babu Moger

author
#0 lore raw

PATCH v2 1/1 target/i386: Remove core_id assert check in CPUID 0x8000001E

With x2apic enabled, configurations can have more that 255 cores. Noticed the device add test is hitting an assert when during cpu hotplug with core_id > 255. This is due to assert check in the CPUID 0x8000001E.

Remove the assert check and fix the problem.

Fixes the bug:

---
v2:
Resubmitting an old patch which was lost in the mix. Just rebased on the latest tree.
v1:
https://lore.kernel.org/qemu-devel/[email protected]/

 target/i386/cpu.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
target/i386/cpu.c +8 -3
index 1c58f764dc..4f1d62c838 100644
@@ -5912,9 +5912,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         }
         break;
     case 0x8000001E:
-        assert(cpu->core_id <= 255);
-        encode_topo_cpuid8000001e(cpu, &topo_info,
-                                  eax, ebx, ecx, edx);
+        if (cpu->core_id <= 255) {
+            encode_topo_cpuid8000001e(cpu, &topo_info, eax, ebx, ecx, edx);
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
         break;
     case 0xC0000000:
         *eax = env->cpuid_xlevel2;
#1 lore raw
Quoted 11 lines · Babu Moger

With x2apic enabled, configurations can have more that 255 cores. Noticed the device add test is hitting an assert when during cpu hotplug with core_id > 255. This is due to assert check in the CPUID 0x8000001E.

Remove the assert check and fix the problem.

Fixes the bug:

Queued, thanks!

Quoted 33 lines

---
v2:
Resubmitting an old patch which was lost in the mix. Just rebased on the latest tree.
v1:
https://lore.kernel.org/qemu-devel/[email protected]/

 target/i386/cpu.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
target/i386/cpu.c +8 -3
index 1c58f764dc..4f1d62c838 100644
@@ -5912,9 +5912,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         }
         break;
     case 0x8000001E:
-        assert(cpu->core_id <= 255);
-        encode_topo_cpuid8000001e(cpu, &topo_info,
-                                  eax, ebx, ecx, edx);
+        if (cpu->core_id <= 255) {
+            encode_topo_cpuid8000001e(cpu, &topo_info, eax, ebx, ecx, edx);
+        } else {
+            *eax = 0;
+            *ebx = 0;
+            *ecx = 0;
+            *edx = 0;
+        }
         break;
     case 0xC0000000:
         *eax = env->cpuid_xlevel2;
Signature · 1 line
Eduardo