Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm64/mm/hugetlbpage.c |
| 3 | * |
| 4 | * Copyright (C) 2013 Linaro Ltd. |
| 5 | * |
| 6 | * Based on arch/x86/mm/hugetlbpage.c. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/fs.h> |
| 24 | #include <linux/mm.h> |
| 25 | #include <linux/hugetlb.h> |
| 26 | #include <linux/pagemap.h> |
| 27 | #include <linux/err.h> |
| 28 | #include <linux/sysctl.h> |
| 29 | #include <asm/mman.h> |
| 30 | #include <asm/tlb.h> |
| 31 | #include <asm/tlbflush.h> |
| 32 | #include <asm/pgalloc.h> |
| 33 | |
| 34 | #ifndef CONFIG_ARCH_WANT_HUGE_PMD_SHARE |
| 35 | int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep) |
| 36 | { |
| 37 | return 0; |
| 38 | } |
| 39 | #endif |
| 40 | |
| 41 | struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, |
| 42 | int write) |
| 43 | { |
| 44 | return ERR_PTR(-EINVAL); |
| 45 | } |
| 46 | |
| 47 | int pmd_huge(pmd_t pmd) |
| 48 | { |
| 49 | return !(pmd_val(pmd) & PMD_TABLE_BIT); |
| 50 | } |
| 51 | |
| 52 | int pud_huge(pud_t pud) |
| 53 | { |
Mark Salter | 4797ec2 | 2014-05-15 15:19:22 +0100 | [diff] [blame] | 54 | #ifndef __PAGETABLE_PMD_FOLDED |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 55 | return !(pud_val(pud) & PUD_TABLE_BIT); |
Mark Salter | 4797ec2 | 2014-05-15 15:19:22 +0100 | [diff] [blame] | 56 | #else |
| 57 | return 0; |
| 58 | #endif |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 61 | static __init int setup_hugepagesz(char *opt) |
| 62 | { |
| 63 | unsigned long ps = memparse(opt, &opt); |
| 64 | if (ps == PMD_SIZE) { |
| 65 | hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT); |
| 66 | } else if (ps == PUD_SIZE) { |
| 67 | hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); |
| 68 | } else { |
| 69 | pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20); |
| 70 | return 0; |
| 71 | } |
| 72 | return 1; |
| 73 | } |
| 74 | __setup("hugepagesz=", setup_hugepagesz); |