Lines Matching full:cpu
55 #include "exec/cpu-common.h"
56 #include "hw/core/cpu.h"
57 #include "accel/accel-cpu-ops.h"
81 static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) in do_hvf_cpu_synchronize_state() argument
83 if (!cpu->vcpu_dirty) { in do_hvf_cpu_synchronize_state()
84 hvf_get_registers(cpu); in do_hvf_cpu_synchronize_state()
85 cpu->vcpu_dirty = true; in do_hvf_cpu_synchronize_state()
89 static void hvf_cpu_synchronize_state(CPUState *cpu) in hvf_cpu_synchronize_state() argument
91 if (!cpu->vcpu_dirty) { in hvf_cpu_synchronize_state()
92 run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL); in hvf_cpu_synchronize_state()
96 static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu, in do_hvf_cpu_synchronize_set_dirty() argument
100 cpu->vcpu_dirty = true; in do_hvf_cpu_synchronize_set_dirty()
103 static void hvf_cpu_synchronize_post_reset(CPUState *cpu) in hvf_cpu_synchronize_post_reset() argument
105 run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); in hvf_cpu_synchronize_post_reset()
108 static void hvf_cpu_synchronize_post_init(CPUState *cpu) in hvf_cpu_synchronize_post_init() argument
110 run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); in hvf_cpu_synchronize_post_init()
113 static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) in hvf_cpu_synchronize_pre_loadvm() argument
115 run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); in hvf_cpu_synchronize_pre_loadvm()
122 static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg) in do_hvf_get_vcpu_exec_time() argument
124 int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr); in do_hvf_get_vcpu_exec_time()
128 static void hvf_vcpu_destroy(CPUState *cpu) in hvf_vcpu_destroy() argument
130 hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd); in hvf_vcpu_destroy()
133 hvf_arch_vcpu_destroy(cpu); in hvf_vcpu_destroy()
134 g_free(cpu->accel); in hvf_vcpu_destroy()
135 cpu->accel = NULL; in hvf_vcpu_destroy()
138 static int hvf_init_vcpu(CPUState *cpu) in hvf_init_vcpu() argument
142 cpu->accel = g_new0(AccelCPUState, 1); in hvf_init_vcpu()
144 /* init cpu signals */ in hvf_init_vcpu()
151 pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask); in hvf_init_vcpu()
152 sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI); in hvf_init_vcpu()
155 r = hv_vcpu_create(&cpu->accel->fd, in hvf_init_vcpu()
156 (hv_vcpu_exit_t **)&cpu->accel->exit, NULL); in hvf_init_vcpu()
158 r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT); in hvf_init_vcpu()
161 cpu->vcpu_dirty = true; in hvf_init_vcpu()
163 cpu->accel->guest_debug_enabled = false; in hvf_init_vcpu()
165 return hvf_arch_init_vcpu(cpu); in hvf_init_vcpu()
170 * CPU supports the VMX "unrestricted guest" feature.
174 CPUState *cpu = arg; in hvf_cpu_thread_fn() local
183 qemu_thread_get_self(cpu->thread); in hvf_cpu_thread_fn()
185 cpu->thread_id = qemu_get_thread_id(); in hvf_cpu_thread_fn()
186 current_cpu = cpu; in hvf_cpu_thread_fn()
188 hvf_init_vcpu(cpu); in hvf_cpu_thread_fn()
190 /* signal CPU creation */ in hvf_cpu_thread_fn()
191 cpu_thread_signal_created(cpu); in hvf_cpu_thread_fn()
192 qemu_guest_random_seed_thread_part2(cpu->random_seed); in hvf_cpu_thread_fn()
195 if (cpu_can_run(cpu)) { in hvf_cpu_thread_fn()
196 r = hvf_vcpu_exec(cpu); in hvf_cpu_thread_fn()
198 cpu_handle_guest_debug(cpu); in hvf_cpu_thread_fn()
201 qemu_wait_io_event(cpu); in hvf_cpu_thread_fn()
202 } while (!cpu->unplug || cpu_can_run(cpu)); in hvf_cpu_thread_fn()
204 hvf_vcpu_destroy(cpu); in hvf_cpu_thread_fn()
205 cpu_thread_signal_destroyed(cpu); in hvf_cpu_thread_fn()
211 static void hvf_start_vcpu_thread(CPUState *cpu) in hvf_start_vcpu_thread() argument
221 snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HVF", in hvf_start_vcpu_thread()
222 cpu->cpu_index); in hvf_start_vcpu_thread()
223 qemu_thread_create(cpu->thread, thread_name, hvf_cpu_thread_fn, in hvf_start_vcpu_thread()
224 cpu, QEMU_THREAD_JOINABLE); in hvf_start_vcpu_thread()
227 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc) in hvf_find_sw_breakpoint() argument
239 int hvf_sw_breakpoints_active(CPUState *cpu) in hvf_sw_breakpoints_active() argument
244 static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg) in do_hvf_update_guest_debug() argument
246 hvf_arch_update_guest_debug(cpu); in do_hvf_update_guest_debug()
249 int hvf_update_guest_debug(CPUState *cpu) in hvf_update_guest_debug() argument
251 run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL); in hvf_update_guest_debug()
255 static int hvf_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len) in hvf_insert_breakpoint() argument
261 bp = hvf_find_sw_breakpoint(cpu, addr); in hvf_insert_breakpoint()
270 err = hvf_arch_insert_sw_breakpoint(cpu, bp); in hvf_insert_breakpoint()
284 CPU_FOREACH(cpu) { in hvf_insert_breakpoint()
285 err = hvf_update_guest_debug(cpu); in hvf_insert_breakpoint()
293 static int hvf_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len) in hvf_remove_breakpoint() argument
299 bp = hvf_find_sw_breakpoint(cpu, addr); in hvf_remove_breakpoint()
309 err = hvf_arch_remove_sw_breakpoint(cpu, bp); in hvf_remove_breakpoint()
323 CPU_FOREACH(cpu) { in hvf_remove_breakpoint()
324 err = hvf_update_guest_debug(cpu); in hvf_remove_breakpoint()
332 static void hvf_remove_all_breakpoints(CPUState *cpu) in hvf_remove_all_breakpoints() argument
338 if (hvf_arch_remove_sw_breakpoint(cpu, bp) != 0) { in hvf_remove_all_breakpoints()
339 /* Try harder to find a CPU that currently sees the breakpoint. */ in hvf_remove_all_breakpoints()
352 CPU_FOREACH(cpu) { in hvf_remove_all_breakpoints()
353 hvf_update_guest_debug(cpu); in hvf_remove_all_breakpoints()
357 static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf) in hvf_get_vcpu_stats() argument
361 run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_mach)); in hvf_get_vcpu_stats()