This RFC series follows on from discussions in the "Migrating decrementer" thread relating to handling migration of the timebase and decrementer registers for both TCG and KVM. The aim is to provide a consistent virtual clock when migrating PPC machines TCG-TCG (already handled) and KVM-KVM with both paused and live VMs in a unified manner for all PPC machine types.
The existing code to handle timebase migration on PPC has a few issues: 1) It uses cpu_get_host_ticks() which doesn't work correctly on TCG with different host architectures 2) tb_offset is calculated from the difference in the host clock between source and destination. Thus if the guest is paused then the resulting offset is calculated incorrectly since the host clock still runs, regardless of the state of the virtual clock. 3) Due to a typo in the existing implementation (MIN instead of MAX) then guest_tb never takes migration_duration_tb into account Patches 1-2 introduce a new PPCMachineClass and derive all the PPC machine classes from it, not dissimilar to x86's PCMachineClass. Patch 3 adds a VM state change hook into PCMachineClass and updates the tb_offset from the host when the machine (re)starts as discussed in the thread. Note that it may be possible to add the hook to specific machine types, however using PPCMachineClass allows all PPC machines to pick up this functionality automatically. Patch 4 temporarily disables the existing timebase migration code to allow testing. Note that this has only been compile-tested on x86 as I have no KVM PPC hardware and so it's really an RFC to determine whether this approach can work, and to invite testing and discussion from existing KVM PPC users. Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk> Mark Cave-Ayland (4): target-ppc: introduce PPCMachineClass and PPCMachineState target-ppc: derive all PPC machine classes to have PPCMachineClass as their superclass target-ppc: synchronise tb_offset with KVM host on machine start target-ppc: hack to remove existing timebase migration code for testing hw/ppc/e500plat.c | 7 +++- hw/ppc/mac_newworld.c | 17 ++------ hw/ppc/mac_oldworld.c | 6 ++- hw/ppc/mpc8544ds.c | 7 +++- hw/ppc/ppc.c | 100 +++++++++++++++++++++++++++++------------------ hw/ppc/ppc405_boards.c | 28 +++---------- hw/ppc/ppc440_bamboo.c | 6 ++- hw/ppc/prep.c | 6 ++- hw/ppc/spapr.c | 2 +- hw/ppc/virtex_ml507.c | 6 ++- include/hw/ppc/ppc.h | 35 +++++++++++++++++ include/qemu/typedefs.h | 2 + 12 files changed, 135 insertions(+), 87 deletions(-) -- 1.7.10.4