|
|
9ae3a8 |
From 62ac85ec7c8e41b0454bdec0e0a9c7d5adc39280 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 22 Oct 2014 09:46:34 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 3/6] Revert "kvmclock: Ensure time in migration never goes
|
|
|
9ae3a8 |
backward"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1413971197-4624-3-git-send-email-dgilbert@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 61788
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 2/5] Revert "kvmclock: Ensure time in migration never goes backward"
|
|
|
9ae3a8 |
Bugzilla: 1098602 1130428
|
|
|
9ae3a8 |
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This reverts commit 4b6035c2a739bc4c086abbb36f0883a1178a8f1c.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The equivalent upstream revert is Paolo's fa666c10f2f3e15685ff
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/i386/kvm/clock.c | 49 -------------------------------------------------
|
|
|
9ae3a8 |
1 file changed, 49 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
|
|
|
9ae3a8 |
index 1f2a26e..6d6f3a7 100644
|
|
|
9ae3a8 |
--- a/hw/i386/kvm/clock.c
|
|
|
9ae3a8 |
+++ b/hw/i386/kvm/clock.c
|
|
|
9ae3a8 |
@@ -14,7 +14,6 @@
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include "qemu-common.h"
|
|
|
9ae3a8 |
-#include "qemu/host-utils.h"
|
|
|
9ae3a8 |
#include "sysemu/sysemu.h"
|
|
|
9ae3a8 |
#include "sysemu/kvm.h"
|
|
|
9ae3a8 |
#include "hw/sysbus.h"
|
|
|
9ae3a8 |
@@ -29,48 +28,6 @@ typedef struct KVMClockState {
|
|
|
9ae3a8 |
bool clock_valid;
|
|
|
9ae3a8 |
} KVMClockState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-struct pvclock_vcpu_time_info {
|
|
|
9ae3a8 |
- uint32_t version;
|
|
|
9ae3a8 |
- uint32_t pad0;
|
|
|
9ae3a8 |
- uint64_t tsc_timestamp;
|
|
|
9ae3a8 |
- uint64_t system_time;
|
|
|
9ae3a8 |
- uint32_t tsc_to_system_mul;
|
|
|
9ae3a8 |
- int8_t tsc_shift;
|
|
|
9ae3a8 |
- uint8_t flags;
|
|
|
9ae3a8 |
- uint8_t pad[2];
|
|
|
9ae3a8 |
-} __attribute__((__packed__)); /* 32 bytes */
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-static uint64_t kvmclock_current_nsec(KVMClockState *s)
|
|
|
9ae3a8 |
-{
|
|
|
9ae3a8 |
- CPUArchState *acpu = first_cpu;
|
|
|
9ae3a8 |
- CPUState *cpu = ENV_GET_CPU(acpu);
|
|
|
9ae3a8 |
- CPUX86State *env = cpu->env_ptr;
|
|
|
9ae3a8 |
- hwaddr kvmclock_struct_pa = env->system_time_msr & ~1ULL;
|
|
|
9ae3a8 |
- uint64_t migration_tsc = env->tsc;
|
|
|
9ae3a8 |
- struct pvclock_vcpu_time_info time;
|
|
|
9ae3a8 |
- uint64_t delta;
|
|
|
9ae3a8 |
- uint64_t nsec_lo;
|
|
|
9ae3a8 |
- uint64_t nsec_hi;
|
|
|
9ae3a8 |
- uint64_t nsec;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- if (!(env->system_time_msr & 1ULL)) {
|
|
|
9ae3a8 |
- /* KVM clock not active */
|
|
|
9ae3a8 |
- return 0;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- cpu_physical_memory_read(kvmclock_struct_pa, &time, sizeof(time));
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- delta = migration_tsc - time.tsc_timestamp;
|
|
|
9ae3a8 |
- if (time.tsc_shift < 0) {
|
|
|
9ae3a8 |
- delta >>= -time.tsc_shift;
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- delta <<= time.tsc_shift;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- mulu64(&nsec_lo, &nsec_hi, delta, time.tsc_to_system_mul);
|
|
|
9ae3a8 |
- nsec = (nsec_lo >> 32) | (nsec_hi << 32);
|
|
|
9ae3a8 |
- return nsec + time.system_time;
|
|
|
9ae3a8 |
-}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void kvmclock_vm_state_change(void *opaque, int running,
|
|
|
9ae3a8 |
RunState state)
|
|
|
9ae3a8 |
@@ -82,15 +39,9 @@ static void kvmclock_vm_state_change(void *opaque, int running,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (running) {
|
|
|
9ae3a8 |
struct kvm_clock_data data;
|
|
|
9ae3a8 |
- uint64_t time_at_migration = kvmclock_current_nsec(s);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->clock_valid = false;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- /* We can't rely on the migrated clock value, just discard it */
|
|
|
9ae3a8 |
- if (time_at_migration) {
|
|
|
9ae3a8 |
- s->clock = time_at_migration;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
data.clock = s->clock;
|
|
|
9ae3a8 |
data.flags = 0;
|
|
|
9ae3a8 |
ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|