Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 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 | |
| 17 | |
| 18 | #include <linux/compiler.h> |
| 19 | #include <linux/mm.h> |
| 20 | #include <linux/page-flags.h> |
| 21 | #include <linux/threads.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 22 | |
| 23 | #include <asm-generic/pgalloc.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 24 | |
| 25 | #include <asm/mmu_context.h> |
| 26 | |
| 27 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
| 28 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 29 | return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 32 | #if CONFIG_PGTABLE_LEVELS == 4 |
| 33 | static inline void |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 34 | p4d_populate(struct mm_struct *mm, p4d_t * p4d_entry, pud_t * pud) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 35 | { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 36 | p4d_val(*p4d_entry) = __pa(pud); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 39 | #define __pud_free_tlb(tlb, pud, address) pud_free((tlb)->mm, pud) |
| 40 | #endif /* CONFIG_PGTABLE_LEVELS == 4 */ |
| 41 | |
| 42 | static inline void |
| 43 | pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd) |
| 44 | { |
| 45 | pud_val(*pud_entry) = __pa(pmd); |
| 46 | } |
| 47 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 48 | #define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd) |
| 49 | |
| 50 | static inline void |
| 51 | pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte) |
| 52 | { |
| 53 | pmd_val(*pmd_entry) = page_to_phys(pte); |
| 54 | } |
| 55 | #define pmd_pgtable(pmd) pmd_page(pmd) |
| 56 | |
| 57 | static inline void |
| 58 | pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte) |
| 59 | { |
| 60 | pmd_val(*pmd_entry) = __pa(pte); |
| 61 | } |
| 62 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 63 | #define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte) |
| 64 | |
| 65 | #endif /* _ASM_IA64_PGALLOC_H */ |