On 3/2/20 7:47 AM, Anshuman Khandual wrote:
> There are many platforms with exact same value for VM_DATA_DEFAULT_FLAGS
> This creates a default value for VM_DATA_DEFAULT_FLAGS in line with the
> existing VM_STACK_DEFAULT_FLAGS. While here, also define some more macros
> with standard VMA access flag combinations that are used frequently across
> many platforms. Apart from simplification, this reduces code duplication
> as well.
> 
> Cc: Richard Henderson <r...@twiddle.net>
> Cc: Vineet Gupta <vgu...@synopsys.com>
> Cc: Russell King <li...@armlinux.org.uk>
> Cc: Catalin Marinas <catalin.mari...@arm.com>
> Cc: Mark Salter <msal...@redhat.com>
> Cc: Guo Ren <guo...@kernel.org>
> Cc: Yoshinori Sato <ys...@users.sourceforge.jp>
> Cc: Brian Cain <bc...@codeaurora.org>
> Cc: Tony Luck <tony.l...@intel.com>
> Cc: Geert Uytterhoeven <ge...@linux-m68k.org>
> Cc: Michal Simek <mon...@monstr.eu>
> Cc: Ralf Baechle <r...@linux-mips.org>
> Cc: Paul Burton <paulbur...@kernel.org>
> Cc: Nick Hu <nic...@andestech.com>
> Cc: Ley Foon Tan <ley.foon....@intel.com>
> Cc: Jonas Bonn <jo...@southpole.se>
> Cc: "James E.J. Bottomley" <james.bottom...@hansenpartnership.com>
> Cc: Michael Ellerman <m...@ellerman.id.au>
> Cc: Paul Walmsley <paul.walms...@sifive.com>
> Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
> Cc: Rich Felker <dal...@libc.org>
> Cc: "David S. Miller" <da...@davemloft.net>
> Cc: Guan Xuetao <g...@pku.edu.cn>
> Cc: Thomas Gleixner <t...@linutronix.de>
> Cc: Jeff Dike <jd...@addtoit.com>
> Cc: Chris Zankel <ch...@zankel.net>
> Cc: Andrew Morton <a...@linux-foundation.org>
> Cc: linux-al...@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org
> Cc: linux-snps-...@lists.infradead.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-c6x-...@linux-c6x.org
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Cc: linux-hexa...@vger.kernel.org
> Cc: linux-i...@vger.kernel.org
> Cc: linux-m...@lists.linux-m68k.org
> Cc: linux-m...@vger.kernel.org
> Cc: nios2-...@lists.rocketboards.org
> Cc: openr...@lists.librecores.org
> Cc: linux-par...@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-ri...@lists.infradead.org
> Cc: linux-s...@vger.kernel.org
> Cc: linux...@vger.kernel.org
> Cc: sparcli...@vger.kernel.org
> Cc: linux...@lists.infradead.org
> Cc: linux-xte...@linux-xtensa.org
> Cc: linux...@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khand...@arm.com
Reviewed-by: Vlastimil Babka <vba...@suse.cz>

Nit:

> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index b0e53ef13ff1..7a764ae6ab68 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -342,6 +342,21 @@ extern unsigned int kobjsize(const void *objp);
>  /* Bits set in the VMA until the stack is in its final location */
>  #define VM_STACK_INCOMPLETE_SETUP    (VM_RAND_READ | VM_SEQ_READ)
>  
> +#define TASK_EXEC ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0)
> +
> +/* Common data flag combinations */
> +#define VM_DATA_FLAGS_TSK_EXEC       (VM_READ | VM_WRITE | TASK_EXEC | \
> +                              VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
> +#define VM_DATA_FLAGS_NON_EXEC       (VM_READ | VM_WRITE | VM_MAYREAD | \
> +                              VM_MAYWRITE | VM_MAYEXEC)
> +#define VM_DATA_FLAGS_EXEC   (VM_READ | VM_WRITE | VM_EXEC | \
> +                              VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
> +
> +#ifndef VM_DATA_DEFAULT_FLAGS                /* arch can override this */
> +#define VM_DATA_DEFAULT_FLAGS        (VM_READ | VM_WRITE | VM_EXEC | \
> +                              VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)

Should you use VM_DATA_FLAGS_EXEC here? Yeah one more macro to expand, but it's
right above this.

> +#endif
> +
>  #ifndef VM_STACK_DEFAULT_FLAGS               /* arch can override this */
>  #define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
>  #endif
> 

Reply via email to