ia64/xen-unstable

changeset 15709:cb3e6fcb7f34

On debug builds, scrub pages with non-zero poison.
Will flush out guests which are relying on zeroed memory.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Aug 03 12:22:33 2007 +0100 (2007-08-03)
parents 52e5c110aadb
children 0120cca78435
files xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/page_alloc.c	Fri Aug 03 12:10:35 2007 +0100
     1.2 +++ b/xen/common/page_alloc.c	Fri Aug 03 12:22:33 2007 +0100
     1.3 @@ -91,6 +91,14 @@ custom_param("dma_emergency_pool", parse
     1.4  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
     1.5  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
     1.6  
     1.7 +#ifndef NDEBUG
     1.8 +/* Avoid callers relying on allocations returning zeroed pages. */
     1.9 +#define scrub_page(p) memset((p), 0xc2, PAGE_SIZE)
    1.10 +#else
    1.11 +/* For a production build, clear_page() is the fastest way to scrub. */
    1.12 +#define scrub_page(p) clear_page(p)
    1.13 +#endif
    1.14 +
    1.15  static DEFINE_SPINLOCK(page_scrub_lock);
    1.16  LIST_HEAD(page_scrub_list);
    1.17  static unsigned long scrub_pages;
    1.18 @@ -618,13 +626,13 @@ void __init scrub_heap_pages(void)
    1.19              {
    1.20                  p = page_to_virt(mfn_to_page(mfn));
    1.21                  memguard_unguard_range(p, PAGE_SIZE);
    1.22 -                clear_page(p);
    1.23 +                scrub_page(p);
    1.24                  memguard_guard_range(p, PAGE_SIZE);
    1.25              }
    1.26              else
    1.27              {
    1.28                  p = map_domain_page(mfn);
    1.29 -                clear_page(p);
    1.30 +                scrub_page(p);
    1.31                  unmap_domain_page(p);
    1.32              }
    1.33          }
    1.34 @@ -1018,7 +1026,7 @@ static void page_scrub_softirq(void)
    1.35              pg = list_entry(ent, struct page_info, list);
    1.36              ent = ent->prev;
    1.37              p = map_domain_page(page_to_mfn(pg));
    1.38 -            clear_page(p);
    1.39 +            scrub_page(p);
    1.40              unmap_domain_page(p);
    1.41              free_heap_pages(pfn_dom_zone_type(page_to_mfn(pg)), pg, 0);
    1.42          }