at v5.3 2.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * linux/arch/unicore32/include/asm/pgalloc.h 4 * 5 * Code specific to PKUnity SoC and UniCore ISA 6 * 7 * Copyright (C) 2001-2010 GUAN Xue-tao 8 */ 9#ifndef __UNICORE_PGALLOC_H__ 10#define __UNICORE_PGALLOC_H__ 11 12#include <asm/pgtable-hwdef.h> 13#include <asm/processor.h> 14#include <asm/cacheflush.h> 15#include <asm/tlbflush.h> 16 17#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL 18#define __HAVE_ARCH_PTE_ALLOC_ONE 19#include <asm-generic/pgalloc.h> 20 21#define check_pgt_cache() do { } while (0) 22 23#define _PAGE_USER_TABLE (PMD_TYPE_TABLE | PMD_PRESENT) 24#define _PAGE_KERNEL_TABLE (PMD_TYPE_TABLE | PMD_PRESENT) 25 26extern pgd_t *get_pgd_slow(struct mm_struct *mm); 27extern void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd); 28 29#define pgd_alloc(mm) get_pgd_slow(mm) 30#define pgd_free(mm, pgd) free_pgd_slow(mm, pgd) 31 32/* 33 * Allocate one PTE table. 34 */ 35static inline pte_t * 36pte_alloc_one_kernel(struct mm_struct *mm) 37{ 38 pte_t *pte = __pte_alloc_one_kernel(mm); 39 40 if (pte) 41 clean_dcache_area(pte, PTRS_PER_PTE * sizeof(pte_t)); 42 43 return pte; 44} 45 46static inline pgtable_t 47pte_alloc_one(struct mm_struct *mm) 48{ 49 struct page *pte; 50 51 pte = __pte_alloc_one(mm, GFP_PGTABLE_USER); 52 if (!pte) 53 return NULL; 54 if (!PageHighMem(pte)) 55 clean_pte_table(page_address(pte)); 56 return pte; 57} 58 59static inline void __pmd_populate(pmd_t *pmdp, unsigned long pmdval) 60{ 61 set_pmd(pmdp, __pmd(pmdval)); 62 flush_pmd_entry(pmdp); 63} 64 65/* 66 * Populate the pmdp entry with a pointer to the pte. This pmd is part 67 * of the mm address space. 68 */ 69static inline void 70pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep) 71{ 72 unsigned long pte_ptr = (unsigned long)ptep; 73 74 /* 75 * The pmd must be loaded with the physical 76 * address of the PTE table 77 */ 78 __pmd_populate(pmdp, __pa(pte_ptr) | _PAGE_KERNEL_TABLE); 79} 80 81static inline void 82pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep) 83{ 84 __pmd_populate(pmdp, 85 page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE); 86} 87#define pmd_pgtable(pmd) pmd_page(pmd) 88 89#endif