mirror of https://github.com/xemu-project/xemu.git
exec: Don't use cpu_index to detect if cpu_exec_init()'s been called
Instead use QTAIL's tqe_prev field to detect if cpu's been placed in list by cpu_exec_init() which is always set if QTAIL element is in list. Fixes SIGSEGV on failure path in case cpu_index is assigned by board and cpu.relalize() fails before cpu_exec_init() is called. In follow up patches, cpu_index will be assigned by boards that support cpu hot(un)plug and need stable cpu_index that doesn't depend on order cpus are created/removed. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reported-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
1bc7e522d9
commit
8b1b835035
5
exec.c
5
exec.c
|
@ -643,13 +643,14 @@ void cpu_exec_exit(CPUState *cpu)
|
||||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||||
|
|
||||||
cpu_list_lock();
|
cpu_list_lock();
|
||||||
if (cpu->cpu_index == -1) {
|
if (cpu->node.tqe_prev == NULL) {
|
||||||
/* cpu_index was never allocated by this @cpu or was already freed. */
|
/* there is nothing to undo since cpu_exec_init() hasn't been called */
|
||||||
cpu_list_unlock();
|
cpu_list_unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_REMOVE(&cpus, cpu, node);
|
QTAILQ_REMOVE(&cpus, cpu, node);
|
||||||
|
cpu->node.tqe_prev = NULL;
|
||||||
cpu_release_index(cpu);
|
cpu_release_index(cpu);
|
||||||
cpu->cpu_index = -1;
|
cpu->cpu_index = -1;
|
||||||
cpu_list_unlock();
|
cpu_list_unlock();
|
||||||
|
|
Loading…
Reference in New Issue