From: Marcelo Tosatti <mtosatti@redhat.com> To: Anthony Liguori <aliguori@us.ibm.com> Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Jan Kiszka <jan.kiszka@siemens.com>, Marcelo Tosatti <mtosatti@redhat.com> Subject: [PATCH 2/4] kvm: i8254: Finish time conversion fix Date: Tue, 14 Aug 2012 20:59:47 -0300 [thread overview] Message-ID: <050a46065de8e3d4ee5a04f5598d666f63d34800.1344988789.git.mtosatti@redhat.com> (raw) In-Reply-To: <cover.1344988789.git.mtosatti@redhat.com> From: Jan Kiszka <jan.kiszka@siemens.com> 0cdd3d1444 fixed reading back the counter load time from the kernel while assuming the kernel would always update its load time on writing the state. That is only true for channel 1, and so pit_get_channel_info returned wrong output pin states for high counter values. Fix this by applying the offset also on kvm_pit_put. Now we also need to update the offset when we write the state while the VM is stopped as it keeps on changing in that state. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> --- hw/kvm/i8254.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index c235d80..53d13e3 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -122,17 +122,23 @@ static void kvm_pit_get(PITCommonState *pit) pit_get_next_transition_time(sc, sc->count_load_time); } -static void kvm_pit_put(PITCommonState *s) +static void kvm_pit_put(PITCommonState *pit) { + KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit); struct kvm_pit_state2 kpit; struct kvm_pit_channel_state *kchan; struct PITChannelState *sc; int i, ret; - kpit.flags = s->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; + /* The offset keeps changing as long as the VM is stopped. */ + if (s->vm_stopped) { + kvm_pit_update_clock_offset(s); + } + + kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; for (i = 0; i < 3; i++) { kchan = &kpit.channels[i]; - sc = &s->channels[i]; + sc = &pit->channels[i]; kchan->count = sc->count; kchan->latched_count = sc->latched_count; kchan->count_latched = sc->count_latched; @@ -145,7 +151,7 @@ static void kvm_pit_put(PITCommonState *s) kchan->mode = sc->mode; kchan->bcd = sc->bcd; kchan->gate = sc->gate; - kchan->count_load_time = sc->count_load_time; + kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset; } ret = kvm_vm_ioctl(kvm_state, -- 1.7.6.4
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Tosatti <mtosatti@redhat.com> To: Anthony Liguori <aliguori@us.ibm.com> Cc: Jan Kiszka <jan.kiszka@siemens.com>, Marcelo Tosatti <mtosatti@redhat.com>, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix Date: Tue, 14 Aug 2012 20:59:47 -0300 [thread overview] Message-ID: <050a46065de8e3d4ee5a04f5598d666f63d34800.1344988789.git.mtosatti@redhat.com> (raw) In-Reply-To: <cover.1344988789.git.mtosatti@redhat.com> From: Jan Kiszka <jan.kiszka@siemens.com> 0cdd3d1444 fixed reading back the counter load time from the kernel while assuming the kernel would always update its load time on writing the state. That is only true for channel 1, and so pit_get_channel_info returned wrong output pin states for high counter values. Fix this by applying the offset also on kvm_pit_put. Now we also need to update the offset when we write the state while the VM is stopped as it keeps on changing in that state. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> --- hw/kvm/i8254.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index c235d80..53d13e3 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -122,17 +122,23 @@ static void kvm_pit_get(PITCommonState *pit) pit_get_next_transition_time(sc, sc->count_load_time); } -static void kvm_pit_put(PITCommonState *s) +static void kvm_pit_put(PITCommonState *pit) { + KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit); struct kvm_pit_state2 kpit; struct kvm_pit_channel_state *kchan; struct PITChannelState *sc; int i, ret; - kpit.flags = s->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; + /* The offset keeps changing as long as the VM is stopped. */ + if (s->vm_stopped) { + kvm_pit_update_clock_offset(s); + } + + kpit.flags = pit->channels[0].irq_disabled ? KVM_PIT_FLAGS_HPET_LEGACY : 0; for (i = 0; i < 3; i++) { kchan = &kpit.channels[i]; - sc = &s->channels[i]; + sc = &pit->channels[i]; kchan->count = sc->count; kchan->latched_count = sc->latched_count; kchan->count_latched = sc->count_latched; @@ -145,7 +151,7 @@ static void kvm_pit_put(PITCommonState *s) kchan->mode = sc->mode; kchan->bcd = sc->bcd; kchan->gate = sc->gate; - kchan->count_load_time = sc->count_load_time; + kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset; } ret = kvm_vm_ioctl(kvm_state, -- 1.7.6.4
next prev parent reply other threads:[~2012-08-15 0:02 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-14 23:59 [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti 2012-08-14 23:59 ` [Qemu-devel] " Marcelo Tosatti 2012-08-14 23:59 ` [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState Marcelo Tosatti 2012-08-14 23:59 ` [Qemu-devel] " Marcelo Tosatti 2012-08-14 23:59 ` Marcelo Tosatti [this message] 2012-08-14 23:59 ` [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix Marcelo Tosatti 2012-08-14 23:59 ` [PATCH 3/4] kvmvapic: Disable if there is insufficient memory Marcelo Tosatti 2012-08-14 23:59 ` [Qemu-devel] " Marcelo Tosatti 2012-08-14 23:59 ` [PATCH 4/4] update-linux-headers.sh: Pull in asm-generic/kvm_para.h Marcelo Tosatti 2012-08-14 23:59 ` [Qemu-devel] " Marcelo Tosatti 2012-08-15 7:46 ` [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Peter Maydell 2012-08-15 7:46 ` [Qemu-devel] " Peter Maydell 2012-08-15 18:10 ` Marcelo Tosatti 2012-08-15 18:10 ` [Qemu-devel] " Marcelo Tosatti 2012-08-15 19:48 ` Anthony Liguori 2012-08-15 19:48 ` [Qemu-devel] " Anthony Liguori
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=050a46065de8e3d4ee5a04f5598d666f63d34800.1344988789.git.mtosatti@redhat.com \ --to=mtosatti@redhat.com \ --cc=aliguori@us.ibm.com \ --cc=jan.kiszka@siemens.com \ --cc=kvm@vger.kernel.org \ --cc=qemu-devel@nongnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.