cpus: Pass CPUState to run_on_cpu()
CPUArchState is no longer needed. Move the declaration to include/qemu/cpu.h and add documentation. Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
8c5cf3b621
commit
f100f0b38f
@ -464,7 +464,6 @@ void cpu_watchpoint_remove_all(CPUArchState *env, int mask);
|
||||
#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */
|
||||
|
||||
void cpu_single_step(CPUArchState *env, int enabled);
|
||||
void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data);
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
|
||||
|
3
cpus.c
3
cpus.c
@ -640,9 +640,8 @@ void qemu_init_cpu_loop(void)
|
||||
qemu_thread_get_self(&io_thread);
|
||||
}
|
||||
|
||||
void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data)
|
||||
void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
struct qemu_work_item wi;
|
||||
|
||||
if (qemu_cpu_is_self(cpu)) {
|
||||
|
@ -143,7 +143,7 @@ static void do_inject_external_nmi(void *data)
|
||||
|
||||
static void kvm_apic_external_nmi(APICCommonState *s)
|
||||
{
|
||||
run_on_cpu(&s->cpu->env, do_inject_external_nmi, s);
|
||||
run_on_cpu(CPU(s->cpu), do_inject_external_nmi, s);
|
||||
}
|
||||
|
||||
static uint64_t kvm_apic_mem_read(void *opaque, hwaddr addr,
|
||||
|
@ -475,11 +475,13 @@ static void vapic_enable_tpr_reporting(bool enable)
|
||||
VAPICEnableTPRReporting info = {
|
||||
.enable = enable,
|
||||
};
|
||||
X86CPU *cpu;
|
||||
CPUX86State *env;
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
cpu = x86_env_get_cpu(env);
|
||||
info.apic = env->apic_state;
|
||||
run_on_cpu(env, vapic_do_enable_tpr_reporting, &info);
|
||||
run_on_cpu(CPU(cpu), vapic_do_enable_tpr_reporting, &info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -717,7 +719,7 @@ static int vapic_post_load(void *opaque, int version_id)
|
||||
}
|
||||
if (s->state == VAPIC_ACTIVE) {
|
||||
if (smp_cpus == 1) {
|
||||
run_on_cpu(first_cpu, do_vapic_enable, s);
|
||||
run_on_cpu(ENV_GET_CPU(first_cpu), do_vapic_enable, s);
|
||||
} else {
|
||||
zero = g_malloc0(s->rom_state.vapic_size);
|
||||
cpu_physical_memory_rw(s->vapic_paddr, zero,
|
||||
|
@ -163,7 +163,7 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value,
|
||||
.spin = curspin,
|
||||
};
|
||||
|
||||
run_on_cpu(env, spin_kick, &kick);
|
||||
run_on_cpu(CPU(kick.cpu), spin_kick, &kick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,5 +125,15 @@ void qemu_cpu_kick(CPUState *cpu);
|
||||
*/
|
||||
bool cpu_is_stopped(CPUState *cpu);
|
||||
|
||||
/**
|
||||
* run_on_cpu:
|
||||
* @cpu: The vCPU to run on.
|
||||
* @func: The function to be executed.
|
||||
* @data: Data to pass to the function.
|
||||
*
|
||||
* Schedules the function @func for execution on the vCPU @cpu.
|
||||
*/
|
||||
void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1500,8 +1500,10 @@ static void do_kvm_cpu_synchronize_state(void *_env)
|
||||
|
||||
void kvm_cpu_synchronize_state(CPUArchState *env)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
|
||||
if (!env->kvm_vcpu_dirty) {
|
||||
run_on_cpu(env, do_kvm_cpu_synchronize_state, env);
|
||||
run_on_cpu(cpu, do_kvm_cpu_synchronize_state, env);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1787,6 +1789,7 @@ static void kvm_invoke_set_guest_debug(void *data)
|
||||
|
||||
int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
struct kvm_set_guest_debug_data data;
|
||||
|
||||
data.dbg.control = reinject_trap;
|
||||
@ -1797,7 +1800,7 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)
|
||||
kvm_arch_update_guest_debug(env, &data.dbg);
|
||||
data.env = env;
|
||||
|
||||
run_on_cpu(env, kvm_invoke_set_guest_debug, &data);
|
||||
run_on_cpu(cpu, kvm_invoke_set_guest_debug, &data);
|
||||
return data.err;
|
||||
}
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,
|
||||
return;
|
||||
}
|
||||
|
||||
run_on_cpu(cenv, do_inject_x86_mce, ¶ms);
|
||||
run_on_cpu(CPU(cpu), do_inject_x86_mce, ¶ms);
|
||||
if (flags & MCE_INJECT_BROADCAST) {
|
||||
params.bank = 1;
|
||||
params.status = MCI_STATUS_VAL | MCI_STATUS_UC;
|
||||
@ -1189,7 +1189,7 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,
|
||||
continue;
|
||||
}
|
||||
params.env = env;
|
||||
run_on_cpu(cenv, do_inject_x86_mce, ¶ms);
|
||||
run_on_cpu(CPU(cpu), do_inject_x86_mce, ¶ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user