Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: refactor xen_{alloc,release}_{pt,pd}()

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Cc: xen-devel@lists.xensource.com
Cc: Mark McLoughlin <markmc@redhat.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Mark McLoughlin and committed by
Ingo Molnar
f6433706 8f59610d

+27 -14
+20 -7
arch/x86/xen/enlighten.c
··· 667 667 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); 668 668 } 669 669 670 - static void pin_pagetable_pfn(unsigned level, unsigned long pfn) 670 + static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn) 671 671 { 672 672 struct mmuext_op op; 673 - op.cmd = level; 673 + op.cmd = cmd; 674 674 op.arg1.mfn = pfn_to_mfn(pfn); 675 675 if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF)) 676 676 BUG(); ··· 687 687 688 688 if (!PageHighMem(page)) { 689 689 make_lowmem_page_readonly(__va(PFN_PHYS(pfn))); 690 - pin_pagetable_pfn(level, pfn); 690 + if (level == PT_PTE) 691 + pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); 692 + else if (level == PT_PMD) 693 + pin_pagetable_pfn(MMUEXT_PIN_L2_TABLE, pfn); 691 694 } else 692 695 /* make sure there are no stray mappings of 693 696 this page */ ··· 700 697 701 698 static void xen_alloc_pt(struct mm_struct *mm, u32 pfn) 702 699 { 703 - xen_alloc_ptpage(mm, pfn, MMUEXT_PIN_L1_TABLE); 700 + xen_alloc_ptpage(mm, pfn, PT_PTE); 704 701 } 705 702 706 703 static void xen_alloc_pd(struct mm_struct *mm, u32 pfn) 707 704 { 708 - xen_alloc_ptpage(mm, pfn, MMUEXT_PIN_L2_TABLE); 705 + xen_alloc_ptpage(mm, pfn, PT_PMD); 709 706 } 710 707 711 708 /* This should never happen until we're OK to use struct page */ 712 - static void xen_release_pt(u32 pfn) 709 + static void xen_release_ptpage(u32 pfn, unsigned level) 713 710 { 714 711 struct page *page = pfn_to_page(pfn); 715 712 ··· 719 716 make_lowmem_page_readwrite(__va(PFN_PHYS(pfn))); 720 717 } 721 718 } 719 + } 720 + 721 + static void xen_release_pt(u32 pfn) 722 + { 723 + xen_release_ptpage(pfn, PT_PTE); 724 + } 725 + 726 + static void xen_release_pd(u32 pfn) 727 + { 728 + xen_release_ptpage(pfn, PT_PMD); 722 729 } 723 730 724 731 #ifdef CONFIG_HIGHPTE ··· 851 838 pv_mmu_ops.alloc_pt = xen_alloc_pt; 852 839 pv_mmu_ops.alloc_pd = xen_alloc_pd; 853 840 pv_mmu_ops.release_pt = xen_release_pt; 854 - pv_mmu_ops.release_pd = xen_release_pt; 841 + pv_mmu_ops.release_pd = xen_release_pd; 855 842 pv_mmu_ops.set_pte = xen_set_pte; 856 843 857 844 setup_shared_info();
-7
arch/x86/xen/mmu.c
··· 310 310 } 311 311 #endif /* CONFIG_X86_PAE */ 312 312 313 - enum pt_level { 314 - PT_PGD, 315 - PT_PUD, 316 - PT_PMD, 317 - PT_PTE 318 - }; 319 - 320 313 /* 321 314 (Yet another) pagetable walker. This one is intended for pinning a 322 315 pagetable. This means that it walks a pagetable and calls the
+7
arch/x86/xen/mmu.h
··· 3 3 #include <linux/linkage.h> 4 4 #include <asm/page.h> 5 5 6 + enum pt_level { 7 + PT_PGD, 8 + PT_PUD, 9 + PT_PMD, 10 + PT_PTE 11 + }; 12 + 6 13 /* 7 14 * Page-directory addresses above 4GB do not fit into architectural %cr3. 8 15 * When accessing %cr3, or equivalent field in vcpu_guest_context, guests