ia64/xen-unstable

changeset 4711:8f212349ae57

bitkeeper revision 1.1395 (4272658bUulIFiNy1X7LMSc8qtcDZw)

Merge http://xen.bkbits.net:8080/xeno-unstable.bk
into gandalf.hpl.hp.com:/var/bk/xeno-unstable.bk
author xenbk@gandalf.hpl.hp.com
date Fri Apr 29 16:49:15 2005 +0000 (2005-04-29)
parents 4aec39caa003 cc205672af7c
children 79b7835ac75d
files BitKeeper/etc/logging_ok linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c
line diff
     1.1 --- a/BitKeeper/etc/logging_ok	Fri Apr 29 10:19:27 2005 +0000
     1.2 +++ b/BitKeeper/etc/logging_ok	Fri Apr 29 16:49:15 2005 +0000
     1.3 @@ -56,6 +56,7 @@ kaf24@striker.cl.cam.ac.uk
     1.4  kaf24@viper.(none)
     1.5  katzj@redhat.com
     1.6  kmacy@shemp.lab.netapp.com
     1.7 +kraxel@bytesex.org
     1.8  laudney@eclipse.(none)
     1.9  leendert@watson.ibm.com
    1.10  lynx@idefix.cl.cam.ac.uk
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Apr 29 10:19:27 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Apr 29 16:49:15 2005 +0000
     2.3 @@ -407,30 +407,58 @@ void make_pages_writable(void *va, unsig
     2.4  }
     2.5  #endif /* CONFIG_XEN_SHADOW_MODE */
     2.6  
     2.7 +static inline void mm_walk_set_prot(void *pt, pgprot_t flags)
     2.8 +{
     2.9 +	struct page *page = virt_to_page(pt);
    2.10 +	unsigned long pfn = page_to_pfn(page);
    2.11 +
    2.12 +	if (PageHighMem(page))
    2.13 +		return;
    2.14 +	HYPERVISOR_update_va_mapping(
    2.15 +		(unsigned long)__va(pfn << PAGE_SHIFT),
    2.16 +		pfn_pte(pfn, flags), 0);
    2.17 +}
    2.18 +
    2.19 +static void mm_walk(struct mm_struct *mm, pgprot_t flags)
    2.20 +{
    2.21 +	pgd_t       *pgd;
    2.22 +	pud_t       *pud;
    2.23 +	pmd_t       *pmd;
    2.24 +	pte_t       *pte;
    2.25 +	int          g,u,m;
    2.26 +
    2.27 +	pgd = mm->pgd;
    2.28 +	for (g = 0; g < USER_PTRS_PER_PGD; g++, pgd++) {
    2.29 +		if (pgd_none(*pgd))
    2.30 +			continue;
    2.31 +		pud = pud_offset(pgd, 0);
    2.32 +		if (PTRS_PER_PUD > 1) /* not folded */
    2.33 +			mm_walk_set_prot(pud,flags);
    2.34 +		for (u = 0; u < PTRS_PER_PUD; u++, pud++) {
    2.35 +			if (pud_none(*pud))
    2.36 +				continue;
    2.37 +			pmd = pmd_offset(pud, 0);
    2.38 +			if (PTRS_PER_PMD > 1) /* not folded */
    2.39 +				mm_walk_set_prot(pmd,flags);
    2.40 +			for (m = 0; m < PTRS_PER_PMD; m++, pmd++) {
    2.41 +				if (pmd_none(*pmd))
    2.42 +					continue;
    2.43 +				pte = pte_offset_kernel(pmd,0);
    2.44 +				mm_walk_set_prot(pte,flags);
    2.45 +			}
    2.46 +		}
    2.47 +	}
    2.48 +}
    2.49 +
    2.50  void mm_pin(struct mm_struct *mm)
    2.51  {
    2.52 -    pgd_t       *pgd;
    2.53 -    struct page *page;
    2.54 -    int          i;
    2.55 -
    2.56      spin_lock(&mm->page_table_lock);
    2.57  
    2.58 -    for ( i = 0, pgd = mm->pgd; i < USER_PTRS_PER_PGD; i++, pgd++ )
    2.59 -    {
    2.60 -        if ( *(unsigned long *)pgd == 0 )
    2.61 -            continue;
    2.62 -        page = pmd_page(*(pmd_t *)pgd);
    2.63 -        if ( !PageHighMem(page) )
    2.64 -            HYPERVISOR_update_va_mapping(
    2.65 -                (unsigned long)__va(page_to_pfn(page)<<PAGE_SHIFT),
    2.66 -                pfn_pte(page_to_pfn(page), PAGE_KERNEL_RO), 0);
    2.67 -    }
    2.68 -
    2.69 +    mm_walk(mm, PAGE_KERNEL_RO);
    2.70      HYPERVISOR_update_va_mapping(
    2.71          (unsigned long)mm->pgd,
    2.72          pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL_RO), 0);
    2.73      xen_pgd_pin(__pa(mm->pgd));
    2.74 -
    2.75      mm->context.pinned = 1;
    2.76  
    2.77      spin_unlock(&mm->page_table_lock);
    2.78 @@ -438,28 +466,13 @@ void mm_pin(struct mm_struct *mm)
    2.79  
    2.80  void mm_unpin(struct mm_struct *mm)
    2.81  {
    2.82 -    pgd_t       *pgd;
    2.83 -    struct page *page;
    2.84 -    int          i;
    2.85 -
    2.86      spin_lock(&mm->page_table_lock);
    2.87  
    2.88      xen_pgd_unpin(__pa(mm->pgd));
    2.89      HYPERVISOR_update_va_mapping(
    2.90          (unsigned long)mm->pgd,
    2.91          pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL), 0);
    2.92 -
    2.93 -    for ( i = 0, pgd = mm->pgd; i < USER_PTRS_PER_PGD; i++, pgd++ )
    2.94 -    {
    2.95 -        if ( *(unsigned long *)pgd == 0 )
    2.96 -            continue;
    2.97 -        page = pmd_page(*(pmd_t *)pgd);
    2.98 -        if ( !PageHighMem(page) )
    2.99 -            HYPERVISOR_update_va_mapping(
   2.100 -                (unsigned long)__va(page_to_pfn(page)<<PAGE_SHIFT),
   2.101 -                pfn_pte(page_to_pfn(page), PAGE_KERNEL), 0);
   2.102 -    }
   2.103 -
   2.104 +    mm_walk(mm, PAGE_KERNEL);
   2.105      mm->context.pinned = 0;
   2.106  
   2.107      spin_unlock(&mm->page_table_lock);