ia64/xen-unstable

changeset 5263:14d754e3b044

bitkeeper revision 1.1629.1.1 (429de4faESWSriZYlaDxRVk7hKj32g)

All page directory pages have to be pinned before/during relocation, so
that the entries they contain can be canonicalised during relocation.
mmu_context.h, mmu.h, pgtable.c, ldt.c, reboot.c:
Pin all unpinned in-use pgd's before relocation.
reboot.c:
Flush the pgd cache before relocation.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Jun 01 16:40:26 2005 +0000 (2005-06-01)
parents f3d83aed87fa
children d8410197d991
files linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	Wed Jun 01 14:57:45 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/ldt.c	Wed Jun 01 16:40:26 2005 +0000
     1.3 @@ -18,6 +18,7 @@
     1.4  #include <asm/system.h>
     1.5  #include <asm/ldt.h>
     1.6  #include <asm/desc.h>
     1.7 +#include <asm/mmu_context.h>
     1.8  
     1.9  #ifdef CONFIG_SMP /* avoids "defined but not used" warnig */
    1.10  static void flush_ldt(void *null)
    1.11 @@ -108,6 +109,11 @@ int init_new_context(struct task_struct 
    1.12  		retval = copy_ldt(&mm->context, &old_mm->context);
    1.13  		up(&old_mm->context.sem);
    1.14  	}
    1.15 +	if (retval == 0) {
    1.16 +		spin_lock(&mm_unpinned_lock);
    1.17 +		list_add(&mm->context.unpinned, &mm_unpinned);
    1.18 +		spin_unlock(&mm_unpinned_lock);
    1.19 +	}
    1.20  	return retval;
    1.21  }
    1.22  
    1.23 @@ -128,6 +134,9 @@ void destroy_context(struct mm_struct *m
    1.24  			kfree(mm->context.ldt);
    1.25  		mm->context.size = 0;
    1.26  	}
    1.27 +	spin_lock(&mm_unpinned_lock);
    1.28 +	list_del(&mm->context.unpinned);
    1.29 +	spin_unlock(&mm_unpinned_lock);
    1.30  }
    1.31  
    1.32  static int read_ldt(void __user * ptr, unsigned long bytecount)
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Wed Jun 01 14:57:45 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Wed Jun 01 16:40:26 2005 +0000
     2.3 @@ -408,6 +408,9 @@ void make_pages_writable(void *va, unsig
     2.4  }
     2.5  #endif /* CONFIG_XEN_SHADOW_MODE */
     2.6  
     2.7 +LIST_HEAD(mm_unpinned);
     2.8 +DEFINE_SPINLOCK(mm_unpinned_lock);
     2.9 +
    2.10  static inline void mm_walk_set_prot(void *pt, pgprot_t flags)
    2.11  {
    2.12  	struct page *page = virt_to_page(pt);
    2.13 @@ -461,6 +464,9 @@ void mm_pin(struct mm_struct *mm)
    2.14          pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL_RO), 0);
    2.15      xen_pgd_pin(__pa(mm->pgd));
    2.16      mm->context.pinned = 1;
    2.17 +    spin_lock(&mm_unpinned_lock);
    2.18 +    list_del(&mm->context.unpinned);
    2.19 +    spin_unlock(&mm_unpinned_lock);
    2.20  
    2.21      spin_unlock(&mm->page_table_lock);
    2.22  }
    2.23 @@ -475,10 +481,20 @@ void mm_unpin(struct mm_struct *mm)
    2.24          pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL), 0);
    2.25      mm_walk(mm, PAGE_KERNEL);
    2.26      mm->context.pinned = 0;
    2.27 +    spin_lock(&mm_unpinned_lock);
    2.28 +    list_add(&mm->context.unpinned, &mm_unpinned);
    2.29 +    spin_unlock(&mm_unpinned_lock);
    2.30  
    2.31      spin_unlock(&mm->page_table_lock);
    2.32  }
    2.33  
    2.34 +void mm_pin_all(void)
    2.35 +{
    2.36 +    while (!list_empty(&mm_unpinned))	
    2.37 +	mm_pin(list_entry(mm_unpinned.next, struct mm_struct,
    2.38 +			  context.unpinned));
    2.39 +}
    2.40 +
    2.41  void _arch_exit_mmap(struct mm_struct *mm)
    2.42  {
    2.43      struct task_struct *tsk = current;
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	Wed Jun 01 14:57:45 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	Wed Jun 01 16:40:26 2005 +0000
     3.3 @@ -103,6 +103,9 @@ static void __do_suspend(void)
     3.4  
     3.5      __cli();
     3.6  
     3.7 +    mm_pin_all();
     3.8 +    kmem_cache_shrink(pgd_cache);
     3.9 +
    3.10      netif_suspend();
    3.11  
    3.12      blkdev_suspend();
     4.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	Wed Jun 01 14:57:45 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu.h	Wed Jun 01 16:40:26 2005 +0000
     4.3 @@ -13,8 +13,12 @@ typedef struct {
     4.4  	struct semaphore sem;
     4.5  	void *ldt;
     4.6  	unsigned pinned:1;
     4.7 +	struct list_head unpinned;
     4.8  } mm_context_t;
     4.9  
    4.10 +extern struct list_head mm_unpinned;
    4.11 +extern spinlock_t mm_unpinned_lock;
    4.12 +
    4.13  /* mm/memory.c:exit_mmap hook */
    4.14  extern void _arch_exit_mmap(struct mm_struct *mm);
    4.15  #define arch_exit_mmap(_mm) _arch_exit_mmap(_mm)
     5.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	Wed Jun 01 14:57:45 2005 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h	Wed Jun 01 16:40:26 2005 +0000
     5.3 @@ -43,6 +43,7 @@ static inline void __prepare_arch_switch
     5.4  
     5.5  extern void mm_pin(struct mm_struct *mm);
     5.6  extern void mm_unpin(struct mm_struct *mm);
     5.7 +void mm_pin_all(void);
     5.8  
     5.9  static inline void switch_mm(struct mm_struct *prev,
    5.10  			     struct mm_struct *next,