[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/9] exec: Don't use cpu_index to detect if cpu_exec_
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 2/9] exec: Don't use cpu_index to detect if cpu_exec_init()'s been called |
Date: |
Wed, 27 Jul 2016 11:29:14 -0300 |
From: Igor Mammedov <address@hidden>
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 <address@hidden>
Reported-by: David Gibson <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
exec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index 2f57c62..ae45a70 100644
--- a/exec.c
+++ b/exec.c
@@ -643,13 +643,14 @@ void cpu_exec_exit(CPUState *cpu)
CPUClass *cc = CPU_GET_CLASS(cpu);
cpu_list_lock();
- if (cpu->cpu_index == -1) {
- /* cpu_index was never allocated by this @cpu or was already freed. */
+ if (cpu->node.tqe_prev == NULL) {
+ /* there is nothing to undo since cpu_exec_init() hasn't been called */
cpu_list_unlock();
return;
}
QTAILQ_REMOVE(&cpus, cpu, node);
+ cpu->node.tqe_prev = NULL;
cpu_release_index(cpu);
cpu->cpu_index = -1;
cpu_list_unlock();
--
2.5.5
- [Qemu-devel] [PULL 0/9] x86 and machine queue, 2016-07-27, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 1/9] exec: Reduce CONFIG_USER_ONLY ifdeffenery, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 2/9] exec: Don't use cpu_index to detect if cpu_exec_init()'s been called,
Eduardo Habkost <=
- [Qemu-devel] [PULL 3/9] exec: Set cpu_index only if it's not been explictly set, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 4/9] qdev: Fix object reference leak in case device.realize() fails, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 6/9] Revert "pc: Enforce adding CPUs contiguously and removing them in opposite order", Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 5/9] pc: Init CPUState->cpu_index with index in possible_cpus[], Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 7/9] machine: Add comment to abort path in machine_set_kernel_irqchip, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 8/9] qdev: ignore GlobalProperty.errp for hotplugged devices, Eduardo Habkost, 2016/07/27
- [Qemu-devel] [PULL 9/9] vl: exit if a bad property value is passed to -global, Eduardo Habkost, 2016/07/27
- Re: [Qemu-devel] [PULL 0/9] x86 and machine queue, 2016-07-27, Peter Maydell, 2016/07/28