Skip to contentSkip to conversation

cpustate patch

Qemu-devel Rafael Espíndola 2 participants 2 messages Sep 14, 2006

lore
Share & tools
lore
#0 lore raw

While hunting a tls related bug in ARM emulation, I found that that qemu distributed with scratchbox includes the attached patch.

Without the patch python's configure halts when checking for the -pthread option.

The patch inverts the order of the list and makes the code simpler. I think that there is a remaining problem, if first_cpu == NULL then env->cpu_index is not initialized. Should an else be added?

Any thoughts on the patch?

Thanks,
Rafael

Index: exec.c
===================================================================
RCS file: /sources/qemu/qemu/exec.c,v
retrieving revision 1.82

exec.c +6 -12
diff -u -r1.82 exec.c
@@ -256,23 +256,17 @@
 
 void cpu_exec_init(CPUState *env)
 {
-    CPUState **penv;
-    int cpu_index;
-
     if (!code_gen_ptr) {
         code_gen_ptr = code_gen_buffer;
         page_init();
         io_mem_init();
     }
-    env->next_cpu = NULL;
-    penv = &first_cpu;
-    cpu_index = 0;
-    while (*penv != NULL) {
-        penv = (CPUState **)&(*penv)->next_cpu;
-        cpu_index++;
-    }
-    env->cpu_index = cpu_index;
-    *penv = env;
+
+    if (first_cpu)
+      env->cpu_index = first_cpu->cpu_index + 1;
+
+    env->next_cpu = first_cpu;
+    first_cpu = env;
 }
 
 static inline void invalidate_page_bitmap(PageDesc *p)
#1 lore raw
Quoted 11 lines · Rafael Espíndola

While hunting a tls related bug in ARM emulation, I found that that qemu distributed with scratchbox includes the attached patch.

Without the patch python's configure halts when checking for the -pthread option.

The patch inverts the order of the list and makes the code simpler. I think that there is a remaining problem, if first_cpu == NULL then env->cpu_index is not initialized. Should an else be added?

Any thoughts on the patch?

For consistency I prefer that the first cpu of the list is number zero, so I prefer to leave the code as it is now.

Regards,

Fabrice.