On 21.05.2021 05:15, Arnabjyoti Kalita wrote:
Thank you for your reply, Pavel.
Yes, I understand. Interrupts might be injected at different times and
this would be a source of indeterminism. But, let's say that I know
when to inject the interrupts.
Is this enough to ensure that the replay of the HPET clocks would be
deterministic? Do you see any other potential causes of concern?
Right, I don't see any other issues.
Best Regards,
Arnabjyoti Kalita
On Mon, May 17, 2021 at 1:05 PM Pavel Dovgalyuk
<pavel.dovgal...@ispras.ru> wrote:
On 14.05.2021 06:30, Arnabjyoti Kalita wrote:
Hello all,
I am recording and replaying HPET timer values for my guest.
I am running QEMU version 5.0.1. The guest kernel is a
4.4.0-21-generic Ubuntu flavor. The host and target architecture is
both x86-64.
To record, I start QEMU in KVM mode as follows -
sudo ./qemu-system-x86_64 -m 1024 --machine pc-i440fx-2.5 -cpu
qemu64,-kvmclock -enable-kvm -clock_replay
mode=record,file=clock_record9.txt -netdev
tap,id=tap1,ifname=tap0,script=no,downscript=no -device
virtio-net-pci,netdev=tap1,mac=00:00:00:00:00:00 -drive
file=~/os_images_for_qemu/ubuntu-16.04-desktop-amd64.qcow2,format=qcow2,if=none,id=img-direct
-device virtio-blk-pci,drive=img-direct
After this, I force the guest to switch to the "hpet" clocksource.
The clock_record9.txt file records the values of the HPET counter. To
perform the recording, I have changed the hpet_ram_read function in
the "hw/timer/hpet.c" file.
static uint64_t hpet_ram_read() {
.....
case HPET_COUNTER:
if (hpet_enabled(s)) {
cur_tick = hpet_get_ticks(s);
} else {
cur_tick = s->hpet_counter;
}
record_hpet_counter((int64_t)cur_tick); <----- record here
return cur_tick;
}
In replay mode, I start the guest in TCG mode as below-
sudo ./qemu-system-x86_64 -m 1024 -clock_replay
mode=replay,file=clock_record9.txt -machine pc-i440fx-2.5 -cpu qemu64
-netdev tap,id=tap1,ifname=tap0,script=no,downscript=no -device
virtio-net-pci,netdev=tap1,mac=00:00:00:00:00:00 -drive
file=~/os_images_for_qemu/ubuntu-16.04-desktop-amd64.qcow2,format=qcow2,if=none,id=img-direct
-device virtio-blk-pci,drive=img-direct -loadvm snapshot1
This is supposed to replay and mimic the HPET counter values. The
snapshot is there to ensure that both record and replay start from the
same guest state.
Is the guest replay going to be deterministic, with respect to the
HPET clock? Are there other factors about the HPET clock that need to
be taken into account while replaying it ?
I don't sure that this is enough.
There is qemu_timer in hpet.c, which is used for injecting the interrupts.
And interrupt handler code may read HPET clock. I mean that there may be
different frequency or timer reads in different runs.
I am not worried about other I/O events right now and I just want to
ensure that HPET timer values are being replayed correctly.
Best Regards,
Arnabjyoti Kalita