direct-io.hg

changeset 14406:a20e3ad50ae8

[HVM][SVM] Save/restore: save the guest's versions of CR0 and EFER
and recalculate the vmcb ones on restore
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Mar 16 11:41:10 2007 +0000 (2007-03-16)
parents 8e76e1b95b12
children ba83d33c961b
files xen/arch/x86/hvm/svm/svm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Mar 16 11:39:50 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Mar 16 11:41:10 2007 +0000
     1.3 @@ -449,6 +449,9 @@ int svm_vmcb_restore(struct vcpu *v, str
     1.4      vmcb->rflags = c->eflags;
     1.5  
     1.6      v->arch.hvm_svm.cpu_shadow_cr0 = c->cr0;
     1.7 +    vmcb->cr0 = c->cr0 | X86_CR0_WP | X86_CR0_ET;
     1.8 +    if ( !paging_mode_hap(v->domain) ) 
     1.9 +        vmcb->cr0 |= X86_CR0_PG;
    1.10  
    1.11  #ifdef HVM_DEBUG_SUSPEND
    1.12      printk("%s: cr3=0x%"PRIx64", cr0=0x%"PRIx64", cr4=0x%"PRIx64".\n",
    1.13 @@ -566,7 +569,7 @@ void svm_save_cpu_state(struct vcpu *v, 
    1.14      data->msr_star         = vmcb->star;
    1.15      data->msr_cstar        = vmcb->cstar;
    1.16      data->msr_syscall_mask = vmcb->sfmask;
    1.17 -    data->msr_efer         = vmcb->efer;
    1.18 +    data->msr_efer         = v->arch.hvm_svm.cpu_shadow_efer;
    1.19  
    1.20      data->tsc = hvm_get_guest_time(v);
    1.21  }
    1.22 @@ -581,7 +584,12 @@ void svm_load_cpu_state(struct vcpu *v, 
    1.23      vmcb->star       = data->msr_star;
    1.24      vmcb->cstar      = data->msr_cstar;
    1.25      vmcb->sfmask     = data->msr_syscall_mask;
    1.26 -    vmcb->efer       = data->msr_efer;
    1.27 +    v->arch.hvm_svm.cpu_shadow_efer = data->msr_efer;
    1.28 +    vmcb->efer       = data->msr_efer | EFER_SVME;
    1.29 +    /* VMCB's EFER.LME isn't set unless we're actually in long mode
    1.30 +     * (see long_mode_do_msr_write()) */
    1.31 +    if ( !(vmcb->efer & EFER_LMA) )
    1.32 +        vmcb->efer &= ~EFER_LME;
    1.33  
    1.34      hvm_set_guest_time(v, data->tsc);
    1.35  }