* [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue
@ 2012-08-14 23:59 Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState Marcelo Tosatti
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 23:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Marcelo Tosatti, qemu-devel, kvm
The following changes since commit 873359d411eeb380906761e46839a2b705dbcf75:
Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm (2012-08-14 19:50:22 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
Jan Kiszka (3):
kvm: i8254: Cache kernel clock offset in KVMPITState
kvm: i8254: Finish time conversion fix
kvmvapic: Disable if there is insufficient memory
Peter Maydell (1):
update-linux-headers.sh: Pull in asm-generic/kvm_para.h
hw/apic_common.c | 4 ++-
hw/kvm/i8254.c | 52 +++++++++++++++++++++++++-------------
scripts/update-linux-headers.sh | 5 +++
3 files changed, 42 insertions(+), 19 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
@ 2012-08-14 23:59 ` Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix Marcelo Tosatti
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 23:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm
From: Jan Kiszka <jan.kiszka@siemens.com>
To prepare the final fix for clock calibration issues with the in-kernel
PIT, we want to cache the offset between vmclock and the clock used by
the in-kernel PIT. So far, we only need to update it when the VM state
changes between running and stopped because we only read the in-kernel
PIT state while the VM is running.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hw/kvm/i8254.c | 38 ++++++++++++++++++++++++--------------
1 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c
index c5d3711..c235d80 100644
--- a/hw/kvm/i8254.c
+++ b/hw/kvm/i8254.c
@@ -35,7 +35,8 @@
typedef struct KVMPITState {
PITCommonState pit;
LostTickPolicy lost_tick_policy;
- bool state_valid;
+ bool vm_stopped;
+ int64_t kernel_clock_offset;
} KVMPITState;
static int64_t abs64(int64_t v)
@@ -43,19 +44,11 @@ static int64_t abs64(int64_t v)
return v < 0 ? -v : v;
}
-static void kvm_pit_get(PITCommonState *pit)
+static void kvm_pit_update_clock_offset(KVMPITState *s)
{
- KVMPITState *s = DO_UPCAST(KVMPITState, pit, pit);
- struct kvm_pit_state2 kpit;
- struct kvm_pit_channel_state *kchan;
- struct PITChannelState *sc;
int64_t offset, clock_offset;
struct timespec ts;
- int i, ret;
-
- if (s->state_valid) {
- return;
- }
+ int i;
/*
* Measure the delta between CLOCK_MONOTONIC, the base used for
@@ -72,6 +65,21 @@ static void kvm_pit_get(PITCommonState *pit)
clock_offset = offset;
}
}
+ s->kernel_clock_offset = clock_offset;
+}
+
+static void kvm_pit_get(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;
+
+ /* No need to re-read the state if VM is stopped. */
+ if (s->vm_stopped) {
+ return;
+ }
if (kvm_has_pit_state2()) {
ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, &kpit);
@@ -106,7 +114,7 @@ static void kvm_pit_get(PITCommonState *pit)
sc->mode = kchan->mode;
sc->bcd = kchan->bcd;
sc->gate = kchan->gate;
- sc->count_load_time = kchan->count_load_time + clock_offset;
+ sc->count_load_time = kchan->count_load_time + s->kernel_clock_offset;
}
sc = &pit->channels[0];
@@ -211,10 +219,12 @@ static void kvm_pit_vm_state_change(void *opaque, int running,
KVMPITState *s = opaque;
if (running) {
- s->state_valid = false;
+ kvm_pit_update_clock_offset(s);
+ s->vm_stopped = false;
} else {
+ kvm_pit_update_clock_offset(s);
kvm_pit_get(&s->pit);
- s->state_valid = true;
+ s->vm_stopped = true;
}
}
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState Marcelo Tosatti
@ 2012-08-14 23:59 ` Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 3/4] kvmvapic: Disable if there is insufficient memory Marcelo Tosatti
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 23:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 3/4] kvmvapic: Disable if there is insufficient memory
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix Marcelo Tosatti
@ 2012-08-14 23:59 ` Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 4/4] update-linux-headers.sh: Pull in asm-generic/kvm_para.h Marcelo Tosatti
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 23:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Jan Kiszka, Marcelo Tosatti, qemu-devel, kvm
From: Jan Kiszka <jan.kiszka@siemens.com>
We need at least 1M of RAM to map the option ROM. Otherwise, we will
corrupt host memory or even crash:
$ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k
Segmentation fault (core dumped)
Reported-and-tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hw/apic_common.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/apic_common.c b/hw/apic_common.c
index 58e63b0..371f95d 100644
--- a/hw/apic_common.c
+++ b/hw/apic_common.c
@@ -299,7 +299,9 @@ static int apic_init_common(SysBusDevice *dev)
sysbus_init_mmio(dev, &s->io_memory);
- if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) {
+ /* Note: We need at least 1M to map the VAPIC option ROM */
+ if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
+ ram_size >= 1024 * 1024) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->vapic = vapic;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 4/4] update-linux-headers.sh: Pull in asm-generic/kvm_para.h
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (2 preceding siblings ...)
2012-08-14 23:59 ` [Qemu-devel] [PATCH 3/4] kvmvapic: Disable if there is insufficient memory Marcelo Tosatti
@ 2012-08-14 23:59 ` Marcelo Tosatti
2012-08-15 7:46 ` [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Peter Maydell
2012-08-15 19:48 ` Anthony Liguori
5 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 23:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm
From: Peter Maydell <peter.maydell@linaro.org>
Add asm-generic/kvm_para.h to the set of non-architecture specific
KVM kernel headers we copy into QEMU. This header may be included
by an architecture's kvm_para.h header.
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
| 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
--git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 9d2a4bc..a639c5b 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -46,6 +46,11 @@ mkdir -p "$output/linux-headers/linux"
for header in kvm.h kvm_para.h vhost.h virtio_config.h virtio_ring.h; do
cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
done
+rm -rf "$output/linux-headers/asm-generic"
+mkdir -p "$output/linux-headers/asm-generic"
+for header in kvm_para.h; do
+ cp "$tmpdir/include/asm-generic/$header" "$output/linux-headers/asm-generic"
+done
if [ -L "$linux/source" ]; then
cp "$linux/source/COPYING" "$output/linux-headers"
else
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (3 preceding siblings ...)
2012-08-14 23:59 ` [Qemu-devel] [PATCH 4/4] update-linux-headers.sh: Pull in asm-generic/kvm_para.h Marcelo Tosatti
@ 2012-08-15 7:46 ` Peter Maydell
2012-08-15 18:10 ` Marcelo Tosatti
2012-08-15 19:48 ` Anthony Liguori
5 siblings, 1 reply; 8+ messages in thread
From: Peter Maydell @ 2012-08-15 7:46 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Anthony Liguori, qemu-devel, kvm
On 15 August 2012 00:59, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> The following changes since commit 873359d411eeb380906761e46839a2b705dbcf75:
>
> Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm (2012-08-14 19:50:22 +0000)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
>
> Jan Kiszka (3):
> kvm: i8254: Cache kernel clock offset in KVMPITState
> kvm: i8254: Finish time conversion fix
> kvmvapic: Disable if there is insufficient memory
>
> Peter Maydell (1):
> update-linux-headers.sh: Pull in asm-generic/kvm_para.h
Did you miss the other update-linux-headers.sh patch?
http://patchwork.ozlabs.org/patch/171628/
thanks
-- PMM
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue
2012-08-15 7:46 ` [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Peter Maydell
@ 2012-08-15 18:10 ` Marcelo Tosatti
0 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2012-08-15 18:10 UTC (permalink / raw)
To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, kvm
On Wed, Aug 15, 2012 at 08:46:21AM +0100, Peter Maydell wrote:
> On 15 August 2012 00:59, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> > The following changes since commit 873359d411eeb380906761e46839a2b705dbcf75:
> >
> > Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm (2012-08-14 19:50:22 +0000)
> >
> > are available in the git repository at:
> >
> > git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
> >
> > Jan Kiszka (3):
> > kvm: i8254: Cache kernel clock offset in KVMPITState
> > kvm: i8254: Finish time conversion fix
> > kvmvapic: Disable if there is insufficient memory
> >
> > Peter Maydell (1):
> > update-linux-headers.sh: Pull in asm-generic/kvm_para.h
>
> Did you miss the other update-linux-headers.sh patch?
You missed CCing the uq/master maintainers :-)
Applied now, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
` (4 preceding siblings ...)
2012-08-15 7:46 ` [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Peter Maydell
@ 2012-08-15 19:48 ` Anthony Liguori
5 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2012-08-15 19:48 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: qemu-devel, kvm
Marcelo Tosatti <mtosatti@redhat.com> writes:
> The following changes since commit 873359d411eeb380906761e46839a2b705dbcf75:
>
> Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm (2012-08-14 19:50:22 +0000)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
Pulled. Thanks.
Regards,
Anthony Liguori
>
> Jan Kiszka (3):
> kvm: i8254: Cache kernel clock offset in KVMPITState
> kvm: i8254: Finish time conversion fix
> kvmvapic: Disable if there is insufficient memory
>
> Peter Maydell (1):
> update-linux-headers.sh: Pull in asm-generic/kvm_para.h
>
> hw/apic_common.c | 4 ++-
> hw/kvm/i8254.c | 52 +++++++++++++++++++++++++-------------
> scripts/update-linux-headers.sh | 5 +++
> 3 files changed, 42 insertions(+), 19 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-15 19:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14 23:59 [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 1/4] kvm: i8254: Cache kernel clock offset in KVMPITState Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 2/4] kvm: i8254: Finish time conversion fix Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 3/4] kvmvapic: Disable if there is insufficient memory Marcelo Tosatti
2012-08-14 23:59 ` [Qemu-devel] [PATCH 4/4] update-linux-headers.sh: Pull in asm-generic/kvm_para.h Marcelo Tosatti
2012-08-15 7:46 ` [Qemu-devel] [PATCH 0/4] [PULL] qemu-kvm.git uq/master queue Peter Maydell
2012-08-15 18:10 ` Marcelo Tosatti
2012-08-15 19:48 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).