pgtable.h (ee01c4d72adffb7d424535adf630f2955748fa8b) pgtable.h (2fb4706057bcf8261b3b0521ec7a62b54b82ce48)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_BOOK3S_64_PGTABLE_H_
3#define _ASM_POWERPC_BOOK3S_64_PGTABLE_H_
4
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_BOOK3S_64_PGTABLE_H_
3#define _ASM_POWERPC_BOOK3S_64_PGTABLE_H_
4
5#include <asm-generic/5level-fixup.h>
5#include <asm-generic/pgtable-nop4d.h>
6
7#ifndef __ASSEMBLY__
8#include <linux/mmdebug.h>
9#include <linux/bug.h>
10#endif
11
12/*
13 * Common bits between hash and Radix page table

--- 232 unchanged lines hidden (view full) ---

246#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
247#define PGDIR_MASK (~(PGDIR_SIZE-1))
248
249/* Bits to mask out from a PMD to get to the PTE page */
250#define PMD_MASKED_BITS 0xc0000000000000ffUL
251/* Bits to mask out from a PUD to get to the PMD page */
252#define PUD_MASKED_BITS 0xc0000000000000ffUL
253/* Bits to mask out from a PGD to get to the PUD page */
6
7#ifndef __ASSEMBLY__
8#include <linux/mmdebug.h>
9#include <linux/bug.h>
10#endif
11
12/*
13 * Common bits between hash and Radix page table

--- 232 unchanged lines hidden (view full) ---

246#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
247#define PGDIR_MASK (~(PGDIR_SIZE-1))
248
249/* Bits to mask out from a PMD to get to the PTE page */
250#define PMD_MASKED_BITS 0xc0000000000000ffUL
251/* Bits to mask out from a PUD to get to the PMD page */
252#define PUD_MASKED_BITS 0xc0000000000000ffUL
253/* Bits to mask out from a PGD to get to the PUD page */
254#define PGD_MASKED_BITS 0xc0000000000000ffUL
254#define P4D_MASKED_BITS 0xc0000000000000ffUL
255
256/*
257 * Used as an indicator for rcu callback functions
258 */
259enum pgtable_index {
260 PTE_INDEX = 0,
261 PMD_INDEX,
262 PUD_INDEX,

--- 681 unchanged lines hidden (view full) ---

944}
945
946#define pud_access_permitted pud_access_permitted
947static inline bool pud_access_permitted(pud_t pud, bool write)
948{
949 return pte_access_permitted(pud_pte(pud), write);
950}
951
255
256/*
257 * Used as an indicator for rcu callback functions
258 */
259enum pgtable_index {
260 PTE_INDEX = 0,
261 PMD_INDEX,
262 PUD_INDEX,

--- 681 unchanged lines hidden (view full) ---

944}
945
946#define pud_access_permitted pud_access_permitted
947static inline bool pud_access_permitted(pud_t pud, bool write)
948{
949 return pte_access_permitted(pud_pte(pud), write);
950}
951
952#define pgd_write(pgd) pte_write(pgd_pte(pgd))
952#define __p4d_raw(x) ((p4d_t) { __pgd_raw(x) })
953static inline __be64 p4d_raw(p4d_t x)
954{
955 return pgd_raw(x.pgd);
956}
953
957
954static inline void pgd_clear(pgd_t *pgdp)
958#define p4d_write(p4d) pte_write(p4d_pte(p4d))
959
960static inline void p4d_clear(p4d_t *p4dp)
955{
961{
956 *pgdp = __pgd(0);
962 *p4dp = __p4d(0);
957}
958
963}
964
959static inline int pgd_none(pgd_t pgd)
965static inline int p4d_none(p4d_t p4d)
960{
966{
961 return !pgd_raw(pgd);
967 return !p4d_raw(p4d);
962}
963
968}
969
964static inline int pgd_present(pgd_t pgd)
970static inline int p4d_present(p4d_t p4d)
965{
971{
966 return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
972 return !!(p4d_raw(p4d) & cpu_to_be64(_PAGE_PRESENT));
967}
968
973}
974
969static inline pte_t pgd_pte(pgd_t pgd)
975static inline pte_t p4d_pte(p4d_t p4d)
970{
976{
971 return __pte_raw(pgd_raw(pgd));
977 return __pte_raw(p4d_raw(p4d));
972}
973
978}
979
974static inline pgd_t pte_pgd(pte_t pte)
980static inline p4d_t pte_p4d(pte_t pte)
975{
981{
976 return __pgd_raw(pte_raw(pte));
982 return __p4d_raw(pte_raw(pte));
977}
978
983}
984
979static inline int pgd_bad(pgd_t pgd)
985static inline int p4d_bad(p4d_t p4d)
980{
981 if (radix_enabled())
986{
987 if (radix_enabled())
982 return radix__pgd_bad(pgd);
983 return hash__pgd_bad(pgd);
988 return radix__p4d_bad(p4d);
989 return hash__p4d_bad(p4d);
984}
985
990}
991
986#define pgd_access_permitted pgd_access_permitted
987static inline bool pgd_access_permitted(pgd_t pgd, bool write)
992#define p4d_access_permitted p4d_access_permitted
993static inline bool p4d_access_permitted(p4d_t p4d, bool write)
988{
994{
989 return pte_access_permitted(pgd_pte(pgd), write);
995 return pte_access_permitted(p4d_pte(p4d), write);
990}
991
996}
997
992extern struct page *pgd_page(pgd_t pgd);
998extern struct page *p4d_page(p4d_t p4d);
993
994/* Pointers in the page table tree are physical addresses */
995#define __pgtable_ptr_val(ptr) __pa(ptr)
996
997#define pmd_page_vaddr(pmd) __va(pmd_val(pmd) & ~PMD_MASKED_BITS)
998#define pud_page_vaddr(pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)
999
1000/* Pointers in the page table tree are physical addresses */
1001#define __pgtable_ptr_val(ptr) __pa(ptr)
1002
1003#define pmd_page_vaddr(pmd) __va(pmd_val(pmd) & ~PMD_MASKED_BITS)
1004#define pud_page_vaddr(pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)
999#define pgd_page_vaddr(pgd) __va(pgd_val(pgd) & ~PGD_MASKED_BITS)
1005#define p4d_page_vaddr(p4d) __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
1000
1001#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
1002#define pud_index(address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1))
1003#define pmd_index(address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1))
1004#define pte_index(address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1))
1005
1006/*
1007 * Find an entry in a page-table-directory. We combine the address region
1008 * (the high order N bits) and the pgd portion of the address.
1009 */
1010
1011#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
1012
1006
1007#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
1008#define pud_index(address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1))
1009#define pmd_index(address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1))
1010#define pte_index(address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1))
1011
1012/*
1013 * Find an entry in a page-table-directory. We combine the address region
1014 * (the high order N bits) and the pgd portion of the address.
1015 */
1016
1017#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
1018
1013#define pud_offset(pgdp, addr) \
1014 (((pud_t *) pgd_page_vaddr(*(pgdp))) + pud_index(addr))
1019#define pud_offset(p4dp, addr) \
1020 (((pud_t *) p4d_page_vaddr(*(p4dp))) + pud_index(addr))
1015#define pmd_offset(pudp,addr) \
1016 (((pmd_t *) pud_page_vaddr(*(pudp))) + pmd_index(addr))
1017#define pte_offset_kernel(dir,addr) \
1018 (((pte_t *) pmd_page_vaddr(*(dir))) + pte_index(addr))
1019
1020#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
1021
1022static inline void pte_unmap(pte_t *pte) { }

--- 338 unchanged lines hidden (view full) ---

1361
1362#define pud_is_leaf pud_is_leaf
1363#define pud_leaf pud_is_leaf
1364static inline bool pud_is_leaf(pud_t pud)
1365{
1366 return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
1367}
1368
1021#define pmd_offset(pudp,addr) \
1022 (((pmd_t *) pud_page_vaddr(*(pudp))) + pmd_index(addr))
1023#define pte_offset_kernel(dir,addr) \
1024 (((pte_t *) pmd_page_vaddr(*(dir))) + pte_index(addr))
1025
1026#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
1027
1028static inline void pte_unmap(pte_t *pte) { }

--- 338 unchanged lines hidden (view full) ---

1367
1368#define pud_is_leaf pud_is_leaf
1369#define pud_leaf pud_is_leaf
1370static inline bool pud_is_leaf(pud_t pud)
1371{
1372 return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
1373}
1374
1369#define pgd_is_leaf pgd_is_leaf
1370#define pgd_leaf pgd_is_leaf
1371static inline bool pgd_is_leaf(pgd_t pgd)
1375#define p4d_is_leaf p4d_is_leaf
1376#define p4d_leaf p4d_is_leaf
1377static inline bool p4d_is_leaf(p4d_t p4d)
1372{
1378{
1373 return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
1379 return !!(p4d_raw(p4d) & cpu_to_be64(_PAGE_PTE));
1374}
1375
1376#endif /* __ASSEMBLY__ */
1377#endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
1380}
1381
1382#endif /* __ASSEMBLY__ */
1383#endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */