ia64/xen-unstable

changeset 12346:d293b17cd1c4

Merge
author Alastair Tse <atse@xensource.com>
date Thu Nov 09 16:20:58 2006 +0000 (2006-11-09)
parents 3b8c07bd0980 b91f42ea5985
children 4eaadb2ae198
files
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/common.c	Thu Nov 09 16:20:26 2006 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/common.c	Thu Nov 09 16:20:58 2006 +0000
     1.3 @@ -635,6 +635,56 @@ void shadow_prealloc(struct domain *d, u
     1.4      BUG();
     1.5  }
     1.6  
     1.7 +#ifndef NDEBUG
     1.8 +/* Deliberately free all the memory we can: this can be used to cause the
     1.9 + * guest's pagetables to be re-shadowed if we suspect that the shadows
    1.10 + * have somehow got out of sync */
    1.11 +static void shadow_blow_tables(unsigned char c)
    1.12 +{
    1.13 +    struct list_head *l, *t;
    1.14 +    struct page_info *pg;
    1.15 +    struct domain *d;
    1.16 +    struct vcpu *v;
    1.17 +    mfn_t smfn;
    1.18 +
    1.19 +    for_each_domain(d)
    1.20 +    {
    1.21 +        if ( shadow_mode_enabled(d) && (v = d->vcpu[0]) != NULL)
    1.22 +        {
    1.23 +            shadow_lock(d);
    1.24 +            printk("Blowing shadow tables for domain %u\n", d->domain_id);
    1.25 +
    1.26 +            /* Pass one: unpin all top-level pages */
    1.27 +            list_for_each_backwards_safe(l,t, &d->arch.shadow.toplevel_shadows)
    1.28 +            {
    1.29 +                pg = list_entry(l, struct page_info, list);
    1.30 +                smfn = page_to_mfn(pg);
    1.31 +                sh_unpin(v, smfn);
    1.32 +            }
    1.33 +
    1.34 +            /* Second pass: unhook entries of in-use shadows */
    1.35 +            list_for_each_backwards_safe(l,t, &d->arch.shadow.toplevel_shadows)
    1.36 +            {
    1.37 +                pg = list_entry(l, struct page_info, list);
    1.38 +                smfn = page_to_mfn(pg);
    1.39 +                shadow_unhook_mappings(v, smfn);
    1.40 +            }
    1.41 +            
    1.42 +            /* Make sure everyone sees the unshadowings */
    1.43 +            flush_tlb_mask(d->domain_dirty_cpumask);
    1.44 +            shadow_unlock(d);
    1.45 +        }
    1.46 +    }
    1.47 +}
    1.48 +
    1.49 +/* Register this function in the Xen console keypress table */
    1.50 +static __init int shadow_blow_tables_keyhandler_init(void)
    1.51 +{
    1.52 +    register_keyhandler('S', shadow_blow_tables, "reset shadow pagetables");
    1.53 +    return 0;
    1.54 +}
    1.55 +__initcall(shadow_blow_tables_keyhandler_init);
    1.56 +#endif /* !NDEBUG */
    1.57  
    1.58  /* Allocate another shadow's worth of (contiguous, aligned) pages,
    1.59   * and fill in the type and backpointer fields of their page_infos.