ca5999fde0
The include/linux/pgtable.h is going to be the home of generic page table manipulation functions. Start with moving asm-generic/pgtable.h to include/linux/pgtable.h and make the latter include asm/pgtable.h. Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Cain <bcain@codeaurora.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Ungerer <gerg@linux-m68k.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Guo Ren <guoren@kernel.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ley Foon Tan <ley.foon.tan@intel.com> Cc: Mark Salter <msalter@redhat.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Nick Hu <nickhu@andestech.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Stafford Horne <shorne@gmail.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vincent Chen <deanbo422@gmail.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will@kernel.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: http://lkml.kernel.org/r/20200514170327.31389-3-rppt@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
182 lines
4.0 KiB
C
182 lines
4.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_PGTABLE_H
|
|
#define _ASM_POWERPC_PGTABLE_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
#include <linux/mmdebug.h>
|
|
#include <linux/mmzone.h>
|
|
#include <asm/processor.h> /* For TASK_SIZE */
|
|
#include <asm/mmu.h>
|
|
#include <asm/page.h>
|
|
#include <asm/tlbflush.h>
|
|
|
|
struct mm_struct;
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S
|
|
#include <asm/book3s/pgtable.h>
|
|
#else
|
|
#include <asm/nohash/pgtable.h>
|
|
#endif /* !CONFIG_PPC_BOOK3S */
|
|
|
|
/* Note due to the way vm flags are laid out, the bits are XWR */
|
|
#define __P000 PAGE_NONE
|
|
#define __P001 PAGE_READONLY
|
|
#define __P010 PAGE_COPY
|
|
#define __P011 PAGE_COPY
|
|
#define __P100 PAGE_READONLY_X
|
|
#define __P101 PAGE_READONLY_X
|
|
#define __P110 PAGE_COPY_X
|
|
#define __P111 PAGE_COPY_X
|
|
|
|
#define __S000 PAGE_NONE
|
|
#define __S001 PAGE_READONLY
|
|
#define __S010 PAGE_SHARED
|
|
#define __S011 PAGE_SHARED
|
|
#define __S100 PAGE_READONLY_X
|
|
#define __S101 PAGE_READONLY_X
|
|
#define __S110 PAGE_SHARED_X
|
|
#define __S111 PAGE_SHARED_X
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifdef CONFIG_PPC32
|
|
static inline pmd_t *pmd_ptr(struct mm_struct *mm, unsigned long va)
|
|
{
|
|
return pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, va), va), va), va);
|
|
}
|
|
|
|
static inline pmd_t *pmd_ptr_k(unsigned long va)
|
|
{
|
|
return pmd_offset(pud_offset(p4d_offset(pgd_offset_k(va), va), va), va);
|
|
}
|
|
|
|
static inline pte_t *virt_to_kpte(unsigned long vaddr)
|
|
{
|
|
pmd_t *pmd = pmd_ptr_k(vaddr);
|
|
|
|
return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
|
|
}
|
|
#endif
|
|
|
|
#include <asm/tlbflush.h>
|
|
|
|
/* Keep these as a macros to avoid include dependency mess */
|
|
#define pte_page(x) pfn_to_page(pte_pfn(x))
|
|
#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
|
|
/*
|
|
* Select all bits except the pfn
|
|
*/
|
|
static inline pgprot_t pte_pgprot(pte_t pte)
|
|
{
|
|
unsigned long pte_flags;
|
|
|
|
pte_flags = pte_val(pte) & ~PTE_RPN_MASK;
|
|
return __pgprot(pte_flags);
|
|
}
|
|
|
|
/*
|
|
* ZERO_PAGE is a global shared page that is always zero: used
|
|
* for zero-mapped memory areas etc..
|
|
*/
|
|
extern unsigned long empty_zero_page[];
|
|
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
|
|
|
|
extern pgd_t swapper_pg_dir[];
|
|
|
|
extern void paging_init(void);
|
|
|
|
extern unsigned long ioremap_bot;
|
|
|
|
/*
|
|
* kern_addr_valid is intended to indicate whether an address is a valid
|
|
* kernel address. Most 32-bit archs define it as always true (like this)
|
|
* but most 64-bit archs actually perform a test. What should we do here?
|
|
*/
|
|
#define kern_addr_valid(addr) (1)
|
|
|
|
#ifndef CONFIG_TRANSPARENT_HUGEPAGE
|
|
#define pmd_large(pmd) 0
|
|
#endif
|
|
|
|
/* can we use this in kvm */
|
|
unsigned long vmalloc_to_phys(void *vmalloc_addr);
|
|
|
|
void pgtable_cache_add(unsigned int shift);
|
|
|
|
pte_t *early_pte_alloc_kernel(pmd_t *pmdp, unsigned long va);
|
|
|
|
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
|
|
void mark_initmem_nx(void);
|
|
#else
|
|
static inline void mark_initmem_nx(void) { }
|
|
#endif
|
|
|
|
/*
|
|
* When used, PTE_FRAG_NR is defined in subarch pgtable.h
|
|
* so we are sure it is included when arriving here.
|
|
*/
|
|
#ifdef PTE_FRAG_NR
|
|
static inline void *pte_frag_get(mm_context_t *ctx)
|
|
{
|
|
return ctx->pte_frag;
|
|
}
|
|
|
|
static inline void pte_frag_set(mm_context_t *ctx, void *p)
|
|
{
|
|
ctx->pte_frag = p;
|
|
}
|
|
#else
|
|
#define PTE_FRAG_NR 1
|
|
#define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT
|
|
#define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)
|
|
|
|
static inline void *pte_frag_get(mm_context_t *ctx)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline void pte_frag_set(mm_context_t *ctx, void *p)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#ifndef pmd_is_leaf
|
|
#define pmd_is_leaf pmd_is_leaf
|
|
static inline bool pmd_is_leaf(pmd_t pmd)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#ifndef pud_is_leaf
|
|
#define pud_is_leaf pud_is_leaf
|
|
static inline bool pud_is_leaf(pud_t pud)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#ifndef p4d_is_leaf
|
|
#define p4d_is_leaf p4d_is_leaf
|
|
static inline bool p4d_is_leaf(p4d_t p4d)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_PPC64
|
|
#define is_ioremap_addr is_ioremap_addr
|
|
static inline bool is_ioremap_addr(const void *x)
|
|
{
|
|
unsigned long addr = (unsigned long)x;
|
|
|
|
return addr >= IOREMAP_BASE && addr < IOREMAP_END;
|
|
}
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_POWERPC_PGTABLE_H */
|