@@ -441,7 +441,7 @@ struct qemu_work_item;
* @opaque: User data.
* @mem_io_pc: Host Program Counter at which the memory was accessed.
* @accel: Pointer to accelerator specific state.
- * @vcpu_dirty: Hardware accelerator is not synchronized with QEMU state
+ * @hwaccel_synchronized: Hardware accelerator is synchronized with QEMU state
* @kvm_fd: vCPU file descriptor for KVM.
* @work_mutex: Lock to prevent multiple access to @work_list.
* @work_list: List of pending asynchronous work.
@@ -538,7 +538,6 @@ struct CPUState {
uint32_t kvm_fetch_index;
uint64_t dirty_pages;
int kvm_vcpu_stats_fd;
- bool vcpu_dirty;
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
@@ -555,6 +554,7 @@ struct CPUState {
int32_t exception_index;
AccelCPUState *accel;
+ bool hwaccel_synchronized;
/* Used to keep track of an outstanding cpu throttle thread for migration
* autoconverge
@@ -478,8 +478,8 @@ static int kvm_create_vcpu(CPUState *cpu)
cpu->kvm_fd = kvm_fd;
cpu->kvm_state = s;
- if (!s->guest_state_protected) {
- cpu->vcpu_dirty = true;
+ if (s->guest_state_protected) {
+ cpu->hwaccel_synchronized = true;
}
cpu->dirty_pages = 0;
cpu->throttle_us_per_full = 0;
@@ -2880,7 +2880,7 @@ void kvm_flush_coalesced_mmio_buffer(void)
static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
- if (!cpu->vcpu_dirty && !kvm_state->guest_state_protected) {
+ if (cpu->hwaccel_synchronized && !kvm_state->guest_state_protected) {
Error *err = NULL;
int ret = kvm_arch_get_registers(cpu, &err);
if (ret) {
@@ -2894,13 +2894,13 @@ static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
vm_stop(RUN_STATE_INTERNAL_ERROR);
}
- cpu->vcpu_dirty = true;
+ cpu->hwaccel_synchronized = false;
}
}
void kvm_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->vcpu_dirty && !kvm_state->guest_state_protected) {
+ if (cpu->hwaccel_synchronized && !kvm_state->guest_state_protected) {
run_on_cpu(cpu, do_kvm_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -2920,7 +2920,7 @@ static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg
vm_stop(RUN_STATE_INTERNAL_ERROR);
}
- cpu->vcpu_dirty = false;
+ cpu->hwaccel_synchronized = true;
}
void kvm_cpu_synchronize_post_reset(CPUState *cpu)
@@ -2946,7 +2946,7 @@ static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
exit(1);
}
- cpu->vcpu_dirty = false;
+ cpu->hwaccel_synchronized = true;
}
void kvm_cpu_synchronize_post_init(CPUState *cpu)
@@ -2962,7 +2962,7 @@ void kvm_cpu_synchronize_post_init(CPUState *cpu)
static void do_kvm_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg)
{
- cpu->vcpu_dirty = true;
+ cpu->hwaccel_synchronized = false;
}
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu)
@@ -3131,7 +3131,7 @@ int kvm_cpu_exec(CPUState *cpu)
do {
MemTxAttrs attrs;
- if (cpu->vcpu_dirty) {
+ if (!cpu->hwaccel_synchronized) {
Error *err = NULL;
ret = kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE, &err);
if (ret) {
@@ -3145,7 +3145,7 @@ int kvm_cpu_exec(CPUState *cpu)
break;
}
- cpu->vcpu_dirty = false;
+ cpu->hwaccel_synchronized = true;
}
kvm_arch_pre_run(cpu, run);
@@ -565,7 +565,7 @@ static void kvm_mips_update_state(void *opaque, bool running, RunState state)
* already saved and can be restored when it is synced back to KVM.
*/
if (!running) {
- if (!cs->vcpu_dirty) {
+ if (cs->hwaccel_synchronized) {
ret = kvm_mips_save_count(cs);
if (ret < 0) {
warn_report("Failed saving count");
@@ -581,7 +581,7 @@ static void kvm_mips_update_state(void *opaque, bool running, RunState state)
return;
}
- if (!cs->vcpu_dirty) {
+ if (cs->hwaccel_synchronized) {
ret = kvm_mips_restore_count(cs);
if (ret < 0) {
warn_report("Failed restoring count");
Try to better describe which side is dirty (QEMU process or hardware accelerator) by renaming as @hwaccel_synchronized. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/hw/core/cpu.h | 4 ++-- accel/kvm/kvm-all.c | 20 ++++++++++---------- target/mips/kvm.c | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-)