ia64/xen-unstable

changeset 7621:76fbcb25d174

Fix map_domain_page() by reverting a bogus simplification
that I committed in changeset 5303:d68bc64e2cfe38a85483a8c5d349b4ee45e91fb9
This fixes some very weird and nasty Xen crashes.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Nov 02 19:12:30 2005 +0100 (2005-11-02)
parents 9cdfcecf4968
children ca2e91ab4311
files xen/arch/x86/x86_32/domain_page.c
line diff
     1.1 --- a/xen/arch/x86/x86_32/domain_page.c	Wed Nov 02 17:29:32 2005 +0100
     1.2 +++ b/xen/arch/x86/x86_32/domain_page.c	Wed Nov 02 19:12:30 2005 +0100
     1.3 @@ -27,6 +27,19 @@ l1_pgentry_t *mapcache;
     1.4  static unsigned int map_idx, epoch, shadow_epoch[NR_CPUS];
     1.5  static spinlock_t map_lock = SPIN_LOCK_UNLOCKED;
     1.6  
     1.7 +/* Use a spare PTE bit to mark entries ready for recycling. */
     1.8 +#define READY_FOR_TLB_FLUSH (1<<10)
     1.9 +
    1.10 +static void flush_all_ready_maps(void)
    1.11 +{
    1.12 +    l1_pgentry_t *cache = mapcache;
    1.13 +    unsigned int i;
    1.14 +
    1.15 +    for ( i = 0; i < MAPCACHE_ENTRIES; i++ )
    1.16 +        if ( (l1e_get_flags(cache[i]) & READY_FOR_TLB_FLUSH) )
    1.17 +            cache[i] = l1e_empty();
    1.18 +}
    1.19 +
    1.20  void *map_domain_page(unsigned long pfn)
    1.21  {
    1.22      unsigned long va;
    1.23 @@ -54,6 +67,7 @@ void *map_domain_page(unsigned long pfn)
    1.24          if ( unlikely(idx == 0) )
    1.25          {
    1.26              ASSERT(flush_count++ == 0);
    1.27 +            flush_all_ready_maps();
    1.28              perfc_incrc(domain_page_tlb_flush);
    1.29              local_flush_tlb();
    1.30              shadow_epoch[cpu] = ++epoch;
    1.31 @@ -75,5 +89,5 @@ void unmap_domain_page(void *va)
    1.32      ASSERT((void *)MAPCACHE_VIRT_START <= va);
    1.33      ASSERT(va < (void *)MAPCACHE_VIRT_END);
    1.34      idx = ((unsigned long)va - MAPCACHE_VIRT_START) >> PAGE_SHIFT;
    1.35 -    mapcache[idx] = l1e_empty();
    1.36 +    l1e_add_flags(mapcache[idx], READY_FOR_TLB_FLUSH);
    1.37  }