ia64/xen-unstable

changeset 12602:658b9c47db98

[XEN] Don't unpin old shadow top levels until the new ones are pinned.
This will stop a possible case where we unshadow an entire process
on a TLB-flush CR3 write.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Tue Nov 28 09:39:32 2006 +0000 (2006-11-28)
parents 3b961863062d
children b4baf35cff11
files xen/arch/x86/mm/shadow/multi.c
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/multi.c	Mon Nov 27 20:04:20 2006 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Tue Nov 28 09:39:32 2006 +0000
     1.3 @@ -3294,20 +3294,18 @@ sh_set_toplevel_shadow(struct vcpu *v,
     1.4                         unsigned int root_type) 
     1.5  {
     1.6      mfn_t smfn;
     1.7 +    pagetable_t old_entry, new_entry;
     1.8 +
     1.9      struct domain *d = v->domain;
    1.10      
    1.11 -    /* Decrement the refcount of the old contents of this slot */
    1.12 -    smfn = pagetable_get_mfn(v->arch.shadow_table[slot]);
    1.13 -    if ( mfn_x(smfn) )
    1.14 -        sh_put_ref(v, smfn, 0);
    1.15 +    /* Remember the old contents of this slot */
    1.16 +    old_entry = v->arch.shadow_table[slot];
    1.17  
    1.18      /* Now figure out the new contents: is this a valid guest MFN? */
    1.19      if ( !valid_mfn(gmfn) )
    1.20      {
    1.21 -        SHADOW_PRINTK("%u/%u [%u] invalid gmfn\n",
    1.22 -                      GUEST_PAGING_LEVELS, SHADOW_PAGING_LEVELS, slot);
    1.23 -        v->arch.shadow_table[slot] = pagetable_null();
    1.24 -        return;
    1.25 +        new_entry = pagetable_null();
    1.26 +        goto install_new_entry;
    1.27      }
    1.28  
    1.29      /* Guest mfn is valid: shadow it and install the shadow */
    1.30 @@ -3342,11 +3340,18 @@ sh_set_toplevel_shadow(struct vcpu *v,
    1.31          domain_crash(v->domain);
    1.32      }
    1.33  
    1.34 +    new_entry = pagetable_from_mfn(smfn);
    1.35 +
    1.36 + install_new_entry:
    1.37      /* Done.  Install it */
    1.38      SHADOW_PRINTK("%u/%u [%u] gmfn %#"SH_PRI_mfn" smfn %#"SH_PRI_mfn"\n",
    1.39                    GUEST_PAGING_LEVELS, SHADOW_PAGING_LEVELS, slot,
    1.40 -                  mfn_x(gmfn), mfn_x(smfn));
    1.41 -    v->arch.shadow_table[slot] = pagetable_from_mfn(smfn);
    1.42 +                  mfn_x(gmfn), mfn_x(pagetable_get_mfn(new_entry)));
    1.43 +    v->arch.shadow_table[slot] = new_entry;
    1.44 +
    1.45 +    /* Decrement the refcount of the old contents of this slot */
    1.46 +    if ( !pagetable_is_null(old_entry) )
    1.47 +        sh_put_ref(v, pagetable_get_mfn(old_entry), 0);
    1.48  }
    1.49  
    1.50