[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] linux: Clean up mm_pin/unpin.
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1173090405 0 # Node ID f5b9ad8acea58d7396f959cbddadf6da8dc7f272 # Parent 25c0b660f7c6223feaf2387e62a1899f2c85b196 linux: Clean up mm_pin/unpin. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c | 58 ++++++++++----------- linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c | 11 ++- 2 files changed, 37 insertions(+), 32 deletions(-) diff -r 25c0b660f7c6 -r f5b9ad8acea5 linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c --- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c Sat Mar 03 20:42:38 2007 +0000 +++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c Mon Mar 05 10:26:45 2007 +0000 @@ -573,64 +573,67 @@ void make_pages_writable(void *va, unsig } } -static inline int pgd_walk_set_prot(struct page *page, pgprot_t flags) +static inline void pgd_walk_set_prot(struct page *page, pgprot_t flags) { unsigned long pfn = page_to_pfn(page); - - if (PageHighMem(page)) - return pgprot_val(flags) & _PAGE_RW - ? test_and_clear_bit(PG_pinned, &page->flags) - : !test_and_set_bit(PG_pinned, &page->flags); - - BUG_ON(HYPERVISOR_update_va_mapping( - (unsigned long)__va(pfn << PAGE_SHIFT), - pfn_pte(pfn, flags), 0)); - - return 0; -} - -static int pgd_walk(pgd_t *pgd_base, pgprot_t flags) + int rc; + + if (PageHighMem(page)) { + if (pgprot_val(flags) & _PAGE_RW) + clear_bit(PG_pinned, &page->flags); + else + set_bit(PG_pinned, &page->flags); + } else { + rc = HYPERVISOR_update_va_mapping( + (unsigned long)__va(pfn << PAGE_SHIFT), + pfn_pte(pfn, flags), 0); + if (rc) + BUG(); + } +} + +static void pgd_walk(pgd_t *pgd_base, pgprot_t flags) { pgd_t *pgd = pgd_base; pud_t *pud; pmd_t *pmd; - int g, u, m, flush; + int g, u, m, rc; if (xen_feature(XENFEAT_auto_translated_physmap)) return 0; - for (g = 0, flush = 0; g < USER_PTRS_PER_PGD; g++, pgd++) { + for (g = 0; g < USER_PTRS_PER_PGD; g++, pgd++) { if (pgd_none(*pgd)) continue; pud = pud_offset(pgd, 0); if (PTRS_PER_PUD > 1) /* not folded */ - flush |= pgd_walk_set_prot(virt_to_page(pud),flags); + pgd_walk_set_prot(virt_to_page(pud),flags); for (u = 0; u < PTRS_PER_PUD; u++, pud++) { if (pud_none(*pud)) continue; pmd = pmd_offset(pud, 0); if (PTRS_PER_PMD > 1) /* not folded */ - flush |= pgd_walk_set_prot(virt_to_page(pmd),flags); + pgd_walk_set_prot(virt_to_page(pmd),flags); for (m = 0; m < PTRS_PER_PMD; m++, pmd++) { if (pmd_none(*pmd)) continue; - flush |= pgd_walk_set_prot(pmd_page(*pmd),flags); + pgd_walk_set_prot(pmd_page(*pmd),flags); } } } - BUG_ON(HYPERVISOR_update_va_mapping( + rc = HYPERVISOR_update_va_mapping( (unsigned long)pgd_base, pfn_pte(virt_to_phys(pgd_base)>>PAGE_SHIFT, flags), - UVMF_TLB_FLUSH)); - - return flush; + UVMF_TLB_FLUSH); + if (rc) + BUG(); } static void __pgd_pin(pgd_t *pgd) { - if (pgd_walk(pgd, PAGE_KERNEL_RO)) - kmap_flush_unused(); + pgd_walk(pgd, PAGE_KERNEL_RO); + kmap_flush_unused(); xen_pgd_pin(__pa(pgd)); set_bit(PG_pinned, &virt_to_page(pgd)->flags); } @@ -638,8 +641,7 @@ static void __pgd_unpin(pgd_t *pgd) static void __pgd_unpin(pgd_t *pgd) { xen_pgd_unpin(__pa(pgd)); - if (pgd_walk(pgd, PAGE_KERNEL)) - kmap_flush_unused(); + pgd_walk(pgd, PAGE_KERNEL); clear_bit(PG_pinned, &virt_to_page(pgd)->flags); } diff -r 25c0b660f7c6 -r f5b9ad8acea5 linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c --- a/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c Sat Mar 03 20:42:38 2007 +0000 +++ b/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c Mon Mar 05 10:26:45 2007 +0000 @@ -24,10 +24,13 @@ static inline void mm_walk_set_prot(void { struct page *page = virt_to_page(pt); unsigned long pfn = page_to_pfn(page); - - BUG_ON(HYPERVISOR_update_va_mapping( - (unsigned long)__va(pfn << PAGE_SHIFT), - pfn_pte(pfn, flags), 0)); + int rc; + + rc = HYPERVISOR_update_va_mapping( + (unsigned long)__va(pfn << PAGE_SHIFT), + pfn_pte(pfn, flags), 0); + if (rc) + BUG(); } static void mm_walk(struct mm_struct *mm, pgprot_t flags) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |