Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2// Copyright (C) 2005-2017 Andes Technology Corporation
3
4#ifndef _ASMNDS32_PGALLOC_H
5#define _ASMNDS32_PGALLOC_H
6
7#include <asm/processor.h>
8#include <asm/cacheflush.h>
9#include <asm/tlbflush.h>
10#include <asm/proc-fns.h>
11
12#define __HAVE_ARCH_PTE_ALLOC_ONE
13#include <asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */
14
15extern pgd_t *pgd_alloc(struct mm_struct *mm);
16extern void pgd_free(struct mm_struct *mm, pgd_t * pgd);
17
18static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
19{
20 pgtable_t pte;
21
22 pte = __pte_alloc_one(mm, GFP_PGTABLE_USER);
23 if (pte)
24 cpu_dcache_wb_page((unsigned long)page_address(pte));
25
26 return pte;
27}
28
29/*
30 * Populate the pmdp entry with a pointer to the pte. This pmd is part
31 * of the mm address space.
32 *
33 * Ensure that we always set both PMD entries.
34 */
35static inline void
36pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmdp, pte_t * ptep)
37{
38 unsigned long pte_ptr = (unsigned long)ptep;
39 unsigned long pmdval;
40
41 BUG_ON(mm != &init_mm);
42
43 /*
44 * The pmd must be loaded with the physical
45 * address of the PTE table
46 */
47 pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE;
48 set_pmd(pmdp, __pmd(pmdval));
49}
50
51static inline void
52pmd_populate(struct mm_struct *mm, pmd_t * pmdp, pgtable_t ptep)
53{
54 unsigned long pmdval;
55
56 BUG_ON(mm == &init_mm);
57
58 pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE;
59 set_pmd(pmdp, __pmd(pmdval));
60}
61
62#endif