Reverse execution and deterministic replay
cover Reverse execution and deterministic replay
Hi,
This set of patches is related to the reverse execution and deterministic replay of qemu execution Our implementation of replay can be used for deterministic and reverse debugging of guest code through gdb remote interface.
Execution recording writes non-deterministic events log, which can be later used for replaying the execution anywhere and for unlimited number of times. It also supports checkpointing for faster rewinding during reverse debugging. Execution replaying reads the log and replays all non-deterministic events including external input, hardware clocks, and interrupts.
Reverse execution has the following features:
* Deterministically replays whole system execution and all contents of the memory, state of the hadrware devices, clocks, and screen of the VM.
* Writes execution log into the file for latter replaying for multiple times on different machines.
* Supports i386, x86_64, and ARM hardware platforms.
* Performs deterministic replay of all operations with keyboard, mouse, network adapters, audio devices, serial interfaces, and physical USB devices connected to the emulator.
* Provides support for gdb reverse debugging commands like reverse-step and reverse-continue.
* Supports auto-checkpointing for convenient reverse debugging.
* Allows "going to the live execution" from the replay mode.
Usage of the record/replay:
* First, record the execution, by adding '-record fname=replay.bin' to the command line.
* Then you can replay it for the multiple times by using another command line option: '-replay fname=replay.bin'
* Virtual machine should have at least one virtual disk, which is used to store checkpoints. If you want to enable automatic checkpointing, simply add ',period=XX' to record options, where XX is the checkpointing period in seconds.
* Using of the network adapters in record/replay mode is possible with the following command-line options:
- '-net user' (or another host adapter) in record mode
- '-net replay' in replay mode. Every host network adapter should be replaced by 'replay' when replaying the execution.
* Reverse debugging can be used through gdb remote interface. reverse-stepi and reverse-continue commands are supported. Other reverse commands should also work, because they reuse these ones.
* Monitor is extended by the following commands:
- replay_info - prints information about replay mode and current step (number of instructions executed)
- replay_break - sets "breakpoint" at the specified instructions count.
- replay_seek - rewinds (using the checkpoints, if possible) to the specified step of replay log.
- replay_events - prints list of the external events like network packet input, or keyboard and mouse input.
Paper with short description of deterministic replay implementation:
http://www.computer.org/csdl/proceedings/csmr/2012/4666/00/4666a553-abs.html
Makefile.target | 3 + arch_init.c | 9 + async.c | 50 +- audio/audio.c | 10 +- audio/winwaveaudio.c | 171 +++- block.c | 139 +++- block/blkdebug.c | 2 +- block/blkverify.c | 4 +- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 13 +- block/qed.c | 2 +- block/raw-posix.c | 5 +- block/raw-win32.c | 8 +- block/vmdk.c | 8 +- block/vvfat.c | 3 +- block/win32-aio.c | 2 + blockdev.c | 23 +- cpu-exec.c | 73 ++- cpus.c | 151 +++- dma-helpers.c | 15 +- exec.c | 19 + gdbstub.c | 79 ++- hmp-commands.hx | 101 +++ hw/acpi/core.c | 7 +- hw/arm/integratorcp.c | 38 +- hw/audio/pcspk.c | 19 +- hw/block/fdc.c | 11 +- hw/block/virtio-blk.c | 8 +- hw/char/parallel.c | 22 + hw/char/serial.c | 132 ++- hw/display/vga.c | 6 +- hw/i386/kvmvapic.c | 30 +- hw/ide/ahci.c | 10 +- hw/ide/atapi.c | 5 +- hw/ide/core.c | 19 +- hw/ide/pci.c | 10 + hw/input/pckbd.c | 3 +- hw/intc/apic_common.c | 5 +- hw/net/rtl8139.c | 5 +- hw/pci-host/piix.c | 22 +- hw/timer/arm_timer.c | 2 +- hw/timer/hpet.c | 9 +- hw/timer/mc146818rtc.c | 17 +- hw/timer/pl031.c | 32 +- hw/usb/core.c | 6 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/host-libusb.c | 518 ++++++++---- include/block/aio.h | 9 + include/block/block.h | 21 +- include/block/thread-pool.h | 60 ++- include/exec/cpu-defs.h | 1 + include/exec/cpu_ldst_template.h | 28 +- include/exec/exec-all.h | 38 +- include/exec/gen-icount.h | 7 + include/hw/char/serial.h | 2 +- include/hw/host-libusb.h | 103 +++ include/hw/usb.h | 3 + include/migration/vmstate.h | 13 + include/monitor/monitor.h | 1 + include/qemu-common.h | 3 + include/qemu/main-loop.h | 1 + include/qemu/timer.h | 54 ++- include/qom/cpu.h | 4 + include/sysemu/char.h | 4 + include/sysemu/cpus.h | 3 + include/sysemu/sysemu.h | 2 + include/ui/input.h | 2 + main-loop.c | 13 + monitor.c | 139 +++ net/Makefile.objs | 2 +- net/clients.h | 4 + net/dump.c | 6 + net/hub.c | 1 + net/net-replay.c | 56 ++ net/net.c | 9 +- net/slirp.c | 14 +- net/socket.c | 40 +- net/tap-win32.c | 19 +- net/tap.c | 24 +- net/vde.c | 14 +- qapi-schema.json | 10 + qemu-char.c | 103 ++- qemu-img.c | 6 +- qemu-io-cmds.c | 2 +- qemu-io.c | 4 +- qemu-nbd.c | 2 +- qemu-options.hx | 32 + qemu-timer.c | 49 +- replay/Makefile.objs | 1 + replay/replay-audio.c | 238 ++++++ replay/replay-char.c | 119 +++ replay/replay-debug.c | 152 ++++ replay/replay-events.c | 463 ++++++++++ replay/replay-icount.c | 112 +++ replay/replay-input.c | 152 ++++ replay/replay-internal.c | 176 ++++ replay/replay-internal.h | 192 +++++ replay/replay-net.c | 367 ++++++++ replay/replay-usb.c | 241 ++++++ replay/replay.c | 1604 +++++++++++++++++++++++++++++++++++ replay/replay.h | 249 ++++++ roms/openbios | 2 +- roms/qemu-palcode | 2 +- roms/seabios | 2 +- roms/vgabios | 2 +- savevm.c | 31 +- slirp/slirp.c | 7 +- softmmu_template.h | 18 + stubs/Makefile.objs | 1 + stubs/replay.c | 72 ++ stubs/vmstate.c | 3 + target-arm/helper.h | 4 + target-arm/machine.c | 4 + target-arm/op_helper.c | 55 ++ target-arm/translate.c | 109 +++- target-i386/Makefile.objs | 2 +- target-i386/cpu.c | 1 + target-i386/cpu.h | 10 + target-i386/fpu_helper.c | 31 +- target-i386/helper.c | 2 + target-i386/helper.h | 8 + target-i386/machine.c | 5 + target-i386/misc_helper.c | 13 +- target-i386/replay_helper.c | 81 ++ target-i386/seg_helper.c | 1 + target-i386/shift_helper_template.h | 14 +- target-i386/translate.c | 152 +++- tests/test-thread-pool.c | 6 +- thread-pool.c | 101 +-- translate-all.c | 28 +- ui/input.c | 77 ++- util/iov.c | 4 + vl.c | 159 ++++- vmstate.c | 6 + 136 files changed, 7168 insertions(+), 651 deletions(-)
Pavel Dovgalyuk
Hi Pavel,
Thanks for sharing.
I'll take a look at your patch-set.
I suggest you try the icount mechanism and I think it might be interesting to combine our work to have a complete solution and to avoid double copy patches (for example command lines, gdb stub and the snapshot mechanism).
I'll provides the last updates today or tomorrow.
Also do you have any git tree somewhere so it is easier for us to test it? I recommand you to use git send-email to submit your patches so you can CC people and the patch set won't be cutted by other patches in the mailing list.
Thanks,
Fred
Quoted 194 lines · Pavel Dovgaluk
Hi,
This set of patches is related to the reverse execution and deterministic replay of qemu execution Our implementation of replay can be used for deterministic and reverse debugging of guest code through gdb remote interface.
Execution recording writes non-deterministic events log, which can be later used for replaying the execution anywhere and for unlimited number of times. It also supports checkpointing for faster rewinding during reverse debugging. Execution replaying reads the log and replays all non-deterministic events including external input, hardware clocks, and interrupts.
Reverse execution has the following features:
* Deterministically replays whole system execution and all contents of the memory, state of the hadrware devices, clocks, and screen of the VM.
* Writes execution log into the file for latter replaying for multiple times on different machines.
* Supports i386,x86_64, and ARM hardware platforms.
* Performs deterministic replay of all operations with keyboard, mouse, network adapters, audio devices, serial interfaces, and physical USB devices connected to the emulator.
* Provides support for gdb reverse debugging commands like reverse-step and reverse-continue.
* Supports auto-checkpointing for convenient reverse debugging.
* Allows "going to the live execution" from the replay mode.Usage of the record/replay:
* First, record the execution, by adding '-record fname=replay.bin' to the command line.
* Then you can replay it for the multiple times by using another command line option: '-replay fname=replay.bin'
* Virtual machine should have at least one virtual disk, which is used to store checkpoints. If you want to enable automatic checkpointing, simply add ',period=XX' to record options, where XX is the checkpointing period in seconds.
* Using of the network adapters in record/replay mode is possible with the following command-line options:
- '-net user' (or another host adapter) in record mode
- '-net replay' in replay mode. Every host network adapter should be replaced by 'replay' when replaying the execution.
* Reverse debugging can be used through gdb remote interface. reverse-stepi and reverse-continue commands are supported. Other reverse commands should also work, because they reuse these ones.
* Monitor is extended by the following commands:
-replay_info- prints information about replay mode and current step (number of instructions executed)
-replay_break- sets "breakpoint" at the specified instructions count.
-replay_seek- rewinds (using the checkpoints, if possible) to the specified step of replay log.
-replay_events- prints list of the external events like network packet input, or keyboard and mouse input.Paper with short description of deterministic replay implementation:
http://www.computer.org/csdl/proceedings/csmr/2012/4666/00/4666a553-abs.htmlMakefile.target | 3 + arch_init.c | 9 + async.c | 50 +- audio/audio.c | 10 +- audio/winwaveaudio.c | 171 +++- block.c | 139 +++- block/blkdebug.c | 2 +- block/blkverify.c | 4 +- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 13 +- block/qed.c | 2 +- block/raw-posix.c | 5 +- block/raw-win32.c | 8 +- block/vmdk.c | 8 +- block/vvfat.c | 3 +- block/win32-aio.c | 2 + blockdev.c | 23 +- cpu-exec.c | 73 ++- cpus.c | 151 +++- dma-helpers.c | 15 +- exec.c | 19 + gdbstub.c | 79 ++- hmp-commands.hx | 101 +++ hw/acpi/core.c | 7 +- hw/arm/integratorcp.c | 38 +- hw/audio/pcspk.c | 19 +- hw/block/fdc.c | 11 +- hw/block/virtio-blk.c | 8 +- hw/char/parallel.c | 22 + hw/char/serial.c | 132 ++- hw/display/vga.c | 6 +- hw/i386/kvmvapic.c | 30 +- hw/ide/ahci.c | 10 +- hw/ide/atapi.c | 5 +- hw/ide/core.c | 19 +- hw/ide/pci.c | 10 + hw/input/pckbd.c | 3 +- hw/intc/apic_common.c | 5 +- hw/net/rtl8139.c | 5 +- hw/pci-host/piix.c | 22 +- hw/timer/arm_timer.c | 2 +- hw/timer/hpet.c | 9 +- hw/timer/mc146818rtc.c | 17 +- hw/timer/pl031.c | 32 +- hw/usb/core.c | 6 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/host-libusb.c | 518 ++++++++---- include/block/aio.h | 9 + include/block/block.h | 21 +- include/block/thread-pool.h | 60 ++- include/exec/cpu-defs.h | 1 + include/exec/cpu_ldst_template.h | 28 +- include/exec/exec-all.h | 38 +- include/exec/gen-icount.h | 7 + include/hw/char/serial.h | 2 +- include/hw/host-libusb.h | 103 +++ include/hw/usb.h | 3 + include/migration/vmstate.h | 13 + include/monitor/monitor.h | 1 + include/qemu-common.h | 3 + include/qemu/main-loop.h | 1 + include/qemu/timer.h | 54 ++- include/qom/cpu.h | 4 + include/sysemu/char.h | 4 + include/sysemu/cpus.h | 3 + include/sysemu/sysemu.h | 2 + include/ui/input.h | 2 + main-loop.c | 13 + monitor.c | 139 +++ net/Makefile.objs | 2 +- net/clients.h | 4 + net/dump.c | 6 + net/hub.c | 1 + net/net-replay.c | 56 ++ net/net.c | 9 +- net/slirp.c | 14 +- net/socket.c | 40 +- net/tap-win32.c | 19 +- net/tap.c | 24 +- net/vde.c | 14 +- qapi-schema.json | 10 + qemu-char.c | 103 ++- qemu-img.c | 6 +- qemu-io-cmds.c | 2 +- qemu-io.c | 4 +- qemu-nbd.c | 2 +- qemu-options.hx | 32 + qemu-timer.c | 49 +- replay/Makefile.objs | 1 + replay/replay-audio.c | 238 ++++++ replay/replay-char.c | 119 +++ replay/replay-debug.c | 152 ++++ replay/replay-events.c | 463 ++++++++++ replay/replay-icount.c | 112 +++ replay/replay-input.c | 152 ++++ replay/replay-internal.c | 176 ++++ replay/replay-internal.h | 192 +++++ replay/replay-net.c | 367 ++++++++ replay/replay-usb.c | 241 ++++++ replay/replay.c | 1604 +++++++++++++++++++++++++++++++++++ replay/replay.h | 249 ++++++ roms/openbios | 2 +- roms/qemu-palcode | 2 +- roms/seabios | 2 +- roms/vgabios | 2 +- savevm.c | 31 +- slirp/slirp.c | 7 +- softmmu_template.h | 18 + stubs/Makefile.objs | 1 + stubs/replay.c | 72 ++ stubs/vmstate.c | 3 + target-arm/helper.h | 4 + target-arm/machine.c | 4 + target-arm/op_helper.c | 55 ++ target-arm/translate.c | 109 +++- target-i386/Makefile.objs | 2 +- target-i386/cpu.c | 1 + target-i386/cpu.h | 10 + target-i386/fpu_helper.c | 31 +- target-i386/helper.c | 2 + target-i386/helper.h | 8 + target-i386/machine.c | 5 + target-i386/misc_helper.c | 13 +- target-i386/replay_helper.c | 81 ++ target-i386/seg_helper.c | 1 + target-i386/shift_helper_template.h | 14 +- target-i386/translate.c | 152 +++- tests/test-thread-pool.c | 6 +- thread-pool.c | 101 +-- translate-all.c | 28 +- ui/input.c | 77 ++- util/iov.c | 4 + vl.c | 159 ++++- vmstate.c | 6 + 136 files changed, 7168 insertions(+), 651 deletions(-)Pavel Dovgalyuk
Quoted 5 lines · Frederic Konrad
Hi Pavel,
Thanks for sharing.
I'll take a look at your patch-set.
I suggest you try the icount mechanism and I think it might be
There is a problem with icount. I know it operates in two ways: counting VCPU instructions (with TB size accuracy) and "warp"ing with respect to host clock. The last one is necessary for interrupts, timers (and other asynchronous events) while VCPU is halted (and other cases in which VCPU instructions is not being executed). So, this referencing to host clock (which is non-deterministic) make icount a source of non-determinism. Hence, it cannot be used as deterministic timer (for synchronization of asynchronous non-deterministic events) while playing.
Quoted 87 lines
interesting to
combine our work to have a complete solution and to avoid double copy patches
(for example command lines, gdb stub and the snapshot mechanism).I'll provides the last updates today or tomorrow.
Also do you have any git tree somewhere so it is easier for us to test it? I recommand you to use git send-email to submit your patches so you can CC people and the patch set won't be cutted by other patches in the mailing list.
Thanks,
FredQuoted 71 lines · Pavel Dovgaluk
Hi,
This set of patches is related to the reverse execution and deterministic replay of qemu execution Our implementation of replay can be used for deterministic and reverse debugging of guest code through gdb remote interface.
Execution recording writes non-deterministic events log, which can be later
used for replaying the execution anywhere and for unlimited number of times.
It also supports checkpointing for faster rewinding during reverse debugging.
Execution replaying reads the log and replays all non-deterministic events
including external input, hardware clocks, and interrupts.Reverse execution has the following features:
* Deterministically replays whole system execution and all contents
of the memory,
state of the hadrware devices, clocks, and screen of the VM.
* Writes execution log into the file for latter replaying for
multiple times
on different machines.
* Supports i386,x86_64, and ARM hardware platforms.
* Performs deterministic replay of all operations with keyboard,
mouse, network adapters,
audio devices, serial interfaces, and physical USB devices
connected to the emulator.
* Provides support for gdb reverse debugging commands like
reverse-step and reverse-continue.
* Supports auto-checkpointing for convenient reverse debugging.
* Allows "going to the live execution" from the replay mode.Usage of the record/replay:
* First, record the execution, by adding '-record fname=replay.bin'
to the
command line.
* Then you can replay it for the multiple times by using another
command
line option: '-replay fname=replay.bin'
* Virtual machine should have at least one virtual disk, which is
used to
store checkpoints. If you want to enable automatic checkpointing,
simply
add ',period=XX' to record options, where XX is the checkpointing
period
in seconds.
* Using of the network adapters in record/replay mode is possible with the following command-line options:
- '-net user' (or another host adapter) in record mode
- '-net replay' in replay mode. Every host network adapter should be replaced by 'replay' when replaying the execution.
* Reverse debugging can be used through gdb remote interface. reverse-stepi and reverse-continue commands are supported. Other
reverse
commands should also work, because they reuse these ones.
* Monitor is extended by the following commands:
-replay_info- prints information about replay mode and current step (number of instructions executed)
-replay_break- sets "breakpoint" at the specified instructions
count.
-replay_seek- rewinds (using the checkpoints, if possible) to the specified step of replay log.
-replay_events- prints list of the external events like network
packet
input, or keyboard and mouse input.Paper with short description of deterministic replay implementation:
http://www.computer.org/csdl/proceedings/csmr/2012/4666/00/4666a553-abs.html
...
Quoted 4 lines
Quoted 2 lines
Pavel Dovgalyuk
Quoted 9 lines · Vasily Eefimov
Quoted 5 lines · Frederic Konrad
Hi Pavel,
Thanks for sharing.
I'll take a look at your patch-set.
I suggest you try the icount mechanism and I think it might beThere is a problem with icount. I know it operates in two ways: counting VCPU instructions (with TB size accuracy) and "warp"ing with respect to host clock. The last one is necessary for interrupts, timers (and other asynchronous events) while VCPU is halted (and other cases in which VCPU instructions is not being executed). So, this referencing to host clock (which is non-deterministic) make icount a source of non-determinism. Hence, it cannot be used as deterministic timer (for synchronization of asynchronous non-deterministic events) while playing.
True, this is right for virtual clock. That's why we built a new clock which didn't take this warping in account but becomes deterministically correct relative to the instruction counter.
Fred
Quoted 97 lines
Quoted 91 lines
interesting to
combine our work to have a complete solution and to avoid double copy patches
(for example command lines, gdb stub and the snapshot mechanism).I'll provides the last updates today or tomorrow.
Also do you have any git tree somewhere so it is easier for us to test it? I recommand you to use git send-email to submit your patches so you can CC people and the patch set won't be cutted by other patches in the mailing list.
Thanks,
FredQuoted 75 lines · Pavel Dovgaluk
Hi,
This set of patches is related to the reverse execution and deterministic replay of qemu execution Our implementation of replay can be used for deterministic and reverse debugging of guest code through gdb remote interface.
Execution recording writes non-deterministic events log, which can be later
used for replaying the execution anywhere and for unlimited number of times.
It also supports checkpointing for faster rewinding during reverse debugging.
Execution replaying reads the log and replays all non-deterministic events
including external input, hardware clocks, and interrupts.Reverse execution has the following features:
* Deterministically replays whole system execution and all contents
of the memory,
state of the hadrware devices, clocks, and screen of the VM.
* Writes execution log into the file for latter replaying for
multiple times
on different machines.
* Supports i386,x86_64, and ARM hardware platforms.
* Performs deterministic replay of all operations with keyboard,
mouse, network adapters,
audio devices, serial interfaces, and physical USB devices
connected to the emulator.
* Provides support for gdb reverse debugging commands like
reverse-step and reverse-continue.
* Supports auto-checkpointing for convenient reverse debugging.
* Allows "going to the live execution" from the replay mode.Usage of the record/replay:
* First, record the execution, by adding '-record fname=replay.bin'
to the
command line.
* Then you can replay it for the multiple times by using another
command
line option: '-replay fname=replay.bin'
* Virtual machine should have at least one virtual disk, which is
used to
store checkpoints. If you want to enable automatic checkpointing,
simply
add ',period=XX' to record options, where XX is the checkpointing
period
in seconds.
* Using of the network adapters in record/replay mode is possible
with
the following command-line options:
- '-net user' (or another host adapter) in record mode
- '-net replay' in replay mode. Every host network adapter
should be
replaced by 'replay' when replaying the execution.
* Reverse debugging can be used through gdb remote interface. reverse-stepi and reverse-continue commands are supported. Other
reverse
commands should also work, because they reuse these ones.
* Monitor is extended by the following commands:
-replay_info- prints information about replay mode and current
step
(number of instructions executed)
-replay_break- sets "breakpoint" at the specified instructions
count.
-replay_seek- rewinds (using the checkpoints, if possible) to the specified step of replay log.
-replay_events- prints list of the external events like network
packet
input, or keyboard and mouse input.Paper with short description of deterministic replay implementation:
http://www.computer.org/csdl/proceedings/csmr/2012/4666/00/4666a553-abs.html...
Quoted 4 lines
Quoted 2 lines
Pavel Dovgalyuk