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