[PATCH v2 17/23] mm: convert do_brk_flags() to use vma_flags_t
Paul Moore
paul at paul-moore.com
Tue Mar 17 10:23:04 AEDT 2026
On Mon, Mar 16, 2026 at 9:09 AM Lorenzo Stoakes (Oracle) <ljs at kernel.org> wrote:
>
> 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.
>
> Finally, we update the VMA tests to reflect these changes.
>
> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs at kernel.org>
> ---
> arch/arc/include/asm/page.h | 2 +-
> arch/arm/include/asm/page.h | 2 +-
> arch/arm64/include/asm/page.h | 3 +-
> arch/hexagon/include/asm/page.h | 2 +-
> arch/loongarch/include/asm/page.h | 2 +-
> arch/mips/include/asm/page.h | 2 +-
> arch/nios2/include/asm/page.h | 2 +-
> arch/powerpc/include/asm/page.h | 4 +--
> arch/powerpc/include/asm/page_32.h | 2 +-
> arch/powerpc/include/asm/page_64.h | 12 ++++----
> arch/riscv/include/asm/page.h | 2 +-
> arch/s390/include/asm/page.h | 2 +-
> arch/x86/include/asm/page_types.h | 2 +-
> arch/x86/um/asm/vm-flags.h | 4 +--
> include/linux/ksm.h | 10 +++----
> include/linux/mm.h | 47 ++++++++++++++++++------------
> mm/internal.h | 3 ++
> mm/ksm.c | 43 ++++++++++++++-------------
> mm/mmap.c | 13 +++++----
> mm/mprotect.c | 46 +++++++++++++++++------------
> mm/mremap.c | 6 ++--
> mm/vma.c | 34 +++++++++++----------
> mm/vma.h | 14 +++++++--
> mm/vma_exec.c | 5 ++--
> security/selinux/hooks.c | 4 ++-
> tools/testing/vma/include/custom.h | 3 --
> tools/testing/vma/include/dup.h | 42 ++++++++++++++------------
> tools/testing/vma/include/stubs.h | 9 +++---
> tools/testing/vma/tests/merge.c | 3 +-
> 29 files changed, 186 insertions(+), 139 deletions(-)
Not that the SELinux changes are really all that significant, but they
look fine to me.
Acked-by: Paul Moore <paul at paul-moore.com> (SELinux)
--
paul-moore.com
More information about the Linuxppc-dev
mailing list