mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 23:14:31 +08:00
e5080a9677
Every architecture that supports FLATMEM memory model defines its own version of pfn_valid() that essentially compares a pfn to max_mapnr. Use mips/powerpc version implemented as static inline as a generic implementation of pfn_valid() and drop its per-architecture definitions. [rppt@kernel.org: fix the generic pfn_valid()] Link: https://lkml.kernel.org/r/Y9lg7R1Yd931C+y5@kernel.org Link: https://lkml.kernel.org/r/20230129124235.209895-5-rppt@kernel.org Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Guo Ren <guoren@kernel.org> [csky] Acked-by: Huacai Chen <chenhuacai@loongson.cn> [LoongArch] Acked-by: Stafford Horne <shorne@gmail.com> [OpenRISC] Acked-by: Michael Ellerman <mpe@ellerman.id.au> [powerpc] Reviewed-by: David Hildenbrand <david@redhat.com> Tested-by: Conor Dooley <conor.dooley@microchip.com> Cc: Brian Cain <bcain@quicinc.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greg Ungerer <gerg@linux-m68k.org> Cc: Helge Deller <deller@gmx.de> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Vineet Gupta <vgupta@kernel.org> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
139 lines
3.2 KiB
C
139 lines
3.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
|
|
*/
|
|
#ifndef __ASM_ARC_PAGE_H
|
|
#define __ASM_ARC_PAGE_H
|
|
|
|
#include <uapi/asm/page.h>
|
|
|
|
#ifdef CONFIG_ARC_HAS_PAE40
|
|
|
|
#define MAX_POSSIBLE_PHYSMEM_BITS 40
|
|
#define PAGE_MASK_PHYS (0xff00000000ull | PAGE_MASK)
|
|
|
|
#else /* CONFIG_ARC_HAS_PAE40 */
|
|
|
|
#define MAX_POSSIBLE_PHYSMEM_BITS 32
|
|
#define PAGE_MASK_PHYS PAGE_MASK
|
|
|
|
#endif /* CONFIG_ARC_HAS_PAE40 */
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
|
|
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
|
#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
|
|
|
|
struct vm_area_struct;
|
|
struct page;
|
|
|
|
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
|
|
void copy_user_highpage(struct page *to, struct page *from,
|
|
unsigned long u_vaddr, struct vm_area_struct *vma);
|
|
void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
|
|
|
|
typedef struct {
|
|
unsigned long pgd;
|
|
} pgd_t;
|
|
|
|
#define pgd_val(x) ((x).pgd)
|
|
#define __pgd(x) ((pgd_t) { (x) })
|
|
|
|
#if CONFIG_PGTABLE_LEVELS > 3
|
|
|
|
typedef struct {
|
|
unsigned long pud;
|
|
} pud_t;
|
|
|
|
#define pud_val(x) ((x).pud)
|
|
#define __pud(x) ((pud_t) { (x) })
|
|
|
|
#endif
|
|
|
|
#if CONFIG_PGTABLE_LEVELS > 2
|
|
|
|
typedef struct {
|
|
unsigned long pmd;
|
|
} pmd_t;
|
|
|
|
#define pmd_val(x) ((x).pmd)
|
|
#define __pmd(x) ((pmd_t) { (x) })
|
|
|
|
#endif
|
|
|
|
typedef struct {
|
|
#ifdef CONFIG_ARC_HAS_PAE40
|
|
unsigned long long pte;
|
|
#else
|
|
unsigned long pte;
|
|
#endif
|
|
} pte_t;
|
|
|
|
#define pte_val(x) ((x).pte)
|
|
#define __pte(x) ((pte_t) { (x) })
|
|
|
|
typedef struct {
|
|
unsigned long pgprot;
|
|
} pgprot_t;
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
#define __pgprot(x) ((pgprot_t) { (x) })
|
|
#define pte_pgprot(x) __pgprot(pte_val(x))
|
|
|
|
typedef struct page *pgtable_t;
|
|
|
|
/*
|
|
* Use virt_to_pfn with caution:
|
|
* If used in pte or paddr related macros, it could cause truncation
|
|
* in PAE40 builds
|
|
* As a rule of thumb, only use it in helpers starting with virt_
|
|
* You have been warned !
|
|
*/
|
|
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
/*
|
|
* When HIGHMEM is enabled we have holes in the memory map so we need
|
|
* pfn_valid() that takes into account the actual extents of the physical
|
|
* memory
|
|
*/
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
extern unsigned long arch_pfn_offset;
|
|
#define ARCH_PFN_OFFSET arch_pfn_offset
|
|
|
|
extern int pfn_valid(unsigned long pfn);
|
|
#define pfn_valid pfn_valid
|
|
|
|
#else /* CONFIG_HIGHMEM */
|
|
|
|
#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
|
|
|
|
#endif /* CONFIG_HIGHMEM */
|
|
|
|
/*
|
|
* __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
|
|
*
|
|
* These macros have historically been misnamed
|
|
* virt here means link-address/program-address as embedded in object code.
|
|
* And for ARC, link-addr = physical address
|
|
*/
|
|
#define __pa(vaddr) ((unsigned long)(vaddr))
|
|
#define __va(paddr) ((void *)((unsigned long)(paddr)))
|
|
|
|
#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
|
|
#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
|
|
|
|
/* Default Permissions for stack/heaps pages (Non Executable) */
|
|
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
|
|
|
|
#define WANT_PAGE_VIRTUAL 1
|
|
|
|
#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
|
|
#include <asm-generic/getorder.h>
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#endif
|