···8181# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set8282CONFIG_PROC_KCORE=y8383CONFIG_TMPFS=y8484+CONFIG_HUGETLBFS=y8485# CONFIG_MISC_FILESYSTEMS is not set8586CONFIG_PARTITION_ADVANCED=y8687CONFIG_MAC_PARTITION=y
···55#include <asm/page.h>6677extern struct kmem_cache *hugepte_cache;88-extern void __init reserve_hugetlb_gpages(void);98109static inline pte_t *hugepd_page(hugepd_t hpd)1110{···2122 unsigned pdshift)2223{2324 /*2424- * On 32-bit, we have multiple higher-level table entries that point to2525- * the same hugepte. Just use the first one since they're all2525+ * On FSL BookE, we have multiple higher-level table entries that2626+ * point to the same hugepte. Just use the first one since they're all2627 * identical. So for that case, idx=0.2728 */2829 unsigned long idx = 0;29303031 pte_t *dir = hugepd_page(*hpdp);3131-#ifdef CONFIG_PPC643232+#ifndef CONFIG_PPC_FSL_BOOK3E3233 idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(*hpdp);3334#endif3435···5253}5354#endif54555555-void book3e_hugetlb_preload(struct mm_struct *mm, unsigned long ea, pte_t pte);5656+void book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea,5757+ pte_t pte);5658void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);57595860void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,···124124 unsigned long addr, pte_t *ptep,125125 pte_t pte, int dirty)126126{127127+#ifdef HUGETLB_NEED_PRELOAD128128+ /*129129+ * The "return 1" forces a call of update_mmu_cache, which will write a130130+ * TLB entry. Without this, platforms that don't do a write of the TLB131131+ * entry in the TLB miss handler asm will fault ad infinitum.132132+ */133133+ ptep_set_access_flags(vma, addr, ptep, pte, dirty);134134+ return 1;135135+#else127136 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);137137+#endif128138}129139130140static inline pte_t huge_ptep_get(pte_t *ptep)···152142}153143154144#else /* ! CONFIG_HUGETLB_PAGE */155155-static inline void reserve_hugetlb_gpages(void)156156-{157157- pr_err("Cannot reserve gpages without hugetlb enabled\n");158158-}159145static inline void flush_hugetlb_page(struct vm_area_struct *vma,160146 unsigned long vmaddr)147147+{148148+}149149+#endif /* CONFIG_HUGETLB_PAGE */150150+151151+152152+/*153153+ * FSL Book3E platforms require special gpage handling - the gpages154154+ * are reserved early in the boot process by memblock instead of via155155+ * the .dts as on IBM platforms.156156+ */157157+#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_PPC_FSL_BOOK3E)158158+extern void __init reserve_hugetlb_gpages(void);159159+#else160160+static inline void reserve_hugetlb_gpages(void)161161{162162}163163#endif
+7
arch/powerpc/include/asm/mmu-book3e.h
···258258259259#ifdef CONFIG_PPC64260260extern unsigned long linear_map_top;261261+262262+/*263263+ * 64-bit booke platforms don't load the tlb in the tlb miss handler code.264264+ * HUGETLB_NEED_PRELOAD handles this - it causes huge_ptep_set_access_flags to265265+ * return 1, indicating that the tlb requires preloading.266266+ */267267+#define HUGETLB_NEED_PRELOAD261268#endif262269263270#endif /* !__ASSEMBLY__ */
···3535#include <linux/pci.h>3636#include <linux/lockdep.h>3737#include <linux/memblock.h>3838+#include <linux/hugetlb.h>3939+3840#include <asm/io.h>3941#include <asm/kdump.h>4042#include <asm/prom.h>···6664#include <asm/mmu_context.h>6765#include <asm/code-patching.h>6866#include <asm/kvm_ppc.h>6767+#include <asm/hugetlb.h>69687069#include "setup.h"7170···219216220217 /* Initialize the hash table or TLB handling */221218 early_init_mmu();219219+220220+ /*221221+ * Reserve any gigantic pages requested on the command line.222222+ * memblock needs to have been initialized by the time this is223223+ * called since this will reserve memory.224224+ */225225+ reserve_hugetlb_gpages();222226223227 DBG(" <- early_setup()\n");224228}
···28282929/*3030 * Tracks gpages after the device tree is scanned and before the3131- * huge_boot_pages list is ready. On 64-bit implementations, this is3232- * just used to track 16G pages and so is a single array. 32-bit3333- * implementations may have more than one gpage size due to limitations3434- * of the memory allocators, so we need multiple arrays3131+ * huge_boot_pages list is ready. On non-Freescale implementations, this is3232+ * just used to track 16G pages and so is a single array. FSL-based3333+ * implementations may have more than one gpage size, so we need multiple3434+ * arrays3535 */3636-#ifdef CONFIG_PPC643737-#define MAX_NUMBER_GPAGES 10243838-static u64 gpage_freearray[MAX_NUMBER_GPAGES];3939-static unsigned nr_gpages;4040-#else3636+#ifdef CONFIG_PPC_FSL_BOOK3E4137#define MAX_NUMBER_GPAGES 1284238struct psize_gpages {4339 u64 gpage_list[MAX_NUMBER_GPAGES];4440 unsigned int nr_gpages;4541};4642static struct psize_gpages gpage_freearray[MMU_PAGE_COUNT];4343+#else4444+#define MAX_NUMBER_GPAGES 10244545+static u64 gpage_freearray[MAX_NUMBER_GPAGES];4646+static unsigned nr_gpages;4747#endif48484949static inline int shift_to_mmu_psize(unsigned int shift)···114114 struct kmem_cache *cachep;115115 pte_t *new;116116117117-#ifdef CONFIG_PPC64118118- cachep = PGT_CACHE(pdshift - pshift);119119-#else117117+#ifdef CONFIG_PPC_FSL_BOOK3E120118 int i;121119 int num_hugepd = 1 << (pshift - pdshift);122120 cachep = hugepte_cache;121121+#else122122+ cachep = PGT_CACHE(pdshift - pshift);123123#endif124124125125 new = kmem_cache_zalloc(cachep, GFP_KERNEL|__GFP_REPEAT);···131131 return -ENOMEM;132132133133 spin_lock(&mm->page_table_lock);134134-#ifdef CONFIG_PPC64135135- if (!hugepd_none(*hpdp))136136- kmem_cache_free(cachep, new);137137- else138138- hpdp->pd = ((unsigned long)new & ~PD_HUGE) | pshift;139139-#else134134+#ifdef CONFIG_PPC_FSL_BOOK3E140135 /*141136 * We have multiple higher-level entries that point to the same142137 * actual pte location. Fill in each as we go and backtrack on error.···150155 hpdp->pd = 0;151156 kmem_cache_free(cachep, new);152157 }158158+#else159159+ if (!hugepd_none(*hpdp))160160+ kmem_cache_free(cachep, new);161161+ else162162+ hpdp->pd = ((unsigned long)new & ~PD_HUGE) | pshift;153163#endif154164 spin_unlock(&mm->page_table_lock);155165 return 0;156166}167167+168168+/*169169+ * These macros define how to determine which level of the page table holds170170+ * the hpdp.171171+ */172172+#ifdef CONFIG_PPC_FSL_BOOK3E173173+#define HUGEPD_PGD_SHIFT PGDIR_SHIFT174174+#define HUGEPD_PUD_SHIFT PUD_SHIFT175175+#else176176+#define HUGEPD_PGD_SHIFT PUD_SHIFT177177+#define HUGEPD_PUD_SHIFT PMD_SHIFT178178+#endif157179158180pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz)159181{···184172 addr &= ~(sz-1);185173186174 pg = pgd_offset(mm, addr);187187- if (pshift >= PUD_SHIFT) {175175+176176+ if (pshift >= HUGEPD_PGD_SHIFT) {188177 hpdp = (hugepd_t *)pg;189178 } else {190179 pdshift = PUD_SHIFT;191180 pu = pud_alloc(mm, pg, addr);192192- if (pshift >= PMD_SHIFT) {181181+ if (pshift >= HUGEPD_PUD_SHIFT) {193182 hpdp = (hugepd_t *)pu;194183 } else {195184 pdshift = PMD_SHIFT;···210197 return hugepte_offset(hpdp, addr, pdshift);211198}212199213213-#ifdef CONFIG_PPC32200200+#ifdef CONFIG_PPC_FSL_BOOK3E214201/* Build list of addresses of gigantic pages. This function is used in early215202 * boot before the buddy or bootmem allocator is setup.216203 */···330317 }331318}332319333333-#else /* PPC64 */320320+#else /* !PPC_FSL_BOOK3E */334321335322/* Build list of addresses of gigantic pages. This function is used in early336323 * boot before the buddy or bootmem allocator is setup.···368355 return 0;369356}370357371371-#ifdef CONFIG_PPC32358358+#ifdef CONFIG_PPC_FSL_BOOK3E372359#define HUGEPD_FREELIST_SIZE \373360 ((PAGE_SIZE - sizeof(struct hugepd_freelist)) / sizeof(pte_t))374361···428415 unsigned long pdmask = ~((1UL << pdshift) - 1);429416 unsigned int num_hugepd = 1;430417431431-#ifdef CONFIG_PPC64432432- unsigned int shift = hugepd_shift(*hpdp);433433-#else434434- /* Note: On 32-bit the hpdp may be the first of several */418418+#ifdef CONFIG_PPC_FSL_BOOK3E419419+ /* Note: On fsl the hpdp may be the first of several */435420 num_hugepd = (1 << (hugepd_shift(*hpdp) - pdshift));421421+#else422422+ unsigned int shift = hugepd_shift(*hpdp);436423#endif437424438425 start &= pdmask;···450437 hpdp->pd = 0;451438452439 tlb->need_flush = 1;453453-#ifdef CONFIG_PPC64454454- pgtable_free_tlb(tlb, hugepte, pdshift - shift);455455-#else440440+441441+#ifdef CONFIG_PPC_FSL_BOOK3E456442 hugepd_free(tlb, hugepte);443443+#else444444+ pgtable_free_tlb(tlb, hugepte, pdshift - shift);457445#endif458446}459447···467453 unsigned long start;468454469455 start = addr;470470- pmd = pmd_offset(pud, addr);471456 do {457457+ pmd = pmd_offset(pud, addr);472458 next = pmd_addr_end(addr, end);473459 if (pmd_none(*pmd))474460 continue;461461+#ifdef CONFIG_PPC_FSL_BOOK3E462462+ /*463463+ * Increment next by the size of the huge mapping since464464+ * there may be more than one entry at this level for a465465+ * single hugepage, but all of them point to466466+ * the same kmem cache that holds the hugepte.467467+ */468468+ next = addr + (1 << hugepd_shift(*(hugepd_t *)pmd));469469+#endif475470 free_hugepd_range(tlb, (hugepd_t *)pmd, PMD_SHIFT,476471 addr, next, floor, ceiling);477477- } while (pmd++, addr = next, addr != end);472472+ } while (addr = next, addr != end);478473479474 start &= PUD_MASK;480475 if (start < floor)···510487 unsigned long start;511488512489 start = addr;513513- pud = pud_offset(pgd, addr);514490 do {491491+ pud = pud_offset(pgd, addr);515492 next = pud_addr_end(addr, end);516493 if (!is_hugepd(pud)) {517494 if (pud_none_or_clear_bad(pud))···519496 hugetlb_free_pmd_range(tlb, pud, addr, next, floor,520497 ceiling);521498 } else {499499+#ifdef CONFIG_PPC_FSL_BOOK3E500500+ /*501501+ * Increment next by the size of the huge mapping since502502+ * there may be more than one entry at this level for a503503+ * single hugepage, but all of them point to504504+ * the same kmem cache that holds the hugepte.505505+ */506506+ next = addr + (1 << hugepd_shift(*(hugepd_t *)pud));507507+#endif522508 free_hugepd_range(tlb, (hugepd_t *)pud, PUD_SHIFT,523509 addr, next, floor, ceiling);524510 }525525- } while (pud++, addr = next, addr != end);511511+ } while (addr = next, addr != end);526512527513 start &= PGDIR_MASK;528514 if (start < floor)···586554 continue;587555 hugetlb_free_pud_range(tlb, pgd, addr, next, floor, ceiling);588556 } else {589589-#ifdef CONFIG_PPC32557557+#ifdef CONFIG_PPC_FSL_BOOK3E590558 /*591559 * Increment next by the size of the huge mapping since592592- * on 32-bit there may be more than one entry at the pgd593593- * level for a single hugepage, but all of them point to594594- * the same kmem cache that holds the hugepte.560560+ * there may be more than one entry at the pgd level561561+ * for a single hugepage, but all of them point to the562562+ * same kmem cache that holds the hugepte.595563 */596564 next = addr + (1 << hugepd_shift(*(hugepd_t *)pgd));597565#endif···729697 return 1;730698}731699700700+#ifdef CONFIG_PPC_MM_SLICES732701unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,733702 unsigned long len, unsigned long pgoff,734703 unsigned long flags)735704{736736-#ifdef CONFIG_PPC_MM_SLICES737705 struct hstate *hstate = hstate_file(file);738706 int mmu_psize = shift_to_mmu_psize(huge_page_shift(hstate));739707740708 return slice_get_unmapped_area(addr, len, flags, mmu_psize, 1, 0);741741-#else742742- return get_unmapped_area(file, addr, len, pgoff, flags);743743-#endif744709}710710+#endif745711746712unsigned long vma_mmu_pagesize(struct vm_area_struct *vma)747713{···813783}814784__setup("hugepagesz=", hugepage_setup_sz);815785816816-#ifdef CONFIG_FSL_BOOKE786786+#ifdef CONFIG_PPC_FSL_BOOK3E817787struct kmem_cache *hugepte_cache;818788static int __init hugetlbpage_init(void)819789{
···174174config FSL_BOOKE175175 bool176176 depends on (E200 || E500) && PPC32177177- select SYS_SUPPORTS_HUGETLBFS if PHYS_64BIT178177 default y179178180179# this is for common code between PPC32 & PPC64 FSL BOOKE···181182 bool182183 select FSL_EMB_PERFMON183184 select PPC_SMP_MUXED_IPI185185+ select SYS_SUPPORTS_HUGETLBFS if PHYS_64BIT || PPC64184186 default y if FSL_BOOKE185187186188config PTE_64BIT···309309310310config PPC_MM_SLICES311311 bool312312- default y if (PPC64 && HUGETLB_PAGE) || (PPC_STD_MMU_64 && PPC_64K_PAGES)312312+ default y if (!PPC_FSL_BOOK3E && PPC64 && HUGETLB_PAGE) || (PPC_STD_MMU_64 && PPC_64K_PAGES)313313 default n314314315315config VIRT_CPU_ACCOUNTING