All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
@ 2021-11-12  9:20 Huangzhaoyang
  2021-11-12  9:31 ` Ard Biesheuvel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Huangzhaoyang @ 2021-11-12  9:20 UTC (permalink / raw)
  To: Ard Biesheuvel, Catalin Marinas, Will Deacon, Anshuman Khandual,
	Andrew Morton, Nicholas Piggin, Mike Rapoport, Pavel Tatashin,
	Christophe Leroy, Jonathan Marek, Zhaoyang Huang, linux-mm,
	linux-kernel

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

By comparing the swapper_pg_dir with k54 and previous versions,we find
that the linear mappings within which the addr is out of kernel text section
will use the smallest pte. It should arise for the sake of rodata_full, which
set all memblock use NO_CONT_MAPPINGS.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 arch/arm64/mm/mmu.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index cfd9deb..14e1bea 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -252,6 +252,8 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end,
 	pmd_clear_fixmap();
 }
 
+static bool crash_mem_map __initdata;
+
 static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
 				unsigned long end, phys_addr_t phys,
 				pgprot_t prot,
@@ -259,7 +261,15 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
 {
 	unsigned long next;
 	pud_t pud = READ_ONCE(*pudp);
+	unsigned long len = end - addr;
+	phys_addr_t kernel_start = __pa_symbol(_stext);
+	phys_addr_t kernel_end = __pa_symbol(__init_begin);
 
+	if (debug_pagealloc_enabled() || crash_mem_map || IS_ENABLED(CONFIG_KFENCE))
+		;
+	else if (phys > kernel_end || phys + len < kernel_start) {
+		flags &= ~(NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
+	}
 	/*
 	 * Check for initial section mappings in the pgd/pud.
 	 */
@@ -483,7 +493,6 @@ void __init mark_linear_text_alias_ro(void)
 			    PAGE_KERNEL_RO);
 }
 
-static bool crash_mem_map __initdata;
 
 static int __init enable_crash_mem_map(char *arg)
 {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
  2021-11-12  9:20 [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map Huangzhaoyang
@ 2021-11-12  9:31 ` Ard Biesheuvel
  2021-11-12  9:45   ` Zhaoyang Huang
  2021-11-13  2:09 ` kernel test robot
  2021-11-21  9:44   ` kernel test robot
  2 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2021-11-12  9:31 UTC (permalink / raw)
  To: Huangzhaoyang
  Cc: Catalin Marinas, Will Deacon, Anshuman Khandual, Andrew Morton,
	Nicholas Piggin, Mike Rapoport, Pavel Tatashin, Christophe Leroy,
	Jonathan Marek, Zhaoyang Huang, Linux Memory Management List,
	Linux Kernel Mailing List

On Fri, 12 Nov 2021 at 10:21, Huangzhaoyang <huangzhaoyang@gmail.com> wrote:
>
> From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
>
> By comparing the swapper_pg_dir with k54

I take it this means Linux v5.4 ?

> and previous versions,we find
> that the linear mappings within which the addr is out of kernel text section
> will use the smallest pte. It should arise for the sake of rodata_full, which
> set all memblock use NO_CONT_MAPPINGS.
>

OK so your intent seems to be to use block mappings for the linear
alias of the kernel text and rodata, right?

What does that achieve? It should make no difference in TLB pressure,
as the linear alias is rarely referenced (we only kept it around for
hibernate). So I guess we save a handful of pages for page tables.

> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> ---
>  arch/arm64/mm/mmu.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index cfd9deb..14e1bea 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -252,6 +252,8 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end,
>         pmd_clear_fixmap();
>  }
>
> +static bool crash_mem_map __initdata;
> +
>  static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
>                                 unsigned long end, phys_addr_t phys,
>                                 pgprot_t prot,
> @@ -259,7 +261,15 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
>  {
>         unsigned long next;
>         pud_t pud = READ_ONCE(*pudp);
> +       unsigned long len = end - addr;
> +       phys_addr_t kernel_start = __pa_symbol(_stext);
> +       phys_addr_t kernel_end = __pa_symbol(__init_begin);
>
> +       if (debug_pagealloc_enabled() || crash_mem_map || IS_ENABLED(CONFIG_KFENCE))
> +               ;
> +       else if (phys > kernel_end || phys + len < kernel_start) {
> +               flags &= ~(NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
> +       }

Please don't use empty statements like this, and I'm not sure we even
need this check: I wouldn't expect debug_pagealloc or KFENCE to ever
require page granular mappings of this region either.

Also, please add a comment to explain what the condition is meant to
check (i..e, that the PMD entry covers a part of the linear alias of
the kernel image, and so there is no need to map it down to pages or
to avoid contiguous mappings)

>         /*
>          * Check for initial section mappings in the pgd/pud.
>          */
> @@ -483,7 +493,6 @@ void __init mark_linear_text_alias_ro(void)
>                             PAGE_KERNEL_RO);
>  }
>
> -static bool crash_mem_map __initdata;
>
>  static int __init enable_crash_mem_map(char *arg)
>  {
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
  2021-11-12  9:31 ` Ard Biesheuvel
@ 2021-11-12  9:45   ` Zhaoyang Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Zhaoyang Huang @ 2021-11-12  9:45 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Catalin Marinas, Will Deacon, Anshuman Khandual, Andrew Morton,
	Nicholas Piggin, Mike Rapoport, Pavel Tatashin, Christophe Leroy,
	Jonathan Marek, Zhaoyang Huang, Linux Memory Management List,
	Linux Kernel Mailing List, ben.dai, lvqiang.huang, Ke Wang

On Fri, Nov 12, 2021 at 5:31 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 12 Nov 2021 at 10:21, Huangzhaoyang <huangzhaoyang@gmail.com> wrote:
> >
> > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> >
> > By comparing the swapper_pg_dir with k54
>
> I take it this means Linux v5.4 ?
>
> > and previous versions,we find
> > that the linear mappings within which the addr is out of kernel text section
> > will use the smallest pte. It should arise for the sake of rodata_full, which
> > set all memblock use NO_CONT_MAPPINGS.
> >
>
> OK so your intent seems to be to use block mappings for the linear
> alias of the kernel text and rodata, right?
>
> What does that achieve? It should make no difference in TLB pressure,
> as the linear alias is rarely referenced (we only kept it around for
> hibernate). So I guess we save a handful of pages for page tables.
Thanks for the quick response and sorry for causing confusion with my
poor comments. What I want to do is on the contrary, that is using
block mapping on the addr OUT OF the kernel text, which could be
affected by setting rodata_full(can_set_direct_map) so far.


>
> > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > ---
> >  arch/arm64/mm/mmu.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > index cfd9deb..14e1bea 100644
> > --- a/arch/arm64/mm/mmu.c
> > +++ b/arch/arm64/mm/mmu.c
> > @@ -252,6 +252,8 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end,
> >         pmd_clear_fixmap();
> >  }
> >
> > +static bool crash_mem_map __initdata;
> > +
> >  static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
> >                                 unsigned long end, phys_addr_t phys,
> >                                 pgprot_t prot,
> > @@ -259,7 +261,15 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
> >  {
> >         unsigned long next;
> >         pud_t pud = READ_ONCE(*pudp);
> > +       unsigned long len = end - addr;
> > +       phys_addr_t kernel_start = __pa_symbol(_stext);
> > +       phys_addr_t kernel_end = __pa_symbol(__init_begin);
> >
> > +       if (debug_pagealloc_enabled() || crash_mem_map || IS_ENABLED(CONFIG_KFENCE))
> > +               ;
> > +       else if (phys > kernel_end || phys + len < kernel_start) {
> > +               flags &= ~(NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
> > +       }
>
> Please don't use empty statements like this, and I'm not sure we even
> need this check: I wouldn't expect debug_pagealloc or KFENCE to ever
> require page granular mappings of this region either.
>
> Also, please add a comment to explain what the condition is meant to
> check (i..e, that the PMD entry covers a part of the linear alias of
> the kernel image, and so there is no need to map it down to pages or
> to avoid contiguous mappings)
>
> >         /*
> >          * Check for initial section mappings in the pgd/pud.
> >          */
> > @@ -483,7 +493,6 @@ void __init mark_linear_text_alias_ro(void)
> >                             PAGE_KERNEL_RO);
> >  }
> >
> > -static bool crash_mem_map __initdata;
> >
> >  static int __init enable_crash_mem_map(char *arg)
> >  {
> > --
> > 1.9.1
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
  2021-11-12  9:20 [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map Huangzhaoyang
  2021-11-12  9:31 ` Ard Biesheuvel
@ 2021-11-13  2:09 ` kernel test robot
  2021-11-21  9:44   ` kernel test robot
  2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-13  2:09 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2080 bytes --]

Hi Huangzhaoyang,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v5.15 next-20211112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1e24a50ddba38b8bed8d75bc2b788da88b354522
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
        git checkout 1e24a50ddba38b8bed8d75bc2b788da88b354522
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> WARNING: modpost: vmlinux.o(.text+0x22878): Section mismatch in reference from the function alloc_init_cont_pmd() to the variable .init.data:crash_mem_map
The function alloc_init_cont_pmd() references
the variable __initdata crash_mem_map.
This is often because alloc_init_cont_pmd lacks a __initdata
annotation or the annotation of crash_mem_map is wrong.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 55900 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
  2021-11-12  9:20 [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map Huangzhaoyang
@ 2021-11-21  9:44   ` kernel test robot
  2021-11-13  2:09 ` kernel test robot
  2021-11-21  9:44   ` kernel test robot
  2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-21  9:44 UTC (permalink / raw)
  To: Huangzhaoyang; +Cc: llvm, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2245 bytes --]

Hi Huangzhaoyang,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v5.16-rc1 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-randconfig-r023-20211115 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project fbe72e41b99dc7994daac300d208a955be3e4a0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/1e24a50ddba38b8bed8d75bc2b788da88b354522
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
        git checkout 1e24a50ddba38b8bed8d75bc2b788da88b354522
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> WARNING: modpost: vmlinux.o(.text+0x19c54): Section mismatch in reference from the function __create_pgd_mapping() to the variable .init.data:crash_mem_map
The function __create_pgd_mapping() references
the variable __initdata crash_mem_map.
This is often because __create_pgd_mapping lacks a __initdata
annotation or the annotation of crash_mem_map is wrong.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39909 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map
@ 2021-11-21  9:44   ` kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-21  9:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2287 bytes --]

Hi Huangzhaoyang,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v5.16-rc1 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-randconfig-r023-20211115 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project fbe72e41b99dc7994daac300d208a955be3e4a0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/1e24a50ddba38b8bed8d75bc2b788da88b354522
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Huangzhaoyang/arch-arm64-have-memblocks-out-of-kernel-text-use-section-map/20211112-172142
        git checkout 1e24a50ddba38b8bed8d75bc2b788da88b354522
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> WARNING: modpost: vmlinux.o(.text+0x19c54): Section mismatch in reference from the function __create_pgd_mapping() to the variable .init.data:crash_mem_map
The function __create_pgd_mapping() references
the variable __initdata crash_mem_map.
This is often because __create_pgd_mapping lacks a __initdata
annotation or the annotation of crash_mem_map is wrong.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 39909 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-21  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12  9:20 [RFC PATCH] arch: arm64: have memblocks out of kernel text use section map Huangzhaoyang
2021-11-12  9:31 ` Ard Biesheuvel
2021-11-12  9:45   ` Zhaoyang Huang
2021-11-13  2:09 ` kernel test robot
2021-11-21  9:44 ` kernel test robot
2021-11-21  9:44   ` kernel test robot

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.