|
@@ -210,3 +210,125 @@ static inline void pmd_clear(pmd_t *pmdp)
|
|
|
|
|
|
static inline pte_t *pmd_page_vaddr(pmd_t pmd)
|
|
|
{
|
|
|
+ return __va(pmd_val(pmd) & PHYS_MASK & (s32)PAGE_MASK);
|
|
|
+}
|
|
|
+
|
|
|
+#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
|
|
|
+
|
|
|
+/*
|
|
|
+ * Conversion functions: convert a page and protection to a page entry,
|
|
|
+ * and a page entry and page directory to the page they refer to.
|
|
|
+ */
|
|
|
+#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
|
|
|
+
|
|
|
+#ifndef CONFIG_ARM64_64K_PAGES
|
|
|
+
|
|
|
+#define pud_none(pud) (!pud_val(pud))
|
|
|
+#define pud_bad(pud) (!(pud_val(pud) & 2))
|
|
|
+#define pud_present(pud) (pud_val(pud))
|
|
|
+
|
|
|
+static inline void set_pud(pud_t *pudp, pud_t pud)
|
|
|
+{
|
|
|
+ *pudp = pud;
|
|
|
+ dsb();
|
|
|
+}
|
|
|
+
|
|
|
+static inline void pud_clear(pud_t *pudp)
|
|
|
+{
|
|
|
+ set_pud(pudp, __pud(0));
|
|
|
+}
|
|
|
+
|
|
|
+static inline pmd_t *pud_page_vaddr(pud_t pud)
|
|
|
+{
|
|
|
+ return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
|
|
|
+}
|
|
|
+
|
|
|
+#endif /* CONFIG_ARM64_64K_PAGES */
|
|
|
+
|
|
|
+/* to find an entry in a page-table-directory */
|
|
|
+#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
|
|
|
+
|
|
|
+#define pgd_offset(mm, addr) ((mm)->pgd+pgd_index(addr))
|
|
|
+
|
|
|
+/* to find an entry in a kernel page-table-directory */
|
|
|
+#define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
|
|
|
+
|
|
|
+/* Find an entry in the second-level page table.. */
|
|
|
+#ifndef CONFIG_ARM64_64K_PAGES
|
|
|
+#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
|
|
|
+static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
|
|
|
+{
|
|
|
+ return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr);
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+/* Find an entry in the third-level page table.. */
|
|
|
+#define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
|
|
|
+
|
|
|
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
|
|
|
+{
|
|
|
+ const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY |
|
|
|
+ PTE_PROT_NONE | PTE_VALID;
|
|
|
+ pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
|
|
|
+ return pte;
|
|
|
+}
|
|
|
+
|
|
|
+extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
|
|
|
+extern pgd_t idmap_pg_dir[PTRS_PER_PGD];
|
|
|
+
|
|
|
+#define SWAPPER_DIR_SIZE (3 * PAGE_SIZE)
|
|
|
+#define IDMAP_DIR_SIZE (2 * PAGE_SIZE)
|
|
|
+
|
|
|
+/*
|
|
|
+ * Encode and decode a swap entry:
|
|
|
+ * bits 0-1: present (must be zero)
|
|
|
+ * bit 2: PTE_FILE
|
|
|
+ * bits 3-8: swap type
|
|
|
+ * bits 9-63: swap offset
|
|
|
+ */
|
|
|
+#define __SWP_TYPE_SHIFT 3
|
|
|
+#define __SWP_TYPE_BITS 6
|
|
|
+#define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1)
|
|
|
+#define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)
|
|
|
+
|
|
|
+#define __swp_type(x) (((x).val >> __SWP_TYPE_SHIFT) & __SWP_TYPE_MASK)
|
|
|
+#define __swp_offset(x) ((x).val >> __SWP_OFFSET_SHIFT)
|
|
|
+#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })
|
|
|
+
|
|
|
+#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
|
|
|
+#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
|
|
|
+
|
|
|
+/*
|
|
|
+ * Ensure that there are not more swap files than can be encoded in the kernel
|
|
|
+ * the PTEs.
|
|
|
+ */
|
|
|
+#define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > __SWP_TYPE_BITS)
|
|
|
+
|
|
|
+/*
|
|
|
+ * Encode and decode a file entry:
|
|
|
+ * bits 0-1: present (must be zero)
|
|
|
+ * bit 2: PTE_FILE
|
|
|
+ * bits 3-63: file offset / PAGE_SIZE
|
|
|
+ */
|
|
|
+#define pte_file(pte) (pte_val(pte) & PTE_FILE)
|
|
|
+#define pte_to_pgoff(x) (pte_val(x) >> 3)
|
|
|
+#define pgoff_to_pte(x) __pte(((x) << 3) | PTE_FILE)
|
|
|
+
|
|
|
+#define PTE_FILE_MAX_BITS 61
|
|
|
+
|
|
|
+extern int kern_addr_valid(unsigned long addr);
|
|
|
+
|
|
|
+#include <asm-generic/pgtable.h>
|
|
|
+
|
|
|
+/*
|
|
|
+ * remap a physical page `pfn' of size `size' with page protection `prot'
|
|
|
+ * into virtual address `from'
|
|
|
+ */
|
|
|
+#define io_remap_pfn_range(vma,from,pfn,size,prot) \
|
|
|
+ remap_pfn_range(vma, from, pfn, size, prot)
|
|
|
+
|
|
|
+#define pgtable_cache_init() do { } while (0)
|
|
|
+
|
|
|
+#endif /* !__ASSEMBLY__ */
|
|
|
+
|
|
|
+#endif /* __ASM_PGTABLE_H */
|