avoid creating a circular list of cpus
PATCH 1/1 avoid creating a circular list of cpus
The attached patch avoids creating a circular list of cpus in do_fork.
Currently, cpu_init returns a pointer to the last element of the list. This element is then overwritten by memcpy, including the cpu_index and next_cpu fields. The patch simply restores these fields to the correct values.
The circular list causes a test program to halt when cpu_exec_init is called again.
Best Regards,
Rafael
Index: linux-user/syscall.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.75
syscall.c +7 -0
@@ -1616,6 +1616,7 @@TaskState *ts;uint8_t *new_stack;CPUState *new_env; +int cpu_index;if (flags &CLONE_VM ) { ts =malloc (sizeof (TaskState) +NEW_STACK_SIZE );
@@ -1627,7 +1628,13 @@ first_task_state = ts;/* we create a new CPU instance. */ new_env =cpu_init (); + cpu_index = new_env->cpu_index;memcpy (new_env, env,sizeof (CPUState)); +//new_env is the end of the list + new_env->next_cpu =NULL ; + new_env->cpu_index = cpu_index; + +#if defined(TARGET_I386 )if (!newsp) newsp = env->regs[R_ESP ];