hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/arch/riscv/include/asm/pgtable-64.h
....@@ -1,14 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * 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.
124 */
135
146 #ifndef _ASM_RISCV_PGTABLE_64_H
....@@ -51,6 +43,13 @@
5143 return !pud_present(pud);
5244 }
5345
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
+
5453 static inline void set_pud(pud_t *pudp, pud_t pud)
5554 {
5655 *pudp = pud;
....@@ -61,16 +60,14 @@
6160 set_pud(pudp, __pud(0));
6261 }
6362
64
-static inline unsigned long pud_page_vaddr(pud_t pud)
63
+static inline pmd_t *pud_pgtable(pud_t pud)
6564 {
66
- return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
65
+ return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
6766 }
6867
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)
7269 {
73
- return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr);
70
+ return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT);
7471 }
7572
7673 static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot)
....@@ -78,6 +75,11 @@
7875 return __pmd((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot));
7976 }
8077
78
+static inline unsigned long _pmd_pfn(pmd_t pmd)
79
+{
80
+ return pmd_val(pmd) >> _PAGE_PFN_SHIFT;
81
+}
82
+
8183 #define pmd_ERROR(e) \
8284 pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
8385