@@ -926,7 +926,9 @@ static void kvm_cpu_synchronize_kick_all(void)
CPUState *cpu;
CPU_FOREACH(cpu) {
- run_on_cpu(cpu, do_kvm_cpu_synchronize_kick, RUN_ON_CPU_NULL);
+ if (cpu->vcpu_in_kvm) {
+ run_on_cpu(cpu, do_kvm_cpu_synchronize_kick, RUN_ON_CPU_NULL);
+ }
}
}
@@ -3131,7 +3133,9 @@ int kvm_cpu_exec(CPUState *cpu)
*/
smp_rmb();
+ cpu->vcpu_in_kvm = true;
run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0);
+ cpu->vcpu_in_kvm = false;
attrs = kvm_arch_post_run(cpu, run);
@@ -537,6 +537,7 @@ struct CPUState {
uint64_t dirty_pages;
int kvm_vcpu_stats_fd;
bool vcpu_dirty;
+ bool vcpu_in_kvm;
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
@@ -670,6 +670,7 @@ void qemu_init_vcpu(CPUState *cpu)
cpu->nr_threads = ms->smp.threads;
cpu->stopped = true;
cpu->random_seed = qemu_guest_random_seed_thread_part1();
+ cpu->vcpu_in_kvm = false;
if (!cpu->as) {
/* If the target cpu hasn't set up any address spaces itself,