| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2012 Regents of the University of California |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation, version 2. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #ifndef _ASM_RISCV_PGTABLE_64_H |
|---|
| .. | .. |
|---|
| 51 | 43 | return !pud_present(pud); |
|---|
| 52 | 44 | } |
|---|
| 53 | 45 | |
|---|
| 46 | +#define pud_leaf pud_leaf |
|---|
| 47 | +static inline int pud_leaf(pud_t pud) |
|---|
| 48 | +{ |
|---|
| 49 | + return pud_present(pud) && |
|---|
| 50 | + (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); |
|---|
| 51 | +} |
|---|
| 52 | + |
|---|
| 54 | 53 | static inline void set_pud(pud_t *pudp, pud_t pud) |
|---|
| 55 | 54 | { |
|---|
| 56 | 55 | *pudp = pud; |
|---|
| .. | .. |
|---|
| 66 | 65 | return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT); |
|---|
| 67 | 66 | } |
|---|
| 68 | 67 | |
|---|
| 69 | | -#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)) |
|---|
| 70 | | - |
|---|
| 71 | | -static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) |
|---|
| 68 | +static inline struct page *pud_page(pud_t pud) |
|---|
| 72 | 69 | { |
|---|
| 73 | | - return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr); |
|---|
| 70 | + return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT); |
|---|
| 74 | 71 | } |
|---|
| 75 | 72 | |
|---|
| 76 | 73 | static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot) |
|---|
| .. | .. |
|---|
| 78 | 75 | return __pmd((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot)); |
|---|
| 79 | 76 | } |
|---|
| 80 | 77 | |
|---|
| 78 | +static inline unsigned long _pmd_pfn(pmd_t pmd) |
|---|
| 79 | +{ |
|---|
| 80 | + return pmd_val(pmd) >> _PAGE_PFN_SHIFT; |
|---|
| 81 | +} |
|---|
| 82 | + |
|---|
| 81 | 83 | #define pmd_ERROR(e) \ |
|---|
| 82 | 84 | pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) |
|---|
| 83 | 85 | |
|---|