hugetlbpage.c (d053cf0d771f6547cb0537759a9af63cf402908d) hugetlbpage.c (ae94da898133947c2d1f005da10838478e4548db)
1/*
2 * PPC Huge TLB Page Support for Kernel.
3 *
4 * Copyright (C) 2003 David Gibson, IBM Corporation.
5 * Copyright (C) 2011 Becky Bruce, Freescale Semiconductor
6 *
7 * Based on the IA-32 version:
8 * Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com>

--- 544 unchanged lines hidden (view full) ---

553 if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) {
554 unsigned int psize = get_slice_psize(vma->vm_mm, vma->vm_start);
555
556 return 1UL << mmu_psize_to_shift(psize);
557 }
558 return vma_kernel_pagesize(vma);
559}
560
1/*
2 * PPC Huge TLB Page Support for Kernel.
3 *
4 * Copyright (C) 2003 David Gibson, IBM Corporation.
5 * Copyright (C) 2011 Becky Bruce, Freescale Semiconductor
6 *
7 * Based on the IA-32 version:
8 * Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com>

--- 544 unchanged lines hidden (view full) ---

553 if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) {
554 unsigned int psize = get_slice_psize(vma->vm_mm, vma->vm_start);
555
556 return 1UL << mmu_psize_to_shift(psize);
557 }
558 return vma_kernel_pagesize(vma);
559}
560
561static int __init add_huge_page_size(unsigned long long size)
561bool __init arch_hugetlb_valid_size(unsigned long size)
562{
563 int shift = __ffs(size);
564 int mmu_psize;
565
566 /* Check that it is a page size supported by the hardware and
567 * that it fits within pagetable and slice limits. */
568 if (size <= PAGE_SIZE || !is_power_of_2(size))
562{
563 int shift = __ffs(size);
564 int mmu_psize;
565
566 /* Check that it is a page size supported by the hardware and
567 * that it fits within pagetable and slice limits. */
568 if (size <= PAGE_SIZE || !is_power_of_2(size))
569 return -EINVAL;
569 return false;
570
571 mmu_psize = check_and_get_huge_psize(shift);
572 if (mmu_psize < 0)
570
571 mmu_psize = check_and_get_huge_psize(shift);
572 if (mmu_psize < 0)
573 return -EINVAL;
573 return false;
574
575 BUG_ON(mmu_psize_defs[mmu_psize].shift != shift);
576
574
575 BUG_ON(mmu_psize_defs[mmu_psize].shift != shift);
576
577 /* Return if huge page size has already been setup */
578 if (size_to_hstate(size))
579 return 0;
577 return true;
578}
580
579
581 hugetlb_add_hstate(shift - PAGE_SHIFT);
580static int __init add_huge_page_size(unsigned long long size)
581{
582 int shift = __ffs(size);
582
583
584 if (!arch_hugetlb_valid_size((unsigned long)size))
585 return -EINVAL;
586
587 if (!size_to_hstate(size))
588 hugetlb_add_hstate(shift - PAGE_SHIFT);
583 return 0;
584}
585
586static int __init hugepage_setup_sz(char *str)
587{
588 unsigned long long size;
589
590 size = memparse(str, &str);

--- 96 unchanged lines hidden ---
589 return 0;
590}
591
592static int __init hugepage_setup_sz(char *str)
593{
594 unsigned long long size;
595
596 size = memparse(str, &str);

--- 96 unchanged lines hidden ---