Instead of initializing cpu->as, cpu->thread_id, and reloading memory
map while holding cpu_list_lock(), do it earlier, before locking the CPU
list and initializing cpu_index.
This allows the code handling cpu_index and global CPU list to be
isolated from the rest.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
CPUState *some_cpu;
int cpu_index;
+#ifndef CONFIG_USER_ONLY
+ cpu->as = &address_space_memory;
+ cpu->thread_id = qemu_get_thread_id();
+ cpu_reload_memory_map(cpu);
+#endif
+
#if defined(CONFIG_USER_ONLY)
cpu_list_lock();
#endif
cpu_index++;
}
cpu->cpu_index = cpu_index;
-#ifndef CONFIG_USER_ONLY
- cpu->as = &address_space_memory;
- cpu->thread_id = qemu_get_thread_id();
- cpu_reload_memory_map(cpu);
-#endif
QTAILQ_INSERT_TAIL(&cpus, cpu, node);
#if defined(CONFIG_USER_ONLY)
cpu_list_unlock();