Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _ASM_IA64_PGALLOC_H |
| 3 | #define _ASM_IA64_PGALLOC_H |
| 4 | |
| 5 | /* |
| 6 | * This file contains the functions and defines necessary to allocate |
| 7 | * page tables. |
| 8 | * |
| 9 | * This hopefully works with any (fixed) ia-64 page-size, as defined |
| 10 | * in <asm/page.h> (currently 8192). |
| 11 | * |
| 12 | * Copyright (C) 1998-2001 Hewlett-Packard Co |
| 13 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 14 | * Copyright (C) 2000, Goutham Rao <goutham.rao@intel.com> |
| 15 | */ |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | #include <linux/compiler.h> |
| 19 | #include <linux/mm.h> |
| 20 | #include <linux/page-flags.h> |
| 21 | #include <linux/threads.h> |
| 22 | |
Mike Rapoport | 0131992 | 2019-09-23 15:35:22 -0700 | [diff] [blame] | 23 | #include <asm-generic/pgalloc.h> |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/mmu_context.h> |
| 26 | |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 27 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 28 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 29 | return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 32 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 33 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 34 | free_page((unsigned long)pgd); |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Kirill A. Shutemov | 4d66bcc | 2015-04-14 15:45:45 -0700 | [diff] [blame] | 37 | #if CONFIG_PGTABLE_LEVELS == 4 |
Robin Holt | 837cd0b | 2005-11-11 09:35:43 -0600 | [diff] [blame] | 38 | static inline void |
| 39 | pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud) |
| 40 | { |
| 41 | pgd_val(*pgd_entry) = __pa(pud); |
| 42 | } |
| 43 | |
| 44 | static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) |
| 45 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 46 | return (pud_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
Robin Holt | 837cd0b | 2005-11-11 09:35:43 -0600 | [diff] [blame] | 47 | } |
| 48 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 49 | static inline void pud_free(struct mm_struct *mm, pud_t *pud) |
Robin Holt | 837cd0b | 2005-11-11 09:35:43 -0600 | [diff] [blame] | 50 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 51 | free_page((unsigned long)pud); |
Robin Holt | 837cd0b | 2005-11-11 09:35:43 -0600 | [diff] [blame] | 52 | } |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 53 | #define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud) |
Kirill A. Shutemov | 4d66bcc | 2015-04-14 15:45:45 -0700 | [diff] [blame] | 54 | #endif /* CONFIG_PGTABLE_LEVELS == 4 */ |
Robin Holt | 837cd0b | 2005-11-11 09:35:43 -0600 | [diff] [blame] | 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | static inline void |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 57 | pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
| 59 | pud_val(*pud_entry) = __pa(pmd); |
| 60 | } |
| 61 | |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 62 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 64 | return (pmd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 67 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
Nicholas Piggin | 1322479 | 2019-09-23 15:35:19 -0700 | [diff] [blame] | 69 | free_page((unsigned long)pmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 72 | #define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | static inline void |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 75 | pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
| 77 | pmd_val(*pmd_entry) = page_to_phys(pte); |
| 78 | } |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 79 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | static inline void |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 82 | pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { |
| 84 | pmd_val(*pmd_entry) = __pa(pte); |
| 85 | } |
| 86 | |
Benjamin Herrenschmidt | 9e1b32c | 2009-07-22 15:44:28 +1000 | [diff] [blame] | 87 | #define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Robin Holt | fde740e | 2005-04-25 13:13:16 -0700 | [diff] [blame] | 89 | #endif /* _ASM_IA64_PGALLOC_H */ |