kvm: i8254: Fix conversion of in-kernel to userspace state
commit960d355dc60d998dcd7b389b84ffefad9b612650
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 6 Jun 2012 14:28:42 +0000 (6 16:28 +0200)
committerMarcelo Tosatti <mtosatti@redhat.com>
Sat, 30 Jun 2012 02:02:10 +0000 (29 23:02 -0300)
treee756c8b0329b37ddd2e2043bc564ba1213173316
parent15ecf28f39e2b6fba359ed094770c8fa4ad8dc60
kvm: i8254: Fix conversion of in-kernel to userspace state

Due to a offset between the clock used to generate the in-kernel
count_load_time (CLOCK_MONOTONIC) and the clock used for processing this
in userspace (vm_clock), reading back the output of PIT channel 2 via
port 0x61 was broken. One use cases that suffered from it was the CPU
frequency calibration of SeaBIOS, which also affected IDE/AHCI timeouts.

This fixes it by calibrating the offset between both clocks on
kvm_pit_get and adjusting the kernel value before saving it in the
userspace state. As the calibration only works while the vm_clock is
running, we cache the in-kernel state across stopped phases.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
hw/kvm/i8254.c