Skip to content

Commit

Permalink
cpus: Move CPU code from exec.c to cpus-common.c
Browse files Browse the repository at this point in the history
This code was introduced with SMP support in commit 6a00d60,
later commit 267f685 moved CPU list management to common code
but forgot this code. Move now and simplify ifdef'ry.

Reviewed-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
philmd authored and bonzini committed Jul 10, 2020
1 parent cbe0dad commit 421a75e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
18 changes: 18 additions & 0 deletions cpus-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ static int cpu_get_free_index(void)
return max_cpu_index;
}

CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);

void cpu_list_add(CPUState *cpu)
{
QEMU_LOCK_GUARD(&qemu_cpu_list_lock);
Expand All @@ -96,6 +98,22 @@ void cpu_list_remove(CPUState *cpu)
cpu->cpu_index = UNASSIGNED_CPU_INDEX;
}

CPUState *qemu_get_cpu(int index)
{
CPUState *cpu;

CPU_FOREACH(cpu) {
if (cpu->cpu_index == index) {
return cpu;
}
}

return NULL;
}

/* current CPU in the current thread. It is only valid inside cpu_exec() */
__thread CPUState *current_cpu;

struct qemu_work_item {
QSIMPLEQ_ENTRY(qemu_work_item) node;
run_on_cpu_func func;
Expand Down
22 changes: 0 additions & 22 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ AddressSpace address_space_memory;
static MemoryRegion io_mem_unassigned;
#endif

CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);

/* current CPU in the current thread. It is only valid inside
cpu_exec() */
__thread CPUState *current_cpu;

uintptr_t qemu_host_page_size;
intptr_t qemu_host_page_mask;

Expand Down Expand Up @@ -832,22 +826,6 @@ const VMStateDescription vmstate_cpu_common = {
}
};

#endif

CPUState *qemu_get_cpu(int index)
{
CPUState *cpu;

CPU_FOREACH(cpu) {
if (cpu->cpu_index == index) {
return cpu;
}
}

return NULL;
}

#if !defined(CONFIG_USER_ONLY)
void cpu_address_space_init(CPUState *cpu, int asidx,
const char *prefix, MemoryRegion *mr)
{
Expand Down

0 comments on commit 421a75e

Please sign in to comment.