mirror of
https://gitee.com/bianbu-linux/linux-6.6-fh
synced 2025-04-25 04:17:06 -04:00
Most architectures (except arm64/x86/sparc) simply return 1 for kern_addr_valid(), which is only used in read_kcore(), and it calls copy_from_kernel_nofault() which could check whether the address is a valid kernel address. So as there is no need for kern_addr_valid(), let's remove it. Link: https://lkml.kernel.org/r/20221018074014.185687-1-wangkefeng.wang@huawei.com Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k] Acked-by: Heiko Carstens <hca@linux.ibm.com> [s390] Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Helge Deller <deller@gmx.de> [parisc] Acked-by: Michael Ellerman <mpe@ellerman.id.au> [powerpc] Acked-by: Guo Ren <guoren@kernel.org> [csky] Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64] Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: <aou@eecs.berkeley.edu> Cc: Borislav Petkov <bp@alien8.de> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Chris Zankel <chris@zankel.net> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David S. Miller <davem@davemloft.net> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Greg Ungerer <gerg@linux-m68k.org> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Jonas Bonn <jonas@southpole.se> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michal Simek <monstr@monstr.eu> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Palmer Dabbelt <palmer@rivosinc.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Richard Henderson <richard.henderson@linaro.org> 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: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@kernel.org> Cc: Will Deacon <will@kernel.org> Cc: Xuerui Wang <kernel@xen0n.name> Cc: Yoshinori Sato <ysato@users.osdn.me> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
175 lines
3.8 KiB
C
175 lines
3.8 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 */
|
|
|
|
/*
|
|
* Protection used for kernel text. We want the debuggers to be able to
|
|
* set breakpoints anywhere, so don't write protect the kernel text
|
|
* on platforms where such control is possible.
|
|
*/
|
|
#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) || \
|
|
defined(CONFIG_KPROBES) || defined(CONFIG_DYNAMIC_FTRACE)
|
|
#define PAGE_KERNEL_TEXT PAGE_KERNEL_X
|
|
#else
|
|
#define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
|
|
#endif
|
|
|
|
/* Make modules code happy. We don't set RO yet */
|
|
#define PAGE_KERNEL_EXEC PAGE_KERNEL_X
|
|
|
|
/* Advertise special mapping type for AGP */
|
|
#define PAGE_AGP (PAGE_KERNEL_NC)
|
|
#define HAVE_PAGE_AGP
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifndef MAX_PTRS_PER_PGD
|
|
#define MAX_PTRS_PER_PGD PTRS_PER_PGD
|
|
#endif
|
|
|
|
/* 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);
|
|
}
|
|
|
|
#ifndef pmd_page_vaddr
|
|
static inline unsigned long pmd_page_vaddr(pmd_t pmd)
|
|
{
|
|
return ((unsigned long)__va(pmd_val(pmd) & ~PMD_MASKED_BITS));
|
|
}
|
|
#define pmd_page_vaddr pmd_page_vaddr
|
|
#endif
|
|
/*
|
|
* 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);
|
|
void poking_init(void);
|
|
|
|
extern unsigned long ioremap_bot;
|
|
extern const pgprot_t protection_map[16];
|
|
|
|
#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
|
|
|
|
#define pmd_pgtable pmd_pgtable
|
|
static inline pgtable_t pmd_pgtable(pmd_t pmd)
|
|
{
|
|
return (pgtable_t)pmd_page_vaddr(pmd);
|
|
}
|
|
|
|
#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;
|
|
}
|
|
|
|
struct seq_file;
|
|
void arch_report_meminfo(struct seq_file *m);
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_POWERPC_PGTABLE_H */
|