qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

cpus: Move CPU code from exec.c to cpus-common.c

This code was introduced with SMP support in commit 6a00d60127,
later commit 267f685b8b moved CPU list management to common code
but forgot this code. Move now and simplify ifdef'ry.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200702104017.14057-1-philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Philippe Mathieu-Daudé and committed by
Paolo Bonzini
421a75e2 cbe0dad1

+18 -22
+18
cpus-common.c
··· 72 72 return max_cpu_index; 73 73 } 74 74 75 + CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); 76 + 75 77 void cpu_list_add(CPUState *cpu) 76 78 { 77 79 QEMU_LOCK_GUARD(&qemu_cpu_list_lock); ··· 95 97 QTAILQ_REMOVE_RCU(&cpus, cpu, node); 96 98 cpu->cpu_index = UNASSIGNED_CPU_INDEX; 97 99 } 100 + 101 + CPUState *qemu_get_cpu(int index) 102 + { 103 + CPUState *cpu; 104 + 105 + CPU_FOREACH(cpu) { 106 + if (cpu->cpu_index == index) { 107 + return cpu; 108 + } 109 + } 110 + 111 + return NULL; 112 + } 113 + 114 + /* current CPU in the current thread. It is only valid inside cpu_exec() */ 115 + __thread CPUState *current_cpu; 98 116 99 117 struct qemu_work_item { 100 118 QSIMPLEQ_ENTRY(qemu_work_item) node;
-22
exec.c
··· 98 98 static MemoryRegion io_mem_unassigned; 99 99 #endif 100 100 101 - CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); 102 - 103 - /* current CPU in the current thread. It is only valid inside 104 - cpu_exec() */ 105 - __thread CPUState *current_cpu; 106 - 107 101 uintptr_t qemu_host_page_size; 108 102 intptr_t qemu_host_page_mask; 109 103 ··· 832 826 } 833 827 }; 834 828 835 - #endif 836 - 837 - CPUState *qemu_get_cpu(int index) 838 - { 839 - CPUState *cpu; 840 - 841 - CPU_FOREACH(cpu) { 842 - if (cpu->cpu_index == index) { 843 - return cpu; 844 - } 845 - } 846 - 847 - return NULL; 848 - } 849 - 850 - #if !defined(CONFIG_USER_ONLY) 851 829 void cpu_address_space_init(CPUState *cpu, int asidx, 852 830 const char *prefix, MemoryRegion *mr) 853 831 {