blob: 2bbf28cf3aa9258ab1b8970e500c049e708ab842 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001/* SPDX-License-Identifier: GPL-2.0 */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
4 * Copyright 2003 PathScale, Inc.
5 * Derived from include/asm-i386/pgalloc.h and include/asm-i386/pgtable.h
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006 */
7
8#ifndef __UM_PGALLOC_H
9#define __UM_PGALLOC_H
10
11#include <linux/mm.h>
12
Olivier Deprez157378f2022-04-04 15:47:50 +020013#include <asm-generic/pgalloc.h>
David Brazdil0f672f62019-12-10 10:32:29 +000014
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000015#define pmd_populate_kernel(mm, pmd, pte) \
16 set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte)))
17
18#define pmd_populate(mm, pmd, pte) \
19 set_pmd(pmd, __pmd(_PAGE_TABLE + \
20 ((unsigned long long)page_to_pfn(pte) << \
21 (unsigned long long) PAGE_SHIFT)))
22#define pmd_pgtable(pmd) pmd_page(pmd)
23
24/*
25 * Allocate and free page tables.
26 */
27extern pgd_t *pgd_alloc(struct mm_struct *);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000029#define __pte_free_tlb(tlb,pte, address) \
30do { \
David Brazdil0f672f62019-12-10 10:32:29 +000031 pgtable_pte_page_dtor(pte); \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000032 tlb_remove_page((tlb),(pte)); \
33} while (0)
34
35#ifdef CONFIG_3_LEVEL_PGTABLES
36
Olivier Deprez157378f2022-04-04 15:47:50 +020037#define __pmd_free_tlb(tlb, pmd, address) \
38do { \
39 pgtable_pmd_page_dtor(virt_to_page(pmd)); \
40 tlb_remove_page((tlb),virt_to_page(pmd)); \
41} while (0) \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000042
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000043#endif
44
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000045#endif
46