diff options
author | Liu, Jinsong <jinsong.liu@intel.com> | 2012-09-26 12:13:38 +0200 |
---|---|---|
committer | Liu, Jinsong <jinsong.liu@intel.com> | 2012-09-26 12:13:38 +0200 |
commit | e35cd2cce4fe119ef63913f3eb7443b7f5b57d75 (patch) | |
tree | 6b6956fee5f6016a488a44efe54d00bb97d8c470 /xen/arch/x86/hvm/hvm.c | |
parent | 6e0336351ed95e2f72e396b3e1d055a8f5663542 (diff) | |
download | xen-e35cd2cce4fe119ef63913f3eb7443b7f5b57d75.tar.gz xen-e35cd2cce4fe119ef63913f3eb7443b7f5b57d75.tar.bz2 xen-e35cd2cce4fe119ef63913f3eb7443b7f5b57d75.zip |
x86: Save/restore TSC adjust during HVM guest migration
Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/hvm/hvm.c')
-rw-r--r-- | xen/arch/x86/hvm/hvm.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 52ba47ca28..3571916965 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -603,6 +603,46 @@ void hvm_domain_destroy(struct domain *d) hvm_destroy_cacheattr_region_list(d); } +static int hvm_save_tsc_adjust(struct domain *d, hvm_domain_context_t *h) +{ + struct vcpu *v; + struct hvm_tsc_adjust ctxt; + int err = 0; + + for_each_vcpu ( d, v ) + { + ctxt.tsc_adjust = v->arch.hvm_vcpu.msr_tsc_adjust; + err = hvm_save_entry(TSC_ADJUST, v->vcpu_id, h, &ctxt); + if ( err ) + break; + } + + return err; +} + +static int hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *h) +{ + unsigned int vcpuid = hvm_load_instance(h); + struct vcpu *v; + struct hvm_tsc_adjust ctxt; + + if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL ) + { + dprintk(XENLOG_G_ERR, "HVM restore: dom%d has no vcpu%u\n", + d->domain_id, vcpuid); + return -EINVAL; + } + + if ( hvm_load_entry(TSC_ADJUST, h, &ctxt) != 0 ) + return -EINVAL; + + v->arch.hvm_vcpu.msr_tsc_adjust = ctxt.tsc_adjust; + return 0; +} + +HVM_REGISTER_SAVE_RESTORE(TSC_ADJUST, hvm_save_tsc_adjust, + hvm_load_tsc_adjust, 1, HVMSR_PER_VCPU); + static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) { struct vcpu *v; |