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. |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/fs.h> |
| 20 | #include <linux/mm.h> |
| 21 | #include <linux/hugetlb.h> |
| 22 | #include <linux/pagemap.h> |
| 23 | #include <linux/err.h> |
| 24 | #include <linux/sysctl.h> |
| 25 | #include <asm/mman.h> |
| 26 | #include <asm/tlb.h> |
| 27 | #include <asm/tlbflush.h> |
| 28 | #include <asm/pgalloc.h> |
| 29 | |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 30 | int pmd_huge(pmd_t pmd) |
| 31 | { |
Christoffer Dall | fd28f5d | 2015-07-01 14:08:31 +0200 | [diff] [blame] | 32 | return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | int pud_huge(pud_t pud) |
| 36 | { |
Mark Salter | 4797ec2 | 2014-05-15 15:19:22 +0100 | [diff] [blame] | 37 | #ifndef __PAGETABLE_PMD_FOLDED |
Christoffer Dall | fd28f5d | 2015-07-01 14:08:31 +0200 | [diff] [blame] | 38 | return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); |
Mark Salter | 4797ec2 | 2014-05-15 15:19:22 +0100 | [diff] [blame] | 39 | #else |
| 40 | return 0; |
| 41 | #endif |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 42 | } |
| 43 | |
Steve Capper | 084bd29 | 2013-04-10 13:48:00 +0100 | [diff] [blame] | 44 | static __init int setup_hugepagesz(char *opt) |
| 45 | { |
| 46 | unsigned long ps = memparse(opt, &opt); |
| 47 | if (ps == PMD_SIZE) { |
| 48 | hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT); |
| 49 | } else if (ps == PUD_SIZE) { |
| 50 | hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); |
| 51 | } else { |
| 52 | pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20); |
| 53 | return 0; |
| 54 | } |
| 55 | return 1; |
| 56 | } |
| 57 | __setup("hugepagesz=", setup_hugepagesz); |