[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] save/restore : Save guest's preferred TSC frequency in image



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1245836901 -3600
# Node ID 82bbce59b65d568390305f559354b7b1a342fa4c
# Parent  1b6616141e8288ff09e036a813ad712a0f5b6e64
save/restore : Save guest's preferred TSC frequency in image

For save/restore or live migration between two different frequency
platforms, guest's preferred TSC frequency is required to caculate
guest's TSC after resotre, so save it in the image header.

Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx>
---
 xen/arch/x86/hvm/i8254.c               |    2 --
 xen/arch/x86/hvm/save.c                |    6 +++++-
 xen/arch/x86/hvm/vpt.c                 |    2 ++
 xen/include/asm-x86/hvm/domain.h       |    3 ++-
 xen/include/asm-x86/hvm/vpt.h          |    2 --
 xen/include/public/arch-x86/hvm/save.h |    2 +-
 6 files changed, 10 insertions(+), 7 deletions(-)

diff -r 1b6616141e82 -r 82bbce59b65d xen/arch/x86/hvm/i8254.c
--- a/xen/arch/x86/hvm/i8254.c  Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/arch/x86/hvm/i8254.c  Wed Jun 24 10:48:21 2009 +0100
@@ -481,8 +481,6 @@ void pit_init(struct vcpu *v, unsigned l
     register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
     register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);
 
-    ticks_per_sec(v) = cpu_khz * (int64_t)1000;
-
     pit_reset(v->domain);
 }
 
diff -r 1b6616141e82 -r 82bbce59b65d xen/arch/x86/hvm/save.c
--- a/xen/arch/x86/hvm/save.c   Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/arch/x86/hvm/save.c   Wed Jun 24 10:48:21 2009 +0100
@@ -32,7 +32,8 @@ void arch_hvm_save(struct domain *d, str
     cpuid(1, &eax, &ebx, &ecx, &edx);
     hdr->cpuid = eax;
 
-    hdr->pad0 = 0;
+    /* Save guest's preferred TSC. */
+    hdr->gtsc_khz = d->arch.hvm_domain.gtsc_khz;
 }
 
 int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
@@ -59,6 +60,9 @@ int arch_hvm_load(struct domain *d, stru
         gdprintk(XENLOG_WARNING, "HVM restore: saved CPUID (%#"PRIx32") "
                "does not match host (%#"PRIx32").\n", hdr->cpuid, eax);
 
+    /* Restore guest's preferred TSC frequency. */
+    d->arch.hvm_domain.gtsc_khz = hdr->gtsc_khz;
+
     /* VGA state is not saved/restored, so we nobble the cache. */
     d->arch.hvm_domain.stdvga.cache = 0;
 
diff -r 1b6616141e82 -r 82bbce59b65d xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c    Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/arch/x86/hvm/vpt.c    Wed Jun 24 10:48:21 2009 +0100
@@ -32,6 +32,8 @@ void hvm_init_guest_time(struct domain *
     spin_lock_init(&pl->pl_time_lock);
     pl->stime_offset = -(u64)get_s_time();
     pl->last_guest_time = 0;
+
+    d->arch.hvm_domain.gtsc_khz = cpu_khz;
 }
 
 u64 hvm_get_guest_time(struct vcpu *v)
diff -r 1b6616141e82 -r 82bbce59b65d xen/include/asm-x86/hvm/domain.h
--- a/xen/include/asm-x86/hvm/domain.h  Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/include/asm-x86/hvm/domain.h  Wed Jun 24 10:48:21 2009 +0100
@@ -44,7 +44,8 @@ struct hvm_domain {
     struct hvm_ioreq_page  ioreq;
     struct hvm_ioreq_page  buf_ioreq;
 
-    s64                    tsc_frequency;
+    uint32_t               gtsc_khz; /* kHz */
+    uint32_t               pad0;
     struct pl_time         pl_time;
 
     struct hvm_io_handler  io_handler;
diff -r 1b6616141e82 -r 82bbce59b65d xen/include/asm-x86/hvm/vpt.h
--- a/xen/include/asm-x86/hvm/vpt.h     Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/include/asm-x86/hvm/vpt.h     Wed Jun 24 10:48:21 2009 +0100
@@ -136,8 +136,6 @@ struct pl_time {    /* platform time */
     spinlock_t pl_time_lock;
 };
 
-#define ticks_per_sec(v) (v->domain->arch.hvm_domain.tsc_frequency)
-
 void pt_save_timer(struct vcpu *v);
 void pt_restore_timer(struct vcpu *v);
 void pt_update_irq(struct vcpu *v);
diff -r 1b6616141e82 -r 82bbce59b65d xen/include/public/arch-x86/hvm/save.h
--- a/xen/include/public/arch-x86/hvm/save.h    Wed Jun 24 10:47:07 2009 +0100
+++ b/xen/include/public/arch-x86/hvm/save.h    Wed Jun 24 10:48:21 2009 +0100
@@ -38,7 +38,7 @@ struct hvm_save_header {
     uint32_t version;           /* File format version */
     uint64_t changeset;         /* Version of Xen that saved this file */
     uint32_t cpuid;             /* CPUID[0x01][%eax] on the saving machine */
-    uint32_t pad0;
+    uint32_t gtsc_khz;        /* Guest's TSC frequency in kHz */
 };
 
 DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.