ia64/xen-unstable

changeset 14229:f5b9ad8acea5

linux: Clean up mm_pin/unpin.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Mar 05 10:26:45 2007 +0000 (2007-03-05)
parents 25c0b660f7c6
children aae662fdf53e
files linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Sat Mar 03 20:42:38 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Mon Mar 05 10:26:45 2007 +0000
     1.3 @@ -573,64 +573,67 @@ void make_pages_writable(void *va, unsig
     1.4  	}
     1.5  }
     1.6  
     1.7 -static inline int pgd_walk_set_prot(struct page *page, pgprot_t flags)
     1.8 +static inline void pgd_walk_set_prot(struct page *page, pgprot_t flags)
     1.9  {
    1.10  	unsigned long pfn = page_to_pfn(page);
    1.11 -
    1.12 -	if (PageHighMem(page))
    1.13 -		return pgprot_val(flags) & _PAGE_RW
    1.14 -		       ? test_and_clear_bit(PG_pinned, &page->flags)
    1.15 -		       : !test_and_set_bit(PG_pinned, &page->flags);
    1.16 +	int rc;
    1.17  
    1.18 -	BUG_ON(HYPERVISOR_update_va_mapping(
    1.19 -		(unsigned long)__va(pfn << PAGE_SHIFT),
    1.20 -		pfn_pte(pfn, flags), 0));
    1.21 -
    1.22 -	return 0;
    1.23 +	if (PageHighMem(page)) {
    1.24 +		if (pgprot_val(flags) & _PAGE_RW)
    1.25 +			clear_bit(PG_pinned, &page->flags);
    1.26 +		else
    1.27 +			set_bit(PG_pinned, &page->flags);
    1.28 +	} else {
    1.29 +		rc = HYPERVISOR_update_va_mapping(
    1.30 +			(unsigned long)__va(pfn << PAGE_SHIFT),
    1.31 +			pfn_pte(pfn, flags), 0);
    1.32 +		if (rc)
    1.33 +			BUG();
    1.34 +	}
    1.35  }
    1.36  
    1.37 -static int pgd_walk(pgd_t *pgd_base, pgprot_t flags)
    1.38 +static void pgd_walk(pgd_t *pgd_base, pgprot_t flags)
    1.39  {
    1.40  	pgd_t *pgd = pgd_base;
    1.41  	pud_t *pud;
    1.42  	pmd_t *pmd;
    1.43 -	int    g, u, m, flush;
    1.44 +	int    g, u, m, rc;
    1.45  
    1.46  	if (xen_feature(XENFEAT_auto_translated_physmap))
    1.47  		return 0;
    1.48  
    1.49 -	for (g = 0, flush = 0; g < USER_PTRS_PER_PGD; g++, pgd++) {
    1.50 +	for (g = 0; g < USER_PTRS_PER_PGD; g++, pgd++) {
    1.51  		if (pgd_none(*pgd))
    1.52  			continue;
    1.53  		pud = pud_offset(pgd, 0);
    1.54  		if (PTRS_PER_PUD > 1) /* not folded */
    1.55 -			flush |= pgd_walk_set_prot(virt_to_page(pud),flags);
    1.56 +			pgd_walk_set_prot(virt_to_page(pud),flags);
    1.57  		for (u = 0; u < PTRS_PER_PUD; u++, pud++) {
    1.58  			if (pud_none(*pud))
    1.59  				continue;
    1.60  			pmd = pmd_offset(pud, 0);
    1.61  			if (PTRS_PER_PMD > 1) /* not folded */
    1.62 -				flush |= pgd_walk_set_prot(virt_to_page(pmd),flags);
    1.63 +				pgd_walk_set_prot(virt_to_page(pmd),flags);
    1.64  			for (m = 0; m < PTRS_PER_PMD; m++, pmd++) {
    1.65  				if (pmd_none(*pmd))
    1.66  					continue;
    1.67 -				flush |= pgd_walk_set_prot(pmd_page(*pmd),flags);
    1.68 +				pgd_walk_set_prot(pmd_page(*pmd),flags);
    1.69  			}
    1.70  		}
    1.71  	}
    1.72  
    1.73 -	BUG_ON(HYPERVISOR_update_va_mapping(
    1.74 +	rc = HYPERVISOR_update_va_mapping(
    1.75  		(unsigned long)pgd_base,
    1.76  		pfn_pte(virt_to_phys(pgd_base)>>PAGE_SHIFT, flags),
    1.77 -		UVMF_TLB_FLUSH));
    1.78 -
    1.79 -	return flush;
    1.80 +		UVMF_TLB_FLUSH);
    1.81 +	if (rc)
    1.82 +		BUG();
    1.83  }
    1.84  
    1.85  static void __pgd_pin(pgd_t *pgd)
    1.86  {
    1.87 -	if (pgd_walk(pgd, PAGE_KERNEL_RO))
    1.88 -		kmap_flush_unused();
    1.89 +	pgd_walk(pgd, PAGE_KERNEL_RO);
    1.90 +	kmap_flush_unused();
    1.91  	xen_pgd_pin(__pa(pgd));
    1.92  	set_bit(PG_pinned, &virt_to_page(pgd)->flags);
    1.93  }
    1.94 @@ -638,8 +641,7 @@ static void __pgd_pin(pgd_t *pgd)
    1.95  static void __pgd_unpin(pgd_t *pgd)
    1.96  {
    1.97  	xen_pgd_unpin(__pa(pgd));
    1.98 -	if (pgd_walk(pgd, PAGE_KERNEL))
    1.99 -		kmap_flush_unused();
   1.100 +	pgd_walk(pgd, PAGE_KERNEL);
   1.101  	clear_bit(PG_pinned, &virt_to_page(pgd)->flags);
   1.102  }
   1.103  
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c	Sat Mar 03 20:42:38 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c	Mon Mar 05 10:26:45 2007 +0000
     2.3 @@ -24,10 +24,13 @@ static inline void mm_walk_set_prot(void
     2.4  {
     2.5  	struct page *page = virt_to_page(pt);
     2.6  	unsigned long pfn = page_to_pfn(page);
     2.7 +	int rc;
     2.8  
     2.9 -	BUG_ON(HYPERVISOR_update_va_mapping(
    2.10 -		       (unsigned long)__va(pfn << PAGE_SHIFT),
    2.11 -		       pfn_pte(pfn, flags), 0));
    2.12 +	rc = HYPERVISOR_update_va_mapping(
    2.13 +		(unsigned long)__va(pfn << PAGE_SHIFT),
    2.14 +		pfn_pte(pfn, flags), 0);
    2.15 +	if (rc)
    2.16 +		BUG();
    2.17  }
    2.18  
    2.19  static void mm_walk(struct mm_struct *mm, pgprot_t flags)