mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 02:21:39 -04:00
mm/vma: update create_init_stack_vma() to use vma_flags_t
Replace use of the legacy vm_flags_t flags with vma_flags_t values in create_init_stack_vma(). As part of this change we add VMA_STACK_EARLY and VMA_STACK_INCOMPLETE vma_flags_t defines, and slightly rework create_init_stack_vma() for clarity. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-9-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
a2fdfd0080
commit
8e7501a361
@@ -442,8 +442,10 @@ enum {
|
||||
#define VM_STACK INIT_VM_FLAG(STACK)
|
||||
#ifdef CONFIG_STACK_GROWSUP
|
||||
#define VM_STACK_EARLY INIT_VM_FLAG(STACK_EARLY)
|
||||
#define VMA_STACK_EARLY mk_vma_flags(VMA_STACK_EARLY_BIT)
|
||||
#else
|
||||
#define VM_STACK_EARLY VM_NONE
|
||||
#define VMA_STACK_EARLY EMPTY_VMA_FLAGS
|
||||
#endif
|
||||
#ifdef CONFIG_ARCH_HAS_PKEYS
|
||||
#define VM_PKEY_SHIFT ((__force int)VMA_HIGH_ARCH_0_BIT)
|
||||
@@ -544,6 +546,8 @@ enum {
|
||||
|
||||
/* Bits set in the VMA until the stack is in its final location */
|
||||
#define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY)
|
||||
#define VMA_STACK_INCOMPLETE_SETUP append_vma_flags( \
|
||||
VMA_STACK_EARLY, VMA_RAND_READ_BIT, VMA_SEQ_READ_BIT)
|
||||
|
||||
#define TASK_EXEC_BIT ((current->personality & READ_IMPLIES_EXEC) ? \
|
||||
VMA_EXEC_BIT : VMA_READ_BIT)
|
||||
|
||||
@@ -112,15 +112,17 @@ int relocate_vma_down(struct vm_area_struct *vma, unsigned long shift)
|
||||
int create_init_stack_vma(struct mm_struct *mm, struct vm_area_struct **vmap,
|
||||
unsigned long *top_mem_p)
|
||||
{
|
||||
unsigned long flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
|
||||
vma_flags_t flags = VMA_STACK_INCOMPLETE_SETUP;
|
||||
struct vm_area_struct *vma;
|
||||
int err;
|
||||
struct vm_area_struct *vma = vm_area_alloc(mm);
|
||||
|
||||
/* VMA_STACK_FLAGS and VMA_STACK_INCOMPLETE_SETUP must not overlap. */
|
||||
VM_WARN_ON_ONCE(vma_flags_test_any_mask(&flags, VMA_STACK_FLAGS));
|
||||
|
||||
vma = vm_area_alloc(mm);
|
||||
if (!vma)
|
||||
return -ENOMEM;
|
||||
|
||||
vma_set_anonymous(vma);
|
||||
|
||||
if (mmap_write_lock_killable(mm)) {
|
||||
err = -EINTR;
|
||||
goto err_free;
|
||||
@@ -134,18 +136,20 @@ int create_init_stack_vma(struct mm_struct *mm, struct vm_area_struct **vmap,
|
||||
if (err)
|
||||
goto err_ksm;
|
||||
|
||||
vma_flags_set_mask(&flags, VMA_STACK_FLAGS);
|
||||
vma_set_anonymous(vma);
|
||||
|
||||
/*
|
||||
* Place the stack at the largest stack address the architecture
|
||||
* supports. Later, we'll move this to an appropriate place. We don't
|
||||
* use STACK_TOP because that can depend on attributes which aren't
|
||||
* configured yet.
|
||||
*/
|
||||
VM_WARN_ON_ONCE(VM_STACK_FLAGS & VM_STACK_INCOMPLETE_SETUP);
|
||||
vma->vm_end = STACK_TOP_MAX;
|
||||
vma->vm_start = vma->vm_end - PAGE_SIZE;
|
||||
if (pgtable_supports_soft_dirty())
|
||||
flags |= VM_SOFTDIRTY;
|
||||
vm_flags_init(vma, flags);
|
||||
vma_flags_set(&flags, VMA_SOFTDIRTY_BIT);
|
||||
vma->flags = flags;
|
||||
vma->vm_page_prot = vma_get_page_prot(vma);
|
||||
|
||||
err = insert_vm_struct(mm, vma);
|
||||
|
||||
@@ -245,8 +245,10 @@ enum {
|
||||
#define VM_STACK INIT_VM_FLAG(STACK)
|
||||
#ifdef CONFIG_STACK_GROWS_UP
|
||||
#define VM_STACK_EARLY INIT_VM_FLAG(STACK_EARLY)
|
||||
#define VMA_STACK_EARLY mk_vma_flags(VMA_STACK_EARLY_BIT)
|
||||
#else
|
||||
#define VM_STACK_EARLY VM_NONE
|
||||
#define VMA_STACK_EARLY EMPTY_VMA_FLAGS
|
||||
#endif
|
||||
#ifdef CONFIG_ARCH_HAS_PKEYS
|
||||
#define VM_PKEY_SHIFT ((__force int)VMA_HIGH_ARCH_0_BIT)
|
||||
@@ -315,6 +317,8 @@ enum {
|
||||
|
||||
/* Bits set in the VMA until the stack is in its final location */
|
||||
#define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY)
|
||||
#define VMA_STACK_INCOMPLETE_SETUP append_vma_flags( \
|
||||
VMA_STACK_EARLY, VMA_RAND_READ_BIT, VMA_SEQ_READ_BIT)
|
||||
|
||||
#define TASK_EXEC_BIT ((current->personality & READ_IMPLIES_EXEC) ? \
|
||||
VM_EXEC_BIT : VM_READ_BIT)
|
||||
|
||||
Reference in New Issue
Block a user