2019-06-04 10:11:33 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2008-08-02 10:55:55 +01:00
|
|
|
* arch/arm/include/asm/page.h
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
* Copyright (C) 1995-2003 Russell King
|
|
|
|
*/
|
|
|
|
#ifndef _ASMARM_PAGE_H
|
|
|
|
#define _ASMARM_PAGE_H
|
|
|
|
|
|
|
|
/* PAGE_SHIFT determines the page size */
|
2024-02-26 17:14:13 +01:00
|
|
|
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
|
2009-06-24 23:38:56 +01:00
|
|
|
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
|
2012-07-22 13:40:38 -04:00
|
|
|
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2006-06-20 20:46:52 +01:00
|
|
|
#ifndef CONFIG_MMU
|
|
|
|
|
2012-10-02 18:01:25 +01:00
|
|
|
#include <asm/page-nommu.h>
|
2006-06-20 20:46:52 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/glue.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User Space Model
|
|
|
|
* ================
|
|
|
|
*
|
|
|
|
* This section selects the correct set of functions for dealing with
|
|
|
|
* page-based copying and clearing for user space for the particular
|
|
|
|
* processor(s) we're building for.
|
|
|
|
*
|
|
|
|
* We have the following to choose from:
|
|
|
|
* v4wt - ARMv4 with writethrough cache, without minicache
|
|
|
|
* v4wb - ARMv4 with writeback cache, without minicache
|
|
|
|
* v4_mc - ARMv4 with minicache
|
|
|
|
* xscale - Xscale
|
2006-03-28 21:00:40 +01:00
|
|
|
* xsc3 - XScalev3
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
#undef _USER
|
|
|
|
#undef MULTI_USER
|
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_COPY_V4WT
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER v4wt
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_COPY_V4WB
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER v4wb
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2008-04-24 01:31:45 -04:00
|
|
|
#ifdef CONFIG_CPU_COPY_FEROCEON
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER feroceon
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2009-03-25 13:10:01 +02:00
|
|
|
#ifdef CONFIG_CPU_COPY_FA
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER fa
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_CPU_SA1100
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER v4_mc
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_XSCALE
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER xscale_mc
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2006-03-28 21:00:40 +01:00
|
|
|
#ifdef CONFIG_CPU_XSC3
|
|
|
|
# ifdef _USER
|
|
|
|
# define MULTI_USER 1
|
|
|
|
# else
|
|
|
|
# define _USER xsc3_mc
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_CPU_COPY_V6
|
|
|
|
# define MULTI_USER 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(_USER) && !defined(MULTI_USER)
|
|
|
|
#error Unknown user operations model
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 15:08:35 +00:00
|
|
|
struct page;
|
2009-10-05 15:17:45 +01:00
|
|
|
struct vm_area_struct;
|
2008-10-31 15:08:35 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct cpu_user_fns {
|
2008-10-31 16:32:19 +00:00
|
|
|
void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
|
2008-10-31 15:08:35 +00:00
|
|
|
void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
|
2009-10-05 15:17:45 +01:00
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
2023-06-02 19:28:45 +01:00
|
|
|
void fa_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void fa_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void feroceon_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void feroceon_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void v4_mc_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void v4_mc_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void v4wb_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void v4wb_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void v4wt_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void v4wt_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void xsc3_mc_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void xsc3_mc_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
void xscale_mc_copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
void xscale_mc_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef MULTI_USER
|
|
|
|
extern struct cpu_user_fns cpu_user;
|
|
|
|
|
2008-10-31 16:32:19 +00:00
|
|
|
#define __cpu_clear_user_highpage cpu_user.cpu_clear_user_highpage
|
2008-10-31 15:08:35 +00:00
|
|
|
#define __cpu_copy_user_highpage cpu_user.cpu_copy_user_highpage
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-10-31 16:32:19 +00:00
|
|
|
#define __cpu_clear_user_highpage __glue(_USER,_clear_user_highpage)
|
2008-10-31 15:08:35 +00:00
|
|
|
#define __cpu_copy_user_highpage __glue(_USER,_copy_user_highpage)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-10-31 16:32:19 +00:00
|
|
|
extern void __cpu_clear_user_highpage(struct page *page, unsigned long vaddr);
|
2008-10-31 15:08:35 +00:00
|
|
|
extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
|
2009-10-05 15:17:45 +01:00
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|
|
|
|
|
2008-10-31 16:32:19 +00:00
|
|
|
#define clear_user_highpage(page,vaddr) \
|
|
|
|
__cpu_clear_user_highpage(page, vaddr)
|
2008-10-31 15:08:35 +00:00
|
|
|
|
|
|
|
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
|
|
#define copy_user_highpage(to,from,vaddr,vma) \
|
2009-10-05 15:17:45 +01:00
|
|
|
__cpu_copy_user_highpage(to, from, vaddr, vma)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-10-27 11:24:09 +00:00
|
|
|
#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
|
2005-04-16 15:20:36 -07:00
|
|
|
extern void copy_page(void *to, const void *from);
|
|
|
|
|
2013-07-31 21:58:56 +01:00
|
|
|
#ifdef CONFIG_KUSER_HELPERS
|
2012-01-20 12:01:13 +01:00
|
|
|
#define __HAVE_ARCH_GATE_AREA 1
|
2013-07-31 21:58:56 +01:00
|
|
|
#endif
|
2012-01-20 12:01:13 +01:00
|
|
|
|
2011-11-22 17:30:29 +00:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
#include <asm/pgtable-3level-types.h>
|
|
|
|
#else
|
2011-09-05 17:41:02 +01:00
|
|
|
#include <asm/pgtable-2level-types.h>
|
2021-09-23 09:15:53 +02:00
|
|
|
#ifdef CONFIG_VMAP_STACK
|
|
|
|
#define ARCH_PAGE_TABLE_SYNC_MASK PGTBL_PMD_MODIFIED
|
|
|
|
#endif
|
2022-01-10 09:54:22 +01:00
|
|
|
#endif
|
2021-09-23 09:15:53 +02:00
|
|
|
|
2006-06-20 20:46:52 +01:00
|
|
|
#endif /* CONFIG_MMU */
|
|
|
|
|
2008-05-23 07:16:52 +01:00
|
|
|
typedef struct page *pgtable_t;
|
|
|
|
|
ARM: 6913/1: sparsemem: allow pfn_valid to be overridden when using SPARSEMEM
In commit eb33575c ("[ARM] Double check memmap is actually valid with a
memmap has unexpected holes V2"), a new function, memmap_valid_within,
was introduced to mmzone.h so that holes in the memmap which pass
pfn_valid in SPARSEMEM configurations can be detected and avoided.
The fix to this problem checks that the pfn <-> page linkages are
correct by calculating the page for the pfn and then checking that
page_to_pfn on that page returns the original pfn. Unfortunately, in
SPARSEMEM configurations, this results in reading from the page flags to
determine the correct section. Since the memmap here has been freed,
junk is read from memory and the check is no longer robust.
In the best case, reading from /proc/pagetypeinfo will give you the
wrong answer. In the worst case, you get SEGVs, Kernel OOPses and hung
CPUs. Furthermore, ioremap implementations that use pfn_valid to
disallow the remapping of normal memory will break.
This patch allows architectures to provide their own pfn_valid function
instead of using the default implementation used by sparsemem. The
architecture-specific version is aware of the memmap state and will
return false when passed a pfn for a freed page within a valid section.
Acked-by: Mel Gorman <mgorman@suse.de>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-05-19 13:21:14 +01:00
|
|
|
#ifdef CONFIG_HAVE_ARCH_PFN_VALID
|
2009-09-07 15:06:42 +01:00
|
|
|
extern int pfn_valid(unsigned long);
|
2023-01-29 14:42:32 +02:00
|
|
|
#define pfn_valid pfn_valid
|
2009-09-07 15:06:42 +01:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
ARM: mm: Make virt_to_pfn() a static inline
Making virt_to_pfn() a static inline taking a strongly typed
(const void *) makes the contract of a passing a pointer of that
type to the function explicit and exposes any misuse of the
macro virt_to_pfn() acting polymorphic and accepting many types
such as (void *), (unitptr_t) or (unsigned long) as arguments
without warnings.
Doing this is a bit intrusive: virt_to_pfn() requires
PHYS_PFN_OFFSET and PAGE_SHIFT to be defined, and this is defined in
<asm/page.h>, so this must be included *before* <asm/memory.h>.
The use of macros were obscuring the unclear inclusion order here,
as the macros would eventually be resolved, but a static inline
like this cannot be compiled with unresolved macros.
The naive solution to include <asm/page.h> at the top of
<asm/memory.h> does not work, because <asm/memory.h> sometimes
includes <asm/page.h> at the end of itself, which would create a
confusing inclusion loop. So instead, take the approach to always
unconditionally include <asm/page.h> at the end of <asm/memory.h>
arch/arm uses <asm/memory.h> explicitly in a lot of places,
however it turns out that if we just unconditionally include
<asm/memory.h> into <asm/page.h> and switch all inclusions of
<asm/memory.h> to <asm/page.h> instead, we enforce the right
order and <asm/memory.h> will always have access to the
definitions.
Put an inclusion guard in place making it impossible to include
<asm/memory.h> explicitly.
Link: https://lore.kernel.org/linux-mm/20220701160004.2ffff4e5ab59a55499f4c736@linux-foundation.org/
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2022-06-02 10:18:32 +02:00
|
|
|
#include <asm/memory.h>
|
|
|
|
|
2020-04-10 14:33:05 -07:00
|
|
|
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_TSK_EXEC
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-05-13 22:56:30 +00:00
|
|
|
#include <asm-generic/getorder.h>
|
2023-01-29 14:42:32 +02:00
|
|
|
#include <asm-generic/memory_model.h>
|
2005-09-03 15:54:30 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|