ia64/xen-unstable

changeset 15444:b14bbd41e9dc

[VMX] Set up GUEST_CR0 as well as CR0_READ_SHADOW when restoring saved
vcpus. Also simplify the CR3 reload path.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Tue Jun 26 17:54:10 2007 +0100 (2007-06-26)
parents 9261686d840c
children c72a93cbcedb
files xen/arch/x86/hvm/vmx/vmx.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Jun 26 12:40:37 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Jun 26 17:54:10 2007 +0100
     1.3 @@ -560,6 +560,9 @@ int vmx_vmcs_restore(struct vcpu *v, str
     1.4      __vmwrite(GUEST_RSP, c->rsp);
     1.5      __vmwrite(GUEST_RFLAGS, c->rflags);
     1.6  
     1.7 +    v->arch.hvm_vmx.cpu_cr0 = (c->cr0 | X86_CR0_PE | X86_CR0_PG 
     1.8 +                               | X86_CR0_NE | X86_CR0_WP | X86_CR0_ET);
     1.9 +    __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
    1.10      v->arch.hvm_vmx.cpu_shadow_cr0 = c->cr0;
    1.11      __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
    1.12  
    1.13 @@ -577,33 +580,17 @@ int vmx_vmcs_restore(struct vcpu *v, str
    1.14          goto skip_cr3;
    1.15      }
    1.16  
    1.17 -    if (c->cr3 == v->arch.hvm_vmx.cpu_cr3) {
    1.18 -        /*
    1.19 -         * This is simple TLB flush, implying the guest has
    1.20 -         * removed some translation or changed page attributes.
    1.21 -         * We simply invalidate the shadow.
    1.22 -         */
    1.23 -        mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
    1.24 -        if (mfn != pagetable_get_pfn(v->arch.guest_table)) {
    1.25 -            goto bad_cr3;
    1.26 -        }
    1.27 -    } else {
    1.28 -        /*
    1.29 -         * If different, make a shadow. Check if the PDBR is valid
    1.30 -         * first.
    1.31 -         */
    1.32 -        HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %"PRIx64, c->cr3);
    1.33 -        /* current!=vcpu as not called by arch_vmx_do_launch */
    1.34 -        mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
    1.35 -        if( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain)) {
    1.36 -            goto bad_cr3;
    1.37 -        }
    1.38 -        old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
    1.39 -        v->arch.guest_table = pagetable_from_pfn(mfn);
    1.40 -        if (old_base_mfn)
    1.41 -             put_page(mfn_to_page(old_base_mfn));
    1.42 -        v->arch.hvm_vmx.cpu_cr3 = c->cr3;
    1.43 +    HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %"PRIx64, c->cr3);
    1.44 +    /* current!=vcpu as not called by arch_vmx_do_launch */
    1.45 +    mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
    1.46 +    if( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain)) {
    1.47 +        goto bad_cr3;
    1.48      }
    1.49 +    old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
    1.50 +    v->arch.guest_table = pagetable_from_pfn(mfn);
    1.51 +    if (old_base_mfn)
    1.52 +        put_page(mfn_to_page(old_base_mfn));
    1.53 +    v->arch.hvm_vmx.cpu_cr3 = c->cr3;
    1.54  
    1.55   skip_cr3:
    1.56  #if defined(__x86_64__)