ia64/xen-unstable

changeset 13993:d5076a33cbb1

[HVM] Save/restore: explicitly name MSRs in save format
Signed off by: Mats Petersson (Mats.Petersson@amd.com)
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Feb 16 12:34:30 2007 +0000 (2007-02-16)
parents eecd0361df4a
children 8c6d787354d9
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/include/public/hvm/save.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Feb 16 12:13:33 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Feb 16 12:34:30 2007 +0000
     1.3 @@ -362,7 +362,7 @@ static inline void __restore_debug_regis
     1.4  }
     1.5  
     1.6  
     1.7 -int svm_vmcs_save(struct vcpu *v, struct hvm_hw_cpu *c)
     1.8 +int svm_vmcb_save(struct vcpu *v, struct hvm_hw_cpu *c)
     1.9  {
    1.10      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.11  
    1.12 @@ -571,17 +571,14 @@ void svm_save_cpu_state(struct vcpu *v, 
    1.13  {
    1.14      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.15  
    1.16 -    data->shadow_gs = vmcb->kerngsbase;
    1.17 -    /* MSR_LSTAR, MSR_STAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_EFER */    
    1.18 -    data->msr_items[0] = vmcb->lstar;
    1.19 -    data->msr_items[1] = vmcb->star;
    1.20 -    data->msr_items[2] = vmcb->cstar;
    1.21 -    data->msr_items[3] = vmcb->sfmask;
    1.22 -    data->msr_items[4] = vmcb->efer;
    1.23 +    data->shadow_gs        = vmcb->kerngsbase;
    1.24 +    data->msr_lstar        = vmcb->lstar;
    1.25 +    data->msr_star         = vmcb->star;
    1.26 +    data->msr_cstar        = vmcb->cstar;
    1.27 +    data->msr_syscall_mask = vmcb->sfmask;
    1.28 +    data->msr_efer         = vmcb->efer;
    1.29  
    1.30      data->tsc = hvm_get_guest_time(v);
    1.31 -
    1.32 -    // dump_msr_state(guest_state);
    1.33  }
    1.34  
    1.35  
    1.36 @@ -590,22 +587,19 @@ void svm_load_cpu_state(struct vcpu *v, 
    1.37      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.38  
    1.39      vmcb->kerngsbase = data->shadow_gs;
    1.40 -    /* MSR_LSTAR, MSR_STAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_EFER */
    1.41 -    vmcb->lstar  = data->msr_items[0];
    1.42 -    vmcb->star   = data->msr_items[1];
    1.43 -    vmcb->cstar  = data->msr_items[2];
    1.44 -    vmcb->sfmask = data->msr_items[3];
    1.45 -    vmcb->efer   = data->msr_items[4];
    1.46 +    vmcb->lstar      = data->msr_lstar;
    1.47 +    vmcb->star       = data->msr_star;
    1.48 +    vmcb->cstar      = data->msr_cstar;
    1.49 +    vmcb->sfmask     = data->msr_syscall_mask;
    1.50 +    vmcb->efer       = data->msr_efer;
    1.51  
    1.52      hvm_set_guest_time(v, data->tsc);
    1.53 -
    1.54 -    // dump_msr_state(guest_state);
    1.55  }
    1.56  
    1.57  void svm_save_vmcb_ctxt(struct vcpu *v, struct hvm_hw_cpu *ctxt)
    1.58  {
    1.59      svm_save_cpu_state(v, ctxt);
    1.60 -    svm_vmcs_save(v, ctxt);
    1.61 +    svm_vmcb_save(v, ctxt);
    1.62  }
    1.63  
    1.64  int svm_load_vmcb_ctxt(struct vcpu *v, struct hvm_hw_cpu *ctxt)
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Feb 16 12:13:33 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Feb 16 12:34:30 2007 +0000
     2.3 @@ -583,15 +583,17 @@ void vmx_save_cpu_state(struct vcpu *v, 
     2.4  {
     2.5      struct vmx_msr_state *guest_state = &v->arch.hvm_vmx.msr_state;
     2.6      unsigned long guest_flags = guest_state->flags;
     2.7 -    int i = 0;
     2.8  
     2.9      data->shadow_gs = guest_state->shadow_gs;
    2.10  
    2.11      /* save msrs */
    2.12      data->flags = guest_flags;
    2.13 -    for (i = 0; i < VMX_MSR_COUNT; i++)
    2.14 -        data->msr_items[i] = guest_state->msrs[i];
    2.15 -    
    2.16 +    data->msr_lstar        = guest_state->msrs[VMX_INDEX_MSR_LSTAR];
    2.17 +    data->msr_star         = guest_state->msrs[VMX_INDEX_MSR_STAR];
    2.18 +    data->msr_cstar        = guest_state->msrs[VMX_INDEX_MSR_CSTAR];
    2.19 +    data->msr_syscall_mask = guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK];
    2.20 +    data->msr_efer         = guest_state->msrs[VMX_INDEX_MSR_EFER];
    2.21 +
    2.22      data->tsc = hvm_get_guest_time(v);
    2.23      
    2.24      dump_msr_state(guest_state);
    2.25 @@ -599,13 +601,15 @@ void vmx_save_cpu_state(struct vcpu *v, 
    2.26  
    2.27  void vmx_load_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data)
    2.28  {
    2.29 -    int i = 0;
    2.30      struct vmx_msr_state *guest_state = &v->arch.hvm_vmx.msr_state;
    2.31  
    2.32      /* restore msrs */
    2.33      guest_state->flags = data->flags;
    2.34 -    for (i = 0; i < VMX_MSR_COUNT; i++)
    2.35 -        guest_state->msrs[i] = data->msr_items[i];
    2.36 +    guest_state->msrs[VMX_INDEX_MSR_LSTAR]        = data->msr_lstar;
    2.37 +    guest_state->msrs[VMX_INDEX_MSR_STAR]         = data->msr_star;
    2.38 +    guest_state->msrs[VMX_INDEX_MSR_CSTAR]        = data->msr_cstar;
    2.39 +    guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK] = data->msr_syscall_mask;
    2.40 +    guest_state->msrs[VMX_INDEX_MSR_EFER]         = data->msr_efer;
    2.41  
    2.42      guest_state->shadow_gs = data->shadow_gs;
    2.43  
     3.1 --- a/xen/include/public/hvm/save.h	Fri Feb 16 12:13:33 2007 +0000
     3.2 +++ b/xen/include/public/hvm/save.h	Fri Feb 16 12:34:30 2007 +0000
     3.3 @@ -140,10 +140,16 @@ struct hvm_hw_cpu {
     3.4      uint64_t sysenter_esp;
     3.5      uint64_t sysenter_eip;
     3.6  
     3.7 -    /* MSRs */
     3.8 +    /* msr for em64t */
     3.9      uint64_t shadow_gs;
    3.10      uint64_t flags;
    3.11 -    uint64_t msr_items[6];
    3.12 +
    3.13 +    /* msr content saved/restored. */
    3.14 +    uint64_t msr_lstar;
    3.15 +    uint64_t msr_star;
    3.16 +    uint64_t msr_cstar;
    3.17 +    uint64_t msr_syscall_mask;
    3.18 +    uint64_t msr_efer;
    3.19  
    3.20      /* guest's idea of what rdtsc() would return */
    3.21      uint64_t tsc;
    3.22 @@ -311,7 +317,6 @@ struct hvm_hw_pci_link {
    3.23  
    3.24  DECLARE_HVM_SAVE_TYPE(PCI_LINK, 9, struct hvm_hw_pci_link);
    3.25  
    3.26 -
    3.27  /* 
    3.28   *  PIT
    3.29   */