mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
In order to be able to do this, we need to change VM_DATA_DEFAULT_FLAGS and friends and update the architecture-specific definitions also. We then have to update some KSM logic to handle VMA flags, and introduce VMA_STACK_FLAGS to define the vma_flags_t equivalent of VM_STACK_FLAGS. We also introduce two helper functions for use during the time we are converting legacy flags to vma_flags_t values - vma_flags_to_legacy() and legacy_to_vma_flags(). This enables us to iteratively make changes to break these changes up into separate parts. We use these explicitly here to keep VM_STACK_FLAGS around for certain users which need to maintain the legacy vm_flags_t values for the time being. We are no longer able to rely on the simple VM_xxx being set to zero if the feature is not enabled, so in the case of VM_DROPPABLE we introduce VMA_DROPPABLE as the vma_flags_t equivalent, which is set to EMPTY_VMA_FLAGS if the droppable flag is not available. While we're here, we make the description of do_brk_flags() into a kdoc comment, as it almost was already. We use vma_flags_to_legacy() to not need to update the vm_get_page_prot() logic as this time. Note that in create_init_stack_vma() we have to replace the BUILD_BUG_ON() with a VM_WARN_ON_ONCE() as the tested values are no longer build time available. We also update mprotect_fixup() to use VMA flags where possible, though we have to live with a little duplication between vm_flags_t and vma_flags_t values for the time being until further conversions are made. While we're here, update VM_SPECIAL to be defined in terms of VMA_SPECIAL_FLAGS now we have vma_flags_to_legacy(). Finally, we update the VMA tests to reflect these changes. Link: https://lkml.kernel.org/r/d02e3e45d9a33d7904b149f5604904089fd640ae.1774034900.git.ljs@kernel.org Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> Acked-by: Paul Moore <paul@paul-moore.com> [SELinux] Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chengming Zhou <chengming.zhou@linux.dev> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Kees Cook <kees@kernel.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Ondrej Mosnacek <omosnace@redhat.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Richard Weinberger <richard@nod.at> Cc: Russell King <linux@armlinux.org.uk> Cc: Stephen Smalley <stephen.smalley.work@gmail.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@kernel.org> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Cc: xu xin <xu.xin16@zte.com.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
193 lines
4.7 KiB
C
193 lines
4.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* arch/arm/include/asm/page.h
|
|
*
|
|
* Copyright (C) 1995-2003 Russell King
|
|
*/
|
|
#ifndef _ASMARM_PAGE_H
|
|
#define _ASMARM_PAGE_H
|
|
|
|
#include <vdso/page.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifndef CONFIG_MMU
|
|
|
|
#include <asm/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:
|
|
* 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_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);
|
|
};
|
|
|
|
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);
|
|
|
|
#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);
|
|
|
|
#ifdef CONFIG_KUSER_HELPERS
|
|
#define __HAVE_ARCH_GATE_AREA 1
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
#include <asm/pgtable-3level-types.h>
|
|
#else
|
|
#include <asm/pgtable-2level-types.h>
|
|
#ifdef CONFIG_VMAP_STACK
|
|
#define ARCH_PAGE_TABLE_SYNC_MASK PGTBL_PMD_MODIFIED
|
|
#endif
|
|
#endif
|
|
|
|
#endif /* CONFIG_MMU */
|
|
|
|
typedef struct page *pgtable_t;
|
|
|
|
#ifdef CONFIG_HAVE_ARCH_PFN_VALID
|
|
extern int pfn_valid(unsigned long);
|
|
#define pfn_valid pfn_valid
|
|
#endif
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#include <asm/memory.h>
|
|
|
|
#define VMA_DATA_DEFAULT_FLAGS VMA_DATA_FLAGS_TSK_EXEC
|
|
|
|
#include <asm-generic/getorder.h>
|
|
#include <asm-generic/memory_model.h>
|
|
|
|
#endif
|