mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-15 00:36:50 +07:00
7b7bf499f7
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>
215 lines
4.5 KiB
C
215 lines
4.5 KiB
C
/*
|
|
* arch/arm/include/asm/page.h
|
|
*
|
|
* Copyright (C) 1995-2003 Russell King
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
#ifndef _ASMARM_PAGE_H
|
|
#define _ASMARM_PAGE_H
|
|
|
|
/* PAGE_SHIFT determines the page size */
|
|
#define PAGE_SHIFT 12
|
|
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifndef CONFIG_MMU
|
|
|
|
#include "page-nommu.h"
|
|
|
|
#else
|
|
|
|
#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:
|
|
* v3 - ARMv3
|
|
* v4wt - ARMv4 with writethrough cache, without minicache
|
|
* v4wb - ARMv4 with writeback cache, without minicache
|
|
* v4_mc - ARMv4 with minicache
|
|
* xscale - Xscale
|
|
* xsc3 - XScalev3
|
|
*/
|
|
#undef _USER
|
|
#undef MULTI_USER
|
|
|
|
#ifdef CONFIG_CPU_COPY_V3
|
|
# ifdef _USER
|
|
# define MULTI_USER 1
|
|
# else
|
|
# define _USER v3
|
|
# endif
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef CONFIG_CPU_COPY_FEROCEON
|
|
# ifdef _USER
|
|
# define MULTI_USER 1
|
|
# else
|
|
# define _USER feroceon
|
|
# endif
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_COPY_FA
|
|
# ifdef _USER
|
|
# define MULTI_USER 1
|
|
# else
|
|
# define _USER fa
|
|
# endif
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef CONFIG_CPU_XSC3
|
|
# ifdef _USER
|
|
# define MULTI_USER 1
|
|
# else
|
|
# define _USER xsc3_mc
|
|
# endif
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_COPY_V6
|
|
# define MULTI_USER 1
|
|
#endif
|
|
|
|
#if !defined(_USER) && !defined(MULTI_USER)
|
|
#error Unknown user operations model
|
|
#endif
|
|
|
|
struct page;
|
|
struct vm_area_struct;
|
|
|
|
struct cpu_user_fns {
|
|
void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
|
|
void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
};
|
|
|
|
#ifdef MULTI_USER
|
|
extern struct cpu_user_fns cpu_user;
|
|
|
|
#define __cpu_clear_user_highpage cpu_user.cpu_clear_user_highpage
|
|
#define __cpu_copy_user_highpage cpu_user.cpu_copy_user_highpage
|
|
|
|
#else
|
|
|
|
#define __cpu_clear_user_highpage __glue(_USER,_clear_user_highpage)
|
|
#define __cpu_copy_user_highpage __glue(_USER,_copy_user_highpage)
|
|
|
|
extern void __cpu_clear_user_highpage(struct page *page, unsigned long vaddr);
|
|
extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
#endif
|
|
|
|
#define clear_user_highpage(page,vaddr) \
|
|
__cpu_clear_user_highpage(page, vaddr)
|
|
|
|
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
#define copy_user_highpage(to,from,vaddr,vma) \
|
|
__cpu_copy_user_highpage(to, from, vaddr, vma)
|
|
|
|
#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
|
|
extern void copy_page(void *to, const void *from);
|
|
|
|
typedef unsigned long pteval_t;
|
|
|
|
#undef STRICT_MM_TYPECHECKS
|
|
|
|
#ifdef STRICT_MM_TYPECHECKS
|
|
/*
|
|
* These are used to make use of C type-checking..
|
|
*/
|
|
typedef struct { pteval_t pte; } pte_t;
|
|
typedef struct { unsigned long pmd; } pmd_t;
|
|
typedef struct { unsigned long pgd[2]; } pgd_t;
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
|
|
#define pte_val(x) ((x).pte)
|
|
#define pmd_val(x) ((x).pmd)
|
|
#define pgd_val(x) ((x).pgd[0])
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
|
|
#define __pte(x) ((pte_t) { (x) } )
|
|
#define __pmd(x) ((pmd_t) { (x) } )
|
|
#define __pgprot(x) ((pgprot_t) { (x) } )
|
|
|
|
#else
|
|
/*
|
|
* .. while these make it easier on the compiler
|
|
*/
|
|
typedef pteval_t pte_t;
|
|
typedef unsigned long pmd_t;
|
|
typedef unsigned long pgd_t[2];
|
|
typedef unsigned long pgprot_t;
|
|
|
|
#define pte_val(x) (x)
|
|
#define pmd_val(x) (x)
|
|
#define pgd_val(x) ((x)[0])
|
|
#define pgprot_val(x) (x)
|
|
|
|
#define __pte(x) (x)
|
|
#define __pmd(x) (x)
|
|
#define __pgprot(x) (x)
|
|
|
|
#endif /* STRICT_MM_TYPECHECKS */
|
|
|
|
#endif /* CONFIG_MMU */
|
|
|
|
typedef struct page *pgtable_t;
|
|
|
|
#ifdef CONFIG_HAVE_ARCH_PFN_VALID
|
|
extern int pfn_valid(unsigned long);
|
|
#endif
|
|
|
|
#include <asm/memory.h>
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#define VM_DATA_DEFAULT_FLAGS \
|
|
(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
|
|
VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
|
|
|
|
#include <asm-generic/getorder.h>
|
|
|
|
#endif
|