From f8d926e9cd96e52ebcfd9ffdeab83c0d5e6b9622 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Sat, 2 May 2009 02:18:38 +0200 Subject: kvm: x86: Save/restore KVM-specific CPU states Save and restore all so far neglected KVM-specific CPU states. Handling the TSC stabilizes migration in KVM mode. The interrupt_bitmap and mp_state are currently unused, but will become relevant for in-kernel irqchip support. By including proper saving/restoring already, we avoid having to increment CPU_SAVE_VERSION later on once again. v2: - initialize mp_state runnable (for the boot CPU) Signed-off-by: Jan Kiszka Signed-off-by: Anthony Liguori --- target-i386/machine.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'target-i386/machine.c') diff --git a/target-i386/machine.c b/target-i386/machine.c index 69a03a4..bb8b9db 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -140,6 +140,12 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be64s(f, &env->mtrr_var[i].base); qemu_put_be64s(f, &env->mtrr_var[i].mask); } + + for (i = 0; i < sizeof(env->interrupt_bitmap)/8; i++) { + qemu_put_be64s(f, &env->interrupt_bitmap[i]); + } + qemu_put_be64s(f, &env->tsc); + qemu_put_be32s(f, &env->mp_state); } #ifdef USE_X86LDOUBLE @@ -174,8 +180,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) uint16_t fpus, fpuc, fptag, fpregs_format; int32_t a20_mask; - if (version_id != 3 && version_id != 4 && version_id != 5 - && version_id != 6 && version_id != 7 && version_id != 8) + if (version_id < 3 || version_id > CPU_SAVE_VERSION) return -EINVAL; for(i = 0; i < CPU_NB_REGS; i++) qemu_get_betls(f, &env->regs[i]); @@ -319,6 +324,13 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) qemu_get_be64s(f, &env->mtrr_var[i].mask); } } + if (version_id >= 9) { + for (i = 0; i < sizeof(env->interrupt_bitmap)/8; i++) { + qemu_get_be64s(f, &env->interrupt_bitmap[i]); + } + qemu_get_be64s(f, &env->tsc); + qemu_get_be32s(f, &env->mp_state); + } /* XXX: ensure compatiblity for halted bit ? */ /* XXX: compute redundant hflags bits */ -- cgit v1.1