ia64/xen-unstable

changeset 19823:82bbce59b65d

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@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 24 10:48:21 2009 +0100 (2009-06-24)
parents 1b6616141e82
children 50634c215234
files xen/arch/x86/hvm/i8254.c xen/arch/x86/hvm/save.c xen/arch/x86/hvm/vpt.c xen/include/asm-x86/hvm/domain.h xen/include/asm-x86/hvm/vpt.h xen/include/public/arch-x86/hvm/save.h
line diff
     1.1 --- a/xen/arch/x86/hvm/i8254.c	Wed Jun 24 10:47:07 2009 +0100
     1.2 +++ b/xen/arch/x86/hvm/i8254.c	Wed Jun 24 10:48:21 2009 +0100
     1.3 @@ -481,8 +481,6 @@ void pit_init(struct vcpu *v, unsigned l
     1.4      register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
     1.5      register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);
     1.6  
     1.7 -    ticks_per_sec(v) = cpu_khz * (int64_t)1000;
     1.8 -
     1.9      pit_reset(v->domain);
    1.10  }
    1.11  
     2.1 --- a/xen/arch/x86/hvm/save.c	Wed Jun 24 10:47:07 2009 +0100
     2.2 +++ b/xen/arch/x86/hvm/save.c	Wed Jun 24 10:48:21 2009 +0100
     2.3 @@ -32,7 +32,8 @@ void arch_hvm_save(struct domain *d, str
     2.4      cpuid(1, &eax, &ebx, &ecx, &edx);
     2.5      hdr->cpuid = eax;
     2.6  
     2.7 -    hdr->pad0 = 0;
     2.8 +    /* Save guest's preferred TSC. */
     2.9 +    hdr->gtsc_khz = d->arch.hvm_domain.gtsc_khz;
    2.10  }
    2.11  
    2.12  int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
    2.13 @@ -59,6 +60,9 @@ int arch_hvm_load(struct domain *d, stru
    2.14          gdprintk(XENLOG_WARNING, "HVM restore: saved CPUID (%#"PRIx32") "
    2.15                 "does not match host (%#"PRIx32").\n", hdr->cpuid, eax);
    2.16  
    2.17 +    /* Restore guest's preferred TSC frequency. */
    2.18 +    d->arch.hvm_domain.gtsc_khz = hdr->gtsc_khz;
    2.19 +
    2.20      /* VGA state is not saved/restored, so we nobble the cache. */
    2.21      d->arch.hvm_domain.stdvga.cache = 0;
    2.22  
     3.1 --- a/xen/arch/x86/hvm/vpt.c	Wed Jun 24 10:47:07 2009 +0100
     3.2 +++ b/xen/arch/x86/hvm/vpt.c	Wed Jun 24 10:48:21 2009 +0100
     3.3 @@ -32,6 +32,8 @@ void hvm_init_guest_time(struct domain *
     3.4      spin_lock_init(&pl->pl_time_lock);
     3.5      pl->stime_offset = -(u64)get_s_time();
     3.6      pl->last_guest_time = 0;
     3.7 +
     3.8 +    d->arch.hvm_domain.gtsc_khz = cpu_khz;
     3.9  }
    3.10  
    3.11  u64 hvm_get_guest_time(struct vcpu *v)
     4.1 --- a/xen/include/asm-x86/hvm/domain.h	Wed Jun 24 10:47:07 2009 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/domain.h	Wed Jun 24 10:48:21 2009 +0100
     4.3 @@ -44,7 +44,8 @@ struct hvm_domain {
     4.4      struct hvm_ioreq_page  ioreq;
     4.5      struct hvm_ioreq_page  buf_ioreq;
     4.6  
     4.7 -    s64                    tsc_frequency;
     4.8 +    uint32_t               gtsc_khz; /* kHz */
     4.9 +    uint32_t               pad0;
    4.10      struct pl_time         pl_time;
    4.11  
    4.12      struct hvm_io_handler  io_handler;
     5.1 --- a/xen/include/asm-x86/hvm/vpt.h	Wed Jun 24 10:47:07 2009 +0100
     5.2 +++ b/xen/include/asm-x86/hvm/vpt.h	Wed Jun 24 10:48:21 2009 +0100
     5.3 @@ -136,8 +136,6 @@ struct pl_time {    /* platform time */
     5.4      spinlock_t pl_time_lock;
     5.5  };
     5.6  
     5.7 -#define ticks_per_sec(v) (v->domain->arch.hvm_domain.tsc_frequency)
     5.8 -
     5.9  void pt_save_timer(struct vcpu *v);
    5.10  void pt_restore_timer(struct vcpu *v);
    5.11  void pt_update_irq(struct vcpu *v);
     6.1 --- a/xen/include/public/arch-x86/hvm/save.h	Wed Jun 24 10:47:07 2009 +0100
     6.2 +++ b/xen/include/public/arch-x86/hvm/save.h	Wed Jun 24 10:48:21 2009 +0100
     6.3 @@ -38,7 +38,7 @@ struct hvm_save_header {
     6.4      uint32_t version;           /* File format version */
     6.5      uint64_t changeset;         /* Version of Xen that saved this file */
     6.6      uint32_t cpuid;             /* CPUID[0x01][%eax] on the saving machine */
     6.7 -    uint32_t pad0;
     6.8 +    uint32_t gtsc_khz;        /* Guest's TSC frequency in kHz */
     6.9  };
    6.10  
    6.11  DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);