From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "hch@infradead.org" <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
kernel test robot <lkp@intel.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V3 2/2] mm/mmap: Drop generic protection_map[] array
Date: Thu, 16 Jun 2022 05:45:39 +0000 [thread overview]
Message-ID: <7cf922f4-2367-e173-0280-cb498391d9f7@csgroup.eu> (raw)
In-Reply-To: <20220616040924.1022607-3-anshuman.khandual@arm.com>
Le 16/06/2022 à 06:09, Anshuman Khandual a écrit :
> Move the protection_array[] array inside the arch for those platforms which
> do not enable ARCH_HAS_VM_GET_PAGE_PROT. Afterwards __SXXX/__PXX macros can
> be dropped completely which are now redundant.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Reported-by: kernel test robot <lkp@intel.com>
> Acked-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> arch/alpha/include/asm/pgtable.h | 17 -------
> arch/alpha/mm/init.c | 21 +++++++++
> arch/arc/include/asm/pgtable-bits-arcv2.h | 18 --------
> arch/arc/mm/mmap.c | 19 ++++++++
> arch/arm/include/asm/pgtable.h | 17 -------
> arch/arm/lib/uaccess_with_memcpy.c | 2 +-
> arch/arm/mm/mmu.c | 19 ++++++++
> arch/csky/include/asm/pgtable.h | 18 --------
> arch/csky/mm/init.c | 19 ++++++++
> arch/hexagon/include/asm/pgtable.h | 27 ------------
> arch/hexagon/mm/init.c | 41 +++++++++++++++++
> arch/ia64/include/asm/pgtable.h | 18 --------
> arch/ia64/mm/init.c | 27 +++++++++++-
> arch/loongarch/include/asm/pgtable-bits.h | 19 --------
> arch/loongarch/mm/cache.c | 45 +++++++++++++++++++
> arch/m68k/include/asm/mcf_pgtable.h | 54 -----------------------
> arch/m68k/include/asm/motorola_pgtable.h | 22 ---------
> arch/m68k/include/asm/sun3_pgtable.h | 17 -------
> arch/m68k/mm/mcfmmu.c | 54 +++++++++++++++++++++++
> arch/m68k/mm/motorola.c | 19 ++++++++
> arch/m68k/mm/sun3mmu.c | 19 ++++++++
> arch/microblaze/include/asm/pgtable.h | 17 -------
> arch/microblaze/mm/init.c | 19 ++++++++
> arch/mips/include/asm/pgtable.h | 22 ---------
> arch/mips/mm/cache.c | 2 +
> arch/nios2/include/asm/pgtable.h | 16 -------
> arch/nios2/mm/init.c | 19 ++++++++
> arch/openrisc/include/asm/pgtable.h | 18 --------
> arch/openrisc/mm/init.c | 19 ++++++++
> arch/parisc/include/asm/pgtable.h | 18 --------
> arch/parisc/mm/init.c | 19 ++++++++
> arch/powerpc/include/asm/pgtable.h | 20 ---------
> arch/powerpc/mm/book3s64/pgtable.c | 24 +++-------
> arch/powerpc/mm/pgtable.c | 20 +++++++++
> arch/riscv/include/asm/pgtable.h | 20 ---------
> arch/riscv/mm/init.c | 19 ++++++++
> arch/s390/include/asm/pgtable.h | 17 -------
> arch/s390/mm/mmap.c | 19 ++++++++
> arch/sh/include/asm/pgtable.h | 17 -------
> arch/sh/mm/mmap.c | 19 ++++++++
> arch/sparc/include/asm/pgtable_32.h | 19 --------
> arch/sparc/mm/init_32.c | 19 ++++++++
> arch/sparc/mm/init_64.c | 2 +-
> arch/um/include/asm/pgtable.h | 17 -------
> arch/um/kernel/mem.c | 19 ++++++++
> arch/x86/um/mem_32.c | 2 +-
> arch/xtensa/include/asm/pgtable.h | 18 --------
> arch/xtensa/mm/init.c | 19 ++++++++
> include/linux/mm.h | 2 +-
> mm/mmap.c | 19 --------
> 50 files changed, 503 insertions(+), 489 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index 8ed2a80c896e..bd636295a794 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -21,26 +21,6 @@ struct mm_struct;
> #endif /* !CONFIG_PPC_BOOK3S */
>
> /* Note due to the way vm flags are laid out, the bits are XWR */
> -#ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT
> -#define __P000 PAGE_NONE
> -#define __P001 PAGE_READONLY
> -#define __P010 PAGE_COPY
> -#define __P011 PAGE_COPY
> -#define __P100 PAGE_READONLY_X
> -#define __P101 PAGE_READONLY_X
> -#define __P110 PAGE_COPY_X
> -#define __P111 PAGE_COPY_X
> -
> -#define __S000 PAGE_NONE
> -#define __S001 PAGE_READONLY
> -#define __S010 PAGE_SHARED
> -#define __S011 PAGE_SHARED
> -#define __S100 PAGE_READONLY_X
> -#define __S101 PAGE_READONLY_X
> -#define __S110 PAGE_SHARED_X
> -#define __S111 PAGE_SHARED_X
> -#endif
> -
> #ifndef __ASSEMBLY__
>
> #ifndef MAX_PTRS_PER_PGD
> diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c
> index d3b019b95c1d..de76dd4d447c 100644
> --- a/arch/powerpc/mm/book3s64/pgtable.c
> +++ b/arch/powerpc/mm/book3s64/pgtable.c
> @@ -551,25 +551,11 @@ unsigned long memremap_compat_align(void)
> EXPORT_SYMBOL_GPL(memremap_compat_align);
> #endif
>
> -/* Note due to the way vm flags are laid out, the bits are XWR */
> -static const pgprot_t protection_map[16] = {
> - [VM_NONE] = PAGE_NONE,
> - [VM_READ] = PAGE_READONLY,
> - [VM_WRITE] = PAGE_COPY,
> - [VM_WRITE | VM_READ] = PAGE_COPY,
> - [VM_EXEC] = PAGE_READONLY_X,
> - [VM_EXEC | VM_READ] = PAGE_READONLY_X,
> - [VM_EXEC | VM_WRITE] = PAGE_COPY_X,
> - [VM_EXEC | VM_WRITE | VM_READ] = PAGE_COPY_X,
> - [VM_SHARED] = PAGE_NONE,
> - [VM_SHARED | VM_READ] = PAGE_READONLY,
> - [VM_SHARED | VM_WRITE] = PAGE_SHARED,
> - [VM_SHARED | VM_WRITE | VM_READ] = PAGE_SHARED,
> - [VM_SHARED | VM_EXEC] = PAGE_READONLY_X,
> - [VM_SHARED | VM_EXEC | VM_READ] = PAGE_READONLY_X,
> - [VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_SHARED_X,
> - [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED_X
> -};
> +/*
> + * Generic declaration in (include/linux/mm.h) is not available
> + * here as the platform enables ARCH_HAS_VM_GET_PAGE_PROT.
> + */
> +extern pgprot_t protection_map[16];
>
> pgprot_t vm_get_page_prot(unsigned long vm_flags)
> {
> diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
> index e6166b71d36d..780fbecd7bf6 100644
> --- a/arch/powerpc/mm/pgtable.c
> +++ b/arch/powerpc/mm/pgtable.c
> @@ -472,3 +472,23 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea,
> return ret_pte;
> }
> EXPORT_SYMBOL_GPL(__find_linux_pte);
> +
> +/* Note due to the way vm flags are laid out, the bits are XWR */
> +pgprot_t protection_map[16] = {
Was const previously, now back to non const ? Maybe due to a conflict
with linux/mm.h ? At least it should be __ro_after_init.
> + [VM_NONE] = PAGE_NONE,
> + [VM_READ] = PAGE_READONLY,
> + [VM_WRITE] = PAGE_COPY,
> + [VM_WRITE | VM_READ] = PAGE_COPY,
> + [VM_EXEC] = PAGE_READONLY_X,
> + [VM_EXEC | VM_READ] = PAGE_READONLY_X,
> + [VM_EXEC | VM_WRITE] = PAGE_COPY_X,
> + [VM_EXEC | VM_WRITE | VM_READ] = PAGE_COPY_X,
> + [VM_SHARED] = PAGE_NONE,
> + [VM_SHARED | VM_READ] = PAGE_READONLY,
> + [VM_SHARED | VM_WRITE] = PAGE_SHARED,
> + [VM_SHARED | VM_WRITE | VM_READ] = PAGE_SHARED,
> + [VM_SHARED | VM_EXEC] = PAGE_READONLY_X,
> + [VM_SHARED | VM_EXEC | VM_READ] = PAGE_READONLY_X,
> + [VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_SHARED_X,
> + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED_X
> +};
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 2254c1980c8e..65b7f3d9ff87 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -420,11 +420,11 @@ extern unsigned int kobjsize(const void *objp);
> #endif
> #define VM_FLAGS_CLEAR (ARCH_VM_PKEY_FLAGS | VM_ARCH_CLEAR)
>
> -#ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT
> /*
> * mapping from the currently active vm_flags protection bits (the
> * low four bits) to a page protection mask..
> */
> +#ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT
> extern pgprot_t protection_map[16];
> #endif
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index e66920414945..012261c8efb8 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -102,25 +102,6 @@ static void unmap_region(struct mm_struct *mm,
> * x: (yes) yes
> */
> #ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT
> -pgprot_t protection_map[16] __ro_after_init = {
> - [VM_NONE] = __P000,
> - [VM_READ] = __P001,
> - [VM_WRITE] = __P010,
> - [VM_WRITE | VM_READ] = __P011,
> - [VM_EXEC] = __P100,
> - [VM_EXEC | VM_READ] = __P101,
> - [VM_EXEC | VM_WRITE] = __P110,
> - [VM_EXEC | VM_WRITE | VM_READ] = __P111,
> - [VM_SHARED] = __S000,
> - [VM_SHARED | VM_READ] = __S001,
> - [VM_SHARED | VM_WRITE] = __S010,
> - [VM_SHARED | VM_WRITE | VM_READ] = __S011,
> - [VM_SHARED | VM_EXEC] = __S100,
> - [VM_SHARED | VM_EXEC | VM_READ] = __S101,
> - [VM_SHARED | VM_EXEC | VM_WRITE] = __S110,
> - [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = __S111
> -};
> -
> pgprot_t vm_get_page_prot(unsigned long vm_flags)
> {
> return protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
next prev parent reply other threads:[~2022-06-16 5:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 4:09 [PATCH V3 0/2] mm/mmap: Drop __SXXX/__PXXX macros from across platforms Anshuman Khandual
2022-06-16 4:09 ` [PATCH V3 1/2] mm/mmap: Restrict generic protection_map[] array visibility Anshuman Khandual
2022-06-16 5:35 ` Christophe Leroy
2022-06-20 5:16 ` Anshuman Khandual
2022-06-20 6:41 ` Christophe Leroy
2022-06-21 9:44 ` Anshuman Khandual
2022-06-16 12:44 ` kernel test robot
2022-06-20 4:45 ` Anshuman Khandual
2022-06-20 4:45 ` Anshuman Khandual
2022-06-20 5:55 ` Christoph Hellwig
2022-06-20 5:55 ` Christoph Hellwig
2022-06-20 6:43 ` Christophe Leroy
2022-06-20 6:43 ` Christophe Leroy
2022-06-16 4:09 ` [PATCH V3 2/2] mm/mmap: Drop generic protection_map[] array Anshuman Khandual
2022-06-16 5:27 ` Christophe Leroy
2022-06-16 6:10 ` hch
2022-06-17 3:46 ` Anshuman Khandual
2022-06-16 5:45 ` Christophe Leroy [this message]
2022-06-16 6:12 ` hch
2022-06-17 3:29 ` Anshuman Khandual
2022-06-17 5:48 ` Christophe Leroy
2022-06-17 8:00 ` hch
2022-06-20 4:14 ` Anshuman Khandual
2022-06-17 3:43 ` Anshuman Khandual
2022-06-17 5:40 ` Christophe Leroy
2022-06-16 5:22 ` [PATCH V3 0/2] mm/mmap: Drop __SXXX/__PXXX macros from across platforms Christophe Leroy
2022-06-16 6:13 ` hch
2022-06-17 3:07 ` Anshuman Khandual
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7cf922f4-2367-e173-0280-cb498391d9f7@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.